StlIO.h
Go to the documentation of this file.
1 /********************************************************************
2 *
3 * Project Artec 3D Scanning SDK
4 *
5 * Purpose: StereoLithography Interface file format support
6 *
7 * Copyright: Artec Group
8 *
9 ********************************************************************/
10 
11 #ifndef __ArtecBaseSDK_STLIO_H_
12 #define __ArtecBaseSDK_STLIO_H_
13 
15 #include <artec/sdk/base/Errors.h>
16 #include <string>
17 #include <iostream>
18 
19 namespace artec { namespace sdk { namespace base
20 {
21 
22 class ICancellationToken;
23 class IProgressInfo;
24 class IMesh;
25 class IBlob;
26 
27 namespace io {
28 
29 extern "C" {
30 
31  /** Save IMesh surface to STL file
32  * @param path - file path to save mesh to
33  * @param surf - surface to be saved (not empty)
34  * @param binary - text or binary stl format
35  * @param progr - progress interface
36  * @param cncl - cancel interface
37  * @return error code
38  */
40  saveStlMeshToFile(const wchar_t* path, const IMesh * surf, bool binary = true, IProgressInfo* progr = 0, ICancellationToken* cncl = 0);
41 
42  /** Save IMesh surface to ascii STL file
43  * @param path - file path to save mesh to
44  * @param surf - surface to be saved (not empty)
45  * @param name - the name of the mesh
46  * @param progr - progress interface
47  * @param cncl - cancel interface
48  * @return error code
49  */
51  saveStlMeshToFileAscii(const wchar_t* path, const IMesh * surf, const char* name = NULL, IProgressInfo* progr = 0, ICancellationToken* cncl = 0);
52 
53  /** Save IMesh surface to binary STL file
54  * @param path - file path to save mesh to
55  * @param surf - surface to be saved (not empty)
56  * @param progr - progress interface
57  * @param cncl - cancel interface
58  * @return error code
59  */
61  saveStlMeshToFileBinary(const wchar_t* path, const IMesh * surf, IProgressInfo* progr = 0, ICancellationToken* cncl = 0);
62 
63  /** Save IMesh surface to STL blob
64  * @param data - blob to save mesh to
65  * @param surf - surface to be saved (not empty)
66  * @param binary - text or binary stl format
67  * @param progr - progress interface
68  * @param cncl - cancel interface
69  * @return error code
70  */
72  saveStlMeshToBlob(IBlob** data, const IMesh * surf, bool binary = true, IProgressInfo* progr = 0, ICancellationToken* cncl = 0);
73 
74  /** Save IMesh surface to ascii STL blob
75  * @param data - blob to save mesh to
76  * @param surf - surface to be saved (not empty)
77  * @param name - the name of the mesh
78  * @param progr - progress interface
79  * @param cncl - cancel interface
80  * @return error code
81  */
83  saveStlMeshToBlobAscii(IBlob** data, const IMesh * surf, const char * name = NULL, IProgressInfo* progr = 0, ICancellationToken* cncl = 0);
84 
85  /** Save IMesh surface to binary STL blob
86  * @param data - blob to save mesh to
87  * @param surf - surface to be saved (not empty)
88  * @param progr - progress interface
89  * @param cncl - cancel interface
90  * @return error code
91  */
93  saveStlMeshToBlobBinary(IBlob** data, const IMesh * surf, IProgressInfo* progr = 0, ICancellationToken* cncl = 0);
94 
95  ///@{
96  /// Load surface from file/blob in STL format
97  /// @param stream - we intend load surface from here
98  /// @param path - file path to load surface from
99  /// @param surf - loaded surface
100  /// @param binary - format of data - binary or textual. load-from-file functions use isBinary() call to determine it.
101 
103  loadStlMeshFromFile(IMesh** surf, const wchar_t* path, bool binary, IProgressInfo * progr = 0, ICancellationToken * cncl = 0);
104 
106  loadStlMeshFromFileAutodetect(IMesh** surf, const wchar_t* path, IProgressInfo * progr = 0, ICancellationToken * cncl = 0);
107 
109  loadStlMeshFromFileAscii(IMesh** surf, const wchar_t* path, IProgressInfo * progr = 0, ICancellationToken * cncl = 0);
110 
112  loadStlMeshFromFileBinary(IMesh** surf, const wchar_t* path, IProgressInfo * progr = 0, ICancellationToken * cncl = 0);
113 
115  loadStlMeshFromBlob(IMesh** surf, const IBlob* data, bool binary, IProgressInfo * progr = 0, ICancellationToken * cncl = 0);
116 
118  loadStlMeshFromBlobAscii(IMesh** surf, const IBlob* data, IProgressInfo * progr = 0, ICancellationToken * cncl = 0);
119 
121  loadStlMeshFromBlobBinary(IMesh** surf, const IBlob* data, IProgressInfo * progr = 0, ICancellationToken * cncl = 0);
122  ///@}
123 
124  /// Determines the format of saved file
125  bool ABASESDK_LINK_SPEC isStlBinary(const wchar_t* path);
126 
127 }
128 
129 class Stl
130 {
131 public:
132 
133  /** Save IMesh surface to STL file
134  * @param path - file path to save mesh to
135  * @param surf - surface to be saved (not empty)
136  * @param binary - text or binary stl format
137  * @param progr - progress interface
138  * @param cncl - cancel interface
139  * @return error code
140  */
141  static ErrorCode
142  save(const wchar_t* path, const IMesh * surf, bool binary = true, IProgressInfo* progr = 0, ICancellationToken* cncl = 0)
143  {
144  return saveStlMeshToFile(path, surf, binary, progr, cncl);
145  }
146 
147  /** Save IMesh surface to ascii STL file
148  * @param path - file path to save mesh to
149  * @param surf - surface to be saved (not empty)
150  * @param name - the name of the mesh
151  * @param progr - progress interface
152  * @param cncl - cancel interface
153  * @return error code
154  */
155  static ErrorCode
156  saveAscii(const wchar_t* path, const IMesh * surf, const char* name = NULL, IProgressInfo* progr = 0, ICancellationToken* cncl = 0)
157  {
158  return saveStlMeshToFileAscii(path, surf, name, progr, cncl);
159  }
160 
161  /** Save IMesh surface to binary STL file
162  * @param path - file path to save mesh to
163  * @param surf - surface to be saved (not empty)
164  * @param progr - progress interface
165  * @param cncl - cancel interface
166  * @return error code
167  */
168  static ErrorCode
169  saveBinary(const wchar_t* path, const IMesh * surf, IProgressInfo* progr = 0, ICancellationToken* cncl = 0)
170  {
171  return saveStlMeshToFileBinary(path, surf, progr, cncl);
172  }
173 
174  /** Save IMesh surface to STL blob
175  * @param data - blob to save mesh to
176  * @param surf - surface to be saved (not empty)
177  * @param binary - text or binary stl format
178  * @param progr - progress interface
179  * @param cncl - cancel interface
180  * @return error code
181  */
182  static ErrorCode
183  save(IBlob** data, const IMesh * surf, bool binary = true, IProgressInfo* progr = 0, ICancellationToken* cncl = 0)
184  {
185  return saveStlMeshToBlob(data, surf, binary, progr, cncl);
186  }
187 
188  /** Save IMesh surface to ascii STL blob
189  * @param data - blob to save mesh to
190  * @param surf - surface to be saved (not empty)
191  * @param name - the name of the mesh
192  * @param progr - progress interface
193  * @param cncl - cancel interface
194  * @return error code
195  */
196  static ErrorCode
197  saveAscii(IBlob** data, const IMesh * surf, const char * name = NULL, IProgressInfo* progr = 0, ICancellationToken* cncl = 0)
198  {
199  return saveStlMeshToBlobAscii(data, surf, name, progr, cncl);
200  }
201 
202  /** Save IMesh surface to binary STL blob
203  * @param data - blob to save mesh to
204  * @param surf - surface to be saved (not empty)
205  * @param progr - progress interface
206  * @param cncl - cancel interface
207  * @return error code
208  */
209  static ErrorCode saveBinary(IBlob** data, const IMesh * surf, IProgressInfo* progr = 0, ICancellationToken* cncl = 0)
210  {
211  return saveStlMeshToBlobBinary(data, surf, progr, cncl);
212  }
213 
214  ///@{
215  /// Load IMesh surface from file/blob in STL format
216  /// @param stream - we intend load surface from here
217  /// @param path - file path to load surface from
218  /// @param surf - loaded surface
219  /// @param binary - format of data - binary or textual. load-from-file functions use isBinary() call to determine it.
220 
221  static ErrorCode load(IMesh** surf, const wchar_t* path, bool binary, IProgressInfo * progr = 0, ICancellationToken * cncl = 0)
222  {
223  return loadStlMeshFromFile(surf, path, binary, progr, cncl);
224  }
225 
226  static ErrorCode load(IMesh** surf, const wchar_t* path, IProgressInfo * progr = 0, ICancellationToken * cncl = 0)
227  {
228  return loadStlMeshFromFileAutodetect(surf, path, progr, cncl);
229  }
230 
231  static ErrorCode loadAscii(IMesh** surf, const wchar_t* path, IProgressInfo * progr = 0, ICancellationToken * cncl = 0)
232  {
233  return loadStlMeshFromFileAscii(surf, path, progr, cncl);
234  }
235 
236  static ErrorCode loadBinary(IMesh** surf, const wchar_t* path, IProgressInfo * progr = 0, ICancellationToken * cncl = 0)
237  {
238  return loadStlMeshFromFileBinary(surf, path, progr, cncl);
239  }
240 
241  static ErrorCode load(IMesh** surf, const IBlob* data, bool binary, IProgressInfo * progr = 0, ICancellationToken * cncl = 0)
242  {
243  return loadStlMeshFromBlob(surf, data, binary, progr, cncl);
244  }
245 
246  static ErrorCode loadAscii(IMesh** surf, const IBlob* data, IProgressInfo * progr = 0, ICancellationToken * cncl = 0)
247  {
248  return loadStlMeshFromBlobAscii(surf, data, progr, cncl);
249  }
250 
251  static ErrorCode loadBinary(IMesh** surf, const IBlob* data, IProgressInfo * progr = 0, ICancellationToken * cncl = 0)
252  {
253  return loadStlMeshFromBlobBinary(surf, data, progr, cncl);
254  }
255  ///@}
256 
257  /// Determines the format of saved file
258  static bool isBinary(const wchar_t* path)
259  {
260  return isStlBinary(path);
261  }
262 };
263 
264 } } } } // namespace artec::sdk::base::io
265 
266 #endif // __ArtecBaseSDK_STLIO_H_
static ErrorCode loadAscii(IMesh **surf, const wchar_t *path, IProgressInfo *progr=0, ICancellationToken *cncl=0)
Definition: StlIO.h:231
ErrorCode ABASESDK_LINK_SPEC loadStlMeshFromFileAscii(IMesh **surf, const wchar_t *path, IProgressInfo *progr=0, ICancellationToken *cncl=0)
static ErrorCode load(IMesh **surf, const IBlob *data, bool binary, IProgressInfo *progr=0, ICancellationToken *cncl=0)
Definition: StlIO.h:241
ErrorCode ABASESDK_LINK_SPEC loadStlMeshFromFileAutodetect(IMesh **surf, const wchar_t *path, IProgressInfo *progr=0, ICancellationToken *cncl=0)
ErrorCode ABASESDK_LINK_SPEC saveStlMeshToBlob(IBlob **data, const IMesh *surf, bool binary=true, IProgressInfo *progr=0, ICancellationToken *cncl=0)
ErrorCode ABASESDK_LINK_SPEC loadStlMeshFromFileBinary(IMesh **surf, const wchar_t *path, IProgressInfo *progr=0, ICancellationToken *cncl=0)
ErrorCode ABASESDK_LINK_SPEC saveStlMeshToBlobBinary(IBlob **data, const IMesh *surf, IProgressInfo *progr=0, ICancellationToken *cncl=0)
ErrorCode ABASESDK_LINK_SPEC saveStlMeshToFileAscii(const wchar_t *path, const IMesh *surf, const char *name=NULL, IProgressInfo *progr=0, ICancellationToken *cncl=0)
static ErrorCode save(const wchar_t *path, const IMesh *surf, bool binary=true, IProgressInfo *progr=0, ICancellationToken *cncl=0)
Definition: StlIO.h:142
static ErrorCode loadBinary(IMesh **surf, const wchar_t *path, IProgressInfo *progr=0, ICancellationToken *cncl=0)
Definition: StlIO.h:236
ErrorCode ABASESDK_LINK_SPEC saveStlMeshToFileBinary(const wchar_t *path, const IMesh *surf, IProgressInfo *progr=0, ICancellationToken *cncl=0)
static ErrorCode loadBinary(IMesh **surf, const IBlob *data, IProgressInfo *progr=0, ICancellationToken *cncl=0)
Definition: StlIO.h:251
ErrorCode ABASESDK_LINK_SPEC loadStlMeshFromBlobAscii(IMesh **surf, const IBlob *data, IProgressInfo *progr=0, ICancellationToken *cncl=0)
static ErrorCode saveBinary(IBlob **data, const IMesh *surf, IProgressInfo *progr=0, ICancellationToken *cncl=0)
Definition: StlIO.h:209
ErrorCode ABASESDK_LINK_SPEC loadStlMeshFromFile(IMesh **surf, const wchar_t *path, bool binary, IProgressInfo *progr=0, ICancellationToken *cncl=0)
static ErrorCode save(IBlob **data, const IMesh *surf, bool binary=true, IProgressInfo *progr=0, ICancellationToken *cncl=0)
Definition: StlIO.h:183
static ErrorCode saveAscii(IBlob **data, const IMesh *surf, const char *name=NULL, IProgressInfo *progr=0, ICancellationToken *cncl=0)
Definition: StlIO.h:197
ErrorCode ABASESDK_LINK_SPEC loadStlMeshFromBlob(IMesh **surf, const IBlob *data, bool binary, IProgressInfo *progr=0, ICancellationToken *cncl=0)
static ErrorCode load(IMesh **surf, const wchar_t *path, bool binary, IProgressInfo *progr=0, ICancellationToken *cncl=0)
Definition: StlIO.h:221
bool ABASESDK_LINK_SPEC isStlBinary(const wchar_t *path)
Determines the format of saved file.
static ErrorCode loadAscii(IMesh **surf, const IBlob *data, IProgressInfo *progr=0, ICancellationToken *cncl=0)
Definition: StlIO.h:246
static ErrorCode saveAscii(const wchar_t *path, const IMesh *surf, const char *name=NULL, IProgressInfo *progr=0, ICancellationToken *cncl=0)
Definition: StlIO.h:156
static ErrorCode saveBinary(const wchar_t *path, const IMesh *surf, IProgressInfo *progr=0, ICancellationToken *cncl=0)
Definition: StlIO.h:169
#define ABASESDK_LINK_SPEC
Definition: BaseSdkDefines.h:7
ErrorCode ABASESDK_LINK_SPEC saveStlMeshToFile(const wchar_t *path, const IMesh *surf, bool binary=true, IProgressInfo *progr=0, ICancellationToken *cncl=0)
ErrorCode ABASESDK_LINK_SPEC loadStlMeshFromBlobBinary(IMesh **surf, const IBlob *data, IProgressInfo *progr=0, ICancellationToken *cncl=0)
ErrorCode ABASESDK_LINK_SPEC saveStlMeshToBlobAscii(IBlob **data, const IMesh *surf, const char *name=NULL, IProgressInfo *progr=0, ICancellationToken *cncl=0)
static bool isBinary(const wchar_t *path)
Determines the format of saved file.
Definition: StlIO.h:258
static ErrorCode load(IMesh **surf, const wchar_t *path, IProgressInfo *progr=0, ICancellationToken *cncl=0)
Definition: StlIO.h:226