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

Method FromXML

Modules/Core/src/IO/mitkProportionalTimeGeometryToXML.cpp:57–164  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

55}
56
57mitk::ProportionalTimeGeometry::Pointer mitk::ProportionalTimeGeometryToXML::FromXML(const tinyxml2::XMLElement *timeGeometryElement)
58{
59 if (!timeGeometryElement)
60 {
61 MITK_ERROR << "Cannot deserialize ProportionalTimeGeometry from nullptr.";
62 return nullptr;
63 }
64
65 int numberOfTimeSteps = 0;
66
67 if (tinyxml2::XML_SUCCESS != timeGeometryElement->QueryIntAttribute("NumberOfTimeSteps", &numberOfTimeSteps))
68 {
69 MITK_WARN << "<ProportionalTimeGeometry> found without NumberOfTimeSteps attribute. Counting...";
70 }
71
72 // might be missing!
73 TimePointType firstTimePoint;
74 const char* firstTimePoint_s = nullptr;
75 TimePointType stepDuration;
76 const char* stepDuration_s = nullptr;
77 try
78 {
79 firstTimePoint_s = timeGeometryElement->Attribute("FirstTimePoint");
80 if (nullptr != firstTimePoint_s)
81 {
82 firstTimePoint = boost::lexical_cast<double>(firstTimePoint_s);
83 }
84 else
85 {
86 firstTimePoint = -std::numeric_limits<TimePointType>::max();
87 }
88
89 stepDuration_s = timeGeometryElement->Attribute("StepDuration");
90 if (nullptr != stepDuration_s)
91 {
92 stepDuration = boost::lexical_cast<double>(stepDuration_s);
93 }
94 else
95 {
96 stepDuration = std::numeric_limits<TimePointType>::infinity();
97 }
98 }
99 catch ( const boost::bad_lexical_cast &e )
100 {
101 MITK_ERROR << "Could not parse string as number: " << e.what();
102 return nullptr;
103 }
104
105 // list of all geometries with their time steps
106 std::multimap<TimeStepType, BaseGeometry::Pointer> allReadGeometries;
107
108 int indexForUnlabeledTimeStep(-1);
109 for (auto *currentElement = timeGeometryElement->FirstChildElement(); currentElement != nullptr;
110 currentElement = currentElement->NextSiblingElement())
111 {
112 // different geometries could have been inside a ProportionalTimeGeometry.
113 // By now, we only support Geometry3D
114 std::string tagName = currentElement->Value();

Callers

nothing calls this directly

Calls 10

whatMethod · 0.80
ValueMethod · 0.80
IsNotNullMethod · 0.80
countMethod · 0.80
GetPointerMethod · 0.80
UpdateBoundingBoxMethod · 0.80
NewFunction · 0.50
sizeMethod · 0.45
SetTimeStepGeometryMethod · 0.45

Tested by

no test coverage detected