Artec 3D Scanning SDK  2.0
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 where to save mesh
33  * @param mesh - mesh to save
34  * @param calibrationMatrix - calibration matrix 3x4 to save
35  * @param progr - progress interface
36  * @param cncl - cancellation interface
37  * @param binary - text or binary PLY format
38  * @param saveTexCoords - save texture coordinates
39  * @param saveTexMatrix - save texture matrix
40  * @param saveTextures - save texture images alongside with a PLY file (available only for out-to-file functions).
41  * This flag is valid only when saveTexCoords is true
42  * @param imageFormat - texture image format if applicable ("png", "jpg", "bmp")
43  */
45  savePlyFrameToFile(const wchar_t* path, const IFrameMesh* mesh, const Matrix3x4D* calibrationMatrix = NULL, IProgressInfo* progr = NULL, ICancellationToken* cncl = NULL,
46  bool binary = true, bool saveTexCoords = true, bool saveTexMatrix = false, bool saveTextures = true,
47  const wchar_t* imageFormat = L"png");
49  savePlyCompositeToFile(const wchar_t* path, const ICompositeMesh* mesh, const Matrix3x4D* calibrationMatrix = NULL, IProgressInfo* progr = NULL, ICancellationToken* cncl = NULL,
50  bool binary = true, bool saveTexCoords = true, bool saveTexMatrix = false, bool saveTextures = true,
51  const wchar_t* imageFormat = L"png");
52  ///@}
53 
54  ///@{
55  /** Save IFrameMesh/ICompositeMesh to PLY blob
56  * @note Saves only geometry without texture (images are stored in a separate blob)
57  * @param data - blob where to save mesh
58  * @param mesh - mesh to save
59  * @param calibrationMatrix - calibration matrix 3x4 to save
60  * @param progr - progress interface
61  * @param cncl - cancellation interface
62  * @param binary - text or binary PLY format
63  * @param saveTexCoords - save texture coordinates
64  * @param saveTexMatrix - save texture matrix
65  * @param saveTextures - save texture images alongside with a PLY file (available only for out-to-file functions).
66  * This flag is valid only when saveTexCoords is true
67  * @param imageFormat - texture image format if applicable ("png", "jpg", "bmp")
68  */
70  savePlyFrameToBlob(IBlob** data, const IFrameMesh* mesh, const Matrix3x4D* calibrationMatrix, IProgressInfo* progr = 0, ICancellationToken* cncl = 0,
71  bool binary = true, bool saveTexCoords = true, bool saveTexMatrix = false);
73  savePlyCompositeToBlob(IBlob** data, const ICompositeMesh* mesh, const Matrix3x4D* calibrationMatrix, IProgressInfo* progr = 0, ICancellationToken* cncl = 0,
74  bool binary = true, bool saveTexCoords = true, bool saveTexMatrix = false);
75  ///@}
76 
77  ///@{
78  /** Load IFrameMesh/ICompositeMesh from PLY file
79  * @param mesh - loaded mesh
80  * @param calibrationMatrix - calibration matrix 3x4
81  * @param path - file path to load image from
82  * @param progr - progress interface
83  * @param cncl - cancellation interface
84  */
86  loadPlyFrameFromFile(IFrameMesh** mesh, Matrix3x4D* calibrationMatrix, const wchar_t* path, IProgressInfo* progr = 0, ICancellationToken* cncl = 0);
88  loadPlyCompositeFromFile(ICompositeMesh** mesh, Matrix3x4D* calibrationMatrix, const wchar_t* path, IProgressInfo* progr = 0, ICancellationToken* cncl = 0);
89  ///@}
90 
91  ///@{
92  /** Load IFrameMesh/ICompositeMesh from PLY blob
93  * @note Loads only geometry without texture (image is stored in a separate blob)
94  * @param mesh - loaded mesh
95  * @param calibrationMatrix - calibration matrix 3x4
96  * @param data - blob to load image from
97  * @param progr - progress interface
98  * @param cncl - cancellation interface
99  */
101  loadPlyFrameFromBlob(IFrameMesh** mesh, Matrix3x4D* calibrationMatrix, const IBlob* data, IProgressInfo* progr = 0, ICancellationToken* cncl = 0);
103  loadPlyCompositeFromBlob(ICompositeMesh** mesh, Matrix3x4D* calibrationMatrix, const IBlob* data, IProgressInfo* progr = 0, ICancellationToken* cncl = 0);
104  ///@}
105 
106  /** Save texture for a given surface
107  * @note This function is called by the save() (out-to-file versions) functions when save_textures == true && save_texcoords == true.
108  * @param filename - file path to PLY file. File names for textures will be generated automatically.
109  * @param mesh - textured mesh to save
110  * @param imageFormat - texture image format if applicable ("png", "jpg", "bmp")
111  */
113  savePlyTexture(const wchar_t* filename, const IFrameMesh* mesh, const wchar_t* imageFormat = L"png");
114 
115  /** Save textures for a given surface
116  * @note This function is called by the save() (out-to-file versions) functions when save_textures == true && save_texcoords == true.
117  * @param filename - file path to PLY file. File names for textures will be generated automatically.
118  * @param mesh - textured mesh to save
119  * @param imageFormat - texture image format if applicable ("png", "jpg", "bmp")
120  */
122  savePlyTextures(const wchar_t* filename, const ICompositeMesh* mesh, const wchar_t* imageFormat = L"png");
123 }
124  /// Class to save/load PLY files (Stanford Polygon File Format)
125  class Ply
126  {
127  public:
128 
129  ///@{
130  /** Save IFrameMesh/ICompositeMesh to PLY file
131  * @param path - file path where to save mesh
132  * @param mesh - mesh to save
133  * @param calibrationMatrix - calibration matrix 3x4 to save
134  * @param progr - progress interface
135  * @param cncl - cancellation interface
136  * @param binary - text or binary PLY format
137  * @param saveTexCoords - save texture coordinates
138  * @param saveTexMatrix - save texture matrix
139  * @param saveTextures - save texture images alongside with PLY file (available only for out-to-file functions).
140  * This flag is valid only when saveTexCoords == true
141  * @param imageFormat - texture image format if applicable ("png", "jpg", "bmp")
142  */
143  static ErrorCode
144  save(const wchar_t* path, const IFrameMesh* mesh, const Matrix3x4D* calibrationMatrix = NULL, IProgressInfo* progr = NULL, ICancellationToken* cncl = NULL,
145  bool binary = true, bool saveTexCoords = true, bool saveTexMatrix = false, bool saveTextures = true,
146  const wchar_t* imageFormat = L"png")
147  {
148  return savePlyFrameToFile(path, mesh, calibrationMatrix, progr, cncl, binary,
149  saveTexCoords, saveTexMatrix, saveTextures, imageFormat);
150  }
151 
152  static ErrorCode
153  save(const wchar_t* path, const ICompositeMesh* mesh, const Matrix3x4D* calibrationMatrix = NULL, IProgressInfo* progr = NULL, ICancellationToken* cncl = NULL,
154  bool binary = true, bool saveTexCoords = true, bool saveTexMatrix = false, bool saveTextures = true,
155  const wchar_t* imageFormat = L"png")
156  {
157  return savePlyCompositeToFile(path, mesh, calibrationMatrix, progr, cncl, binary,
158  saveTexCoords, saveTexMatrix, saveTextures, imageFormat);
159  }
160  ///@}
161 
162  ///@{
163  /** Save IFrameMesh/ICompositeMesh to PLY blob
164  * @note Saves only geometry without texture (images are stored in a separate blob)
165  * @param data - blob where to save mesh
166  * @param mesh - mesh to save
167  * @param calibrationMatrix - calibration matrix 3x4 to save
168  * @param progr - progress interface
169  * @param cncl - cancellation interface
170  * @param binary - text or binary PLY format
171  * @param saveTexCoords - save texture coordinates
172  * @param saveTexMatrix - save texture matrix
173  * @param saveTextures - save texture images alongside with PLY file (available only for out-to-file functions).
174  * This flag is valid only when saveTexCoords == true
175  * @param imageFormat - texture image format if applicable ("png", "jpg", "bmp")
176  */
177  static ErrorCode
178  save(IBlob** data, const IFrameMesh* mesh, const Matrix3x4D* calibrationMatrix, IProgressInfo* progr = 0, ICancellationToken* cncl = 0,
179  bool binary = true, bool saveTexCoords = true, bool saveTexMatrix = false)
180  {
181  return savePlyFrameToBlob(data, mesh, calibrationMatrix, progr, cncl, binary,
182  saveTexCoords, saveTexMatrix);
183  }
184 
185  static ErrorCode
186  save(IBlob** data, const ICompositeMesh* mesh, const Matrix3x4D* calibrationMatrix, IProgressInfo* progr = 0, ICancellationToken* cncl = 0,
187  bool binary = true, bool saveTexCoords = true, bool saveTexMatrix = false)
188  {
189  return savePlyCompositeToBlob(data, mesh, calibrationMatrix, progr, cncl, binary,
190  saveTexCoords, saveTexMatrix);
191  }
192  ///@}
193 
194  ///@{
195  /** Load IFrameMesh/ICompositeMesh from PLY file
196  * @param mesh - loaded mesh
197  * @param calibrationMatrix - calibration matrix 3x4
198  * @param path - file path to load image from
199  * @param progr - progress interface
200  * @param cncl - cancellation interface
201  */
202  static ErrorCode load(IFrameMesh** mesh, Matrix3x4D* calibrationMatrix, const wchar_t* path, IProgressInfo* progr = 0, ICancellationToken* cncl = 0)
203  {
204  return loadPlyFrameFromFile(mesh, calibrationMatrix, path, progr, cncl);
205  }
206 
207  static ErrorCode load(ICompositeMesh** mesh, Matrix3x4D* calibrationMatrix, const wchar_t* path, IProgressInfo* progr = 0, ICancellationToken* cncl = 0)
208  {
209  return loadPlyCompositeFromFile(mesh, calibrationMatrix, path, progr, cncl);
210  }
211  ///@}
212 
213  ///@{
214  /** Load IFrameMesh/ICompositeMesh from PLY blob
215  * @note Loads only geometry without texture (image is stored in a separate blob)
216  * @param mesh - loaded mesh
217  * @param calibrationMatrix - calibration matrix 3x4
218  * @param data - blob to load image from
219  * @param progr - progress interface
220  * @param cncl - cancellation interface
221  */
222  static ErrorCode load(IFrameMesh** mesh, Matrix3x4D* calibrationMatrix, const IBlob* data, IProgressInfo* progr = 0, ICancellationToken* cncl = 0)
223  {
224  return loadPlyFrameFromBlob(mesh, calibrationMatrix, data, progr, cncl);
225  }
226 
227  static ErrorCode load(ICompositeMesh** mesh, Matrix3x4D* calibrationMatrix, const IBlob* data, IProgressInfo* progr = 0, ICancellationToken* cncl = 0)
228  {
229  return loadPlyCompositeFromBlob(mesh, calibrationMatrix, data, progr, cncl);
230  }
231  ///@}
232 
233  /** Save texture for a given surface
234  * @note This function is called by the save() functions (out-to-file versions) when save_textures == true && save_texcoords == true.
235  * @param filename - file path to the PLY file. File names for textures will be generated automatically.
236  * @param mesh - textured mesh to save
237  * @param imageFormat - texture image format if applicable ("png", "jpg", "bmp")
238  */
239  static ErrorCode saveTexture(const wchar_t* filename, const IFrameMesh* mesh, const wchar_t* imageFormat = L"png");
240 
241  /** Save textures for a given surface
242  * @note This function is called by the save() functions (out-to-file versions) when save_textures == true && save_texcoords == true.
243  * @param filename - file path to the PLY file. File names for textures will be generated automatically.
244  * @param mesh - textured mesh to save
245  * @param imageFormat - texture image format if applicable ("png", "jpg", "bmp")
246  */
247  static ErrorCode saveTextures(const wchar_t* filename, const ICompositeMesh* mesh, const wchar_t* imageFormat = L"png");
248  };
249 
250 } } } } // namespace artec::sdk::base::io
251 
252 #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")
Save IFrameMesh/ICompositeMesh to PLY file.
Definition: PlyIO.h:144
ErrorCode ABASESDK_LINK_SPEC loadPlyFrameFromBlob(IFrameMesh **mesh, Matrix3x4D *calibrationMatrix, const IBlob *data, IProgressInfo *progr=0, ICancellationToken *cncl=0)
Load IFrameMesh/ICompositeMesh from PLY blob.
static ErrorCode saveTexture(const wchar_t *filename, const IFrameMesh *mesh, const wchar_t *imageFormat=L"png")
Save texture for a given surface.
static ErrorCode saveTextures(const wchar_t *filename, const ICompositeMesh *mesh, const wchar_t *imageFormat=L"png")
Save textures for a given surface.
ErrorCode ABASESDK_LINK_SPEC savePlyTexture(const wchar_t *filename, const IFrameMesh *mesh, const wchar_t *imageFormat=L"png")
Save texture for a given surface.
static ErrorCode load(ICompositeMesh **mesh, Matrix3x4D *calibrationMatrix, const wchar_t *path, IProgressInfo *progr=0, ICancellationToken *cncl=0)
Load IFrameMesh/ICompositeMesh from PLY file.
Definition: PlyIO.h:207
Indexed triangle mesh with optional texture.
Definition: IFrameMesh.h:42
static ErrorCode load(IFrameMesh **mesh, Matrix3x4D *calibrationMatrix, const wchar_t *path, IProgressInfo *progr=0, ICancellationToken *cncl=0)
Load IFrameMesh/ICompositeMesh from PLY file.
Definition: PlyIO.h:202
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")
Save IFrameMesh/ICompositeMesh to PLY file.
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)
Save IFrameMesh/ICompositeMesh to PLY blob.
Definition: PlyIO.h:186
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)
Save IFrameMesh/ICompositeMesh to PLY blob.
Definition: PlyIO.h:178
Callback interface to notify process about cancellation.
static ErrorCode load(ICompositeMesh **mesh, Matrix3x4D *calibrationMatrix, const IBlob *data, IProgressInfo *progr=0, ICancellationToken *cncl=0)
Load IFrameMesh/ICompositeMesh from PLY blob.
Definition: PlyIO.h:227
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")
Save IFrameMesh/ICompositeMesh to PLY file.
Definition: PlyIO.h:153
Matrix of unspecified size.
Definition: GenericMatrix.h:30
Interface for Binary Large Object (memory chunk) with smart reference counting.
Definition: IBlob.h:35
static ErrorCode load(IFrameMesh **mesh, Matrix3x4D *calibrationMatrix, const IBlob *data, IProgressInfo *progr=0, ICancellationToken *cncl=0)
Load IFrameMesh/ICompositeMesh from PLY blob.
Definition: PlyIO.h:222
Interface for a progress notification listener.
Definition: IProgressInfo.h:76
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")
Save IFrameMesh/ICompositeMesh to PLY file.
ErrorCode ABASESDK_LINK_SPEC savePlyTextures(const wchar_t *filename, const ICompositeMesh *mesh, const wchar_t *imageFormat=L"png")
Save textures for a given surface.
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)
Save IFrameMesh/ICompositeMesh to PLY blob.
Indexed triangle mesh with optional unwrapped textures.
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)
Save IFrameMesh/ICompositeMesh to PLY blob.
ErrorCode ABASESDK_LINK_SPEC loadPlyFrameFromFile(IFrameMesh **mesh, Matrix3x4D *calibrationMatrix, const wchar_t *path, IProgressInfo *progr=0, ICancellationToken *cncl=0)
Load IFrameMesh/ICompositeMesh from PLY file.
Class to save/load PLY files (Stanford Polygon File Format)
Definition: PlyIO.h:125
GenericMatrix< 3, 4, double > Matrix3x4D
Definition: Matrix.h:783
#define ABASESDK_LINK_SPEC
ErrorCode ABASESDK_LINK_SPEC loadPlyCompositeFromFile(ICompositeMesh **mesh, Matrix3x4D *calibrationMatrix, const wchar_t *path, IProgressInfo *progr=0, ICancellationToken *cncl=0)
Load IFrameMesh/ICompositeMesh from PLY file.
ErrorCode ABASESDK_LINK_SPEC loadPlyCompositeFromBlob(ICompositeMesh **mesh, Matrix3x4D *calibrationMatrix, const IBlob *data, IProgressInfo *progr=0, ICancellationToken *cncl=0)
Load IFrameMesh/ICompositeMesh from PLY blob.