Artec 3D Scanning SDK  2.0
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 where to save mesh
33  * @param surf - surface to save (not empty)
34  * @param binary - text or binary STL format
35  * @param progr - progress interface
36  * @param cncl - cancellation interface
37  */
39  saveStlMeshToFile(const wchar_t* path, const IMesh * surf, bool binary = true, IProgressInfo* progr = 0, ICancellationToken* cncl = 0);
40 
41  /** Save IMesh surface to ASCII STL file
42  * @param path - file path where to save mesh
43  * @param surf - surface to save (not empty)
44  * @param name - mesh name
45  * @param progr - progress interface
46  * @param cncl - cancellation interface
47  */
49  saveStlMeshToFileAscii(const wchar_t* path, const IMesh * surf, const char* name = NULL, IProgressInfo* progr = 0, ICancellationToken* cncl = 0);
50 
51  /** Save IMesh surface to binary STL file
52  * @param path - file path where to save mesh
53  * @param surf - surface to save (not empty)
54  * @param progr - progress interface
55  * @param cncl - cancellation interface
56  */
58  saveStlMeshToFileBinary(const wchar_t* path, const IMesh * surf, IProgressInfo* progr = 0, ICancellationToken* cncl = 0);
59 
60  /** Save IMesh surface to STL blob
61  * @param data - blob where to save mesh
62  * @param surf - surface to save (not empty)
63  * @param binary - text or binary STL format
64  * @param progr - progress interface
65  * @param cncl - cancellation interface
66  */
68  saveStlMeshToBlob(IBlob** data, const IMesh * surf, bool binary = true, IProgressInfo* progr = 0, ICancellationToken* cncl = 0);
69 
70  /** Save IMesh surface to ASCII STL blob
71  * @param data - blob where to save mesh
72  * @param surf - surface to save (not empty)
73  * @param name - mesh name
74  * @param progr - progress interface
75  * @param cncl - cancel interface
76  */
78  saveStlMeshToBlobAscii(IBlob** data, const IMesh * surf, const char * name = NULL, IProgressInfo* progr = 0, ICancellationToken* cncl = 0);
79 
80  /** Save IMesh surface to binary STL blob
81  * @param data - blob where to save mesh
82  * @param surf - surface to save (not empty)
83  * @param progr - progress interface
84  * @param cncl - cancellation interface
85  */
87  saveStlMeshToBlobBinary(IBlob** data, const IMesh * surf, IProgressInfo* progr = 0, ICancellationToken* cncl = 0);
88 
89  ///@{
90  /// Load surface from file/blob in STL format
91  /// @param stream - where the surface will be loaded from
92  /// @param path - file path to load surface from
93  /// @param surf - loaded surface
94  /// @param binary - data format: binary or text. Load-from-file functions use the isBinary() call to determine it.
95 
97  loadStlMeshFromFile(IMesh** surf, const wchar_t* path, bool binary, IProgressInfo * progr = 0, ICancellationToken * cncl = 0);
98 
100  loadStlMeshFromFileAutodetect(IMesh** surf, const wchar_t* path, IProgressInfo * progr = 0, ICancellationToken * cncl = 0);
101 
103  loadStlMeshFromFileAscii(IMesh** surf, const wchar_t* path, IProgressInfo * progr = 0, ICancellationToken * cncl = 0);
104 
106  loadStlMeshFromFileBinary(IMesh** surf, const wchar_t* path, IProgressInfo * progr = 0, ICancellationToken * cncl = 0);
107 
109  loadStlMeshFromBlob(IMesh** surf, const IBlob* data, bool binary, IProgressInfo * progr = 0, ICancellationToken * cncl = 0);
110 
112  loadStlMeshFromBlobAscii(IMesh** surf, const IBlob* data, IProgressInfo * progr = 0, ICancellationToken * cncl = 0);
113 
115  loadStlMeshFromBlobBinary(IMesh** surf, const IBlob* data, IProgressInfo * progr = 0, ICancellationToken * cncl = 0);
116  ///@}
117 
118  /// Determines the format of the saved file
119  bool ABASESDK_LINK_SPEC isStlBinary(const wchar_t* path);
120 
121 }
122 /// Class to save/load STL files (STereoLithography)
123 class Stl
124 {
125 public:
126 
127  /** Save IMesh surface to STL file
128  * @param path - file path where to save mesh
129  * @param surf - surface to save (not empty)
130  * @param binary - text or binary STL format
131  * @param progr - progress interface
132  * @param cncl - cancellation interface
133  */
134  static ErrorCode
135  save(const wchar_t* path, const IMesh * surf, bool binary = true, IProgressInfo* progr = 0, ICancellationToken* cncl = 0)
136  {
137  return saveStlMeshToFile(path, surf, binary, progr, cncl);
138  }
139 
140  /** Save IMesh surface to ASCII STL file
141  * @param path - file path where to save mesh
142  * @param surf - surface to save (not empty)
143  * @param name - mesh name
144  * @param progr - progress interface
145  * @param cncl - cancellation interface
146  */
147  static ErrorCode
148  saveAscii(const wchar_t* path, const IMesh * surf, const char* name = NULL, IProgressInfo* progr = 0, ICancellationToken* cncl = 0)
149  {
150  return saveStlMeshToFileAscii(path, surf, name, progr, cncl);
151  }
152 
153  /** Save IMesh surface to binary STL file
154  * @param path - file path where to save mesh
155  * @param surf - surface to save (not empty)
156  * @param progr - progress interface
157  * @param cncl - cancellation interface
158  */
159  static ErrorCode
160  saveBinary(const wchar_t* path, const IMesh * surf, IProgressInfo* progr = 0, ICancellationToken* cncl = 0)
161  {
162  return saveStlMeshToFileBinary(path, surf, progr, cncl);
163  }
164 
165  /** Save IMesh surface to STL blob
166  * @param data - blob where to save mesh
167  * @param surf - surface to save (not empty)
168  * @param binary - text or binary STL format
169  * @param progr - progress interface
170  * @param cncl - cancellation interface
171  */
172  static ErrorCode
173  save(IBlob** data, const IMesh * surf, bool binary = true, IProgressInfo* progr = 0, ICancellationToken* cncl = 0)
174  {
175  return saveStlMeshToBlob(data, surf, binary, progr, cncl);
176  }
177 
178  /** Save IMesh surface to ASCII STL blob
179  * @param data - blob where to save mesh
180  * @param surf - surface to save (not empty)
181  * @param name - mesh name
182  * @param progr - progress interface
183  * @param cncl - cancellation interface
184  */
185  static ErrorCode
186  saveAscii(IBlob** data, const IMesh * surf, const char * name = NULL, IProgressInfo* progr = 0, ICancellationToken* cncl = 0)
187  {
188  return saveStlMeshToBlobAscii(data, surf, name, progr, cncl);
189  }
190 
191  /** Save IMesh surface to binary STL blob
192  * @param data - blob where to save mesh
193  * @param surf - surface to save (not empty)
194  * @param progr - progress interface
195  * @param cncl - cancel interface
196  */
197  static ErrorCode saveBinary(IBlob** data, const IMesh * surf, IProgressInfo* progr = 0, ICancellationToken* cncl = 0)
198  {
199  return saveStlMeshToBlobBinary(data, surf, progr, cncl);
200  }
201 
202  ///@{
203  /// Load IMesh surface from file/blob in STL format
204  /// @param stream - where the surface will be loaded from
205  /// @param path - file path to load surface from
206  /// @param surf - loaded surface
207  /// @param binary - data format: binary or text. Load-from-file functions use the isBinary() call to determine it.
208 
209  static ErrorCode load(IMesh** surf, const wchar_t* path, bool binary, IProgressInfo * progr = 0, ICancellationToken * cncl = 0)
210  {
211  return loadStlMeshFromFile(surf, path, binary, progr, cncl);
212  }
213 
214  static ErrorCode load(IMesh** surf, const wchar_t* path, IProgressInfo * progr = 0, ICancellationToken * cncl = 0)
215  {
216  return loadStlMeshFromFileAutodetect(surf, path, progr, cncl);
217  }
218 
219  static ErrorCode loadAscii(IMesh** surf, const wchar_t* path, IProgressInfo * progr = 0, ICancellationToken * cncl = 0)
220  {
221  return loadStlMeshFromFileAscii(surf, path, progr, cncl);
222  }
223 
224  static ErrorCode loadBinary(IMesh** surf, const wchar_t* path, IProgressInfo * progr = 0, ICancellationToken * cncl = 0)
225  {
226  return loadStlMeshFromFileBinary(surf, path, progr, cncl);
227  }
228 
229  static ErrorCode load(IMesh** surf, const IBlob* data, bool binary, IProgressInfo * progr = 0, ICancellationToken * cncl = 0)
230  {
231  return loadStlMeshFromBlob(surf, data, binary, progr, cncl);
232  }
233 
234  static ErrorCode loadAscii(IMesh** surf, const IBlob* data, IProgressInfo * progr = 0, ICancellationToken * cncl = 0)
235  {
236  return loadStlMeshFromBlobAscii(surf, data, progr, cncl);
237  }
238 
239  static ErrorCode loadBinary(IMesh** surf, const IBlob* data, IProgressInfo * progr = 0, ICancellationToken * cncl = 0)
240  {
241  return loadStlMeshFromBlobBinary(surf, data, progr, cncl);
242  }
243  ///@}
244 
245  /// Determines format of the saved file
246  static bool isBinary(const wchar_t* path)
247  {
248  return isStlBinary(path);
249  }
250 };
251 
252 } } } } // namespace artec::sdk::base::io
253 
254 #endif // __ArtecBaseSDK_STLIO_H_
Indexed triangle mesh.
Definition: IMesh.h:32
static ErrorCode loadAscii(IMesh **surf, const wchar_t *path, IProgressInfo *progr=0, ICancellationToken *cncl=0)
Definition: StlIO.h:219
ErrorCode ABASESDK_LINK_SPEC loadStlMeshFromFileAscii(IMesh **surf, const wchar_t *path, IProgressInfo *progr=0, ICancellationToken *cncl=0)
Class to save/load STL files (STereoLithography)
Definition: StlIO.h:123
static ErrorCode load(IMesh **surf, const IBlob *data, bool binary, IProgressInfo *progr=0, ICancellationToken *cncl=0)
Definition: StlIO.h:229
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)
Save IMesh surface to STL blob.
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)
Save IMesh surface to binary STL blob.
ErrorCode ABASESDK_LINK_SPEC saveStlMeshToFileAscii(const wchar_t *path, const IMesh *surf, const char *name=NULL, IProgressInfo *progr=0, ICancellationToken *cncl=0)
Save IMesh surface to ASCII STL file.
static ErrorCode save(const wchar_t *path, const IMesh *surf, bool binary=true, IProgressInfo *progr=0, ICancellationToken *cncl=0)
Save IMesh surface to STL file.
Definition: StlIO.h:135
static ErrorCode loadBinary(IMesh **surf, const wchar_t *path, IProgressInfo *progr=0, ICancellationToken *cncl=0)
Definition: StlIO.h:224
Callback interface to notify process about cancellation.
ErrorCode ABASESDK_LINK_SPEC saveStlMeshToFileBinary(const wchar_t *path, const IMesh *surf, IProgressInfo *progr=0, ICancellationToken *cncl=0)
Save IMesh surface to binary STL file.
static ErrorCode loadBinary(IMesh **surf, const IBlob *data, IProgressInfo *progr=0, ICancellationToken *cncl=0)
Definition: StlIO.h:239
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)
Save IMesh surface to binary STL blob.
Definition: StlIO.h:197
ErrorCode ABASESDK_LINK_SPEC loadStlMeshFromFile(IMesh **surf, const wchar_t *path, bool binary, IProgressInfo *progr=0, ICancellationToken *cncl=0)
Interface for Binary Large Object (memory chunk) with smart reference counting.
Definition: IBlob.h:35
static ErrorCode save(IBlob **data, const IMesh *surf, bool binary=true, IProgressInfo *progr=0, ICancellationToken *cncl=0)
Save IMesh surface to STL blob.
Definition: StlIO.h:173
static ErrorCode saveAscii(IBlob **data, const IMesh *surf, const char *name=NULL, IProgressInfo *progr=0, ICancellationToken *cncl=0)
Save IMesh surface to ASCII STL blob.
Definition: StlIO.h:186
Interface for a progress notification listener.
Definition: IProgressInfo.h:76
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:209
bool ABASESDK_LINK_SPEC isStlBinary(const wchar_t *path)
Determines the format of the saved file.
static ErrorCode loadAscii(IMesh **surf, const IBlob *data, IProgressInfo *progr=0, ICancellationToken *cncl=0)
Definition: StlIO.h:234
static ErrorCode saveAscii(const wchar_t *path, const IMesh *surf, const char *name=NULL, IProgressInfo *progr=0, ICancellationToken *cncl=0)
Save IMesh surface to ASCII STL file.
Definition: StlIO.h:148
static ErrorCode saveBinary(const wchar_t *path, const IMesh *surf, IProgressInfo *progr=0, ICancellationToken *cncl=0)
Save IMesh surface to binary STL file.
Definition: StlIO.h:160
#define ABASESDK_LINK_SPEC
ErrorCode ABASESDK_LINK_SPEC saveStlMeshToFile(const wchar_t *path, const IMesh *surf, bool binary=true, IProgressInfo *progr=0, ICancellationToken *cncl=0)
Save IMesh surface to STL file.
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)
Save IMesh surface to ASCII STL blob.
static bool isBinary(const wchar_t *path)
Determines format of the saved file.
Definition: StlIO.h:246
static ErrorCode load(IMesh **surf, const wchar_t *path, IProgressInfo *progr=0, ICancellationToken *cncl=0)
Definition: StlIO.h:214