D3MFImporter.cpp 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634
  1. /*
  2. Open Asset Import Library (assimp)
  3. ----------------------------------------------------------------------
  4. Copyright (c) 2006-2021, assimp team
  5. All rights reserved.
  6. Redistribution and use of this software in source and binary forms,
  7. with or without modification, are permitted provided that the
  8. following conditions are met:
  9. * Redistributions of source code must retain the above
  10. copyright notice, this list of conditions and the
  11. following disclaimer.
  12. * Redistributions in binary form must reproduce the above
  13. copyright notice, this list of conditions and the
  14. following disclaimer in the documentation and/or other
  15. materials provided with the distribution.
  16. * Neither the name of the assimp team, nor the names of its
  17. contributors may be used to endorse or promote products
  18. derived from this software without specific prior
  19. written permission of the assimp team.
  20. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  21. "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  22. LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  23. A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  24. OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  25. SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  26. LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  27. DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  28. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  29. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  30. OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  31. ----------------------------------------------------------------------
  32. */
  33. #ifndef ASSIMP_BUILD_NO_3MF_IMPORTER
  34. #include "D3MFImporter.h"
  35. #include "3MFXmlTags.h"
  36. #include "D3MFOpcPackage.h"
  37. #include <assimp/StringComparison.h>
  38. #include <assimp/StringUtils.h>
  39. #include <assimp/XmlParser.h>
  40. #include <assimp/ZipArchiveIOSystem.h>
  41. #include <assimp/importerdesc.h>
  42. #include <assimp/scene.h>
  43. #include <assimp/DefaultLogger.hpp>
  44. #include <assimp/IOSystem.hpp>
  45. #include <assimp/fast_atof.h>
  46. #include <cassert>
  47. #include <map>
  48. #include <memory>
  49. #include <string>
  50. #include <vector>
  51. #include <iomanip>
  52. #include <string.h>
  53. namespace Assimp {
  54. namespace D3MF {
  55. enum class ResourceType {
  56. RT_Object,
  57. RT_BaseMaterials,
  58. RT_Unknown
  59. }; // To be extended with other resource types (eg. material extension resources like Texture2d, Texture2dGroup...)
  60. class Resource {
  61. public:
  62. int mId;
  63. Resource(int id) :
  64. mId(id) {
  65. // empty
  66. }
  67. virtual ~Resource() {
  68. // empty
  69. }
  70. virtual ResourceType getType() const {
  71. return ResourceType::RT_Unknown;
  72. }
  73. };
  74. class BaseMaterials : public Resource {
  75. public:
  76. std::vector<aiMaterial *> mMaterials;
  77. std::vector<unsigned int> mMaterialIndex;
  78. BaseMaterials(int id) :
  79. Resource(id),
  80. mMaterials(),
  81. mMaterialIndex() {
  82. // empty
  83. }
  84. ~BaseMaterials() = default;
  85. ResourceType getType() const override {
  86. return ResourceType::RT_BaseMaterials;
  87. }
  88. };
  89. struct Component {
  90. int mObjectId;
  91. aiMatrix4x4 mTransformation;
  92. };
  93. class Object : public Resource {
  94. public:
  95. std::vector<aiMesh *> mMeshes;
  96. std::vector<unsigned int> mMeshIndex;
  97. std::vector<Component> mComponents;
  98. std::string mName;
  99. Object(int id) :
  100. Resource(id),
  101. mName(std::string("Object_") + ai_to_string(id)) {
  102. // empty
  103. }
  104. ~Object() = default;
  105. ResourceType getType() const override {
  106. return ResourceType::RT_Object;
  107. }
  108. };
  109. class XmlSerializer {
  110. public:
  111. XmlSerializer(XmlParser *xmlParser) :
  112. mResourcesDictionnary(),
  113. mMaterialCount(0),
  114. mMeshCount(0),
  115. mXmlParser(xmlParser) {
  116. // empty
  117. }
  118. ~XmlSerializer() {
  119. for (auto it = mResourcesDictionnary.begin(); it != mResourcesDictionnary.end(); ++it ) {
  120. delete it->second;
  121. }
  122. }
  123. void ImportXml(aiScene *scene) {
  124. if (nullptr == scene) {
  125. return;
  126. }
  127. scene->mRootNode = new aiNode(XmlTag::RootTag);
  128. XmlNode node = mXmlParser->getRootNode().child(XmlTag::model);
  129. if (node.empty()) {
  130. return;
  131. }
  132. XmlNode resNode = node.child(XmlTag::resources);
  133. for (auto &currentNode : resNode.children()) {
  134. const std::string currentNodeName = currentNode.name();
  135. if (currentNodeName == XmlTag::object) {
  136. ReadObject(currentNode);
  137. } else if (currentNodeName == XmlTag::basematerials) {
  138. ReadBaseMaterials(currentNode);
  139. } else if (currentNodeName == XmlTag::meta) {
  140. ReadMetadata(currentNode);
  141. }
  142. }
  143. XmlNode buildNode = node.child(XmlTag::build);
  144. for (auto &currentNode : buildNode.children()) {
  145. const std::string currentNodeName = currentNode.name();
  146. if (currentNodeName == XmlTag::item) {
  147. int objectId = -1;
  148. std::string transformationMatrixStr;
  149. aiMatrix4x4 transformationMatrix;
  150. getNodeAttribute(currentNode, D3MF::XmlTag::objectid, objectId);
  151. bool hasTransform = getNodeAttribute(currentNode, D3MF::XmlTag::transform, transformationMatrixStr);
  152. auto it = mResourcesDictionnary.find(objectId);
  153. if (it != mResourcesDictionnary.end() && it->second->getType() == ResourceType::RT_Object) {
  154. Object *obj = static_cast<Object *>(it->second);
  155. if (hasTransform) {
  156. transformationMatrix = parseTransformMatrix(transformationMatrixStr);
  157. }
  158. addObjectToNode(scene->mRootNode, obj, transformationMatrix);
  159. }
  160. }
  161. }
  162. // import the metadata
  163. if (!mMetaData.empty()) {
  164. const size_t numMeta = mMetaData.size();
  165. scene->mMetaData = aiMetadata::Alloc(static_cast<unsigned int>(numMeta));
  166. for (size_t i = 0; i < numMeta; ++i) {
  167. aiString val(mMetaData[i].value);
  168. scene->mMetaData->Set(static_cast<unsigned int>(i), mMetaData[i].name, val);
  169. }
  170. }
  171. // import the meshes
  172. scene->mNumMeshes = static_cast<unsigned int>(mMeshCount);
  173. if (scene->mNumMeshes != 0) {
  174. scene->mMeshes = new aiMesh *[scene->mNumMeshes]();
  175. for (auto it = mResourcesDictionnary.begin(); it != mResourcesDictionnary.end(); ++it) {
  176. if (it->second->getType() == ResourceType::RT_Object) {
  177. Object *obj = static_cast<Object *>(it->second);
  178. ai_assert(nullptr != obj);
  179. for (unsigned int i = 0; i < obj->mMeshes.size(); ++i) {
  180. scene->mMeshes[obj->mMeshIndex[i]] = obj->mMeshes[i];
  181. }
  182. }
  183. }
  184. }
  185. // import the materials
  186. scene->mNumMaterials = mMaterialCount;
  187. if (scene->mNumMaterials != 0) {
  188. scene->mMaterials = new aiMaterial *[scene->mNumMaterials];
  189. for (auto it = mResourcesDictionnary.begin(); it != mResourcesDictionnary.end(); ++it) {
  190. if (it->second->getType() == ResourceType::RT_BaseMaterials) {
  191. BaseMaterials *baseMaterials = static_cast<BaseMaterials *>(it->second);
  192. for (unsigned int i = 0; i < baseMaterials->mMaterials.size(); ++i) {
  193. scene->mMaterials[baseMaterials->mMaterialIndex[i]] = baseMaterials->mMaterials[i];
  194. }
  195. }
  196. }
  197. }
  198. }
  199. private:
  200. void addObjectToNode(aiNode *parent, Object *obj, aiMatrix4x4 nodeTransform) {
  201. ai_assert(nullptr != obj);
  202. aiNode *sceneNode = new aiNode(obj->mName);
  203. sceneNode->mNumMeshes = static_cast<unsigned int>(obj->mMeshes.size());
  204. sceneNode->mMeshes = new unsigned int[sceneNode->mNumMeshes];
  205. std::copy(obj->mMeshIndex.begin(), obj->mMeshIndex.end(), sceneNode->mMeshes);
  206. sceneNode->mTransformation = nodeTransform;
  207. if (nullptr != parent) {
  208. parent->addChildren(1, &sceneNode);
  209. }
  210. for (size_t i = 0; i < obj->mComponents.size(); ++i) {
  211. Component c = obj->mComponents[i];
  212. auto it = mResourcesDictionnary.find(c.mObjectId);
  213. if (it != mResourcesDictionnary.end() && it->second->getType() == ResourceType::RT_Object) {
  214. addObjectToNode(sceneNode, static_cast<Object *>(it->second), c.mTransformation);
  215. }
  216. }
  217. }
  218. bool getNodeAttribute(const XmlNode &node, const std::string &attribute, std::string &value) {
  219. pugi::xml_attribute objectAttribute = node.attribute(attribute.c_str());
  220. if (!objectAttribute.empty()) {
  221. value = objectAttribute.as_string();
  222. return true;
  223. }
  224. return false;
  225. }
  226. bool getNodeAttribute(const XmlNode &node, const std::string &attribute, int &value) {
  227. std::string strValue;
  228. bool ret = getNodeAttribute(node, attribute, strValue);
  229. if (ret) {
  230. value = std::atoi(strValue.c_str());
  231. return true;
  232. }
  233. return false;
  234. }
  235. aiMatrix4x4 parseTransformMatrix(std::string matrixStr) {
  236. // split the string
  237. std::vector<float> numbers;
  238. std::string currentNumber;
  239. for (size_t i = 0; i < matrixStr.size(); ++i) {
  240. const char c = matrixStr[i];
  241. if (c == ' ') {
  242. if (currentNumber.size() > 0) {
  243. float f = std::stof(currentNumber);
  244. numbers.push_back(f);
  245. currentNumber.clear();
  246. }
  247. } else {
  248. currentNumber.push_back(c);
  249. }
  250. }
  251. if (currentNumber.size() > 0) {
  252. const float f = std::stof(currentNumber);
  253. numbers.push_back(f);
  254. }
  255. aiMatrix4x4 transformMatrix;
  256. transformMatrix.a1 = numbers[0];
  257. transformMatrix.b1 = numbers[1];
  258. transformMatrix.c1 = numbers[2];
  259. transformMatrix.d1 = 0;
  260. transformMatrix.a2 = numbers[3];
  261. transformMatrix.b2 = numbers[4];
  262. transformMatrix.c2 = numbers[5];
  263. transformMatrix.d2 = 0;
  264. transformMatrix.a3 = numbers[6];
  265. transformMatrix.b3 = numbers[7];
  266. transformMatrix.c3 = numbers[8];
  267. transformMatrix.d3 = 0;
  268. transformMatrix.a4 = numbers[9];
  269. transformMatrix.b4 = numbers[10];
  270. transformMatrix.c4 = numbers[11];
  271. transformMatrix.d4 = 1;
  272. return transformMatrix;
  273. }
  274. void ReadObject(XmlNode &node) {
  275. int id = -1, pid = -1, pindex = -1;
  276. bool hasId = getNodeAttribute(node, XmlTag::id, id);
  277. bool hasPid = getNodeAttribute(node, XmlTag::pid, pid);
  278. bool hasPindex = getNodeAttribute(node, XmlTag::pindex, pindex);
  279. if (!hasId) {
  280. return;
  281. }
  282. Object *obj = new Object(id);
  283. for (XmlNode &currentNode : node.children()) {
  284. const std::string &currentName = currentNode.name();
  285. if (currentName == D3MF::XmlTag::mesh) {
  286. auto mesh = ReadMesh(currentNode);
  287. mesh->mName.Set(ai_to_string(id));
  288. if (hasPid) {
  289. auto it = mResourcesDictionnary.find(pid);
  290. if (hasPindex && it != mResourcesDictionnary.end() && it->second->getType() == ResourceType::RT_BaseMaterials) {
  291. BaseMaterials *materials = static_cast<BaseMaterials *>(it->second);
  292. mesh->mMaterialIndex = materials->mMaterialIndex[pindex];
  293. }
  294. }
  295. obj->mMeshes.push_back(mesh);
  296. obj->mMeshIndex.push_back(mMeshCount);
  297. mMeshCount++;
  298. } else if (currentName == D3MF::XmlTag::components) {
  299. for (XmlNode &currentSubNode : currentNode.children()) {
  300. const std::string subNodeName = currentSubNode.name();
  301. if (subNodeName == D3MF::XmlTag::component) {
  302. int objectId = -1;
  303. std::string componentTransformStr;
  304. aiMatrix4x4 componentTransform;
  305. if (getNodeAttribute(currentSubNode, D3MF::XmlTag::transform, componentTransformStr)) {
  306. componentTransform = parseTransformMatrix(componentTransformStr);
  307. }
  308. if (getNodeAttribute(currentSubNode, D3MF::XmlTag::objectid, objectId)) {
  309. obj->mComponents.push_back({ objectId, componentTransform });
  310. }
  311. }
  312. }
  313. }
  314. }
  315. mResourcesDictionnary.insert(std::make_pair(id, obj));
  316. }
  317. aiMesh *ReadMesh(XmlNode &node) {
  318. aiMesh *mesh = new aiMesh();
  319. for (XmlNode &currentNode : node.children()) {
  320. const std::string currentName = currentNode.name();
  321. if (currentName == XmlTag::vertices) {
  322. ImportVertices(currentNode, mesh);
  323. } else if (currentName == XmlTag::triangles) {
  324. ImportTriangles(currentNode, mesh);
  325. }
  326. }
  327. return mesh;
  328. }
  329. void ReadMetadata(XmlNode &node) {
  330. pugi::xml_attribute attribute = node.attribute(D3MF::XmlTag::meta_name);
  331. const std::string name = attribute.as_string();
  332. const std::string value = node.value();
  333. if (name.empty()) {
  334. return;
  335. }
  336. MetaEntry entry;
  337. entry.name = name;
  338. entry.value = value;
  339. mMetaData.push_back(entry);
  340. }
  341. void ImportVertices(XmlNode &node, aiMesh *mesh) {
  342. std::vector<aiVector3D> vertices;
  343. for (XmlNode &currentNode : node.children()) {
  344. const std::string currentName = currentNode.name();
  345. if (currentName == XmlTag::vertex) {
  346. vertices.push_back(ReadVertex(currentNode));
  347. }
  348. }
  349. mesh->mNumVertices = static_cast<unsigned int>(vertices.size());
  350. mesh->mVertices = new aiVector3D[mesh->mNumVertices];
  351. std::copy(vertices.begin(), vertices.end(), mesh->mVertices);
  352. }
  353. aiVector3D ReadVertex(XmlNode &node) {
  354. aiVector3D vertex;
  355. vertex.x = ai_strtof(node.attribute(XmlTag::x).as_string(), nullptr);
  356. vertex.y = ai_strtof(node.attribute(XmlTag::y).as_string(), nullptr);
  357. vertex.z = ai_strtof(node.attribute(XmlTag::z).as_string(), nullptr);
  358. return vertex;
  359. }
  360. void ImportTriangles(XmlNode &node, aiMesh *mesh) {
  361. std::vector<aiFace> faces;
  362. for (XmlNode &currentNode : node.children()) {
  363. const std::string currentName = currentNode.name();
  364. if (currentName == XmlTag::triangle) {
  365. aiFace face = ReadTriangle(currentNode);
  366. faces.push_back(face);
  367. int pid = 0, p1 = 0;
  368. bool hasPid = getNodeAttribute(currentNode, D3MF::XmlTag::pid, pid);
  369. bool hasP1 = getNodeAttribute(currentNode, D3MF::XmlTag::p1, p1);
  370. if (hasPid && hasP1) {
  371. auto it = mResourcesDictionnary.find(pid);
  372. if (it != mResourcesDictionnary.end()) {
  373. if (it->second->getType() == ResourceType::RT_BaseMaterials) {
  374. BaseMaterials *baseMaterials = static_cast<BaseMaterials *>(it->second);
  375. mesh->mMaterialIndex = baseMaterials->mMaterialIndex[p1];
  376. }
  377. // TODO: manage the separation into several meshes if the triangles of the mesh do not all refer to the same material
  378. }
  379. }
  380. }
  381. }
  382. mesh->mNumFaces = static_cast<unsigned int>(faces.size());
  383. mesh->mFaces = new aiFace[mesh->mNumFaces];
  384. mesh->mPrimitiveTypes = aiPrimitiveType_TRIANGLE;
  385. std::copy(faces.begin(), faces.end(), mesh->mFaces);
  386. }
  387. aiFace ReadTriangle(XmlNode &node) {
  388. aiFace face;
  389. face.mNumIndices = 3;
  390. face.mIndices = new unsigned int[face.mNumIndices];
  391. face.mIndices[0] = static_cast<unsigned int>(std::atoi(node.attribute(XmlTag::v1).as_string()));
  392. face.mIndices[1] = static_cast<unsigned int>(std::atoi(node.attribute(XmlTag::v2).as_string()));
  393. face.mIndices[2] = static_cast<unsigned int>(std::atoi(node.attribute(XmlTag::v3).as_string()));
  394. return face;
  395. }
  396. void ReadBaseMaterials(XmlNode &node) {
  397. int id = -1;
  398. if (getNodeAttribute(node, D3MF::XmlTag::basematerials_id, id)) {
  399. BaseMaterials *baseMaterials = new BaseMaterials(id);
  400. for (XmlNode &currentNode : node.children()) {
  401. const std::string currentName = currentNode.name();
  402. if (currentName == XmlTag::basematerials_base) {
  403. baseMaterials->mMaterialIndex.push_back(mMaterialCount);
  404. baseMaterials->mMaterials.push_back(readMaterialDef(currentNode, id));
  405. ++mMaterialCount;
  406. }
  407. }
  408. mResourcesDictionnary.insert(std::make_pair(id, baseMaterials));
  409. }
  410. }
  411. bool parseColor(const char *color, aiColor4D &diffuse) {
  412. if (nullptr == color) {
  413. return false;
  414. }
  415. //format of the color string: #RRGGBBAA or #RRGGBB (3MF Core chapter 5.1.1)
  416. const size_t len = strlen(color);
  417. if (9 != len && 7 != len) {
  418. return false;
  419. }
  420. const char *buf(color);
  421. if ('#' != buf[0]) {
  422. return false;
  423. }
  424. char r[3] = { buf[1], buf[2], '\0' };
  425. diffuse.r = static_cast<ai_real>(strtol(r, nullptr, 16)) / ai_real(255.0);
  426. char g[3] = { buf[3], buf[4], '\0' };
  427. diffuse.g = static_cast<ai_real>(strtol(g, nullptr, 16)) / ai_real(255.0);
  428. char b[3] = { buf[5], buf[6], '\0' };
  429. diffuse.b = static_cast<ai_real>(strtol(b, nullptr, 16)) / ai_real(255.0);
  430. if (7 == len)
  431. return true;
  432. char a[3] = { buf[7], buf[8], '\0' };
  433. diffuse.a = static_cast<ai_real>(strtol(a, nullptr, 16)) / ai_real(255.0);
  434. return true;
  435. }
  436. void assignDiffuseColor(XmlNode &node, aiMaterial *mat) {
  437. const char *color = node.attribute(XmlTag::basematerials_displaycolor).as_string();
  438. aiColor4D diffuse;
  439. if (parseColor(color, diffuse)) {
  440. mat->AddProperty<aiColor4D>(&diffuse, 1, AI_MATKEY_COLOR_DIFFUSE);
  441. }
  442. }
  443. aiMaterial *readMaterialDef(XmlNode &node, unsigned int basematerialsId) {
  444. aiMaterial *material = new aiMaterial();
  445. material->mNumProperties = 0;
  446. std::string name;
  447. bool hasName = getNodeAttribute(node, D3MF::XmlTag::basematerials_name, name);
  448. std::string stdMaterialName;
  449. const std::string strId(ai_to_string(basematerialsId));
  450. stdMaterialName += "id";
  451. stdMaterialName += strId;
  452. stdMaterialName += "_";
  453. if (hasName) {
  454. stdMaterialName += std::string(name);
  455. } else {
  456. stdMaterialName += "basemat_";
  457. stdMaterialName += ai_to_string(mMaterialCount - basematerialsId);
  458. }
  459. aiString assimpMaterialName(stdMaterialName);
  460. material->AddProperty(&assimpMaterialName, AI_MATKEY_NAME);
  461. assignDiffuseColor(node, material);
  462. return material;
  463. }
  464. private:
  465. struct MetaEntry {
  466. std::string name;
  467. std::string value;
  468. };
  469. std::vector<MetaEntry> mMetaData;
  470. std::map<unsigned int, Resource *> mResourcesDictionnary;
  471. unsigned int mMaterialCount, mMeshCount;
  472. XmlParser *mXmlParser;
  473. };
  474. } //namespace D3MF
  475. using namespace D3MF;
  476. static const aiImporterDesc desc = {
  477. "3mf Importer",
  478. "",
  479. "",
  480. "http://3mf.io/",
  481. aiImporterFlags_SupportBinaryFlavour | aiImporterFlags_SupportCompressedFlavour,
  482. 0,
  483. 0,
  484. 0,
  485. 0,
  486. "3mf"
  487. };
  488. D3MFImporter::D3MFImporter() :
  489. BaseImporter() {
  490. // empty
  491. }
  492. D3MFImporter::~D3MFImporter() {
  493. // empty
  494. }
  495. bool D3MFImporter::CanRead(const std::string &filename, IOSystem *pIOHandler, bool checkSig) const {
  496. const std::string extension(GetExtension(filename));
  497. if (extension == desc.mFileExtensions) {
  498. return true;
  499. } else if (!extension.length() || checkSig) {
  500. if (nullptr == pIOHandler) {
  501. return false;
  502. }
  503. if (!ZipArchiveIOSystem::isZipArchive(pIOHandler, filename)) {
  504. return false;
  505. }
  506. D3MFOpcPackage opcPackage(pIOHandler, filename);
  507. return opcPackage.validate();
  508. }
  509. return false;
  510. }
  511. void D3MFImporter::SetupProperties(const Importer * /*pImp*/) {
  512. // empty
  513. }
  514. const aiImporterDesc *D3MFImporter::GetInfo() const {
  515. return &desc;
  516. }
  517. void D3MFImporter::InternReadFile(const std::string &filename, aiScene *pScene, IOSystem *pIOHandler) {
  518. D3MFOpcPackage opcPackage(pIOHandler, filename);
  519. XmlParser xmlParser;
  520. if (xmlParser.parse(opcPackage.RootStream())) {
  521. XmlSerializer xmlSerializer(&xmlParser);
  522. xmlSerializer.ImportXml(pScene);
  523. }
  524. }
  525. } // Namespace Assimp
  526. #endif // ASSIMP_BUILD_NO_3MF_IMPORTER