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

Method LoadScene

Modules/SceneSerialization/src/mitkSceneReaderV1.cpp:78–298  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

76}
77
78bool mitk::SceneReaderV1::LoadScene(tinyxml2::XMLDocument &document, const std::string &workingDirectory, DataStorage *storage)
79{
80 assert(storage);
81 bool error(false);
82
83 // TODO prepare to detect errors (such as cycles) from wrongly written or edited xml files
84
85 // Get number of elements to initialize progress bar
86 // 1. if there is a <data type="..." file="..."> element,
87 // - construct a name for the appropriate serializer
88 // - try to instantiate this serializer via itk object factory
89 // - if serializer could be created, use it to read the file into a BaseData object
90 // - if successful, call the new node's SetData(..)
91
92 // create a node for the tag "data" and test if node was created
93 typedef std::vector<mitk::DataNode::Pointer> DataNodeVector;
94 DataNodeVector DataNodes;
95 unsigned int listSize = 0;
96 for (auto *element = document.FirstChildElement("node"); element != nullptr;
97 element = element->NextSiblingElement("node"))
98 {
99 ++listSize;
100 }
101
102 ProgressBar::GetInstance()->AddStepsToDo(listSize * 2);
103
104 // Deserialize base data properties before reading the actual data to be
105 // able to provide them as read-only meta data to the data reader.
106 std::map<std::string, PropertyList::Pointer> baseDataPropertyLists;
107
108 for (auto *nodeElement = document.FirstChildElement("node"); nodeElement != nullptr;
109 nodeElement = nodeElement->NextSiblingElement("node"))
110 {
111 const auto *uid = nodeElement->Attribute("UID");
112
113 if (uid == nullptr)
114 continue;
115
116 auto *dataElement = nodeElement->FirstChildElement("data");
117
118 if (dataElement != nullptr)
119 {
120 auto properties = DeserializeProperties(dataElement->FirstChildElement("properties"), workingDirectory);
121
122 if (properties.IsNotNull())
123 baseDataPropertyLists[uid] = properties;
124 }
125 }
126
127 for (auto *element = document.FirstChildElement("node"); element != nullptr;
128 element = element->NextSiblingElement("node"))
129 {
130 mitk::PropertyList* properties = nullptr;
131 const auto *uid = element->Attribute("UID");
132
133 if (uid != nullptr)
134 {
135 auto iter = baseDataPropertyLists.find(uid);

Callers

nothing calls this directly

Calls 15

DeserializePropertiesFunction · 0.85
IsNotNullMethod · 0.80
GetPointerMethod · 0.80
backMethod · 0.80
NewFunction · 0.50
AddStepsToDoMethod · 0.45
findMethod · 0.45
endMethod · 0.45
IsNullMethod · 0.45
GetDataMethod · 0.45

Tested by

no test coverage detected