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

Method LoadSceneUnzipped

Modules/SceneSerialization/src/mitkSceneIO.cpp:193–269  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

191}
192
193mitk::DataStorage::Pointer mitk::SceneIO::LoadSceneUnzipped(const std::string &indexfilename,
194 DataStorage *pStorage,
195 bool clearStorageFirst)
196{
197 mitk::LocaleSwitch localeSwitch("C");
198
199 // prepare data storage
200 DataStorage::Pointer storage = pStorage;
201 if (storage.IsNull())
202 {
203 storage = StandaloneDataStorage::New().GetPointer();
204 }
205
206 // test input filename
207 if (indexfilename.empty())
208 {
209 MITK_ERROR << "No filename given. Not possible to load scene.";
210 return storage;
211 }
212
213 // transcode locale-dependent string
214 std::string tempfilename;
215 std::string workingDir;
216 itksys::SystemTools::SplitProgramPath(indexfilename, workingDir, tempfilename);
217
218 // Route JSON index files to the JSON reader. Clearing is delegated so it
219 // can be deferred until the descriptor is validated; a malformed scene
220 // file must not wipe the caller's session.
221 if (mitk::EndsWithCaseInsensitive(indexfilename, ".json"))
222 {
223 try
224 {
225 SceneJsonReader::Pointer jsonReader = SceneJsonReader::New();
226 if (!jsonReader->LoadScene(indexfilename, storage, clearStorageFirst))
227 {
228 MITK_ERROR << "There were errors while loading scene file " << indexfilename
229 << ". Your data may be corrupted";
230 }
231 }
232 catch (const std::exception &e)
233 {
234 MITK_ERROR << "Failed to load JSON scene index '" << indexfilename << "': " << e.what();
235 }
236 return storage;
237 }
238
239 // XML path: clear now (legacy SceneReader has no clearStorageFirst plumbing),
240 // then parse the scene descriptor.
241 if (clearStorageFirst)
242 {
243 try
244 {
245 storage->Remove(storage->GetAll());
246 }
247 catch (...)
248 {
249 MITK_ERROR << "DataStorage cannot be cleared properly.";
250 }

Callers 2

LoadTaskMethod · 0.80
loadDataFromDiskMethod · 0.80

Calls 8

GetPointerMethod · 0.80
whatMethod · 0.80
GetAllMethod · 0.80
NewFunction · 0.50
IsNullMethod · 0.45
emptyMethod · 0.45
LoadSceneMethod · 0.45
RemoveMethod · 0.45

Tested by

no test coverage detected