Importer.hpp 31 KB

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