Page MenuHomePhabricator

4DPointSetReaderPatch.patch

Authored By
kast
Mar 3 2010, 5:33 PM
Size
3 KB
Referenced Files
None
Subscribers
None

4DPointSetReaderPatch.patch

Index: mitkPointSetReader.cpp
===================================================================
--- mitkPointSetReader.cpp (revision 21521)
+++ mitkPointSetReader.cpp (working copy)
@@ -17,10 +17,11 @@
#include "mitkPointSetReader.h"
-#include "vtkPointSetXMLParser.h"
-#include "vtkSmartPointer.h"
+//#include "vtkPointSetXMLParser.h"
+//#include "vtkSmartPointer.h"
#include <iostream>
#include <fstream>
+#include <tinyxml.h>
mitk::PointSetReader::PointSetReader()
{
@@ -46,27 +47,69 @@
return ;
}
- vtkSmartPointer< vtkPointSetXMLParser > parser = vtkPointSetXMLParser::New();
- parser->SetFileName( m_FileName.c_str() );
+ TiXmlDocument doc(m_FileName.c_str());
+ bool loadOkay = doc.LoadFile();
+ if (loadOkay)
+ {
+ mitk::PointSet::Pointer newPointSet = mitk::PointSet::New();
+
+ TiXmlHandle docHandle( &doc );
- if ( parser->Parse() == 0 ) //Parse returns zero as error indicator
- {
- itkWarningMacro( << "Sorry, an error occurred during parsing!" );
- return ;
- }
- mitk::vtkPointSetXMLParser::PointSetList pointSetList = parser->GetParsedPointSets();
- this->ResizeOutputs( pointSetList.size() );
+ unsigned int pointSetCounter(0);
+ for( TiXmlElement* currentPointSetElement = docHandle.FirstChildElement("point_set_file").FirstChildElement( "point_set" ).ToElement();
+ currentPointSetElement != NULL; currentPointSetElement = currentPointSetElement->NextSibling()->ToElement())
+ {
+ mitk::PointSet::Pointer newPointSet = mitk::PointSet::New();
- unsigned int i = 0;
- for ( mitk::vtkPointSetXMLParser::PointSetList::iterator it = pointSetList.begin(); it != pointSetList.end(); ++it, ++i )
- {
- this->SetNthOutput( i, *it );
- }
+ for( TiXmlElement* currentTimeSeries = currentPointSetElement->FirstChildElement("time_series");
+ currentTimeSeries != NULL; currentTimeSeries = currentPointSetElement->NextSibling()->ToElement())
+ {
+ unsigned int currentTimeStep(0);
+ TiXmlElement* currentTimeSeriesID = currentTimeSeries->FirstChildElement("time_series_id");
+ currentTimeStep = atoi(currentTimeSeriesID->GetText());
+
+ for( TiXmlElement* currentPoint = currentTimeSeries->FirstChildElement("point");
+ currentPoint != NULL; currentPoint = currentTimeSeries->NextSibling()->ToElement())
+ {
+ unsigned int id(0);
+ int x(0);
+ int y(0);
+ int z(0);
+ id = atoi(currentPoint->FirstChildElement("id")->GetText());
+ x = atoi(currentPoint->FirstChildElement("x")->GetText());
+ y = atoi(currentPoint->FirstChildElement("y")->GetText());
+ z = atoi(currentPoint->FirstChildElement("z")->GetText());
+
+ mitk::Point3D point;
+ mitk::FillVector3D(point, x, y, z);
+
+ newPointSet->SetPoint(id, point, currentTimeStep);
+ MITK_INFO << "PointSet " << id << " " << x << " " << y << " " << currentTimeStep;
+ }
+ }
+
+ this->SetNthOutput( pointSetCounter, newPointSet );
+ pointSetCounter++;
+ }
+
+ }
+ else
+ {
+ MITK_WARN << "Cannot load XML file!";
+ }
+
+ //this->ResizeOutputs( pointSetList.size() );
+
+ //unsigned int i = 0;
+ //for ( mitk::vtkPointSetXMLParser::PointSetList::iterator it = pointSetList.begin(); it != pointSetList.end(); ++it, ++i )
+ //{
+ // this->SetNthOutput( i, *it );
+ //}
+
m_Success = true;
}
-
void mitk::PointSetReader::GenerateOutputInformation()
{
}

File Metadata

Mime Type
text/plain
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
135
Default Alt Text
4DPointSetReaderPatch.patch (3 KB)

Event Timeline

Reimplementation with tinyXML