39 itkWarningMacro(<<
"Sorry, filename has not been set!");
42 if (!this->CanReadFile(m_FileName.c_str()))
44 itkWarningMacro(<<
"Sorry, can't read file " << m_FileName <<
"!");
50 TiXmlDocument doc(m_FileName.c_str());
51 bool loadOkay = doc.LoadFile();
54 TiXmlHandle docHandle(&doc);
55 unsigned int pointSetCounter(0);
56 for (TiXmlElement *currentPointSetElement =
57 docHandle.FirstChildElement(
"point_set_file").FirstChildElement(
"point_set").ToElement();
58 currentPointSetElement !=
nullptr;
59 currentPointSetElement = currentPointSetElement->NextSiblingElement())
62 if (currentPointSetElement->FirstChildElement(
"time_series") !=
nullptr)
64 for (TiXmlElement *currentTimeSeries = currentPointSetElement->FirstChildElement(
"time_series")->ToElement();
65 currentTimeSeries !=
nullptr;
66 currentTimeSeries = currentTimeSeries->NextSiblingElement())
68 unsigned int currentTimeStep(0);
69 TiXmlElement *currentTimeSeriesID = currentTimeSeries->FirstChildElement(
"time_series_id");
71 currentTimeStep = atoi(currentTimeSeriesID->GetText());
73 newPointSet = this->ReadPoint(newPointSet, currentTimeSeries, currentTimeStep);
78 newPointSet = this->ReadPoint(newPointSet, currentPointSetElement, 0);
80 this->SetNthOutput(pointSetCounter, newPointSet);
98 TiXmlElement *currentTimeSeries,
99 unsigned int currentTimeStep)
101 if (currentTimeSeries->FirstChildElement(
"point") !=
nullptr)
103 for (TiXmlElement *currentPoint = currentTimeSeries->FirstChildElement(
"point")->ToElement();
104 currentPoint !=
nullptr;
105 currentPoint = currentPoint->NextSiblingElement())
113 id = atoi(currentPoint->FirstChildElement(
"id")->GetText());
114 if (currentPoint->FirstChildElement(
"specification") !=
nullptr)
118 x = atof(currentPoint->FirstChildElement(
"x")->GetText());
119 y = atof(currentPoint->FirstChildElement(
"y")->GetText());
120 z = atof(currentPoint->FirstChildElement(
"z")->GetText());
124 newPointSet->SetPoint(
id, point, spec, currentTimeStep);
129 if (currentTimeStep != newPointSet->GetTimeSteps() + 1)
131 newPointSet->Expand(currentTimeStep + 1);
143 std::ifstream
in(name);
144 bool isGood = in.good();
150 const std::string filePrefix,
151 const std::string filePattern)
161 if (filePattern !=
"" && filePrefix !=
"")
164 bool extensionFound =
false;
165 std::string::size_type MPSPos = filename.rfind(
".mps");
166 if ((MPSPos != std::string::npos) && (MPSPos == filename.length() - 4))
168 extensionFound =
true;
171 MPSPos = filename.rfind(
".MPS");
172 if ((MPSPos != std::string::npos) && (MPSPos == filename.length() - 4))
174 extensionFound =
true;
188 unsigned int prevNum = this->GetNumberOfOutputs();
189 this->SetNumberOfIndexedOutputs(num);
190 for (
unsigned int i = prevNum; i < num; ++i)
192 this->SetNthOutput(i, this->MakeOutput(i).GetPointer());
void FillVector3D(Tout &out, mitk::ScalarType x, mitk::ScalarType y, mitk::ScalarType z)
virtual void GenerateData() override
virtual void GenerateOutputInformation() override
Convenience class to temporarily change the current locale.
static const std::string filename
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)
virtual ~PointSetReader()
PointSpecificationType
enumeration of the type a point can be