MCPcopy Create free account
hub / github.com/MITK/MITK / LoadScene

Method LoadScene

Modules/SceneSerialization/src/mitkSceneIO.cpp:90–191  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

88}
89
90mitk::DataStorage::Pointer mitk::SceneIO::LoadScene(const std::string &filename,
91 DataStorage *pStorage,
92 bool clearStorageFirst)
93{
94 mitk::LocaleSwitch localeSwitch("C");
95
96 // prepare data storage
97 DataStorage::Pointer storage = pStorage;
98 if (storage.IsNull())
99 {
100 storage = StandaloneDataStorage::New().GetPointer();
101 }
102
103 // test input filename
104 if (filename.empty())
105 {
106 MITK_ERROR << "No filename given. Not possible to load scene.";
107 return storage;
108 }
109
110 // Standalone JSON scene (not a ZIP archive): route directly to the
111 // JSON reader without unpacking.
112 if (mitk::EndsWithCaseInsensitive(filename, ".mitkscene.json"))
113 {
114 // Clearing is delegated to the reader so it can be deferred until
115 // after the scene descriptor has been validated (a malformed JSON
116 // file must not wipe the caller's session).
117 try
118 {
119 SceneJsonReader::Pointer jsonReader = SceneJsonReader::New();
120 if (!jsonReader->LoadScene(filename, storage, clearStorageFirst))
121 {
122 MITK_ERROR << "There were errors while loading scene file " << filename
123 << ". Your data may be corrupted";
124 }
125 }
126 catch (const std::exception &e)
127 {
128 MITK_ERROR << "Failed to load JSON scene file '" << filename << "': " << e.what();
129 }
130
131 return storage;
132 }
133
134 // test if filename can be read
135 std::ifstream file(filename.c_str(), std::ios::binary);
136 if (!file.good())
137 {
138 MITK_ERROR << "Cannot open '" << filename << "' for reading";
139 return storage;
140 }
141
142 // get new temporary directory
143 m_WorkingDirectory = CreateEmptyTempDirectory();
144 if (m_WorkingDirectory.empty())
145 {
146 MITK_ERROR << "Could not create temporary directory. Cannot open scene files.";
147 return storage;

Callers 15

LoadTaskMethod · 0.45
SaveMethod · 0.45
LoadMethod · 0.45
ReadMethod · 0.45
ReadMethod · 0.45
TestLoadRealImageMethod · 0.45
TestFileIndirectionMethod · 0.45
TestLayerOrderingMethod · 0.45
TestDataTypeMismatchMethod · 0.45

Calls 6

PathClass · 0.85
GetPointerMethod · 0.80
whatMethod · 0.80
NewFunction · 0.50
IsNullMethod · 0.45
emptyMethod · 0.45