| 58 | } |
| 59 | |
| 60 | std::vector<itk::SmartPointer<mitk::BaseData>> mitk::ContourModelReader::DoRead() |
| 61 | { |
| 62 | std::vector<itk::SmartPointer<mitk::BaseData>> result; |
| 63 | std::string location = GetInputLocation(); |
| 64 | |
| 65 | // Switch the current locale to "C" |
| 66 | LocaleSwitch localeSwitch("C"); |
| 67 | |
| 68 | try |
| 69 | { |
| 70 | auto string = RemoveErroneousXMLDeclarations(location); |
| 71 | |
| 72 | tinyxml2::XMLDocument doc; |
| 73 | if (tinyxml2::XML_SUCCESS == doc.Parse(string.c_str())) |
| 74 | { |
| 75 | tinyxml2::XMLHandle docHandle(&doc); |
| 76 | |
| 77 | /*++++ handle n contourModels within data tags ++++*/ |
| 78 | for (auto *currentContourElement = docHandle.FirstChildElement("contourModel").ToElement(); |
| 79 | currentContourElement != nullptr; |
| 80 | currentContourElement = currentContourElement->NextSiblingElement()) |
| 81 | { |
| 82 | mitk::ContourModel::Pointer newContourModel = mitk::ContourModel::New(); |
| 83 | if (currentContourElement->FirstChildElement("data")->FirstChildElement("timestep") != nullptr) |
| 84 | { |
| 85 | /*++++ handle n timesteps within timestep tags ++++*/ |
| 86 | for (auto *currentTimeSeries = |
| 87 | currentContourElement->FirstChildElement("data")->FirstChildElement("timestep")->ToElement(); |
| 88 | currentTimeSeries != nullptr; |
| 89 | currentTimeSeries = currentTimeSeries->NextSiblingElement()) |
| 90 | { |
| 91 | unsigned int currentTimeStep(0); |
| 92 | |
| 93 | currentTimeStep = atoi(currentTimeSeries->Attribute("n")); |
| 94 | |
| 95 | this->ReadPoints(newContourModel, currentTimeSeries, currentTimeStep); |
| 96 | |
| 97 | int isClosed; |
| 98 | currentTimeSeries->QueryIntAttribute("isClosed", &isClosed); |
| 99 | if (isClosed) |
| 100 | { |
| 101 | newContourModel->Close(currentTimeStep); |
| 102 | } |
| 103 | } |
| 104 | /*++++ END handle n timesteps within timestep tags ++++*/ |
| 105 | } |
| 106 | else |
| 107 | { |
| 108 | // this should not happen |
| 109 | MITK_WARN << "wrong file format!"; |
| 110 | // newContourModel = this->ReadPoint(newContourModel, currentContourElement, 0); |
| 111 | } |
| 112 | newContourModel->UpdateOutputInformation(); |
| 113 | result.push_back(dynamic_cast<mitk::BaseData *>(newContourModel.GetPointer())); |
| 114 | } |
| 115 | /*++++ END handle n contourModels within data tags ++++*/ |
| 116 | } |
| 117 | else |
nothing calls this directly
no test coverage detected