Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #include "mitkSceneReader.h"
00019
00020 bool mitk::SceneReader::LoadScene( TiXmlDocument& document, const std::string& workingDirectory, DataStorage* storage )
00021 {
00022
00023 int fileVersion = 1;
00024 TiXmlElement* versionObject = document.FirstChildElement("Version");
00025 if (versionObject)
00026 {
00027 if ( versionObject->QueryIntAttribute( "FileVersion", &fileVersion ) != TIXML_SUCCESS )
00028 {
00029 MITK_ERROR << "Scene file " << workingDirectory + "/index.xml" << " does not contain version information! Trying version 1 format." << std::endl;
00030 }
00031 }
00032
00033 std::stringstream sceneReaderClassName;
00034 sceneReaderClassName << "SceneReaderV" << fileVersion;
00035
00036 std::list<itk::LightObject::Pointer> sceneReaders = itk::ObjectFactoryBase::CreateAllInstance(sceneReaderClassName.str().c_str());
00037 if (sceneReaders.size() < 1)
00038 {
00039 MITK_ERROR << "No scene reader found for scene file version " << fileVersion;
00040 }
00041 if (sceneReaders.size() > 1)
00042 {
00043 MITK_WARN << "Multiple scene readers found for scene file version " << fileVersion << ". Using arbitrary first one.";
00044 }
00045
00046 for ( std::list<itk::LightObject::Pointer>::iterator iter = sceneReaders.begin();
00047 iter != sceneReaders.end();
00048 ++iter )
00049 {
00050 if (SceneReader* reader = dynamic_cast<SceneReader*>( iter->GetPointer() ) )
00051 {
00052 if ( !reader->LoadScene( document, workingDirectory, storage ) )
00053 {
00054 MITK_ERROR << "There were errors while loding scene file " << workingDirectory + "/index.xml. Your data may be corrupted";
00055 return false;
00056 }
00057 else
00058 {
00059 return true;
00060 }
00061 }
00062 }
00063 return false;
00064 }