35 itkWarningMacro(<<
"Sorry, filename has not been set!");
40 itkWarningMacro(<<
"Sorry, can't read file " <<
m_FileName <<
"!");
47 bool loadOkay = doc.LoadFile();
50 TiXmlHandle docHandle(&doc);
51 unsigned int pointSetCounter(0);
52 for (TiXmlElement *currentPointSetElement =
53 docHandle.FirstChildElement(
"point_set_file").FirstChildElement(
"point_set").ToElement();
54 currentPointSetElement !=
nullptr;
55 currentPointSetElement = currentPointSetElement->NextSiblingElement())
58 if (currentPointSetElement->FirstChildElement(
"time_series") !=
nullptr)
60 for (TiXmlElement *currentTimeSeries = currentPointSetElement->FirstChildElement(
"time_series")->ToElement();
61 currentTimeSeries !=
nullptr;
62 currentTimeSeries = currentTimeSeries->NextSiblingElement())
64 unsigned int currentTimeStep(0);
65 TiXmlElement *currentTimeSeriesID = currentTimeSeries->FirstChildElement(
"time_series_id");
67 currentTimeStep = atoi(currentTimeSeriesID->GetText());
69 newPointSet = this->
ReadPoint(newPointSet, currentTimeSeries, currentTimeStep);
74 newPointSet = this->
ReadPoint(newPointSet, currentPointSetElement, 0);
76 this->SetNthOutput(pointSetCounter, newPointSet);
94 TiXmlElement *currentTimeSeries,
95 unsigned int currentTimeStep)
97 if (currentTimeSeries->FirstChildElement(
"point") !=
nullptr)
99 for (TiXmlElement *currentPoint = currentTimeSeries->FirstChildElement(
"point")->ToElement();
100 currentPoint !=
nullptr;
101 currentPoint = currentPoint->NextSiblingElement())
109 id = atoi(currentPoint->FirstChildElement(
"id")->GetText());
110 if (currentPoint->FirstChildElement(
"specification") !=
nullptr)
114 x = atof(currentPoint->FirstChildElement(
"x")->GetText());
115 y = atof(currentPoint->FirstChildElement(
"y")->GetText());
116 z = atof(currentPoint->FirstChildElement(
"z")->GetText());
120 newPointSet->SetPoint(
id, point, spec, currentTimeStep);
125 if (currentTimeStep != newPointSet->GetTimeSteps() + 1)
127 newPointSet->Expand(currentTimeStep + 1);
139 std::ifstream
in(name);
140 bool isGood = in.good();
146 const std::string filePrefix,
147 const std::string filePattern)
157 if (filePattern !=
"" && filePrefix !=
"")
160 bool extensionFound =
false;
161 std::string::size_type MPSPos = filename.rfind(
".mps");
162 if ((MPSPos != std::string::npos) && (MPSPos == filename.length() - 4))
164 extensionFound =
true;
167 MPSPos = filename.rfind(
".MPS");
168 if ((MPSPos != std::string::npos) && (MPSPos == filename.length() - 4))
170 extensionFound =
true;
184 unsigned int prevNum = this->GetNumberOfOutputs();
185 this->SetNumberOfIndexedOutputs(num);
186 for (
unsigned int i = prevNum; i < num; ++i)
188 this->SetNthOutput(i, this->
MakeOutput(i).GetPointer());
itk::DataObject::Pointer MakeOutput(DataObjectPointerArraySizeType idx) override
~PointSetReader() override
void FillVector3D(Tout &out, mitk::ScalarType x, mitk::ScalarType y, mitk::ScalarType z)
void GenerateData() override
void GenerateOutputInformation() override
Convenience class to temporarily change the current locale.
virtual void ResizeOutputs(const unsigned int &num)
static bool in(Reader::Char c, Reader::Char c1, Reader::Char c2, Reader::Char c3, Reader::Char c4)
static bool CanReadFile(const std::string filename, const std::string filePrefix, const std::string filePattern)
virtual mitk::PointSet::Pointer ReadPoint(mitk::PointSet::Pointer newPointSet, TiXmlElement *currentTimeSeries, unsigned int currentTimeStep)
PointSpecificationType
enumeration of the type a point can be