Exporter.cpp 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602
  1. /*
  2. ---------------------------------------------------------------------------
  3. Open Asset Import Library (assimp)
  4. ---------------------------------------------------------------------------
  5. Copyright (c) 2006-2017, 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 Exporter.cpp
  35. Assimp export interface. While it's public interface bears many similarities
  36. to the import interface (in fact, it is largely symmetric), the internal
  37. implementations differs a lot. Exporters are considered stateless and are
  38. simple callbacks which we maintain in a global list along with their
  39. description strings.
  40. Here we implement only the C++ interface (Assimp::Exporter).
  41. */
  42. #ifndef ASSIMP_BUILD_NO_EXPORT
  43. #include "BlobIOSystem.h"
  44. #include <assimp/SceneCombiner.h>
  45. #include "BaseProcess.h"
  46. #include "Importer.h" // need this for GetPostProcessingStepInstanceList()
  47. #include "JoinVerticesProcess.h"
  48. #include "MakeVerboseFormat.h"
  49. #include "ConvertToLHProcess.h"
  50. #include "Exceptional.h"
  51. #include "ScenePrivate.h"
  52. #include <memory>
  53. #include <assimp/DefaultIOSystem.h>
  54. #include <assimp/Exporter.hpp>
  55. #include <assimp/mesh.h>
  56. #include <assimp/postprocess.h>
  57. #include <assimp/scene.h>
  58. namespace Assimp {
  59. // PostStepRegistry.cpp
  60. void GetPostProcessingStepInstanceList(std::vector< BaseProcess* >& out);
  61. // ------------------------------------------------------------------------------------------------
  62. // Exporter worker function prototypes. Should not be necessary to #ifndef them, it's just a prototype
  63. // do not use const, because some exporter need to convert the scene temporary
  64. void ExportSceneCollada(const char*,IOSystem*, const aiScene*, const ExportProperties*);
  65. void ExportSceneXFile(const char*,IOSystem*, const aiScene*, const ExportProperties*);
  66. void ExportSceneStep(const char*,IOSystem*, const aiScene*, const ExportProperties*);
  67. void ExportSceneObj(const char*,IOSystem*, const aiScene*, const ExportProperties*);
  68. void ExportSceneObjNoMtl(const char*,IOSystem*, const aiScene*, const ExportProperties*);
  69. void ExportSceneSTL(const char*,IOSystem*, const aiScene*, const ExportProperties*);
  70. void ExportSceneSTLBinary(const char*,IOSystem*, const aiScene*, const ExportProperties*);
  71. void ExportScenePly(const char*,IOSystem*, const aiScene*, const ExportProperties*);
  72. void ExportScenePlyBinary(const char*, IOSystem*, const aiScene*, const ExportProperties*);
  73. void ExportScene3DS(const char*, IOSystem*, const aiScene*, const ExportProperties*);
  74. void ExportSceneGLTF(const char*, IOSystem*, const aiScene*, const ExportProperties*);
  75. void ExportSceneGLB(const char*, IOSystem*, const aiScene*, const ExportProperties*);
  76. void ExportSceneGLTF2(const char*, IOSystem*, const aiScene*, const ExportProperties*);
  77. void ExportSceneAssbin(const char*, IOSystem*, const aiScene*, const ExportProperties*);
  78. void ExportSceneAssxml(const char*, IOSystem*, const aiScene*, const ExportProperties*);
  79. void ExportSceneX3D(const char*, IOSystem*, const aiScene*, const ExportProperties*);
  80. void ExportScene3MF( const char*, IOSystem*, const aiScene*, const ExportProperties* );
  81. // ------------------------------------------------------------------------------------------------
  82. // global array of all export formats which Assimp supports in its current build
  83. Exporter::ExportFormatEntry gExporters[] =
  84. {
  85. #ifndef ASSIMP_BUILD_NO_COLLADA_EXPORTER
  86. Exporter::ExportFormatEntry( "collada", "COLLADA - Digital Asset Exchange Schema", "dae", &ExportSceneCollada ),
  87. #endif
  88. #ifndef ASSIMP_BUILD_NO_X_EXPORTER
  89. Exporter::ExportFormatEntry( "x", "X Files", "x", &ExportSceneXFile,
  90. aiProcess_MakeLeftHanded | aiProcess_FlipWindingOrder | aiProcess_FlipUVs ),
  91. #endif
  92. #ifndef ASSIMP_BUILD_NO_STEP_EXPORTER
  93. Exporter::ExportFormatEntry( "stp", "Step Files", "stp", &ExportSceneStep, 0 ),
  94. #endif
  95. #ifndef ASSIMP_BUILD_NO_OBJ_EXPORTER
  96. Exporter::ExportFormatEntry( "obj", "Wavefront OBJ format", "obj", &ExportSceneObj,
  97. aiProcess_GenSmoothNormals /*| aiProcess_PreTransformVertices */ ),
  98. Exporter::ExportFormatEntry( "objnomtl", "Wavefront OBJ format without material file", "obj", &ExportSceneObjNoMtl,
  99. aiProcess_GenSmoothNormals /*| aiProcess_PreTransformVertices */ ),
  100. #endif
  101. #ifndef ASSIMP_BUILD_NO_STL_EXPORTER
  102. Exporter::ExportFormatEntry( "stl", "Stereolithography", "stl" , &ExportSceneSTL,
  103. aiProcess_Triangulate | aiProcess_GenNormals | aiProcess_PreTransformVertices
  104. ),
  105. Exporter::ExportFormatEntry( "stlb", "Stereolithography (binary)", "stl" , &ExportSceneSTLBinary,
  106. aiProcess_Triangulate | aiProcess_GenNormals | aiProcess_PreTransformVertices
  107. ),
  108. #endif
  109. #ifndef ASSIMP_BUILD_NO_PLY_EXPORTER
  110. Exporter::ExportFormatEntry( "ply", "Stanford Polygon Library", "ply" , &ExportScenePly,
  111. aiProcess_PreTransformVertices
  112. ),
  113. Exporter::ExportFormatEntry( "plyb", "Stanford Polygon Library (binary)", "ply", &ExportScenePlyBinary,
  114. aiProcess_PreTransformVertices
  115. ),
  116. #endif
  117. #ifndef ASSIMP_BUILD_NO_3DS_EXPORTER
  118. Exporter::ExportFormatEntry( "3ds", "Autodesk 3DS (legacy)", "3ds" , &ExportScene3DS,
  119. aiProcess_Triangulate | aiProcess_SortByPType | aiProcess_JoinIdenticalVertices ),
  120. #endif
  121. #ifndef ASSIMP_BUILD_NO_GLTF_EXPORTER
  122. Exporter::ExportFormatEntry( "gltf", "GL Transmission Format", "gltf", &ExportSceneGLTF,
  123. aiProcess_JoinIdenticalVertices | aiProcess_Triangulate | aiProcess_SortByPType ),
  124. Exporter::ExportFormatEntry( "glb", "GL Transmission Format (binary)", "glb", &ExportSceneGLB,
  125. aiProcess_JoinIdenticalVertices | aiProcess_Triangulate | aiProcess_SortByPType ),
  126. Exporter::ExportFormatEntry( "gltf2", "GL Transmission Format v. 2", "gltf2", &ExportSceneGLTF2,
  127. aiProcess_JoinIdenticalVertices | aiProcess_Triangulate | aiProcess_SortByPType ),
  128. #endif
  129. #ifndef ASSIMP_BUILD_NO_ASSBIN_EXPORTER
  130. Exporter::ExportFormatEntry( "assbin", "Assimp Binary", "assbin" , &ExportSceneAssbin, 0 ),
  131. #endif
  132. #ifndef ASSIMP_BUILD_NO_ASSXML_EXPORTER
  133. Exporter::ExportFormatEntry( "assxml", "Assxml Document", "assxml" , &ExportSceneAssxml, 0 ),
  134. #endif
  135. #ifndef ASSIMP_BUILD_NO_X3D_EXPORTER
  136. Exporter::ExportFormatEntry( "x3d", "Extensible 3D", "x3d" , &ExportSceneX3D, 0 ),
  137. #endif
  138. #ifndef ASSIMP_BUILD_NO3MF_EXPORTER
  139. Exporter::ExportFormatEntry( "3mf", "The 3MF-File-Format", "3mf", &ExportScene3MF, 0 )
  140. #endif
  141. };
  142. #define ASSIMP_NUM_EXPORTERS (sizeof(gExporters)/sizeof(gExporters[0]))
  143. class ExporterPimpl {
  144. public:
  145. ExporterPimpl()
  146. : blob()
  147. , mIOSystem(new Assimp::DefaultIOSystem())
  148. , mIsDefaultIOHandler(true)
  149. {
  150. GetPostProcessingStepInstanceList(mPostProcessingSteps);
  151. // grab all built-in exporters
  152. if ( 0 != ( ASSIMP_NUM_EXPORTERS ) ) {
  153. mExporters.resize( ASSIMP_NUM_EXPORTERS );
  154. std::copy( gExporters, gExporters + ASSIMP_NUM_EXPORTERS, mExporters.begin() );
  155. }
  156. }
  157. ~ExporterPimpl()
  158. {
  159. delete blob;
  160. // Delete all post-processing plug-ins
  161. for( unsigned int a = 0; a < mPostProcessingSteps.size(); a++) {
  162. delete mPostProcessingSteps[a];
  163. }
  164. }
  165. public:
  166. aiExportDataBlob* blob;
  167. std::shared_ptr< Assimp::IOSystem > mIOSystem;
  168. bool mIsDefaultIOHandler;
  169. /** Post processing steps we can apply at the imported data. */
  170. std::vector< BaseProcess* > mPostProcessingSteps;
  171. /** Last fatal export error */
  172. std::string mError;
  173. /** Exporters, this includes those registered using #Assimp::Exporter::RegisterExporter */
  174. std::vector<Exporter::ExportFormatEntry> mExporters;
  175. };
  176. } // end of namespace Assimp
  177. using namespace Assimp;
  178. // ------------------------------------------------------------------------------------------------
  179. Exporter :: Exporter()
  180. : pimpl(new ExporterPimpl()) {
  181. // empty
  182. }
  183. // ------------------------------------------------------------------------------------------------
  184. Exporter::~Exporter() {
  185. FreeBlob();
  186. delete pimpl;
  187. }
  188. // ------------------------------------------------------------------------------------------------
  189. void Exporter::SetIOHandler( IOSystem* pIOHandler) {
  190. pimpl->mIsDefaultIOHandler = !pIOHandler;
  191. pimpl->mIOSystem.reset(pIOHandler);
  192. }
  193. // ------------------------------------------------------------------------------------------------
  194. IOSystem* Exporter::GetIOHandler() const {
  195. return pimpl->mIOSystem.get();
  196. }
  197. // ------------------------------------------------------------------------------------------------
  198. bool Exporter::IsDefaultIOHandler() const {
  199. return pimpl->mIsDefaultIOHandler;
  200. }
  201. // ------------------------------------------------------------------------------------------------
  202. const aiExportDataBlob* Exporter::ExportToBlob( const aiScene* pScene, const char* pFormatId,
  203. unsigned int, const ExportProperties* /*pProperties*/ ) {
  204. if (pimpl->blob) {
  205. delete pimpl->blob;
  206. pimpl->blob = NULL;
  207. }
  208. std::shared_ptr<IOSystem> old = pimpl->mIOSystem;
  209. BlobIOSystem* blobio = new BlobIOSystem();
  210. pimpl->mIOSystem = std::shared_ptr<IOSystem>( blobio );
  211. if (AI_SUCCESS != Export(pScene,pFormatId,blobio->GetMagicFileName())) {
  212. pimpl->mIOSystem = old;
  213. return NULL;
  214. }
  215. pimpl->blob = blobio->GetBlobChain();
  216. pimpl->mIOSystem = old;
  217. return pimpl->blob;
  218. }
  219. // ------------------------------------------------------------------------------------------------
  220. bool IsVerboseFormat(const aiMesh* mesh) {
  221. // avoid slow vector<bool> specialization
  222. std::vector<unsigned int> seen(mesh->mNumVertices,0);
  223. for(unsigned int i = 0; i < mesh->mNumFaces; ++i) {
  224. const aiFace& f = mesh->mFaces[i];
  225. for(unsigned int j = 0; j < f.mNumIndices; ++j) {
  226. if(++seen[f.mIndices[j]] == 2) {
  227. // found a duplicate index
  228. return false;
  229. }
  230. }
  231. }
  232. return true;
  233. }
  234. // ------------------------------------------------------------------------------------------------
  235. bool IsVerboseFormat(const aiScene* pScene) {
  236. for(unsigned int i = 0; i < pScene->mNumMeshes; ++i) {
  237. if(!IsVerboseFormat(pScene->mMeshes[i])) {
  238. return false;
  239. }
  240. }
  241. return true;
  242. }
  243. // ------------------------------------------------------------------------------------------------
  244. aiReturn Exporter::Export( const aiScene* pScene, const char* pFormatId, const char* pPath, unsigned int pPreprocessing, const ExportProperties* pProperties) {
  245. ASSIMP_BEGIN_EXCEPTION_REGION();
  246. // when they create scenes from scratch, users will likely create them not in verbose
  247. // format. They will likely not be aware that there is a flag in the scene to indicate
  248. // this, however. To avoid surprises and bug reports, we check for duplicates in
  249. // meshes upfront.
  250. const bool is_verbose_format = !(pScene->mFlags & AI_SCENE_FLAGS_NON_VERBOSE_FORMAT) || IsVerboseFormat(pScene);
  251. pimpl->mError = "";
  252. for (size_t i = 0; i < pimpl->mExporters.size(); ++i) {
  253. const Exporter::ExportFormatEntry& exp = pimpl->mExporters[i];
  254. if (!strcmp(exp.mDescription.id,pFormatId)) {
  255. try {
  256. // Always create a full copy of the scene. We might optimize this one day,
  257. // but for now it is the most pragmatic way.
  258. aiScene* scenecopy_tmp = NULL;
  259. SceneCombiner::CopyScene(&scenecopy_tmp,pScene);
  260. std::unique_ptr<aiScene> scenecopy(scenecopy_tmp);
  261. const ScenePrivateData* const priv = ScenePriv(pScene);
  262. // steps that are not idempotent, i.e. we might need to run them again, usually to get back to the
  263. // original state before the step was applied first. When checking which steps we don't need
  264. // to run, those are excluded.
  265. const unsigned int nonIdempotentSteps = aiProcess_FlipWindingOrder | aiProcess_FlipUVs | aiProcess_MakeLeftHanded;
  266. // Erase all pp steps that were already applied to this scene
  267. const unsigned int pp = (exp.mEnforcePP | pPreprocessing) & ~(priv && !priv->mIsCopy
  268. ? (priv->mPPStepsApplied & ~nonIdempotentSteps)
  269. : 0u);
  270. // If no extra post-processing was specified, and we obtained this scene from an
  271. // Assimp importer, apply the reverse steps automatically.
  272. // TODO: either drop this, or document it. Otherwise it is just a bad surprise.
  273. //if (!pPreprocessing && priv) {
  274. // pp |= (nonIdempotentSteps & priv->mPPStepsApplied);
  275. //}
  276. // If the input scene is not in verbose format, but there is at least post-processing step that relies on it,
  277. // we need to run the MakeVerboseFormat step first.
  278. bool must_join_again = false;
  279. if (!is_verbose_format) {
  280. bool verbosify = false;
  281. for( unsigned int a = 0; a < pimpl->mPostProcessingSteps.size(); a++) {
  282. BaseProcess* const p = pimpl->mPostProcessingSteps[a];
  283. if (p->IsActive(pp) && p->RequireVerboseFormat()) {
  284. verbosify = true;
  285. break;
  286. }
  287. }
  288. if (verbosify || (exp.mEnforcePP & aiProcess_JoinIdenticalVertices)) {
  289. DefaultLogger::get()->debug("export: Scene data not in verbose format, applying MakeVerboseFormat step first");
  290. MakeVerboseFormatProcess proc;
  291. proc.Execute(scenecopy.get());
  292. if(!(exp.mEnforcePP & aiProcess_JoinIdenticalVertices)) {
  293. must_join_again = true;
  294. }
  295. }
  296. }
  297. if (pp) {
  298. // the three 'conversion' steps need to be executed first because all other steps rely on the standard data layout
  299. {
  300. FlipWindingOrderProcess step;
  301. if (step.IsActive(pp)) {
  302. step.Execute(scenecopy.get());
  303. }
  304. }
  305. {
  306. FlipUVsProcess step;
  307. if (step.IsActive(pp)) {
  308. step.Execute(scenecopy.get());
  309. }
  310. }
  311. {
  312. MakeLeftHandedProcess step;
  313. if (step.IsActive(pp)) {
  314. step.Execute(scenecopy.get());
  315. }
  316. }
  317. // dispatch other processes
  318. for( unsigned int a = 0; a < pimpl->mPostProcessingSteps.size(); a++) {
  319. BaseProcess* const p = pimpl->mPostProcessingSteps[a];
  320. if (p->IsActive(pp)
  321. && !dynamic_cast<FlipUVsProcess*>(p)
  322. && !dynamic_cast<FlipWindingOrderProcess*>(p)
  323. && !dynamic_cast<MakeLeftHandedProcess*>(p)) {
  324. p->Execute(scenecopy.get());
  325. }
  326. }
  327. ScenePrivateData* const privOut = ScenePriv(scenecopy.get());
  328. ai_assert(privOut);
  329. privOut->mPPStepsApplied |= pp;
  330. }
  331. if(must_join_again) {
  332. JoinVerticesProcess proc;
  333. proc.Execute(scenecopy.get());
  334. }
  335. ExportProperties emptyProperties; // Never pass NULL ExportProperties so Exporters don't have to worry.
  336. exp.mExportFunction(pPath,pimpl->mIOSystem.get(),scenecopy.get(), pProperties ? pProperties : &emptyProperties);
  337. } catch (DeadlyExportError& err) {
  338. pimpl->mError = err.what();
  339. return AI_FAILURE;
  340. }
  341. return AI_SUCCESS;
  342. }
  343. }
  344. pimpl->mError = std::string("Found no exporter to handle this file format: ") + pFormatId;
  345. ASSIMP_END_EXCEPTION_REGION(aiReturn);
  346. return AI_FAILURE;
  347. }
  348. // ------------------------------------------------------------------------------------------------
  349. const char* Exporter::GetErrorString() const {
  350. return pimpl->mError.c_str();
  351. }
  352. // ------------------------------------------------------------------------------------------------
  353. void Exporter::FreeBlob() {
  354. delete pimpl->blob;
  355. pimpl->blob = NULL;
  356. pimpl->mError = "";
  357. }
  358. // ------------------------------------------------------------------------------------------------
  359. const aiExportDataBlob* Exporter::GetBlob() const {
  360. return pimpl->blob;
  361. }
  362. // ------------------------------------------------------------------------------------------------
  363. const aiExportDataBlob* Exporter::GetOrphanedBlob() const {
  364. const aiExportDataBlob* tmp = pimpl->blob;
  365. pimpl->blob = NULL;
  366. return tmp;
  367. }
  368. // ------------------------------------------------------------------------------------------------
  369. size_t Exporter::GetExportFormatCount() const {
  370. return pimpl->mExporters.size();
  371. }
  372. // ------------------------------------------------------------------------------------------------
  373. const aiExportFormatDesc* Exporter::GetExportFormatDescription( size_t index ) const {
  374. if (index >= GetExportFormatCount()) {
  375. return NULL;
  376. }
  377. // Return from static storage if the requested index is built-in.
  378. if (index < sizeof(gExporters) / sizeof(gExporters[0])) {
  379. return &gExporters[index].mDescription;
  380. }
  381. return &pimpl->mExporters[index].mDescription;
  382. }
  383. // ------------------------------------------------------------------------------------------------
  384. aiReturn Exporter::RegisterExporter(const ExportFormatEntry& desc) {
  385. for(const ExportFormatEntry& e : pimpl->mExporters) {
  386. if (!strcmp(e.mDescription.id,desc.mDescription.id)) {
  387. return aiReturn_FAILURE;
  388. }
  389. }
  390. pimpl->mExporters.push_back(desc);
  391. return aiReturn_SUCCESS;
  392. }
  393. // ------------------------------------------------------------------------------------------------
  394. void Exporter::UnregisterExporter(const char* id) {
  395. for(std::vector<ExportFormatEntry>::iterator it = pimpl->mExporters.begin(); it != pimpl->mExporters.end(); ++it) {
  396. if (!strcmp((*it).mDescription.id,id)) {
  397. pimpl->mExporters.erase(it);
  398. break;
  399. }
  400. }
  401. }
  402. // ------------------------------------------------------------------------------------------------
  403. ExportProperties::ExportProperties() {
  404. // empty
  405. }
  406. // ------------------------------------------------------------------------------------------------
  407. ExportProperties::ExportProperties(const ExportProperties &other)
  408. : mIntProperties(other.mIntProperties)
  409. , mFloatProperties(other.mFloatProperties)
  410. , mStringProperties(other.mStringProperties)
  411. , mMatrixProperties(other.mMatrixProperties) {
  412. // empty
  413. }
  414. // ------------------------------------------------------------------------------------------------
  415. // Set a configuration property
  416. bool ExportProperties::SetPropertyInteger(const char* szName, int iValue) {
  417. return SetGenericProperty<int>(mIntProperties, szName,iValue);
  418. }
  419. // ------------------------------------------------------------------------------------------------
  420. // Set a configuration property
  421. bool ExportProperties::SetPropertyFloat(const char* szName, ai_real iValue) {
  422. return SetGenericProperty<ai_real>(mFloatProperties, szName,iValue);
  423. }
  424. // ------------------------------------------------------------------------------------------------
  425. // Set a configuration property
  426. bool ExportProperties :: SetPropertyString(const char* szName, const std::string& value)
  427. {
  428. return SetGenericProperty<std::string>(mStringProperties, szName,value);
  429. }
  430. // ------------------------------------------------------------------------------------------------
  431. // Set a configuration property
  432. bool ExportProperties :: SetPropertyMatrix(const char* szName, const aiMatrix4x4& value)
  433. {
  434. return SetGenericProperty<aiMatrix4x4>(mMatrixProperties, szName,value);
  435. }
  436. // ------------------------------------------------------------------------------------------------
  437. // Get a configuration property
  438. int ExportProperties :: GetPropertyInteger(const char* szName,
  439. int iErrorReturn /*= 0xffffffff*/) const
  440. {
  441. return GetGenericProperty<int>(mIntProperties,szName,iErrorReturn);
  442. }
  443. // ------------------------------------------------------------------------------------------------
  444. // Get a configuration property
  445. ai_real ExportProperties :: GetPropertyFloat(const char* szName,
  446. ai_real iErrorReturn /*= 10e10*/) const
  447. {
  448. return GetGenericProperty<ai_real>(mFloatProperties,szName,iErrorReturn);
  449. }
  450. // ------------------------------------------------------------------------------------------------
  451. // Get a configuration property
  452. const std::string ExportProperties :: GetPropertyString(const char* szName,
  453. const std::string& iErrorReturn /*= ""*/) const
  454. {
  455. return GetGenericProperty<std::string>(mStringProperties,szName,iErrorReturn);
  456. }
  457. // ------------------------------------------------------------------------------------------------
  458. // Has a configuration property
  459. const aiMatrix4x4 ExportProperties :: GetPropertyMatrix(const char* szName,
  460. const aiMatrix4x4& iErrorReturn /*= aiMatrix4x4()*/) const
  461. {
  462. return GetGenericProperty<aiMatrix4x4>(mMatrixProperties,szName,iErrorReturn);
  463. }
  464. // ------------------------------------------------------------------------------------------------
  465. // Has a configuration property
  466. bool ExportProperties :: HasPropertyInteger(const char* szName) const
  467. {
  468. return HasGenericProperty<int>(mIntProperties, szName);
  469. }
  470. // ------------------------------------------------------------------------------------------------
  471. // Has a configuration property
  472. bool ExportProperties :: HasPropertyBool(const char* szName) const
  473. {
  474. return HasGenericProperty<int>(mIntProperties, szName);
  475. }
  476. // ------------------------------------------------------------------------------------------------
  477. // Has a configuration property
  478. bool ExportProperties :: HasPropertyFloat(const char* szName) const
  479. {
  480. return HasGenericProperty<ai_real>(mFloatProperties, szName);
  481. }
  482. // ------------------------------------------------------------------------------------------------
  483. // Has a configuration property
  484. bool ExportProperties :: HasPropertyString(const char* szName) const
  485. {
  486. return HasGenericProperty<std::string>(mStringProperties, szName);
  487. }
  488. // ------------------------------------------------------------------------------------------------
  489. // Has a configuration property
  490. bool ExportProperties :: HasPropertyMatrix(const char* szName) const
  491. {
  492. return HasGenericProperty<aiMatrix4x4>(mMatrixProperties, szName);
  493. }
  494. #endif // !ASSIMP_BUILD_NO_EXPORT