GraphicsAPI_2020C
Importer.hpp
Go to the documentation of this file.
1 /*
2 ---------------------------------------------------------------------------
3 Open Asset Import Library (assimp)
4 ---------------------------------------------------------------------------
5 
6 Copyright (c) 2006-2017, assimp team
7 
8 
9 All rights reserved.
10 
11 Redistribution and use of this software in source and binary forms,
12 with or without modification, are permitted provided that the following
13 conditions are met:
14 
15 * Redistributions of source code must retain the above
16  copyright notice, this list of conditions and the
17  following disclaimer.
18 
19 * Redistributions in binary form must reproduce the above
20  copyright notice, this list of conditions and the
21  following disclaimer in the documentation and/or other
22  materials provided with the distribution.
23 
24 * Neither the name of the assimp team, nor the names of its
25  contributors may be used to endorse or promote products
26  derived from this software without specific prior
27  written permission of the assimp team.
28 
29 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
30 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
31 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
32 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
33 OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
34 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
35 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
36 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
37 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
38 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
39 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
40 ---------------------------------------------------------------------------
41 */
42 
46 #pragma once
47 #ifndef AI_ASSIMP_HPP_INC
48 #define AI_ASSIMP_HPP_INC
49 
50 #ifndef __cplusplus
51 # error This header requires C++ to be used. Use assimp.h for plain C.
52 #endif // __cplusplus
53 
54 // Public ASSIMP data structures
55 #include <assimp/types.h>
56 
57 namespace Assimp {
58  // =======================================================================
59  // Public interface to Assimp
60  class Importer;
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 }
80 
81 #define AI_PROPERTY_WAS_NOT_EXISTING 0xffffffff
82 
83 struct aiScene;
84 
85 // importerdesc.h
86 struct aiImporterDesc;
87 
89 namespace Assimp {
90 
91 // ----------------------------------------------------------------------------------
115 class ASSIMP_API Importer {
116 public:
120  static const unsigned int MaxLenHint = 200;
121 
122 public:
123 
124  // -------------------------------------------------------------------
130  Importer();
131 
132  // -------------------------------------------------------------------
139  Importer(const Importer& other);
140 
141  // -------------------------------------------------------------------
145  ~Importer();
146 
147 
148  // -------------------------------------------------------------------
157  aiReturn RegisterLoader(BaseImporter* pImp);
158 
159  // -------------------------------------------------------------------
168  aiReturn UnregisterLoader(BaseImporter* pImp);
169 
170  // -------------------------------------------------------------------
181  aiReturn RegisterPPStep(BaseProcess* pImp);
182 
183  // -------------------------------------------------------------------
192  aiReturn UnregisterPPStep(BaseProcess* pImp);
193 
194  // -------------------------------------------------------------------
207  bool SetPropertyInteger(const char* szName, int iValue);
208 
209  // -------------------------------------------------------------------
216  bool SetPropertyBool(const char* szName, bool value) {
217  return SetPropertyInteger(szName,value);
218  }
219 
220  // -------------------------------------------------------------------
224  bool SetPropertyFloat(const char* szName, ai_real fValue);
225 
226  // -------------------------------------------------------------------
230  bool SetPropertyString(const char* szName, const std::string& sValue);
231 
232  // -------------------------------------------------------------------
236  bool SetPropertyMatrix(const char* szName, const aiMatrix4x4& sValue);
237 
238  // -------------------------------------------------------------------
251  int GetPropertyInteger(const char* szName,
252  int iErrorReturn = 0xffffffff) const;
253 
254  // -------------------------------------------------------------------
261  bool GetPropertyBool(const char* szName, bool bErrorReturn = false) const {
262  return GetPropertyInteger(szName,bErrorReturn)!=0;
263  }
264 
265  // -------------------------------------------------------------------
269  ai_real GetPropertyFloat(const char* szName,
270  ai_real fErrorReturn = 10e10) const;
271 
272  // -------------------------------------------------------------------
278  const std::string GetPropertyString(const char* szName,
279  const std::string& sErrorReturn = "") const;
280 
281  // -------------------------------------------------------------------
287  const aiMatrix4x4 GetPropertyMatrix(const char* szName,
288  const aiMatrix4x4& sErrorReturn = aiMatrix4x4()) const;
289 
290  // -------------------------------------------------------------------
305  void SetIOHandler( IOSystem* pIOHandler);
306 
307  // -------------------------------------------------------------------
315  IOSystem* GetIOHandler() const;
316 
317  // -------------------------------------------------------------------
323  bool IsDefaultIOHandler() const;
324 
325  // -------------------------------------------------------------------
336  void SetProgressHandler ( ProgressHandler* pHandler );
337 
338  // -------------------------------------------------------------------
346  ProgressHandler* GetProgressHandler() const;
347 
348  // -------------------------------------------------------------------
354  bool IsDefaultProgressHandler() const;
355 
356  // -------------------------------------------------------------------
368  bool ValidateFlags(unsigned int pFlags) const;
369 
370  // -------------------------------------------------------------------
392  const aiScene* ReadFile(
393  const char* pFile,
394  unsigned int pFlags);
395 
396  // -------------------------------------------------------------------
433  const aiScene* ReadFileFromMemory(
434  const void* pBuffer,
435  size_t pLength,
436  unsigned int pFlags,
437  const char* pHint = "");
438 
439  // -------------------------------------------------------------------
457  const aiScene* ApplyPostProcessing(unsigned int pFlags);
458 
459  const aiScene* ApplyCustomizedPostProcessing( BaseProcess *rootProcess, bool requestValidation );
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  // -------------------------------------------------------------------
524  bool IsExtensionSupported(const char* szExtension) const;
525 
526  // -------------------------------------------------------------------
532  inline bool IsExtensionSupported(const std::string& szExtension) const;
533 
534  // -------------------------------------------------------------------
544  void GetExtensionList(aiString& szOut) const;
545 
546  // -------------------------------------------------------------------
552  inline void GetExtensionList(std::string& szOut) const;
553 
554  // -------------------------------------------------------------------
556  size_t GetImporterCount() const;
557 
558  // -------------------------------------------------------------------
566  const aiImporterDesc* GetImporterInfo(size_t index) const;
567 
568  // -------------------------------------------------------------------
574  BaseImporter* GetImporter(size_t index) const;
575 
576  // -------------------------------------------------------------------
586  BaseImporter* GetImporter (const char* szExtension) const;
587 
588  // -------------------------------------------------------------------
596  size_t GetImporterIndex (const char* szExtension) const;
597 
598  // -------------------------------------------------------------------
607  void GetMemoryRequirements(aiMemoryInfo& in) const;
608 
609  // -------------------------------------------------------------------
616  void SetExtraVerbose(bool bDo);
617 
618  // -------------------------------------------------------------------
620  ImporterPimpl* Pimpl() { return pimpl; }
621  const ImporterPimpl* Pimpl() const { return pimpl; }
622 
623 protected:
624 
625  // Just because we don't want you to know how we're hacking around.
626  ImporterPimpl* pimpl;
627 };
628 
629 
630 // ----------------------------------------------------------------------------
631 // For compatibility, the interface of some functions taking a std::string was
632 // changed to const char* to avoid crashes between binary incompatible STL
633 // versions. This code her is inlined, so it shouldn't cause any problems.
634 // ----------------------------------------------------------------------------
635 
636 // ----------------------------------------------------------------------------
637 AI_FORCE_INLINE const aiScene* Importer::ReadFile( const std::string& pFile,unsigned int pFlags){
638  return ReadFile(pFile.c_str(),pFlags);
639 }
640 // ----------------------------------------------------------------------------
641 AI_FORCE_INLINE void Importer::GetExtensionList(std::string& szOut) const {
642  aiString s;
643  GetExtensionList(s);
644  szOut = s.data;
645 }
646 // ----------------------------------------------------------------------------
647 AI_FORCE_INLINE bool Importer::IsExtensionSupported(const std::string& szExtension) const {
648  return IsExtensionSupported(szExtension.c_str());
649 }
650 
651 } // !namespace Assimp
652 
653 #endif // AI_ASSIMP_HPP_INC
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:261
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&#39;s CPP-API and all internal APIs.
Definition: DefaultIOStream.h:51
Definition: matrix4x4.h:269
CPP-API: The Importer class forms an C++ interface to the functionality of the Open Asset Import Libr...
Definition: Importer.hpp:115
CPP-API: Abstract interface for custom progress report receivers.
Definition: ProgressHandler.hpp:58
Stores the memory requirements for different components (e.g.
Definition: types.h:463
aiReturn
Standard return type for some library functions.
Definition: types.h:375
CPP-API: Interface to the file system.
Definition: IOSystem.hpp:84
Represents an UTF-8 string, zero byte terminated.
Definition: types.h:252
bool SetPropertyBool(const char *szName, bool value)
Set a boolean configuration property.
Definition: Importer.hpp:216
Meta information about a particular importer.
Definition: importerdesc.h:89
The root structure of the imported data.
Definition: scene.h:240
char data[MAXLEN]
String buffer.
Definition: types.h:367
ImporterPimpl * Pimpl()
Private, do not use.
Definition: Importer.hpp:620
const aiScene * ReadFile(const char *pFile, unsigned int pFlags)
Reads the given file and returns its contents if successful.