Artec 3D Scanning SDK  2.0
ObjIO.h
Go to the documentation of this file.
1 /********************************************************************
2 *
3 * Project Artec 3D Scanning SDK
4 *
5 * Purpose: Wavefront OBJ file format support
6 *
7 * Copyright: Artec Group
8 *
9 ********************************************************************/
10 
11 #ifndef _OBJIO_H_
12 #define _OBJIO_H_
13 
15 #include <artec/sdk/base/Errors.h>
16 
17 namespace artec { namespace sdk { namespace base
18 {
19  class IBlob;
20  class IFrameMesh;
21  class ICompositeMesh;
22  class ICancellationToken;
23  class IProgressInfo;
24 
25 namespace io {
26 
27 extern "C" {
28 
29  ///@{
30  /** Save IFrameMesh/ICompositeMesh to OBJ file
31  * @param path - file path where to save mesh
32  * @param mesh - mesh to save
33  * @param progr - progress interface
34  * @param cncl - cancellation interface
35  * @param saveNormals - save normals to file
36  * @param saveTexCoords - save texture coordinates
37  * @param imageFormat - texture image format if applicable ("png","jpg","bmp")
38  * @note If you set the saveTexCoords flag, then texture images will also be saved.
39  */
41  saveObjFrameToFile(const wchar_t* path, const IFrameMesh* mesh, IProgressInfo* progr = 0, ICancellationToken* cncl = 0,
42  bool saveNormals = true, bool saveTexCoords = true, const wchar_t* imageFormat = L"png");
44  saveObjCompositeToFile(const wchar_t* path, const ICompositeMesh* mesh, IProgressInfo* progr = 0, ICancellationToken* cncl = 0,
45  bool saveNormals = true, bool saveTexCoords = true, const wchar_t* imageFormat = L"png");
46  ///@}
47 
48  ///@{
49  /** Save IFrameMesh/ICompositeMesh to OBJ blob
50  * @note Saves only geometry without texture and material (material and images are stored in a separate blob)
51  * @param data - blob where to save mesh
52  * @param mesh - mesh to save
53  * @param progr - progress interface
54  * @param cncl - cancellation interface
55  * @param saveNormals - save normals to file
56  * @param saveTexCoords - save texture coordinates
57  */
59  saveObjFrameToBlob(IBlob** data, const IFrameMesh* mesh, IProgressInfo* progr = 0, ICancellationToken* cncl = 0,
60  bool saveNormals = true, bool saveTexCoords = true, const wchar_t* materialFilename = NULL);
62  saveObjCompositeToBlob(IBlob** data, const ICompositeMesh* mesh, IProgressInfo* progr = 0, ICancellationToken* cncl = 0,
63  bool saveNormals = true, bool saveTexCoords = true, const wchar_t* materialFilename = NULL);
64  ///@}
65 
66  ///@{
67  /** Load IFrameMesh/ICompositeMesh from OBJ file
68  * @param mesh - loaded mesh
69  * @param path - file path to load image from
70  * @param progr - progress interface
71  * @param cncl - cancellation interface
72  */
74  loadObjFrameFromFile(IFrameMesh** mesh, const wchar_t* path, IProgressInfo* progr = 0, ICancellationToken* cncl = 0);
76  loadObjCompositeFromFile(ICompositeMesh** mesh, const wchar_t* path, IProgressInfo* progr = 0, ICancellationToken* cncl = 0);
77  ///@}
78 
79  ///@{
80  /** Load IFrameMesh/ICompositeMesh from OBJ blob
81  * @note Loads only geometry without texture (image is stored in a separate blob)
82  * @param mesh - loaded mesh
83  * @param data - blob to load image from
84  * @param progr - progress interface
85  * @param cncl - cancellation interface
86  */
88  loadObjFrameFromBlob(IFrameMesh** mesh, const IBlob* data, IProgressInfo* progr = 0, ICancellationToken* cncl = 0);
90  loadObjCompositeFromBlob(ICompositeMesh** mesh, const IBlob* data, IProgressInfo* progr = 0, ICancellationToken* cncl = 0);
91  ///@}
92 }
93  /// Class to save/load OBJ files
94  class Obj
95  {
96  public:
97  ///@{
98  /** Save IFrameMesh/ICompositeMesh to OBJ file
99  * @param path - file path where to save mesh
100  * @param mesh - mesh to save
101  * @param progr - progress interface
102  * @param cncl - cancellation interface
103  * @param saveNormals - save normals to file
104  * @param saveTexCoords - save texture coordinates
105  * @param imageFormat - texture image format if applicable ("png","jpg","bmp")
106  * @note If you set the saveTexCoords flag, then texture images will also be saved.
107  */
108  static ErrorCode
109  save(const wchar_t* path, const IFrameMesh* mesh, IProgressInfo* progr = 0, ICancellationToken* cncl = 0,
110  bool saveNormals = true, bool saveTexCoords = true, const wchar_t* imageFormat = L"png")
111  {
112  return saveObjFrameToFile(path, mesh, progr, cncl, saveNormals, saveTexCoords, imageFormat);
113  }
114 
115  static ErrorCode
116  save(const wchar_t* path, const ICompositeMesh* mesh, IProgressInfo* progr = 0, ICancellationToken* cncl = 0,
117  bool saveNormals = true, bool saveTexCoords = true, const wchar_t* imageFormat = L"png")
118  {
119  return saveObjCompositeToFile(path, mesh, progr, cncl, saveNormals, saveTexCoords, imageFormat);
120  }
121  ///@}
122 
123  ///@{
124  /** Save IFrameMesh/ICompositeMesh to OBJ blob
125  * @note Saves only geometry without texture and material (material and images are stored in a separate blob)
126  * @param data - blob where to save mesh
127  * @param mesh - mesh to save
128  * @param progr - progress interface
129  * @param cncl - cancellation interface
130  * @param saveNormals - save normals to file
131  * @param saveTexCoords - save texture coordinates
132  */
133  static ErrorCode
134  save(IBlob** data, const IFrameMesh* mesh, IProgressInfo* progr = 0, ICancellationToken* cncl = 0,
135  bool saveNormals = true, bool saveTexCoords = true, const wchar_t* materialFilename = NULL)
136  {
137  return saveObjFrameToBlob(data, mesh, progr, cncl, saveNormals, saveTexCoords, materialFilename);
138  }
139 
140  static ErrorCode
141  save(IBlob** data, const ICompositeMesh* mesh, IProgressInfo* progr = 0, ICancellationToken* cncl = 0,
142  bool saveNormals = true, bool saveTexCoords = true, const wchar_t* materialFilename = NULL)
143  {
144  return saveObjCompositeToBlob(data, mesh, progr, cncl, saveNormals, saveTexCoords, materialFilename);
145  }
146  ///@}
147 
148  ///@{
149  /** Load IFrameMesh/ICompositeMesh from OBJ file
150  * @param mesh - loaded mesh
151  * @param path - file path to load image from
152  * @param progr - progress interface
153  * @param cncl - cancellation interface
154  */
155  static ErrorCode load(IFrameMesh** mesh, const wchar_t* path, IProgressInfo* progr = 0, ICancellationToken* cncl = 0)
156  {
157  return loadObjFrameFromFile(mesh, path, progr, cncl);
158  }
159 
160  static ErrorCode load(ICompositeMesh** mesh, const wchar_t* path, IProgressInfo* progr = 0, ICancellationToken* cncl = 0)
161  {
162  return loadObjCompositeFromFile(mesh, path, progr, cncl);
163  }
164  ///@}
165 
166  ///@{
167  /** Load IFrameMesh/ICompositeMesh from OBJ blob
168  * @note Loads only geometry without texture (image is stored in a separate blob)
169  * @param mesh - loaded mesh
170  * @param data - blob to load image from
171  * @param progr - progress interface
172  * @param cncl - cancellation interface
173  */
174  static ErrorCode load(IFrameMesh** mesh, const IBlob* data, IProgressInfo* progr = 0, ICancellationToken* cncl = 0)
175  {
176  return loadObjFrameFromBlob(mesh, data, progr, cncl);
177  }
178 
179  static ErrorCode load(ICompositeMesh** mesh, const IBlob* data, IProgressInfo* progr = 0, ICancellationToken* cncl = 0)
180  {
181  return loadObjCompositeFromBlob(mesh, data, progr, cncl);
182  }
183  ///@}
184 
185  };
186 
187 } } } } // namespace artec::sdk::base::io
188 
189 #endif // _OBJIO_H_
static ErrorCode save(IBlob **data, const IFrameMesh *mesh, IProgressInfo *progr=0, ICancellationToken *cncl=0, bool saveNormals=true, bool saveTexCoords=true, const wchar_t *materialFilename=NULL)
Save IFrameMesh/ICompositeMesh to OBJ blob.
Definition: ObjIO.h:134
static ErrorCode save(const wchar_t *path, const ICompositeMesh *mesh, IProgressInfo *progr=0, ICancellationToken *cncl=0, bool saveNormals=true, bool saveTexCoords=true, const wchar_t *imageFormat=L"png")
Save IFrameMesh/ICompositeMesh to OBJ file.
Definition: ObjIO.h:116
Class to save/load OBJ files.
Definition: ObjIO.h:94
ErrorCode ABASESDK_LINK_SPEC saveObjCompositeToBlob(IBlob **data, const ICompositeMesh *mesh, IProgressInfo *progr=0, ICancellationToken *cncl=0, bool saveNormals=true, bool saveTexCoords=true, const wchar_t *materialFilename=NULL)
Save IFrameMesh/ICompositeMesh to OBJ blob.
ErrorCode ABASESDK_LINK_SPEC loadObjCompositeFromFile(ICompositeMesh **mesh, const wchar_t *path, IProgressInfo *progr=0, ICancellationToken *cncl=0)
Load IFrameMesh/ICompositeMesh from OBJ file.
ErrorCode ABASESDK_LINK_SPEC loadObjFrameFromBlob(IFrameMesh **mesh, const IBlob *data, IProgressInfo *progr=0, ICancellationToken *cncl=0)
Load IFrameMesh/ICompositeMesh from OBJ blob.
Indexed triangle mesh with optional texture.
Definition: IFrameMesh.h:42
static ErrorCode load(ICompositeMesh **mesh, const IBlob *data, IProgressInfo *progr=0, ICancellationToken *cncl=0)
Load IFrameMesh/ICompositeMesh from OBJ blob.
Definition: ObjIO.h:179
ErrorCode ABASESDK_LINK_SPEC saveObjCompositeToFile(const wchar_t *path, const ICompositeMesh *mesh, IProgressInfo *progr=0, ICancellationToken *cncl=0, bool saveNormals=true, bool saveTexCoords=true, const wchar_t *imageFormat=L"png")
Save IFrameMesh/ICompositeMesh to OBJ file.
ErrorCode ABASESDK_LINK_SPEC loadObjFrameFromFile(IFrameMesh **mesh, const wchar_t *path, IProgressInfo *progr=0, ICancellationToken *cncl=0)
Load IFrameMesh/ICompositeMesh from OBJ file.
static ErrorCode save(const wchar_t *path, const IFrameMesh *mesh, IProgressInfo *progr=0, ICancellationToken *cncl=0, bool saveNormals=true, bool saveTexCoords=true, const wchar_t *imageFormat=L"png")
Save IFrameMesh/ICompositeMesh to OBJ file.
Definition: ObjIO.h:109
Callback interface to notify process about cancellation.
ErrorCode ABASESDK_LINK_SPEC loadObjCompositeFromBlob(ICompositeMesh **mesh, const IBlob *data, IProgressInfo *progr=0, ICancellationToken *cncl=0)
Load IFrameMesh/ICompositeMesh from OBJ blob.
Interface for Binary Large Object (memory chunk) with smart reference counting.
Definition: IBlob.h:35
static ErrorCode load(IFrameMesh **mesh, const IBlob *data, IProgressInfo *progr=0, ICancellationToken *cncl=0)
Load IFrameMesh/ICompositeMesh from OBJ blob.
Definition: ObjIO.h:174
Interface for a progress notification listener.
Definition: IProgressInfo.h:76
static ErrorCode load(IFrameMesh **mesh, const wchar_t *path, IProgressInfo *progr=0, ICancellationToken *cncl=0)
Load IFrameMesh/ICompositeMesh from OBJ file.
Definition: ObjIO.h:155
Indexed triangle mesh with optional unwrapped textures.
ErrorCode ABASESDK_LINK_SPEC saveObjFrameToBlob(IBlob **data, const IFrameMesh *mesh, IProgressInfo *progr=0, ICancellationToken *cncl=0, bool saveNormals=true, bool saveTexCoords=true, const wchar_t *materialFilename=NULL)
Save IFrameMesh/ICompositeMesh to OBJ blob.
static ErrorCode save(IBlob **data, const ICompositeMesh *mesh, IProgressInfo *progr=0, ICancellationToken *cncl=0, bool saveNormals=true, bool saveTexCoords=true, const wchar_t *materialFilename=NULL)
Save IFrameMesh/ICompositeMesh to OBJ blob.
Definition: ObjIO.h:141
static ErrorCode load(ICompositeMesh **mesh, const wchar_t *path, IProgressInfo *progr=0, ICancellationToken *cncl=0)
Load IFrameMesh/ICompositeMesh from OBJ file.
Definition: ObjIO.h:160
#define ABASESDK_LINK_SPEC
ErrorCode ABASESDK_LINK_SPEC saveObjFrameToFile(const wchar_t *path, const IFrameMesh *mesh, IProgressInfo *progr=0, ICancellationToken *cncl=0, bool saveNormals=true, bool saveTexCoords=true, const wchar_t *imageFormat=L"png")
Save IFrameMesh/ICompositeMesh to OBJ file.