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 to save mesh to
32  * @param mesh - mesh to be saved
33  * @param progr - progress interface
34  * @param cncl - cancel interface
35  * @param saveNormals - if we need to save normals in file
36  * @param saveTexCoords - if texture coordinates should be saved
37  * @param imageFormat - format for texture images if they should be saved ("png","jpg","bmp")
38  * @return error code
39  * @note if you set saveTexCoords flag then texture images will also be saved
40  */
42  saveObjFrameToFile(const wchar_t* path, const IFrameMesh* mesh, IProgressInfo* progr = 0, ICancellationToken* cncl = 0,
43  bool saveNormals = true, bool saveTexCoords = true, const wchar_t* imageFormat = L"png");
45  saveObjCompositeToFile(const wchar_t* path, const ICompositeMesh* mesh, IProgressInfo* progr = 0, ICancellationToken* cncl = 0,
46  bool saveNormals = true, bool saveTexCoords = true, const wchar_t* imageFormat = L"png");
47  ///@}
48 
49  ///@{
50  /** Save IFrameMesh/ICompositeMesh to OBJ blob
51  * @note save only geometry, not texture and material also, because material and images is stored in separate blob
52  * @param data - blob to save mesh to
53  * @param mesh - mesh to be saved
54  * @param progr - progress interface
55  * @param cncl - cancel interface
56  * @param saveNormals - if we need to save normals in file
57  * @param saveTexCoords - if texture coordinates should be saved
58  * @return error code
59  */
61  saveObjFrameToBlob(IBlob** data, const IFrameMesh* mesh, IProgressInfo* progr = 0, ICancellationToken* cncl = 0,
62  bool saveNormals = true, bool saveTexCoords = true, const wchar_t* materialFilename = NULL);
64  saveObjCompositeToBlob(IBlob** data, const ICompositeMesh* mesh, IProgressInfo* progr = 0, ICancellationToken* cncl = 0,
65  bool saveNormals = true, bool saveTexCoords = true, const wchar_t* materialFilename = NULL);
66  ///@}
67 
68  ///@{
69  /** Load IFrameMesh/ICompositeMesh from OBJ file
70  * @param mesh - loaded mesh
71  * @param path - file path to load image from
72  * @param progr - progress interface
73  * @param cncl - cancel interface
74  * @return error code
75  */
77  loadObjFrameFromFile(IFrameMesh** mesh, const wchar_t* path, IProgressInfo* progr = 0, ICancellationToken* cncl = 0);
79  loadObjCompositeFromFile(ICompositeMesh** mesh, const wchar_t* path, IProgressInfo* progr = 0, ICancellationToken* cncl = 0);
80  ///@}
81 
82  ///@{
83  /** Load IFrameMesh/ICompositeMesh from OBJ blob
84  * @note load only geometry, not texture also, because image is stored in separate blob
85  * @param mesh - loaded mesh
86  * @param data - blob to load image from
87  * @param progr - progress interface
88  * @param cncl - cancel interface
89  * @return error code
90  */
92  loadObjFrameFromBlob(IFrameMesh** mesh, const IBlob* data, IProgressInfo* progr = 0, ICancellationToken* cncl = 0);
94  loadObjCompositeFromBlob(ICompositeMesh** mesh, const IBlob* data, IProgressInfo* progr = 0, ICancellationToken* cncl = 0);
95  ///@}
96 }
97 
98  class Obj
99  {
100  public:
101  ///@{
102  /** Save IFrameMesh/ICompositeMesh to OBJ file
103  * @param path - file path to save mesh to
104  * @param mesh - mesh to be saved
105  * @param progr - progress interface
106  * @param cncl - cancel interface
107  * @param saveNormals - if we need to save normals in file
108  * @param saveTexCoords - if texture coordinates should be saved
109  * @param imageFormat - format for texture images if they should be saved ("png","jpg","bmp")
110  * @return error code
111  * @note if you set saveTexCoords flag then texture images will also be saved
112  */
113  static ErrorCode
114  save(const wchar_t* path, const IFrameMesh* mesh, IProgressInfo* progr = 0, ICancellationToken* cncl = 0,
115  bool saveNormals = true, bool saveTexCoords = true, const wchar_t* imageFormat = L"png")
116  {
117  return saveObjFrameToFile(path, mesh, progr, cncl, saveNormals, saveTexCoords, imageFormat);
118  }
119 
120  static ErrorCode
121  save(const wchar_t* path, const ICompositeMesh* mesh, IProgressInfo* progr = 0, ICancellationToken* cncl = 0,
122  bool saveNormals = true, bool saveTexCoords = true, const wchar_t* imageFormat = L"png")
123  {
124  return saveObjCompositeToFile(path, mesh, progr, cncl, saveNormals, saveTexCoords, imageFormat);
125  }
126  ///@}
127 
128  ///@{
129  /** Save IFrameMesh/ICompositeMesh to OBJ blob
130  * @note save only geometry, not texture and material also, because material and images is stored in separate blob
131  * @param data - blob to save mesh to
132  * @param mesh - mesh to be saved
133  * @param progr - progress interface
134  * @param cncl - cancel interface
135  * @param saveNormals - if we need to save normals in file
136  * @param saveTexCoords - if texture coordinates should be saved
137  * @return error code
138  */
139  static ErrorCode
140  save(IBlob** data, const IFrameMesh* mesh, IProgressInfo* progr = 0, ICancellationToken* cncl = 0,
141  bool saveNormals = true, bool saveTexCoords = true, const wchar_t* materialFilename = NULL)
142  {
143  return saveObjFrameToBlob(data, mesh, progr, cncl, saveNormals, saveTexCoords, materialFilename);
144  }
145 
146  static ErrorCode
147  save(IBlob** data, const ICompositeMesh* mesh, IProgressInfo* progr = 0, ICancellationToken* cncl = 0,
148  bool saveNormals = true, bool saveTexCoords = true, const wchar_t* materialFilename = NULL)
149  {
150  return saveObjCompositeToBlob(data, mesh, progr, cncl, saveNormals, saveTexCoords, materialFilename);
151  }
152  ///@}
153 
154  ///@{
155  /** Load IFrameMesh/ICompositeMesh from OBJ file
156  * @param mesh - loaded mesh
157  * @param path - file path to load image from
158  * @param progr - progress interface
159  * @param cncl - cancel interface
160  * @return error code
161  */
162  static ErrorCode load(IFrameMesh** mesh, const wchar_t* path, IProgressInfo* progr = 0, ICancellationToken* cncl = 0)
163  {
164  return loadObjFrameFromFile(mesh, path, progr, cncl);
165  }
166 
167  static ErrorCode load(ICompositeMesh** mesh, const wchar_t* path, IProgressInfo* progr = 0, ICancellationToken* cncl = 0)
168  {
169  return loadObjCompositeFromFile(mesh, path, progr, cncl);
170  }
171  ///@}
172 
173  ///@{
174  /** Load IFrameMesh/ICompositeMesh from OBJ blob
175  * @note load only geometry, not texture also, because image is stored in separate blob
176  * @param mesh - loaded mesh
177  * @param data - blob to load image from
178  * @param progr - progress interface
179  * @param cncl - cancel interface
180  * @return error code
181  */
182  static ErrorCode load(IFrameMesh** mesh, const IBlob* data, IProgressInfo* progr = 0, ICancellationToken* cncl = 0)
183  {
184  return loadObjFrameFromBlob(mesh, data, progr, cncl);
185  }
186 
187  static ErrorCode load(ICompositeMesh** mesh, const IBlob* data, IProgressInfo* progr = 0, ICancellationToken* cncl = 0)
188  {
189  return loadObjCompositeFromBlob(mesh, data, progr, cncl);
190  }
191  ///@}
192 
193  };
194 
195 } } } } // namespace artec::sdk::base::io
196 
197 #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)
Definition: ObjIO.h:140
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")
Definition: ObjIO.h:121
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)
ErrorCode ABASESDK_LINK_SPEC loadObjCompositeFromFile(ICompositeMesh **mesh, const wchar_t *path, IProgressInfo *progr=0, ICancellationToken *cncl=0)
ErrorCode ABASESDK_LINK_SPEC loadObjFrameFromBlob(IFrameMesh **mesh, const IBlob *data, IProgressInfo *progr=0, ICancellationToken *cncl=0)
static ErrorCode load(ICompositeMesh **mesh, const IBlob *data, IProgressInfo *progr=0, ICancellationToken *cncl=0)
Definition: ObjIO.h:187
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")
ErrorCode ABASESDK_LINK_SPEC loadObjFrameFromFile(IFrameMesh **mesh, const wchar_t *path, IProgressInfo *progr=0, ICancellationToken *cncl=0)
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")
Definition: ObjIO.h:114
ErrorCode ABASESDK_LINK_SPEC loadObjCompositeFromBlob(ICompositeMesh **mesh, const IBlob *data, IProgressInfo *progr=0, ICancellationToken *cncl=0)
static ErrorCode load(IFrameMesh **mesh, const IBlob *data, IProgressInfo *progr=0, ICancellationToken *cncl=0)
Definition: ObjIO.h:182
static ErrorCode load(IFrameMesh **mesh, const wchar_t *path, IProgressInfo *progr=0, ICancellationToken *cncl=0)
Definition: ObjIO.h:162
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)
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)
Definition: ObjIO.h:147
static ErrorCode load(ICompositeMesh **mesh, const wchar_t *path, IProgressInfo *progr=0, ICancellationToken *cncl=0)
Definition: ObjIO.h:167
#define ABASESDK_LINK_SPEC
Definition: BaseSdkDefines.h:7
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")