MCPcopy Create free account
hub / github.com/assimp/assimp / ColladaParser

Method ColladaParser

code/AssetLib/Collada/ColladaParser.cpp:414–468  ·  view source on GitHub ↗

------------------------------------------------------------------------------------------------ Constructor to be privately used by Importer

Source from the content-addressed store, hash-verified

412// ------------------------------------------------------------------------------------------------
413// Constructor to be privately used by Importer
414ColladaParser::ColladaParser(IOSystem *pIOHandler, const std::string &pFile) :
415 mFileName(pFile),
416 mRootNode(nullptr),
417 mUnitSize(1.0f),
418 mUpDirection(UP_Y),
419 mFormat(FV_1_5_n) {
420 if (nullptr == pIOHandler) {
421 throw DeadlyImportError("IOSystem is nullptr.");
422 }
423
424 std::unique_ptr<IOStream> daeFile;
425 std::unique_ptr<ZipArchiveIOSystem> zip_archive;
426
427 // Determine type
428 const std::string extension = BaseImporter::GetExtension(pFile);
429 if (extension != "dae") {
430 zip_archive = std::make_unique<ZipArchiveIOSystem>(pIOHandler, pFile);
431 }
432
433 if (zip_archive && zip_archive->isOpen()) {
434 std::string dae_filename = ReadZaeManifest(*zip_archive);
435
436 if (dae_filename.empty()) {
437 throw DeadlyImportError("Invalid ZAE");
438 }
439
440 daeFile.reset(zip_archive->Open(dae_filename.c_str()));
441 if (daeFile == nullptr) {
442 throw DeadlyImportError("Invalid ZAE manifest: '", dae_filename, "' is missing");
443 }
444 } else {
445 // attempt to open the file directly
446 daeFile.reset(pIOHandler->Open(pFile));
447 if (daeFile == nullptr) {
448 throw DeadlyImportError("Failed to open file '", pFile, "'.");
449 }
450 }
451
452 // generate a XML reader for it
453 if (!mXmlParser.parse(daeFile.get())) {
454 throw DeadlyImportError("Unable to read file, malformed XML");
455 }
456 // start reading
457 const XmlNode node = mXmlParser.getRootNode();
458 XmlNode colladaNode = node.child("COLLADA");
459 if (colladaNode.empty()) {
460 return;
461 }
462
463 // Read content and embedded textures
464 ReadContents(colladaNode);
465 if (zip_archive && zip_archive->isOpen()) {
466 ReadEmbeddedTextures(*zip_archive);
467 }
468}
469
470// ------------------------------------------------------------------------------------------------
471// Destructor, private as well

Callers

nothing calls this directly

Calls 9

DeadlyImportErrorFunction · 0.85
getRootNodeMethod · 0.80
childMethod · 0.80
isOpenMethod · 0.45
emptyMethod · 0.45
resetMethod · 0.45
OpenMethod · 0.45
parseMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected