Path Tracer
Importer.hpp
Go to the documentation of this file.
1 /*
2 ---------------------------------------------------------------------------
3 Open Asset Import Library (assimp)
4 ---------------------------------------------------------------------------
5 
6 Copyright (c) 2006-2020, assimp team
7 
8 
9 
10 All rights reserved.
11 
12 Redistribution and use of this software in source and binary forms,
13 with or without modification, are permitted provided that the following
14 conditions are met:
15 
16 * Redistributions of source code must retain the above
17  copyright notice, this list of conditions and the
18  following disclaimer.
19 
20 * Redistributions in binary form must reproduce the above
21  copyright notice, this list of conditions and the
22  following disclaimer in the documentation and/or other
23  materials provided with the distribution.
24 
25 * Neither the name of the assimp team, nor the names of its
26  contributors may be used to endorse or promote products
27  derived from this software without specific prior
28  written permission of the assimp team.
29 
30 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
31 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
32 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
33 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
34 OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
35 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
36 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
37 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
38 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
39 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
40 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
41 ---------------------------------------------------------------------------
42 */
43 
47 #pragma once
48 #ifndef AI_ASSIMP_HPP_INC
49 #define AI_ASSIMP_HPP_INC
50 
51 #ifdef __GNUC__
52 #pragma GCC system_header
53 #endif
54 
55 #ifndef __cplusplus
56 #error This header requires C++ to be used. Use assimp.h for plain C.
57 #endif // __cplusplus
58 
59 // Public ASSIMP data structures
60 #include <assimp/types.h>
61 
62 namespace Assimp {
63 // =======================================================================
64 // Public interface to Assimp
65 class Importer;
66 class IOStream;
67 class IOSystem;
68 class ProgressHandler;
69 
70 // =======================================================================
71 // Plugin development
72 //
73 // Include the following headers for the declarations:
74 // BaseImporter.h
75 // BaseProcess.h
76 class BaseImporter;
77 class BaseProcess;
78 class SharedPostProcessInfo;
79 class BatchLoader;
80 
81 // =======================================================================
82 // Holy stuff, only for members of the high council of the Jedi.
83 class ImporterPimpl;
84 } // namespace Assimp
85 
86 #define AI_PROPERTY_WAS_NOT_EXISTING 0xffffffff
87 
88 struct aiScene;
89 
90 // importerdesc.h
91 struct aiImporterDesc;
92 
94 namespace Assimp {
95 
96 // ----------------------------------------------------------------------------------
120 class ASSIMP_API Importer {
121 public:
125  static const unsigned int MaxLenHint = 200;
126 
127 public:
128  // -------------------------------------------------------------------
135 
136  // -------------------------------------------------------------------
143  Importer(const Importer &other) = delete;
144 
145  // -------------------------------------------------------------------
148  Importer &operator=(const Importer &) = delete;
149 
150  // -------------------------------------------------------------------
155 
156  // -------------------------------------------------------------------
166 
167  // -------------------------------------------------------------------
177 
178  // -------------------------------------------------------------------
189  aiReturn RegisterPPStep(BaseProcess *pImp);
190 
191  // -------------------------------------------------------------------
200  aiReturn UnregisterPPStep(BaseProcess *pImp);
201 
202  // -------------------------------------------------------------------
215  bool SetPropertyInteger(const char *szName, int iValue);
216 
217  // -------------------------------------------------------------------
224  bool SetPropertyBool(const char *szName, bool value) {
225  return SetPropertyInteger(szName, value);
226  }
227 
228  // -------------------------------------------------------------------
232  bool SetPropertyFloat(const char *szName, ai_real fValue);
233 
234  // -------------------------------------------------------------------
238  bool SetPropertyString(const char *szName, const std::string &sValue);
239 
240  // -------------------------------------------------------------------
244  bool SetPropertyMatrix(const char *szName, const aiMatrix4x4 &sValue);
245 
246  // -------------------------------------------------------------------
259  int GetPropertyInteger(const char *szName,
260  int iErrorReturn = 0xffffffff) const;
261 
262  // -------------------------------------------------------------------
269  bool GetPropertyBool(const char *szName, bool bErrorReturn = false) const {
270  return GetPropertyInteger(szName, bErrorReturn) != 0;
271  }
272 
273  // -------------------------------------------------------------------
277  ai_real GetPropertyFloat(const char *szName,
278  ai_real fErrorReturn = 10e10) const;
279 
280  // -------------------------------------------------------------------
286  std::string GetPropertyString(const char *szName,
287  const std::string &sErrorReturn = "") const;
288 
289  // -------------------------------------------------------------------
295  aiMatrix4x4 GetPropertyMatrix(const char *szName,
296  const aiMatrix4x4 &sErrorReturn = aiMatrix4x4()) const;
297 
298  // -------------------------------------------------------------------
313  void SetIOHandler(IOSystem *pIOHandler);
314 
315  // -------------------------------------------------------------------
324 
325  // -------------------------------------------------------------------
331  bool IsDefaultIOHandler() const;
332 
333  // -------------------------------------------------------------------
345 
346  // -------------------------------------------------------------------
355 
356  // -------------------------------------------------------------------
363 
364  // -------------------------------------------------------------------
376  bool ValidateFlags(unsigned int pFlags) const;
377 
378  // -------------------------------------------------------------------
401  const char *pFile,
402  unsigned int pFlags);
403 
404  // -------------------------------------------------------------------
442  const void *pBuffer,
443  size_t pLength,
444  unsigned int pFlags,
445  const char *pHint = "");
446 
447  // -------------------------------------------------------------------
465  const aiScene *ApplyPostProcessing(unsigned int pFlags);
466 
467  const aiScene *ApplyCustomizedPostProcessing(BaseProcess *rootProcess, bool requestValidation);
468 
469  // -------------------------------------------------------------------
475  const aiScene *ReadFile(
476  const std::string &pFile,
477  unsigned int pFlags);
478 
479  // -------------------------------------------------------------------
485  void FreeScene();
486 
487  // -------------------------------------------------------------------
496  const char *GetErrorString() const;
497 
498  // -------------------------------------------------------------------
505  const std::exception_ptr& GetException() const;
506 
507  // -------------------------------------------------------------------
511  const aiScene *GetScene() const;
512 
513  // -------------------------------------------------------------------
533 
534  // -------------------------------------------------------------------
541  bool IsExtensionSupported(const char *szExtension) const;
542 
543  // -------------------------------------------------------------------
549  inline bool IsExtensionSupported(const std::string &szExtension) const;
550 
551  // -------------------------------------------------------------------
561  void GetExtensionList(aiString &szOut) const;
562 
563  // -------------------------------------------------------------------
569  inline void GetExtensionList(std::string &szOut) const;
570 
571  // -------------------------------------------------------------------
573  size_t GetImporterCount() const;
574 
575  // -------------------------------------------------------------------
583  const aiImporterDesc *GetImporterInfo(size_t index) const;
584 
585  // -------------------------------------------------------------------
591  BaseImporter *GetImporter(size_t index) const;
592 
593  // -------------------------------------------------------------------
603  BaseImporter *GetImporter(const char *szExtension) const;
604 
605  // -------------------------------------------------------------------
613  size_t GetImporterIndex(const char *szExtension) const;
614 
615  // -------------------------------------------------------------------
625 
626  // -------------------------------------------------------------------
633  void SetExtraVerbose(bool bDo);
634 
635  // -------------------------------------------------------------------
637  ImporterPimpl *Pimpl() { return pimpl; }
638  const ImporterPimpl *Pimpl() const { return pimpl; }
639 
640 protected:
641  // Just because we don't want you to know how we're hacking around.
642  ImporterPimpl *pimpl;
643 };
644 
645 // ----------------------------------------------------------------------------
646 // For compatibility, the interface of some functions taking a std::string was
647 // changed to const char* to avoid crashes between binary incompatible STL
648 // versions. This code her is inlined, so it shouldn't cause any problems.
649 // ----------------------------------------------------------------------------
650 
651 // ----------------------------------------------------------------------------
652 AI_FORCE_INLINE const aiScene *Importer::ReadFile(const std::string &pFile, unsigned int pFlags) {
653  return ReadFile(pFile.c_str(), pFlags);
654 }
655 // ----------------------------------------------------------------------------
656 AI_FORCE_INLINE void Importer::GetExtensionList(std::string &szOut) const {
657  aiString s;
658  GetExtensionList(s);
659  szOut = s.data;
660 }
661 // ----------------------------------------------------------------------------
662 AI_FORCE_INLINE bool Importer::IsExtensionSupported(const std::string &szExtension) const {
663  return IsExtensionSupported(szExtension.c_str());
664 }
665 
666 } // namespace Assimp
667 
668 #endif // AI_ASSIMP_HPP_INC
Assimp::Importer::GetIOHandler
IOSystem * GetIOHandler() const
Assimp::Importer::ReadFileFromMemory
const aiScene * ReadFileFromMemory(const void *pBuffer, size_t pLength, unsigned int pFlags, const char *pHint="")
Assimp::Importer::GetException
const std::exception_ptr & GetException() const
Assimp::Importer::GetPropertyInteger
int GetPropertyInteger(const char *szName, int iErrorReturn=0xffffffff) const
types.h
Assimp::Importer
Definition: Importer.hpp:120
Assimp::Importer::operator=
Importer & operator=(const Importer &)=delete
Assimp::Importer::SetPropertyBool
bool SetPropertyBool(const char *szName, bool value)
Definition: Importer.hpp:224
Assimp::Importer::Importer
Importer(const Importer &other)=delete
Assimp::Importer::SetProgressHandler
void SetProgressHandler(ProgressHandler *pHandler)
Assimp::Importer::Importer
Importer()
aiReturn
aiReturn
Definition: types.h:397
Assimp::Importer::SetPropertyInteger
bool SetPropertyInteger(const char *szName, int iValue)
Assimp::Importer::GetScene
const aiScene * GetScene() const
Assimp::Importer::GetExtensionList
void GetExtensionList(aiString &szOut) const
Assimp::Importer::GetErrorString
const char * GetErrorString() const
Assimp::Importer::ApplyPostProcessing
const aiScene * ApplyPostProcessing(unsigned int pFlags)
Assimp::Importer::GetImporter
BaseImporter * GetImporter(size_t index) const
Assimp::Importer::GetPropertyFloat
ai_real GetPropertyFloat(const char *szName, ai_real fErrorReturn=10e10) const
Assimp::Importer::ValidateFlags
bool ValidateFlags(unsigned int pFlags) const
Check whether a given set of post-processing flags is supported.
Assimp::Importer::ReadFile
const aiScene * ReadFile(const char *pFile, unsigned int pFlags)
Assimp::Importer::SetPropertyFloat
bool SetPropertyFloat(const char *szName, ai_real fValue)
aiImporterDesc
Definition: importerdesc.h:91
Assimp::Importer::~Importer
~Importer()
Assimp::Importer::GetImporter
BaseImporter * GetImporter(const char *szExtension) const
Assimp::Importer::SetIOHandler
void SetIOHandler(IOSystem *pIOHandler)
Assimp::Importer::GetPropertyBool
bool GetPropertyBool(const char *szName, bool bErrorReturn=false) const
Definition: Importer.hpp:269
Assimp::Importer::UnregisterPPStep
aiReturn UnregisterPPStep(BaseProcess *pImp)
Assimp::Importer::SetPropertyString
bool SetPropertyString(const char *szName, const std::string &sValue)
Assimp::Importer::IsExtensionSupported
bool IsExtensionSupported(const char *szExtension) const
aiString
Definition: types.h:266
Assimp::Importer::UnregisterLoader
aiReturn UnregisterLoader(BaseImporter *pImp)
Assimp::Importer::GetImporterInfo
const aiImporterDesc * GetImporterInfo(size_t index) const
aiString::data
char data[MAXLEN]
Definition: types.h:390
Assimp::Importer::RegisterPPStep
aiReturn RegisterPPStep(BaseProcess *pImp)
Assimp::Importer::RegisterLoader
aiReturn RegisterLoader(BaseImporter *pImp)
Assimp::Importer::GetImporterCount
size_t GetImporterCount() const
Assimp::Importer::IsDefaultProgressHandler
bool IsDefaultProgressHandler() const
Assimp::Importer::GetProgressHandler
ProgressHandler * GetProgressHandler() const
Assimp::Importer::GetOrphanedScene
aiScene * GetOrphanedScene()
Assimp::Importer::GetMemoryRequirements
void GetMemoryRequirements(aiMemoryInfo &in) const
Assimp::Importer::FreeScene
void FreeScene()
Assimp::Importer::GetPropertyMatrix
aiMatrix4x4 GetPropertyMatrix(const char *szName, const aiMatrix4x4 &sErrorReturn=aiMatrix4x4()) const
Assimp::Importer::GetImporterIndex
size_t GetImporterIndex(const char *szExtension) const
Assimp::IOSystem
CPP-API: Interface to the file system.
Definition: IOSystem.hpp:93
aiMatrix4x4
Definition: matrix4x4.h:266
Assimp::BaseImporter
Definition: BaseImporter.h:87
aiMemoryInfo
Definition: types.h:482
Assimp::Importer::GetPropertyString
std::string GetPropertyString(const char *szName, const std::string &sErrorReturn="") const
Assimp
Definition: ai_assert.h:50
Assimp::Importer::IsDefaultIOHandler
bool IsDefaultIOHandler() const
Assimp::Importer::SetPropertyMatrix
bool SetPropertyMatrix(const char *szName, const aiMatrix4x4 &sValue)
Assimp::Importer::Pimpl
ImporterPimpl * Pimpl()
Definition: Importer.hpp:637
aiScene
Definition: scene.h:247
Assimp::Importer::SetExtraVerbose
void SetExtraVerbose(bool bDo)
Assimp::ProgressHandler
CPP-API: Abstract interface for custom progress report receivers.
Definition: ProgressHandler.hpp:67