int addRefArchive(std::string const& path) { ESS_PROFILE_SCOPE("addRefArchive"); if (path.empty()) return -1; std::string resolvedPath = resolvePath(path); // call get archive to ensure to create it! getArchiveFromID(path); std::map<std::string, AlembicArchiveInfo>::iterator it; it = gArchives.find(resolvedPath); if (it == gArchives.end()) return -1; it->second.refCount++; #ifdef _DEBUG EC_LOG_INFO("ref count (a): " << it->second.refCount); #endif return it->second.refCount; }
Alembic::Abc::IArchive * getArchiveFromID(XSI::CString path) { std::map<std::string,Alembic::Abc::IArchive *>::iterator it; it = gArchives.find(path.GetAsciiString()); if(it == gArchives.end()) { // check if the file exists FILE * file = fopen(path.GetAsciiString(),"rb"); if(file != NULL) { fclose(file); addArchive(new Alembic::Abc::IArchive( Alembic::AbcCoreHDF5::ReadArchive(), path.GetAsciiString())); return getArchiveFromID(path); } return NULL; } return it->second; }
AbcArchiveCache* getArchiveCache(std::string const& path, CommonProgressBar* pBar) { ESS_PROFILE_SCOPE("getArchiveCache"); getArchiveFromID(path); std::string resolvedPath = resolvePath(path); std::map<std::string, AlembicArchiveInfo>::iterator it; it = gArchives.find(resolvedPath); if (it == gArchives.end()) return NULL; // compute cache if required. if (it->second.archiveCache.size() == 0) { if (!createAbcArchiveCache(it->second.archive, &(it->second.archiveCache), pBar)) { it->second.archiveCache.clear(); return 0; } } return &(it->second.archiveCache); }
Alembic::Abc::IObject getObjectFromArchive(XSI::CString path, XSI::CString identifier) { Alembic::Abc::IArchive * archive = getArchiveFromID(path); if(archive == NULL) return Alembic::Abc::IObject(); // split the path std::string stdIdentifier(identifier.GetAsciiString()); std::vector<std::string> parts; boost::split(parts, stdIdentifier, boost::is_any_of("/")); // recurse to find it Alembic::Abc::IObject obj = archive->getTop(); for(size_t i=1;i<parts.size();i++) { Alembic::Abc::IObject child(obj,parts[i]); obj = child; } return obj; }