Importer.hpp 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683
  1. /*
  2. ---------------------------------------------------------------------------
  3. Open Asset Import Library (assimp)
  4. ---------------------------------------------------------------------------
  5. Copyright (c) 2006-2025, assimp team
  6. All rights reserved.
  7. Redistribution and use of this software in source and binary forms,
  8. with or without modification, are permitted provided that the following
  9. conditions are met:
  10. * Redistributions of source code must retain the above
  11. copyright notice, this list of conditions and the
  12. following disclaimer.
  13. * Redistributions in binary form must reproduce the above
  14. copyright notice, this list of conditions and the
  15. following disclaimer in the documentation and/or other
  16. materials provided with the distribution.
  17. * Neither the name of the assimp team, nor the names of its
  18. contributors may be used to endorse or promote products
  19. derived from this software without specific prior
  20. written permission of the assimp team.
  21. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  22. "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  23. LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  24. A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  25. OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  26. SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  27. LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  28. DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  29. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  30. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  31. OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  32. ---------------------------------------------------------------------------
  33. */
  34. /** @file Importer.hpp
  35. * @brief Defines the C++-API to the Open Asset Import Library.
  36. */
  37. #pragma once
  38. #ifndef AI_ASSIMP_HPP_INC
  39. #define AI_ASSIMP_HPP_INC
  40. #ifdef __GNUC__
  41. #pragma GCC system_header
  42. #endif
  43. #ifndef __cplusplus
  44. #error This header requires C++ to be used. Use assimp.h for plain C.
  45. #endif // __cplusplus
  46. // Public ASSIMP data structures
  47. #include <assimp/types.h>
  48. #include <exception>
  49. namespace Assimp {
  50. // =======================================================================
  51. // Public interface to Assimp
  52. class Importer;
  53. class IOStream;
  54. class IOSystem;
  55. class ProgressHandler;
  56. // =======================================================================
  57. // Plugin development
  58. //
  59. // Include the following headers for the declarations:
  60. // BaseImporter.h
  61. // BaseProcess.h
  62. class BaseImporter;
  63. class BaseProcess;
  64. class SharedPostProcessInfo;
  65. class BatchLoader;
  66. // =======================================================================
  67. // Holy stuff, only for members of the high council of the Jedi.
  68. class ImporterPimpl;
  69. } // namespace Assimp
  70. #define AI_PROPERTY_WAS_NOT_EXISTING 0xffffffff
  71. struct aiScene;
  72. // importerdesc.h
  73. struct aiImporterDesc;
  74. /** @namespace Assimp Assimp's CPP-API and all internal APIs */
  75. namespace Assimp {
  76. // ----------------------------------------------------------------------------------
  77. /** CPP-API: The Importer class forms an C++ interface to the functionality of the
  78. * Open Asset Import Library.
  79. *
  80. * Create an object of this class and call ReadFile() to import a file.
  81. * If the import succeeds, the function returns a pointer to the imported data.
  82. * The data remains property of the object, it is intended to be accessed
  83. * read-only. The imported data will be destroyed along with the Importer
  84. * object. If the import fails, ReadFile() returns a nullptr pointer. In this
  85. * case you can retrieve a human-readable error description be calling
  86. * GetErrorString(). You can call ReadFile() multiple times with a single Importer
  87. * instance. Actually, constructing Importer objects involves quite many
  88. * allocations and may take some time, so it's better to reuse them as often as
  89. * possible.
  90. *
  91. * If you need the Importer to do custom file handling to access the files,
  92. * implement IOSystem and IOStream and supply an instance of your custom
  93. * IOSystem implementation by calling SetIOHandler() before calling ReadFile().
  94. * If you do not assign a custom IO handler, a default handler using the
  95. * standard C++ IO logic will be used.
  96. *
  97. * @note One Importer instance is not thread-safe. If you use multiple
  98. * threads for loading, each thread should maintain its own Importer instance.
  99. */
  100. class ASSIMP_API Importer {
  101. public:
  102. /**
  103. * @brief The upper limit for hints.
  104. */
  105. static const unsigned int MaxLenHint = 200;
  106. public:
  107. // -------------------------------------------------------------------
  108. /** Constructor. Creates an empty importer object.
  109. *
  110. * Call ReadFile() to start the import process. The configuration
  111. * property table is initially empty.
  112. */
  113. Importer();
  114. // -------------------------------------------------------------------
  115. /** Copy constructor.
  116. *
  117. * This copies the configuration properties of another Importer.
  118. * If this Importer owns a scene it won't be copied.
  119. * Call ReadFile() to start the import process.
  120. */
  121. Importer(const Importer &other) = delete;
  122. // -------------------------------------------------------------------
  123. /** Assignment operator has been deleted
  124. */
  125. Importer &operator=(const Importer &) = delete;
  126. // -------------------------------------------------------------------
  127. /** Destructor. The object kept ownership of the imported data,
  128. * which now will be destroyed along with the object.
  129. */
  130. ~Importer();
  131. // -------------------------------------------------------------------
  132. /** Registers a new loader.
  133. *
  134. * @param pImp Importer to be added. The Importer instance takes
  135. * ownership of the pointer, so it will be automatically deleted
  136. * with the Importer instance.
  137. * @return AI_SUCCESS if the loader has been added. The registration
  138. * fails if there is already a loader for a specific file extension.
  139. */
  140. aiReturn RegisterLoader(BaseImporter *pImp);
  141. // -------------------------------------------------------------------
  142. /** Unregisters a loader.
  143. *
  144. * @param pImp Importer to be unregistered.
  145. * @return AI_SUCCESS if the loader has been removed. The function
  146. * fails if the loader is currently in use (this could happen
  147. * if the #Importer instance is used by more than one thread) or
  148. * if it has not yet been registered.
  149. */
  150. aiReturn UnregisterLoader(BaseImporter *pImp);
  151. // -------------------------------------------------------------------
  152. /** Registers a new post-process step.
  153. *
  154. * At the moment, there's a small limitation: new post processing
  155. * steps are added to end of the list, or in other words, executed
  156. * last, after all built-in steps.
  157. * @param pImp Post-process step to be added. The Importer instance
  158. * takes ownership of the pointer, so it will be automatically
  159. * deleted with the Importer instance.
  160. * @return AI_SUCCESS if the step has been added correctly.
  161. */
  162. aiReturn RegisterPPStep(BaseProcess *pImp);
  163. // -------------------------------------------------------------------
  164. /** Unregisters a post-process step.
  165. *
  166. * @param pImp Step to be unregistered.
  167. * @return AI_SUCCESS if the step has been removed. The function
  168. * fails if the step is currently in use (this could happen
  169. * if the #Importer instance is used by more than one thread) or
  170. * if it has not yet been registered.
  171. */
  172. aiReturn UnregisterPPStep(BaseProcess *pImp);
  173. // -------------------------------------------------------------------
  174. /** Set an integer configuration property.
  175. * @param szName Name of the property. All supported properties
  176. * are defined in the aiConfig.g header (all constants share the
  177. * prefix AI_CONFIG_XXX and are simple strings).
  178. * @param iValue New value of the property
  179. * @return true if the property was set before. The new value replaces
  180. * the previous value in this case.
  181. * @note Property of different types (float, int, string ..) are kept
  182. * on different stacks, so calling SetPropertyInteger() for a
  183. * floating-point property has no effect - the loader will call
  184. * GetPropertyFloat() to read the property, but it won't be there.
  185. */
  186. bool SetPropertyInteger(const char *szName, int iValue);
  187. // -------------------------------------------------------------------
  188. /** Set a boolean configuration property. Boolean properties
  189. * are stored on the integer stack internally so it's possible
  190. * to set them via #SetPropertyBool and query them with
  191. * #GetPropertyBool and vice versa.
  192. * @see SetPropertyInteger()
  193. */
  194. bool SetPropertyBool(const char *szName, bool value) {
  195. return SetPropertyInteger(szName, value);
  196. }
  197. // -------------------------------------------------------------------
  198. /** Set a floating-point configuration property.
  199. * @see SetPropertyInteger()
  200. */
  201. bool SetPropertyFloat(const char *szName, ai_real fValue);
  202. // -------------------------------------------------------------------
  203. /** Set a string configuration property.
  204. * @see SetPropertyInteger()
  205. */
  206. bool SetPropertyString(const char *szName, const std::string &sValue);
  207. // -------------------------------------------------------------------
  208. /** Set a matrix configuration property.
  209. * @see SetPropertyInteger()
  210. */
  211. bool SetPropertyMatrix(const char *szName, const aiMatrix4x4 &sValue);
  212. // -------------------------------------------------------------------
  213. /** Set a pointer configuration property.
  214. * @see SetPropertyInteger()
  215. */
  216. bool SetPropertyPointer(const char *szName, void *sValue);
  217. // -------------------------------------------------------------------
  218. /** Get a configuration property.
  219. * @param szName Name of the property. All supported properties
  220. * are defined in the aiConfig.g header (all constants share the
  221. * prefix AI_CONFIG_XXX).
  222. * @param iErrorReturn Value that is returned if the property
  223. * is not found.
  224. * @return Current value of the property
  225. * @note Property of different types (float, int, string ..) are kept
  226. * on different lists, so calling SetPropertyInteger() for a
  227. * floating-point property has no effect - the loader will call
  228. * GetPropertyFloat() to read the property, but it won't be there.
  229. */
  230. int GetPropertyInteger(const char *szName,
  231. int iErrorReturn = 0xffffffff) const;
  232. // -------------------------------------------------------------------
  233. /** Get a boolean configuration property. Boolean properties
  234. * are stored on the integer stack internally so it's possible
  235. * to set them via #SetPropertyBool and query them with
  236. * #GetPropertyBool and vice versa.
  237. * @see GetPropertyInteger()
  238. */
  239. bool GetPropertyBool(const char *szName, bool bErrorReturn = false) const {
  240. return GetPropertyInteger(szName, bErrorReturn) != 0;
  241. }
  242. // -------------------------------------------------------------------
  243. /** Get a floating-point configuration property
  244. * @see GetPropertyInteger()
  245. */
  246. ai_real GetPropertyFloat(const char *szName,
  247. ai_real fErrorReturn = 10e10) const;
  248. // -------------------------------------------------------------------
  249. /** Get a string configuration property
  250. *
  251. * The return value remains valid until the property is modified.
  252. * @see GetPropertyInteger()
  253. */
  254. std::string GetPropertyString(const char *szName,
  255. const std::string &sErrorReturn = std::string()) const;
  256. // -------------------------------------------------------------------
  257. /** Get a matrix configuration property
  258. *
  259. * The return value remains valid until the property is modified.
  260. * @see GetPropertyInteger()
  261. */
  262. aiMatrix4x4 GetPropertyMatrix(const char *szName,
  263. const aiMatrix4x4 &sErrorReturn = aiMatrix4x4()) const;
  264. // -------------------------------------------------------------------
  265. /** Get a pointer configuration property
  266. *
  267. * The return value remains valid until the property is modified.
  268. * @see GetPropertyInteger()
  269. */
  270. void* GetPropertyPointer(const char *szName,
  271. void *sErrorReturn = nullptr) const;
  272. // -------------------------------------------------------------------
  273. /** Supplies a custom IO handler to the importer to use to open and
  274. * access files. If you need the importer to use custom IO logic to
  275. * access the files, you need to provide a custom implementation of
  276. * IOSystem and IOFile to the importer. Then create an instance of
  277. * your custom IOSystem implementation and supply it by this function.
  278. *
  279. * The Importer takes ownership of the object and will destroy it
  280. * afterwards. The previously assigned handler will be deleted.
  281. * Pass nullptr to take again ownership of your IOSystem and reset Assimp
  282. * to use its default implementation.
  283. *
  284. * @param pIOHandler The IO handler to be used in all file accesses
  285. * of the Importer.
  286. */
  287. void SetIOHandler(IOSystem *pIOHandler);
  288. // -------------------------------------------------------------------
  289. /** Retrieves the IO handler that is currently set.
  290. * You can use #IsDefaultIOHandler() to check whether the returned
  291. * interface is the default IO handler provided by ASSIMP. The default
  292. * handler is active as long the application doesn't supply its own
  293. * custom IO handler via #SetIOHandler().
  294. * @return A valid IOSystem interface, never nullptr.
  295. */
  296. IOSystem *GetIOHandler() const;
  297. // -------------------------------------------------------------------
  298. /** Checks whether a default IO handler is active
  299. * A default handler is active as long the application doesn't
  300. * supply its own custom IO handler via #SetIOHandler().
  301. * @return true by default
  302. */
  303. bool IsDefaultIOHandler() const;
  304. // -------------------------------------------------------------------
  305. /** Supplies a custom progress handler to the importer. This
  306. * interface exposes an #Update() callback, which is called
  307. * more or less periodically (please don't sue us if it
  308. * isn't as periodically as you'd like it to have ...).
  309. * This can be used to implement progress bars and loading
  310. * timeouts.
  311. * @param pHandler Progress callback interface. Pass nullptr to
  312. * disable progress reporting.
  313. * @note Progress handlers can be used to abort the loading
  314. * at almost any time.*/
  315. void SetProgressHandler(ProgressHandler *pHandler);
  316. // -------------------------------------------------------------------
  317. /** Retrieves the progress handler that is currently set.
  318. * You can use #IsDefaultProgressHandler() to check whether the returned
  319. * interface is the default handler provided by ASSIMP. The default
  320. * handler is active as long the application doesn't supply its own
  321. * custom handler via #SetProgressHandler().
  322. * @return A valid ProgressHandler interface, never nullptr.
  323. */
  324. ProgressHandler *GetProgressHandler() const;
  325. // -------------------------------------------------------------------
  326. /** Checks whether a default progress handler is active
  327. * A default handler is active as long the application doesn't
  328. * supply its own custom progress handler via #SetProgressHandler().
  329. * @return true by default
  330. */
  331. bool IsDefaultProgressHandler() const;
  332. // -------------------------------------------------------------------
  333. /** @brief Check whether a given set of post-processing flags
  334. * is supported.
  335. *
  336. * Some flags are mutually exclusive, others are probably
  337. * not available because your excluded them from your
  338. * Assimp builds. Calling this function is recommended if
  339. * you're unsure.
  340. *
  341. * @param pFlags Bitwise combination of the aiPostProcess flags.
  342. * @return true if this flag combination is fine.
  343. */
  344. bool ValidateFlags(unsigned int pFlags) const;
  345. // -------------------------------------------------------------------
  346. /** Reads the given file and returns its contents if successful.
  347. *
  348. * If the call succeeds, the contents of the file are returned as a
  349. * pointer to an aiScene object. The returned data is intended to be
  350. * read-only, the importer object keeps ownership of the data and will
  351. * destroy it upon destruction. If the import fails, nullptr is returned.
  352. * A human-readable error description can be retrieved by calling
  353. * GetErrorString(). The previous scene will be deleted during this call.
  354. * @param pFile Path and filename to the file to be imported.
  355. * @param pFlags Optional post processing steps to be executed after
  356. * a successful import. Provide a bitwise combination of the
  357. * #aiPostProcessSteps flags. If you wish to inspect the imported
  358. * scene first in order to fine-tune your post-processing setup,
  359. * consider to use #ApplyPostProcessing().
  360. * @return A pointer to the imported data, nullptr if the import failed.
  361. * The pointer to the scene remains in possession of the Importer
  362. * instance. Use GetOrphanedScene() to take ownership of it.
  363. *
  364. * @note Assimp is able to determine the file format of a file
  365. * automatically.
  366. */
  367. const aiScene *ReadFile(
  368. const char *pFile,
  369. unsigned int pFlags);
  370. // -------------------------------------------------------------------
  371. /** Reads the given file from a memory buffer and returns its
  372. * contents if successful.
  373. *
  374. * If the call succeeds, the contents of the file are returned as a
  375. * pointer to an aiScene object. The returned data is intended to be
  376. * read-only, the importer object keeps ownership of the data and will
  377. * destroy it upon destruction. If the import fails, nullptr is returned.
  378. * A human-readable error description can be retrieved by calling
  379. * GetErrorString(). The previous scene will be deleted during this call.
  380. * Calling this method doesn't affect the active IOSystem.
  381. * @param pBuffer Pointer to the file data
  382. * @param pLength Length of pBuffer, in bytes
  383. * @param pFlags Optional post processing steps to be executed after
  384. * a successful import. Provide a bitwise combination of the
  385. * #aiPostProcessSteps flags. If you wish to inspect the imported
  386. * scene first in order to fine-tune your post-processing setup,
  387. * consider to use #ApplyPostProcessing().
  388. * @param pHint An additional hint to the library. If this is a non
  389. * empty string, the library looks for a loader to support
  390. * the file extension specified by pHint and passes the file to
  391. * the first matching loader. If this loader is unable to completely
  392. * the request, the library continues and tries to determine the
  393. * file format on its own, a task that may or may not be successful.
  394. * Check the return value, and you'll know ...
  395. * @return A pointer to the imported data, nullptr if the import failed.
  396. * The pointer to the scene remains in possession of the Importer
  397. * instance. Use GetOrphanedScene() to take ownership of it.
  398. *
  399. * @note This is a straightforward way to decode models from memory
  400. * buffers, but it doesn't handle model formats that spread their
  401. * data across multiple files or even directories. Examples include
  402. * OBJ or MD3, which outsource parts of their material info into
  403. * external scripts. If you need full functionality, provide
  404. * a custom IOSystem to make Assimp find these files and use
  405. * the regular ReadFile() API.
  406. */
  407. const aiScene *ReadFileFromMemory(
  408. const void *pBuffer,
  409. size_t pLength,
  410. unsigned int pFlags,
  411. const char *pHint = "");
  412. // -------------------------------------------------------------------
  413. /** Apply post-processing to an already-imported scene.
  414. *
  415. * This is strictly equivalent to calling #ReadFile() with the same
  416. * flags. However, you can use this separate function to inspect
  417. * the imported scene first to fine-tune your post-processing setup.
  418. * @param pFlags Provide a bitwise combination of the
  419. * #aiPostProcessSteps flags.
  420. * @return A pointer to the post-processed data. This is still the
  421. * same as the pointer returned by #ReadFile(). However, if
  422. * post-processing fails, the scene could now be nullptr.
  423. * That's quite a rare case, post processing steps are not really
  424. * designed to 'fail'. To be exact, the #aiProcess_ValidateDS
  425. * flag is currently the only post processing step which can actually
  426. * cause the scene to be reset to nullptr.
  427. *
  428. * @note The method does nothing if no scene is currently bound
  429. * to the #Importer instance. */
  430. const aiScene *ApplyPostProcessing(unsigned int pFlags);
  431. const aiScene *ApplyCustomizedPostProcessing(BaseProcess *rootProcess, bool requestValidation);
  432. // -------------------------------------------------------------------
  433. /** @brief Reads the given file and returns its contents if successful.
  434. *
  435. * This function is provided for backward compatibility.
  436. * See the const char* version for detailed docs.
  437. * @see ReadFile(const char*, pFlags) */
  438. const aiScene *ReadFile(
  439. const std::string &pFile,
  440. unsigned int pFlags);
  441. // -------------------------------------------------------------------
  442. /** Frees the current scene.
  443. *
  444. * The function does nothing if no scene has previously been
  445. * read via ReadFile(). FreeScene() is called automatically by the
  446. * destructor and ReadFile() itself. */
  447. void FreeScene();
  448. // -------------------------------------------------------------------
  449. /** Returns an error description of an error that occurred in ReadFile().
  450. *
  451. * Returns an empty string if no error occurred.
  452. * @return A description of the last error, an empty string if no
  453. * error occurred. The string is never nullptr.
  454. *
  455. * @note The returned function remains valid until one of the
  456. * following methods is called: #ReadFile(), #FreeScene(). */
  457. const char *GetErrorString() const;
  458. // -------------------------------------------------------------------
  459. /** Returns an exception if one occurred during import.
  460. *
  461. * @return The last exception which occurred.
  462. *
  463. * @note The returned value remains valid until one of the
  464. * following methods is called: #ReadFile(), #FreeScene(). */
  465. const std::exception_ptr& GetException() const;
  466. // -------------------------------------------------------------------
  467. /** Returns the scene loaded by the last successful call to ReadFile()
  468. *
  469. * @return Current scene or nullptr if there is currently no scene loaded */
  470. const aiScene *GetScene() const;
  471. // -------------------------------------------------------------------
  472. /** Returns the scene loaded by the last successful call to ReadFile()
  473. * and releases the scene from the ownership of the Importer
  474. * instance. The application is now responsible for deleting the
  475. * scene. Any further calls to GetScene() or GetOrphanedScene()
  476. * will return nullptr - until a new scene has been loaded via ReadFile().
  477. *
  478. * @return Current scene or nullptr if there is currently no scene loaded
  479. * @note Use this method with maximal caution, and only if you have to.
  480. * By design, aiScene's are exclusively maintained, allocated and
  481. * deallocated by Assimp and no one else. The reasoning behind this
  482. * is the golden rule that deallocations should always be done
  483. * by the module that did the original allocation because heaps
  484. * are not necessarily shared. GetOrphanedScene() enforces you
  485. * to delete the returned scene by yourself, but this will only
  486. * be fine if and only if you're using the same heap as assimp.
  487. * On Windows, it's typically fine provided everything is linked
  488. * against the multithreaded-dll version of the runtime library.
  489. * It will work as well for static linkage with Assimp.*/
  490. aiScene *GetOrphanedScene();
  491. // -------------------------------------------------------------------
  492. /** Returns whether a given file extension is supported by ASSIMP.
  493. *
  494. * @param szExtension Extension to be checked.
  495. * Must include a trailing dot '.'. Example: ".3ds", ".md3".
  496. * Cases-insensitive.
  497. * @return true if the extension is supported, false otherwise */
  498. bool IsExtensionSupported(const char *szExtension) const;
  499. // -------------------------------------------------------------------
  500. /** @brief Returns whether a given file extension is supported by ASSIMP.
  501. *
  502. * This function is provided for backward compatibility.
  503. * See the const char* version for detailed and up-to-date docs.
  504. * @see IsExtensionSupported(const char*) */
  505. inline bool IsExtensionSupported(const std::string &szExtension) const;
  506. // -------------------------------------------------------------------
  507. /** Get a full list of all file extensions supported by ASSIMP.
  508. *
  509. * If a file extension is contained in the list this does of course not
  510. * mean that ASSIMP is able to load all files with this extension ---
  511. * it simply means there is an importer loaded which claims to handle
  512. * files with this file extension.
  513. * @param szOut String to receive the extension list.
  514. * Format of the list: "*.3ds;*.obj;*.dae". This is useful for
  515. * use with the WinAPI call GetOpenFileName(Ex). */
  516. void GetExtensionList(aiString &szOut) const;
  517. // -------------------------------------------------------------------
  518. /** @brief Get a full list of all file extensions supported by ASSIMP.
  519. *
  520. * This function is provided for backward compatibility.
  521. * See the aiString version for detailed and up-to-date docs.
  522. * @see GetExtensionList(aiString&)*/
  523. inline void GetExtensionList(std::string &szOut) const;
  524. // -------------------------------------------------------------------
  525. /** Get the number of importers currently registered with Assimp. */
  526. size_t GetImporterCount() const;
  527. // -------------------------------------------------------------------
  528. /** Get meta data for the importer corresponding to a specific index..
  529. *
  530. * For the declaration of #aiImporterDesc, include <assimp/importerdesc.h>.
  531. * @param index Index to query, must be within [0,GetImporterCount())
  532. * @return Importer meta data structure, nullptr if the index does not
  533. * exist or if the importer doesn't offer meta information (
  534. * importers may do this at the cost of being hated by their peers).*/
  535. const aiImporterDesc *GetImporterInfo(size_t index) const;
  536. // -------------------------------------------------------------------
  537. /** Find the importer corresponding to a specific index.
  538. *
  539. * @param index Index to query, must be within [0,GetImporterCount())
  540. * @return Importer instance. nullptr if the index does not
  541. * exist. */
  542. BaseImporter *GetImporter(size_t index) const;
  543. // -------------------------------------------------------------------
  544. /** Find the importer corresponding to a specific file extension.
  545. *
  546. * This is quite similar to #IsExtensionSupported except a
  547. * BaseImporter instance is returned.
  548. * @param szExtension Extension to check for. The following formats
  549. * are recognized (BAH being the file extension): "BAH" (comparison
  550. * is case-insensitive), ".bah", "*.bah" (wild card and dot
  551. * characters at the beginning of the extension are skipped).
  552. * @return nullptr if no importer is found*/
  553. BaseImporter *GetImporter(const char *szExtension) const;
  554. // -------------------------------------------------------------------
  555. /** Find the importer index corresponding to a specific file extension.
  556. *
  557. * @param szExtension Extension to check for. The following formats
  558. * are recognized (BAH being the file extension): "BAH" (comparison
  559. * is case-insensitive), ".bah", "*.bah" (wild card and dot
  560. * characters at the beginning of the extension are skipped).
  561. * @return (size_t)-1 if no importer is found */
  562. size_t GetImporterIndex(const char *szExtension) const;
  563. // -------------------------------------------------------------------
  564. /** Returns the storage allocated by ASSIMP to hold the scene data
  565. * in memory.
  566. *
  567. * This refers to the currently loaded file, see #ReadFile().
  568. * @param in Data structure to be filled.
  569. * @note The returned memory statistics refer to the actual
  570. * size of the use data of the aiScene. Heap-related overhead
  571. * is (naturally) not included.*/
  572. void GetMemoryRequirements(aiMemoryInfo &in) const;
  573. // -------------------------------------------------------------------
  574. /** Enables "extra verbose" mode.
  575. *
  576. * 'Extra verbose' means the data structure is validated after *every*
  577. * single post processing step to make sure everyone modifies the data
  578. * structure in a well-defined manner. This is a debug feature and not
  579. * intended for use in production environments. */
  580. void SetExtraVerbose(bool bDo);
  581. // -------------------------------------------------------------------
  582. /** Private, do not use. */
  583. ImporterPimpl *Pimpl() { return pimpl; }
  584. const ImporterPimpl *Pimpl() const { return pimpl; }
  585. protected:
  586. // Just because we don't want you to know how we're hacking around.
  587. ImporterPimpl *pimpl;
  588. }; //! class Importer
  589. // ----------------------------------------------------------------------------
  590. // For compatibility, the interface of some functions taking a std::string was
  591. // changed to const char* to avoid crashes between binary incompatible STL
  592. // versions. This code her is inlined, so it shouldn't cause any problems.
  593. // ----------------------------------------------------------------------------
  594. // ----------------------------------------------------------------------------
  595. AI_FORCE_INLINE const aiScene *Importer::ReadFile(const std::string &pFile, unsigned int pFlags) {
  596. return ReadFile(pFile.c_str(), pFlags);
  597. }
  598. // ----------------------------------------------------------------------------
  599. AI_FORCE_INLINE void Importer::GetExtensionList(std::string &szOut) const {
  600. aiString s;
  601. GetExtensionList(s);
  602. szOut = s.data;
  603. }
  604. // ----------------------------------------------------------------------------
  605. AI_FORCE_INLINE bool Importer::IsExtensionSupported(const std::string &szExtension) const {
  606. return IsExtensionSupported(szExtension.c_str());
  607. }
  608. } // namespace Assimp
  609. #endif // AI_ASSIMP_HPP_INC