29 std::string category =
"Contour File";
46 std::vector<itk::SmartPointer<mitk::BaseData>> result;
47 std::string location = GetInputLocation();
54 TiXmlDocument doc(location.c_str());
55 bool loadOkay = doc.LoadFile();
58 TiXmlHandle docHandle(&doc);
61 for (TiXmlElement *currentContourElement = docHandle.FirstChildElement(
"contourModel").ToElement();
62 currentContourElement != NULL;
63 currentContourElement = currentContourElement->NextSiblingElement())
66 if (currentContourElement->FirstChildElement(
"data")->FirstChildElement(
"timestep") != NULL)
74 for (TiXmlElement *currentTimeSeries =
75 currentContourElement->FirstChildElement(
"data")->FirstChildElement(
"timestep")->ToElement();
76 currentTimeSeries != NULL;
77 currentTimeSeries = currentTimeSeries->NextSiblingElement())
79 unsigned int currentTimeStep(0);
81 currentTimeStep = atoi(currentTimeSeries->Attribute(
"n"));
83 this->ReadPoints(newContourModel, currentTimeSeries, currentTimeStep);
86 currentTimeSeries->QueryIntAttribute(
"isClosed", &isClosed);
89 newContourModel->Close(currentTimeStep);
100 newContourModel->UpdateOutputInformation();
101 result.push_back(dynamic_cast<mitk::BaseData *>(newContourModel.GetPointer()));
124 TiXmlElement *currentTimeSeries,
125 unsigned int currentTimeStep)
128 if (currentTimeStep != newContourModel->GetTimeSteps())
130 newContourModel->Expand(currentTimeStep + 1);
134 if (currentTimeSeries->FirstChildElement(
"controlPoints")->FirstChildElement(
"point") != NULL)
136 for (TiXmlElement *currentPoint =
137 currentTimeSeries->FirstChildElement(
"controlPoints")->FirstChildElement(
"point")->ToElement();
138 currentPoint != NULL;
139 currentPoint = currentPoint->NextSiblingElement())
145 x = atof(currentPoint->FirstChildElement(
"x")->GetText());
146 y = atof(currentPoint->FirstChildElement(
"y")->GetText());
147 z = atof(currentPoint->FirstChildElement(
"z")->GetText());
150 currentPoint->QueryIntAttribute(
"isActive", &isActivePoint);
154 newContourModel->AddVertex(point, isActivePoint, currentTimeStep);
DataCollection - Class to facilitate loading/accessing structured data.
virtual std::vector< itk::SmartPointer< BaseData > > Read() override
Reads a path or stream and creates a list of BaseData objects.
void FillVector3D(Tout &out, mitk::ScalarType x, mitk::ScalarType y, mitk::ScalarType z)
void SetMimeType(const CustomMimeType &mimeType)
The CustomMimeType class represents a custom mime-type which may be registered as a service object...
us::ServiceRegistration< IFileReader > RegisterService(us::ModuleContext *context=us::GetModuleContext())
Convenience class to temporarily change the current locale.
virtual void ReadPoints(mitk::ContourModel::Pointer newContourModel, TiXmlElement *currentTimeSeries, unsigned int currentTimeStep)
void SetDescription(const std::string &description)
void AddExtension(const std::string &extension)
void SetCategory(const std::string &category)
Base class for creating mitk::BaseData objects from files or streams.
virtual ~ContourModelReader()