BRE12
Exporter.hpp
1 /*
2 ---------------------------------------------------------------------------
3 Open Asset Import Library (assimp)
4 ---------------------------------------------------------------------------
5 
6 Copyright (c) 2006-2011, assimp team
7 
8 All rights reserved.
9 
10 Redistribution and use of this software in source and binary forms,
11 with or without modification, are permitted provided that the following
12 conditions are met:
13 
14 * Redistributions of source code must retain the above
15 copyright notice, this list of conditions and the
16 following disclaimer.
17 
18 * Redistributions in binary form must reproduce the above
19 copyright notice, this list of conditions and the
20 following disclaimer in the documentation and/or other
21 materials provided with the distribution.
22 
23 * Neither the name of the assimp team, nor the names of its
24 contributors may be used to endorse or promote products
25 derived from this software without specific prior
26 written permission of the assimp team.
27 
28 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
29 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
30 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
31 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
32 OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
33 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
34 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
35 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
36 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
37 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
38 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
39 ---------------------------------------------------------------------------
40 */
41 
45 #ifndef AI_EXPORT_HPP_INC
46 #define AI_EXPORT_HPP_INC
47 
48 #ifndef ASSIMP_BUILD_NO_EXPORT
49 
50 #include "cexport.h"
51 
52 namespace Assimp {
53  class ExporterPimpl;
54  class IOSystem;
55 
56 
57 // ----------------------------------------------------------------------------------
75 class ASSIMP_API Exporter
76  // TODO: causes good ol' base class has no dll interface warning
77 //#ifdef __cplusplus
78 // : public boost::noncopyable
79 //#endif // __cplusplus
80 {
81 public:
82 
84  typedef void (*fpExportFunc)(const char*,IOSystem*,const aiScene*);
85 
88  {
91 
92  // Worker function to do the actual exporting
93  fpExportFunc mExportFunction;
94 
95  // Postprocessing steps to be executed PRIOR to invoking mExportFunction
96  unsigned int mEnforcePP;
97 
98  // Constructor to fill all entries
99  ExportFormatEntry( const char* pId, const char* pDesc, const char* pExtension, fpExportFunc pFunction, unsigned int pEnforcePP = 0u)
100  {
101  mDescription.id = pId;
102  mDescription.description = pDesc;
103  mDescription.fileExtension = pExtension;
104  mExportFunction = pFunction;
105  mEnforcePP = pEnforcePP;
106  }
107 
108  ExportFormatEntry() : mExportFunction(), mEnforcePP() {}
109  };
110 
111 
112 public:
113 
114 
115  Exporter();
116  ~Exporter();
117 
118 public:
119 
120 
121  // -------------------------------------------------------------------
136  void SetIOHandler( IOSystem* pIOHandler);
137 
138  // -------------------------------------------------------------------
145  IOSystem* GetIOHandler() const;
146 
147  // -------------------------------------------------------------------
152  bool IsDefaultIOHandler() const;
153 
154 
155 
156  // -------------------------------------------------------------------
174  const aiExportDataBlob* ExportToBlob( const aiScene* pScene, const char* pFormatId, unsigned int pPreprocessing = 0u );
175  inline const aiExportDataBlob* ExportToBlob( const aiScene* pScene, const std::string& pFormatId, unsigned int pPreprocessing = 0u );
176 
177 
178  // -------------------------------------------------------------------
211  aiReturn Export( const aiScene* pScene, const char* pFormatId, const char* pPath, unsigned int pPreprocessing = 0u);
212  inline aiReturn Export( const aiScene* pScene, const std::string& pFormatId, const std::string& pPath, unsigned int pPreprocessing = 0u);
213 
214 
215  // -------------------------------------------------------------------
225  const char* GetErrorString() const;
226 
227 
228  // -------------------------------------------------------------------
230  const aiExportDataBlob* GetBlob() const;
231 
232 
233  // -------------------------------------------------------------------
237  const aiExportDataBlob* GetOrphanedBlob() const;
238 
239 
240  // -------------------------------------------------------------------
248  void FreeBlob( );
249 
250 
251  // -------------------------------------------------------------------
255  size_t GetExportFormatCount() const;
256 
257 
258  // -------------------------------------------------------------------
266  const aiExportFormatDesc* GetExportFormatDescription( size_t pIndex ) const;
267 
268 
269  // -------------------------------------------------------------------
278  aiReturn RegisterExporter(const ExportFormatEntry& desc);
279 
280 
281  // -------------------------------------------------------------------
290  void UnregisterExporter(const char* id);
291 
292 
293 protected:
294 
295  // Just because we don't want you to know how we're hacking around.
296  ExporterPimpl* pimpl;
297 };
298 
299 
300 // ----------------------------------------------------------------------------------
301 inline const aiExportDataBlob* Exporter :: ExportToBlob( const aiScene* pScene, const std::string& pFormatId,unsigned int pPreprocessing )
302 {
303  return ExportToBlob(pScene,pFormatId.c_str(),pPreprocessing);
304 }
305 
306 // ----------------------------------------------------------------------------------
307 inline aiReturn Exporter :: Export( const aiScene* pScene, const std::string& pFormatId, const std::string& pPath, unsigned int pPreprocessing )
308 {
309  return Export(pScene,pFormatId.c_str(),pPath.c_str(),pPreprocessing);
310 }
311 
312 } // namespace Assimp
313 #endif // ASSIMP_BUILD_NO_EXPORT
314 #endif // AI_EXPORT_HPP_INC
315 
Assimp's CPP-API and all internal APIs.
Definition: DefaultLogger.hpp:51
const aiExportDataBlob * ExportToBlob(const aiScene *pScene, const char *pFormatId, unsigned int pPreprocessing=0u)
Exports the given scene to a chosen file format.
const char * fileExtension
Recommended file extension for the exported file in lower case.
Definition: cexport.h:76
Defines the C-API for the Assimp export interface.
CPP-API: Interface to the file system.
Definition: IOSystem.hpp:67
Describes a blob of exported scene data.
Definition: cexport.h:194
const char * id
a short string ID to uniquely identify the export format.
Definition: cexport.h:69
CPP-API: The Exporter class forms an C++ interface to the export functionality of the Open Asset Impo...
Definition: Exporter.hpp:75
const char * description
A short description of the file format to present to users.
Definition: cexport.h:73
aiReturn Export(const aiScene *pScene, const char *pFormatId, const char *pPath, unsigned int pPreprocessing=0u)
Convenience function to export directly to a file.
Internal description of an Assimp export format option.
Definition: Exporter.hpp:87
Describes an file format which Assimp can export to.
Definition: cexport.h:64
aiExportFormatDesc mDescription
Public description structure to be returned by aiGetExportFormatDescription()
Definition: Exporter.hpp:90