PlyIO.h
Go to the documentation of this file.
1 /********************************************************************
2 *
3 * Project Artec 3D Scanning SDK
4 *
5 * Purpose: Greg Turk (Cyberware) polygon file format support
6 *
7 * Copyright: Artec Group
8 *
9 ********************************************************************/
10 
11 #ifndef _PLYIO_H_
12 #define _PLYIO_H_
13 
15 #include <artec/sdk/base/Errors.h>
16 #include <artec/sdk/base/Matrix.h>
17 
18 namespace artec { namespace sdk { namespace base
19 {
20  class IBlob;
21  class IFrameMesh;
22  class ICompositeMesh;
23  class ICancellationToken;
24  class IProgressInfo;
25 
26 namespace io {
27 
28 extern "C" {
29 
30  ///@{
31  /** Save IFrameMesh/ICompositeMesh to PLY file
32  * @param path - file path to save mesh to
33  * @param mesh - mesh to be saved
34  * @param calibrationMatrix - calibration matrix 3x4 to be saved
35  * @param progr - progress interface
36  * @param cncl - cancel interface
37  * @param binary - text or binary ply format
38  * @param saveTexCoords - if texture coordinates should be saved
39  * @param saveTexMatrix - if texture matrix should be saved
40  * @param saveTextures - if texture images should be saved near PLY file (available only for out-to-file functions).
41  * this flag is valid only when save_texcoords == true
42  * @param imageFormat - format for texture images if they should be saved ("png","jpg","bmp")
43  * @return error code
44  */
46  savePlyFrameToFile(const wchar_t* path, const IFrameMesh* mesh, const Matrix3x4D* calibrationMatrix = NULL, IProgressInfo* progr = NULL, ICancellationToken* cncl = NULL,
47  bool binary = true, bool saveTexCoords = true, bool saveTexMatrix = false, bool saveTextures = true,
48  const wchar_t* imageFormat = L"png");
50  savePlyCompositeToFile(const wchar_t* path, const ICompositeMesh* mesh, const Matrix3x4D* calibrationMatrix = NULL, IProgressInfo* progr = NULL, ICancellationToken* cncl = NULL,
51  bool binary = true, bool saveTexCoords = true, bool saveTexMatrix = false, bool saveTextures = true,
52  const wchar_t* imageFormat = L"png");
53  ///@}
54 
55  ///@{
56  /** Save IFrameMesh/ICompositeMesh to PLY blob
57  * @note save only geometry, not texture also, because images is stored in separate blob
58  * @param data - blob to save mesh to
59  * @param mesh - mesh to be saved
60  * @param calibrationMatrix - calibration matrix 3x4 to be saved
61  * @param progr - progress interface
62  * @param cncl - cancel interface
63  * @param binary - text or binary ply format
64  * @param saveTexCoords - if texture coordinates should be saved
65  * @param saveTexMatrix - if texture matrix should be saved
66  * @param saveTextures - if texture images should be saved near PLY file (available only for out-to-file functions).
67  * this flag is valid only when save_texcoords == true
68  * @param imageFormat - format for texture images if they should be saved ("png","jpg","bmp")
69  * @return error code
70  */
72  savePlyFrameToBlob(IBlob** data, const IFrameMesh* mesh, const Matrix3x4D* calibrationMatrix, IProgressInfo* progr = 0, ICancellationToken* cncl = 0,
73  bool binary = true, bool saveTexCoords = true, bool saveTexMatrix = false);
75  savePlyCompositeToBlob(IBlob** data, const ICompositeMesh* mesh, const Matrix3x4D* calibrationMatrix, IProgressInfo* progr = 0, ICancellationToken* cncl = 0,
76  bool binary = true, bool saveTexCoords = true, bool saveTexMatrix = false);
77  ///@}
78 
79  ///@{
80  /** Load IFrameMesh/ICompositeMesh from PLY file
81  * @param mesh - loaded mesh
82  * @param calibrationMatrix - calibration matrix 3x4
83  * @param path - file path to load image from
84  * @param progr - progress interface
85  * @param cncl - cancel interface
86  * @return error code
87  */
89  loadPlyFrameFromFile(IFrameMesh** mesh, Matrix3x4D* calibrationMatrix, const wchar_t* path, IProgressInfo* progr = 0, ICancellationToken* cncl = 0);
91  loadPlyCompositeFromFile(ICompositeMesh** mesh, Matrix3x4D* calibrationMatrix, const wchar_t* path, IProgressInfo* progr = 0, ICancellationToken* cncl = 0);
92  ///@}
93 
94  ///@{
95  /** Load IFrameMesh/ICompositeMesh from PLY blob
96  * @note load only geometry, not texture also, because image is stored in separate blob
97  * @param mesh - loaded mesh
98  * @param calibrationMatrix - calibration matrix 3x4
99  * @param data - blob to load image from
100  * @param progr - progress interface
101  * @param cncl - cancel interface
102  * @return error code
103  */
105  loadPlyFrameFromBlob(IFrameMesh** mesh, Matrix3x4D* calibrationMatrix, const IBlob* data, IProgressInfo* progr = 0, ICancellationToken* cncl = 0);
107  loadPlyCompositeFromBlob(ICompositeMesh** mesh, Matrix3x4D* calibrationMatrix, const IBlob* data, IProgressInfo* progr = 0, ICancellationToken* cncl = 0);
108  ///@}
109 
110  /** Save texture for given surface
111  * @note This function is called by save() (out-to-file versions) functions when save_textures == true && save_texcoords == true.
112  * @param filename - file path to .ply file. File names for textures will be generated automatically.
113  * @param mesh - textured mesh to be saved
114  * @param imageFormat - format for texture images if they should be saved ("png","jpg","bmp")
115  * @return error code
116  */
118  savePlyTexture(const wchar_t* filename, const IFrameMesh* mesh, const wchar_t* imageFormat = L"png");
119 
120  /** Save textures for given surface
121  * @note This function is called by save() (out-to-file versions) functions when save_textures == true && save_texcoords == true.
122  * @param filename - file path to .ply file. File names for textures will be generated automatically.
123  * @param mesh - textured mesh to be saved
124  * @param imageFormat - format for texture images if they should be saved ("png","jpg","bmp")
125  * @return error code
126  */
128  savePlyTextures(const wchar_t* filename, const ICompositeMesh* mesh, const wchar_t* imageFormat = L"png");
129 }
130 
131  class Ply
132  {
133  public:
134 
135  ///@{
136  /** Save IFrameMesh/ICompositeMesh to PLY file
137  * @param path - file path to save mesh to
138  * @param mesh - mesh to be saved
139  * @param calibrationMatrix - calibration matrix 3x4 to be saved
140  * @param progr - progress interface
141  * @param cncl - cancel interface
142  * @param binary - text or binary ply format
143  * @param saveTexCoords - if texture coordinates should be saved
144  * @param saveTexMatrix - if texture matrix should be saved
145  * @param saveTextures - if texture images should be saved near PLY file (available only for out-to-file functions).
146  * this flag is valid only when save_texcoords == true
147  * @param imageFormat - format for texture images if they should be saved ("png","jpg","bmp")
148  * @return error code
149  */
150  static ErrorCode
151  save(const wchar_t* path, const IFrameMesh* mesh, const Matrix3x4D* calibrationMatrix = NULL, IProgressInfo* progr = NULL, ICancellationToken* cncl = NULL,
152  bool binary = true, bool saveTexCoords = true, bool saveTexMatrix = false, bool saveTextures = true,
153  const wchar_t* imageFormat = L"png")
154  {
155  return savePlyFrameToFile(path, mesh, calibrationMatrix, progr, cncl, binary,
156  saveTexCoords, saveTexMatrix, saveTextures, imageFormat);
157  }
158 
159  static ErrorCode
160  save(const wchar_t* path, const ICompositeMesh* mesh, const Matrix3x4D* calibrationMatrix = NULL, IProgressInfo* progr = NULL, ICancellationToken* cncl = NULL,
161  bool binary = true, bool saveTexCoords = true, bool saveTexMatrix = false, bool saveTextures = true,
162  const wchar_t* imageFormat = L"png")
163  {
164  return savePlyCompositeToFile(path, mesh, calibrationMatrix, progr, cncl, binary,
165  saveTexCoords, saveTexMatrix, saveTextures, imageFormat);
166  }
167  ///@}
168 
169  ///@{
170  /** Save IFrameMesh/ICompositeMesh to PLY blob
171  * @note save only geometry, not texture also, because images is stored in separate blob
172  * @param data - blob to save mesh to
173  * @param mesh - mesh to be saved
174  * @param calibrationMatrix - calibration matrix 3x4 to be saved
175  * @param progr - progress interface
176  * @param cncl - cancel interface
177  * @param binary - text or binary ply format
178  * @param saveTexCoords - if texture coordinates should be saved
179  * @param saveTexMatrix - if texture matrix should be saved
180  * @param saveTextures - if texture images should be saved near PLY file (available only for out-to-file functions).
181  * this flag is valid only when save_texcoords == true
182  * @param imageFormat - format for texture images if they should be saved ("png","jpg","bmp")
183  * @return error code
184  */
185  static ErrorCode
186  save(IBlob** data, const IFrameMesh* mesh, const Matrix3x4D* calibrationMatrix, IProgressInfo* progr = 0, ICancellationToken* cncl = 0,
187  bool binary = true, bool saveTexCoords = true, bool saveTexMatrix = false)
188  {
189  return savePlyFrameToBlob(data, mesh, calibrationMatrix, progr, cncl, binary,
190  saveTexCoords, saveTexMatrix);
191  }
192 
193  static ErrorCode
194  save(IBlob** data, const ICompositeMesh* mesh, const Matrix3x4D* calibrationMatrix, IProgressInfo* progr = 0, ICancellationToken* cncl = 0,
195  bool binary = true, bool saveTexCoords = true, bool saveTexMatrix = false)
196  {
197  return savePlyCompositeToBlob(data, mesh, calibrationMatrix, progr, cncl, binary,
198  saveTexCoords, saveTexMatrix);
199  }
200  ///@}
201 
202  ///@{
203  /** Load IFrameMesh/ICompositeMesh from PLY file
204  * @param mesh - loaded mesh
205  * @param calibrationMatrix - calibration matrix 3x4
206  * @param path - file path to load image from
207  * @param progr - progress interface
208  * @param cncl - cancel interface
209  * @return error code
210  */
211  static ErrorCode load(IFrameMesh** mesh, Matrix3x4D* calibrationMatrix, const wchar_t* path, IProgressInfo* progr = 0, ICancellationToken* cncl = 0)
212  {
213  return loadPlyFrameFromFile(mesh, calibrationMatrix, path, progr, cncl);
214  }
215 
216  static ErrorCode load(ICompositeMesh** mesh, Matrix3x4D* calibrationMatrix, const wchar_t* path, IProgressInfo* progr = 0, ICancellationToken* cncl = 0)
217  {
218  return loadPlyCompositeFromFile(mesh, calibrationMatrix, path, progr, cncl);
219  }
220  ///@}
221 
222  ///@{
223  /** Load IFrameMesh/ICompositeMesh from PLY blob
224  * @note load only geometry, not texture also, because image is stored in separate blob
225  * @param mesh - loaded mesh
226  * @param calibrationMatrix - calibration matrix 3x4
227  * @param data - blob to load image from
228  * @param progr - progress interface
229  * @param cncl - cancel interface
230  * @return error code
231  */
232  static ErrorCode load(IFrameMesh** mesh, Matrix3x4D* calibrationMatrix, const IBlob* data, IProgressInfo* progr = 0, ICancellationToken* cncl = 0)
233  {
234  return loadPlyFrameFromBlob(mesh, calibrationMatrix, data, progr, cncl);
235  }
236 
237  static ErrorCode load(ICompositeMesh** mesh, Matrix3x4D* calibrationMatrix, const IBlob* data, IProgressInfo* progr = 0, ICancellationToken* cncl = 0)
238  {
239  return loadPlyCompositeFromBlob(mesh, calibrationMatrix, data, progr, cncl);
240  }
241  ///@}
242 
243  /** Save texture for given surface
244  * @note This function is called by save() (out-to-file versions) functions when save_textures == true && save_texcoords == true.
245  * @param filename - file path to .ply file. File names for textures will be generated automatically.
246  * @param mesh - textured mesh to be saved
247  * @param imageFormat - format for texture images if they should be saved ("png","jpg","bmp")
248  * @return error code
249  */
250  static ErrorCode saveTexture(const wchar_t* filename, const IFrameMesh* mesh, const wchar_t* imageFormat = L"png");
251 
252  /** Save textures for given surface
253  * @note This function is called by save() (out-to-file versions) functions when save_textures == true && save_texcoords == true.
254  * @param filename - file path to .ply file. File names for textures will be generated automatically.
255  * @param mesh - textured mesh to be saved
256  * @param imageFormat - format for texture images if they should be saved ("png","jpg","bmp")
257  * @return error code
258  */
259  static ErrorCode saveTextures(const wchar_t* filename, const ICompositeMesh* mesh, const wchar_t* imageFormat = L"png");
260  };
261 
262 } } } } // namespace artec::sdk::base::io
263 
264 #endif // _PLYIO_H_
static ErrorCode save(const wchar_t *path, const IFrameMesh *mesh, const Matrix3x4D *calibrationMatrix=NULL, IProgressInfo *progr=NULL, ICancellationToken *cncl=NULL, bool binary=true, bool saveTexCoords=true, bool saveTexMatrix=false, bool saveTextures=true, const wchar_t *imageFormat=L"png")
Definition: PlyIO.h:151
ErrorCode ABASESDK_LINK_SPEC loadPlyFrameFromBlob(IFrameMesh **mesh, Matrix3x4D *calibrationMatrix, const IBlob *data, IProgressInfo *progr=0, ICancellationToken *cncl=0)
static ErrorCode saveTexture(const wchar_t *filename, const IFrameMesh *mesh, const wchar_t *imageFormat=L"png")
static ErrorCode saveTextures(const wchar_t *filename, const ICompositeMesh *mesh, const wchar_t *imageFormat=L"png")
ErrorCode ABASESDK_LINK_SPEC savePlyTexture(const wchar_t *filename, const IFrameMesh *mesh, const wchar_t *imageFormat=L"png")
static ErrorCode load(ICompositeMesh **mesh, Matrix3x4D *calibrationMatrix, const wchar_t *path, IProgressInfo *progr=0, ICancellationToken *cncl=0)
Definition: PlyIO.h:216
static ErrorCode load(IFrameMesh **mesh, Matrix3x4D *calibrationMatrix, const wchar_t *path, IProgressInfo *progr=0, ICancellationToken *cncl=0)
Definition: PlyIO.h:211
ErrorCode ABASESDK_LINK_SPEC savePlyFrameToFile(const wchar_t *path, const IFrameMesh *mesh, const Matrix3x4D *calibrationMatrix=NULL, IProgressInfo *progr=NULL, ICancellationToken *cncl=NULL, bool binary=true, bool saveTexCoords=true, bool saveTexMatrix=false, bool saveTextures=true, const wchar_t *imageFormat=L"png")
static ErrorCode save(IBlob **data, const ICompositeMesh *mesh, const Matrix3x4D *calibrationMatrix, IProgressInfo *progr=0, ICancellationToken *cncl=0, bool binary=true, bool saveTexCoords=true, bool saveTexMatrix=false)
Definition: PlyIO.h:194
static ErrorCode save(IBlob **data, const IFrameMesh *mesh, const Matrix3x4D *calibrationMatrix, IProgressInfo *progr=0, ICancellationToken *cncl=0, bool binary=true, bool saveTexCoords=true, bool saveTexMatrix=false)
Definition: PlyIO.h:186
static ErrorCode load(ICompositeMesh **mesh, Matrix3x4D *calibrationMatrix, const IBlob *data, IProgressInfo *progr=0, ICancellationToken *cncl=0)
Definition: PlyIO.h:237
static ErrorCode save(const wchar_t *path, const ICompositeMesh *mesh, const Matrix3x4D *calibrationMatrix=NULL, IProgressInfo *progr=NULL, ICancellationToken *cncl=NULL, bool binary=true, bool saveTexCoords=true, bool saveTexMatrix=false, bool saveTextures=true, const wchar_t *imageFormat=L"png")
Definition: PlyIO.h:160
static ErrorCode load(IFrameMesh **mesh, Matrix3x4D *calibrationMatrix, const IBlob *data, IProgressInfo *progr=0, ICancellationToken *cncl=0)
Definition: PlyIO.h:232
ErrorCode ABASESDK_LINK_SPEC savePlyCompositeToFile(const wchar_t *path, const ICompositeMesh *mesh, const Matrix3x4D *calibrationMatrix=NULL, IProgressInfo *progr=NULL, ICancellationToken *cncl=NULL, bool binary=true, bool saveTexCoords=true, bool saveTexMatrix=false, bool saveTextures=true, const wchar_t *imageFormat=L"png")
ErrorCode ABASESDK_LINK_SPEC savePlyTextures(const wchar_t *filename, const ICompositeMesh *mesh, const wchar_t *imageFormat=L"png")
ErrorCode ABASESDK_LINK_SPEC savePlyCompositeToBlob(IBlob **data, const ICompositeMesh *mesh, const Matrix3x4D *calibrationMatrix, IProgressInfo *progr=0, ICancellationToken *cncl=0, bool binary=true, bool saveTexCoords=true, bool saveTexMatrix=false)
ErrorCode ABASESDK_LINK_SPEC savePlyFrameToBlob(IBlob **data, const IFrameMesh *mesh, const Matrix3x4D *calibrationMatrix, IProgressInfo *progr=0, ICancellationToken *cncl=0, bool binary=true, bool saveTexCoords=true, bool saveTexMatrix=false)
ErrorCode ABASESDK_LINK_SPEC loadPlyFrameFromFile(IFrameMesh **mesh, Matrix3x4D *calibrationMatrix, const wchar_t *path, IProgressInfo *progr=0, ICancellationToken *cncl=0)
GenericMatrix< 3, 4, double > Matrix3x4D
Definition: Matrix.h:820
#define ABASESDK_LINK_SPEC
Definition: BaseSdkDefines.h:7
ErrorCode ABASESDK_LINK_SPEC loadPlyCompositeFromFile(ICompositeMesh **mesh, Matrix3x4D *calibrationMatrix, const wchar_t *path, IProgressInfo *progr=0, ICancellationToken *cncl=0)
ErrorCode ABASESDK_LINK_SPEC loadPlyCompositeFromBlob(ICompositeMesh **mesh, Matrix3x4D *calibrationMatrix, const IBlob *data, IProgressInfo *progr=0, ICancellationToken *cncl=0)