BRE12
Importer.hpp
1 /*
2 ---------------------------------------------------------------------------
3 Open Asset Import Library (assimp)
4 ---------------------------------------------------------------------------
5 
6 Copyright (c) 2006-2012, 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 INCLUDED_AI_ASSIMP_HPP
46 #define INCLUDED_AI_ASSIMP_HPP
47 
48 #ifndef __cplusplus
49 # error This header requires C++ to be used. Use assimp.h for plain C.
50 #endif
51 
52 // Public ASSIMP data structures
53 #include "types.h"
54 #include "config.h"
55 
56 namespace Assimp {
57  // =======================================================================
58  // Public interface to Assimp
59  class Importer;
60  class Exporter; // export.hpp
61  class IOStream;
62  class IOSystem;
63  class ProgressHandler;
64 
65  // =======================================================================
66  // Plugin development
67  //
68  // Include the following headers for the declarations:
69  // BaseImporter.h
70  // BaseProcess.h
71  class BaseImporter;
72  class BaseProcess;
73  class SharedPostProcessInfo;
74  class BatchLoader;
75 
76  // =======================================================================
77  // Holy stuff, only for members of the high council of the Jedi.
78  class ImporterPimpl;
79  class ExporterPimpl; // export.hpp
80 }
81 
82 #define AI_PROPERTY_WAS_NOT_EXISTING 0xffffffff
83 
84 struct aiScene;
85 
86 // importerdesc.h
87 struct aiImporterDesc;
88 
90 namespace Assimp {
91 
92 // ----------------------------------------------------------------------------------
116 class ASSIMP_API Importer {
117 
118 public:
119 
120  // -------------------------------------------------------------------
126  Importer();
127 
128  // -------------------------------------------------------------------
135  Importer(const Importer& other);
136 
137  // -------------------------------------------------------------------
141  ~Importer();
142 
143 
144  // -------------------------------------------------------------------
153  aiReturn RegisterLoader(BaseImporter* pImp);
154 
155  // -------------------------------------------------------------------
164  aiReturn UnregisterLoader(BaseImporter* pImp);
165 
166  // -------------------------------------------------------------------
177  aiReturn RegisterPPStep(BaseProcess* pImp);
178 
179  // -------------------------------------------------------------------
188  aiReturn UnregisterPPStep(BaseProcess* pImp);
189 
190 
191  // -------------------------------------------------------------------
205  void SetPropertyInteger(const char* szName, int iValue,
206  bool* bWasExisting = NULL);
207 
208  // -------------------------------------------------------------------
215  void SetPropertyBool(const char* szName, bool value, bool* bWasExisting = NULL) {
216  SetPropertyInteger(szName,value,bWasExisting);
217  }
218 
219  // -------------------------------------------------------------------
223  void SetPropertyFloat(const char* szName, float fValue,
224  bool* bWasExisting = NULL);
225 
226  // -------------------------------------------------------------------
230  void SetPropertyString(const char* szName, const std::string& sValue,
231  bool* bWasExisting = NULL);
232 
233  // -------------------------------------------------------------------
237  void SetPropertyMatrix(const char* szName, const aiMatrix4x4& sValue,
238  bool* bWasExisting = NULL);
239 
240  // -------------------------------------------------------------------
253  int GetPropertyInteger(const char* szName,
254  int iErrorReturn = 0xffffffff) const;
255 
256  // -------------------------------------------------------------------
263  bool GetPropertyBool(const char* szName, bool bErrorReturn = false) const {
264  return GetPropertyInteger(szName,bErrorReturn)!=0;
265  }
266 
267  // -------------------------------------------------------------------
271  float GetPropertyFloat(const char* szName,
272  float fErrorReturn = 10e10f) const;
273 
274  // -------------------------------------------------------------------
280  const std::string GetPropertyString(const char* szName,
281  const std::string& sErrorReturn = "") const;
282 
283  // -------------------------------------------------------------------
289  const aiMatrix4x4 GetPropertyMatrix(const char* szName,
290  const aiMatrix4x4& sErrorReturn = aiMatrix4x4()) const;
291 
292  // -------------------------------------------------------------------
307  void SetIOHandler( IOSystem* pIOHandler);
308 
309  // -------------------------------------------------------------------
317  IOSystem* GetIOHandler() const;
318 
319  // -------------------------------------------------------------------
325  bool IsDefaultIOHandler() const;
326 
327  // -------------------------------------------------------------------
338  void SetProgressHandler ( ProgressHandler* pHandler );
339 
340  // -------------------------------------------------------------------
348  ProgressHandler* GetProgressHandler() const;
349 
350  // -------------------------------------------------------------------
356  bool IsDefaultProgressHandler() const;
357 
358  // -------------------------------------------------------------------
370  bool ValidateFlags(unsigned int pFlags) const;
371 
372  // -------------------------------------------------------------------
394  const aiScene* ReadFile(
395  const char* pFile,
396  unsigned int pFlags);
397 
398  // -------------------------------------------------------------------
435  const aiScene* ReadFileFromMemory(
436  const void* pBuffer,
437  size_t pLength,
438  unsigned int pFlags,
439  const char* pHint = "");
440 
441  // -------------------------------------------------------------------
459  const aiScene* ApplyPostProcessing(unsigned int pFlags);
460 
461  // -------------------------------------------------------------------
467  const aiScene* ReadFile(
468  const std::string& pFile,
469  unsigned int pFlags);
470 
471  // -------------------------------------------------------------------
477  void FreeScene( );
478 
479  // -------------------------------------------------------------------
488  const char* GetErrorString() const;
489 
490  // -------------------------------------------------------------------
494  const aiScene* GetScene() const;
495 
496  // -------------------------------------------------------------------
515  aiScene* GetOrphanedScene();
516 
517 
518 
519 
520  // -------------------------------------------------------------------
527  bool IsExtensionSupported(const char* szExtension) const;
528 
529  // -------------------------------------------------------------------
535  inline bool IsExtensionSupported(const std::string& szExtension) const;
536 
537  // -------------------------------------------------------------------
547  void GetExtensionList(aiString& szOut) const;
548 
549  // -------------------------------------------------------------------
555  inline void GetExtensionList(std::string& szOut) const;
556 
557  // -------------------------------------------------------------------
559  size_t GetImporterCount() const;
560 
561  // -------------------------------------------------------------------
569  const aiImporterDesc* GetImporterInfo(size_t index) const;
570 
571  // -------------------------------------------------------------------
577  BaseImporter* GetImporter(size_t index) const;
578 
579  // -------------------------------------------------------------------
589  BaseImporter* GetImporter (const char* szExtension) const;
590 
591  // -------------------------------------------------------------------
599  size_t GetImporterIndex (const char* szExtension) const;
600 
601 
602 
603 
604  // -------------------------------------------------------------------
613  void GetMemoryRequirements(aiMemoryInfo& in) const;
614 
615  // -------------------------------------------------------------------
622  void SetExtraVerbose(bool bDo);
623 
624 
625  // -------------------------------------------------------------------
627  ImporterPimpl* Pimpl() { return pimpl; };
628  const ImporterPimpl* Pimpl() const { return pimpl; };
629 
630 protected:
631 
632  // Just because we don't want you to know how we're hacking around.
633  ImporterPimpl* pimpl;
634 };
635 
636 
637 // ----------------------------------------------------------------------------
638 // For compatibility, the interface of some functions taking a std::string was
639 // changed to const char* to avoid crashes between binary incompatible STL
640 // versions. This code her is inlined, so it shouldn't cause any problems.
641 // ----------------------------------------------------------------------------
642 
643 // ----------------------------------------------------------------------------
644 AI_FORCE_INLINE const aiScene* Importer::ReadFile( const std::string& pFile,unsigned int pFlags){
645  return ReadFile(pFile.c_str(),pFlags);
646 }
647 // ----------------------------------------------------------------------------
648 AI_FORCE_INLINE void Importer::GetExtensionList(std::string& szOut) const {
649  aiString s;
650  GetExtensionList(s);
651  szOut = s.data;
652 }
653 // ----------------------------------------------------------------------------
654 AI_FORCE_INLINE bool Importer::IsExtensionSupported(const std::string& szExtension) const {
655  return IsExtensionSupported(szExtension.c_str());
656 }
657 
658 } // !namespace Assimp
659 #endif // INCLUDED_AI_ASSIMP_HPP
void GetExtensionList(aiString &szOut) const
Get a full list of all file extensions supported by ASSIMP.
bool GetPropertyBool(const char *szName, bool bErrorReturn=false) const
Get a boolean configuration property.
Definition: Importer.hpp:263
bool IsExtensionSupported(const char *szExtension) const
Returns whether a given file extension is supported by ASSIMP.
Basic data types and primitives, such as vectors or colors.
Assimp's CPP-API and all internal APIs.
Definition: DefaultLogger.hpp:51
Definition: matrix4x4.h:236
CPP-API: The Importer class forms an C++ interface to the functionality of the Open Asset Import Libr...
Definition: Importer.hpp:116
Defines constants for configurable properties for the library.
CPP-API: Abstract interface for custom progress report receivers.
Definition: ProgressHandler.hpp:54
CPP-API: Interface to the file system.
Definition: IOSystem.hpp:67
Represents an UTF-8 string, zero byte terminated.
Definition: types.h:251
Meta information about a particular importer.
Definition: importerdesc.h:87
char data[MAXLEN]
String buffer.
Definition: types.h:366
ImporterPimpl * Pimpl()
Private, do not use.
Definition: Importer.hpp:627
const aiScene * ReadFile(const char *pFile, unsigned int pFlags)
Reads the given file and returns its contents if successful.
void SetPropertyBool(const char *szName, bool value, bool *bWasExisting=NULL)
Set a boolean configuration property.
Definition: Importer.hpp:215