NodeTransitPtr SceneFileHandlerBase::read( std::istream &is, const Char8 *fileNameOrExtension, GraphOpSeq *graphOpSeq , Resolver resolver ) { SceneFileType *type = getFileType(fileNameOrExtension); NodeUnrecPtr scene = NULL; if(!fileNameOrExtension) { SWARNING << "cannot read NULL extension" << std::endl; return NodeTransitPtr(scene); } if(type != NULL) { SINFO << "try to read stream as " << type->getName() << std::endl; // check for fileio read callback if(_readFP != NULL) { initReadProgress(is); scene = _readFP(type, is, fileNameOrExtension); terminateReadProgress(); } else { if(isGZip(is)) { SINFO << "Detected gzip compressed stream." << std::endl; #ifdef OSG_WITH_ZLIB initReadProgress(is); zip_istream unzipper(is); scene = type->read(unzipper, fileNameOrExtension, resolver ? resolver : _oGlobalResolver); if(scene != NULL) { if(unzipper.check_crc() == true) { SINFO << "Compressed stream has correct checksum." << std::endl; } else { SWARNING << "Compressed stream has wrong checksum." << std::endl; } } terminateReadProgress(); #else SFATAL << "Compressed streams are not supported! Configure " << "with --enable-png --with-png=DIR options." << std::endl; #endif } else { initReadProgress(is); scene = type->read(is, fileNameOrExtension, resolver ? resolver : _oGlobalResolver); terminateReadProgress(); } } if(scene != NULL) { if(graphOpSeq != NULL) graphOpSeq->traverse(scene); SINFO << "read ok:" << std::endl; } else { SWARNING << "could not read " << std::endl; } } else { SWARNING << "could not read unknown file format" << std::endl; } commitChanges(); return NodeTransitPtr(scene); }
NodePtr SceneFileHandler::read(std::istream &is, const Char8* fileNameOrExtension, GraphOpSeq *graphOpSeq) { SceneFileType *type = getFileType(fileNameOrExtension); NodePtr scene = NullFC; if(!fileNameOrExtension) { SWARNING << "cannot read NULL extension" << std::endl; return NullFC; } if (type) { SINFO << "try to read stream as " << type->getName() << std::endl; // check for fileio read callback if(_readFP != NULL) { initReadProgress(is); scene = _readFP(type, is, fileNameOrExtension); terminateReadProgress(); } else { if(isGZip(is)) { SINFO << "Detected gzip compressed stream." << std::endl; #ifdef OSG_ZSTREAM_SUPPORTED initReadProgress(is); zip_istream unzipper(is); scene = type->read(unzipper, fileNameOrExtension); if(scene != NullFC) { if(unzipper.check_crc()) SINFO << "Compressed stream has correct checksum." << std::endl; else SFATAL << "Compressed stream has wrong checksum." << std::endl; } terminateReadProgress(); #else SFATAL << "Compressed streams are not supported! Configure with --enable-png --with-png=DIR options." << std::endl; #endif } else { initReadProgress(is); scene = type->read(is, fileNameOrExtension); terminateReadProgress(); } } if(scene != NullFC) { if(graphOpSeq != NULL) graphOpSeq->run(scene); SINFO << "read ok:" << std::endl; } else { SWARNING << "could not read " << std::endl; } } else { SWARNING << "could not read unknown file format" << std::endl; } return scene; }