| 92 | } |
| 93 | |
| 94 | tinyxml2::XMLElement *mitk::PointSetWriterService::ToXML(tinyxml2::XMLDocument& doc, const mitk::PointSet *pointSet) |
| 95 | { |
| 96 | // the following is rather bloated and could be expressed in more compact XML |
| 97 | // (e.g. using attributes instead of tags for x/y/z). The current format is |
| 98 | // kept to be compatible with the previous writer. |
| 99 | auto *pointSetElement = doc.NewElement(XML_POINT_SET.c_str()); |
| 100 | unsigned int timecount = pointSet->GetTimeSteps(); |
| 101 | |
| 102 | for (unsigned int i = 0; i < timecount; i++) |
| 103 | { |
| 104 | auto *timeSeriesElement = doc.NewElement(XML_TIME_SERIES.c_str()); |
| 105 | pointSetElement->InsertEndChild(timeSeriesElement); |
| 106 | |
| 107 | auto *timeSeriesIDElement = doc.NewElement(XML_TIME_SERIES_ID.c_str()); |
| 108 | timeSeriesElement->InsertEndChild(timeSeriesIDElement); |
| 109 | auto *timeSeriesIDText = doc.NewText(ConvertToString(i).c_str()); |
| 110 | timeSeriesIDElement->InsertEndChild(timeSeriesIDText); |
| 111 | |
| 112 | PointSet::PointsContainer *pointsContainer = pointSet->GetPointSet(i)->GetPoints(); |
| 113 | PointSet::PointsContainer::Iterator it; |
| 114 | |
| 115 | auto *geometry = dynamic_cast<Geometry3D *>(pointSet->GetGeometry(i)); |
| 116 | if (geometry == nullptr) |
| 117 | { |
| 118 | MITK_WARN << "Writing a PointSet with something other that a Geometry3D. This is not foreseen and not handled."; |
| 119 | // we'll continue anyway, this imitates previous behavior |
| 120 | } |
| 121 | else |
| 122 | { |
| 123 | auto *geometryElement = Geometry3DToXML::ToXML(doc, geometry); |
| 124 | timeSeriesElement->InsertEndChild(geometryElement); |
| 125 | } |
| 126 | |
| 127 | for (it = pointsContainer->Begin(); it != pointsContainer->End(); ++it) |
| 128 | { |
| 129 | auto *pointElement = doc.NewElement(XML_POINT.c_str()); |
| 130 | timeSeriesElement->InsertEndChild(pointElement); |
| 131 | |
| 132 | auto *pointIDElement = doc.NewElement(XML_ID.c_str()); |
| 133 | auto *pointIDText = doc.NewText(ConvertToString(it->Index()).c_str()); |
| 134 | pointIDElement->InsertEndChild(pointIDText); |
| 135 | pointElement->InsertEndChild(pointIDElement); |
| 136 | |
| 137 | mitk::PointSet::PointType point = it->Value(); |
| 138 | |
| 139 | auto *pointSpecElement = doc.NewElement(XML_SPEC.c_str()); |
| 140 | auto *pointSpecText = doc.NewText(ConvertToString(pointSet->GetSpecificationTypeInfo(it->Index(), i)).c_str()); |
| 141 | pointSpecElement->InsertEndChild(pointSpecText); |
| 142 | pointElement->InsertEndChild(pointSpecElement); |
| 143 | |
| 144 | auto *pointXElement = doc.NewElement(XML_X.c_str()); |
| 145 | auto *pointXText = doc.NewText(ConvertToString(point[0]).c_str()); |
| 146 | pointXElement->InsertEndChild(pointXText); |
| 147 | pointElement->InsertEndChild(pointXElement); |
| 148 | |
| 149 | auto *pointYElement = doc.NewElement(XML_Y.c_str()); |
| 150 | auto *pointYText = doc.NewText(ConvertToString(point[1]).c_str()); |
| 151 | pointYElement->InsertEndChild(pointYText); |
nothing calls this directly
no test coverage detected