Index: mitkPointSetReader.cpp =================================================================== --- mitkPointSetReader.cpp (revision 21795) +++ mitkPointSetReader.cpp (working copy) @@ -17,10 +17,11 @@ #include "mitkPointSetReader.h" -#include "vtkPointSetXMLParser.h" -#include "vtkSmartPointer.h" +//#include "vtkPointSetXMLParser.h" +//#include "vtkSmartPointer.h" #include #include +#include mitk::PointSetReader::PointSetReader() { @@ -46,27 +47,71 @@ 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->NextSiblingElement()) + { + 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")->ToElement(); + currentTimeSeries != NULL; currentTimeSeries = currentTimeSeries->NextSiblingElement()) + { + unsigned int currentTimeStep(0); + TiXmlElement* currentTimeSeriesID = currentTimeSeries->FirstChildElement("time_series_id"); + currentTimeStep = atoi(currentTimeSeriesID->GetText()); + + for( TiXmlElement* currentPoint = currentTimeSeries->FirstChildElement("point")->ToElement(); + currentPoint != NULL; currentPoint = currentPoint->NextSiblingElement()) + { + unsigned int id(0); + mitk::PointSpecificationType spec; + int x(0); + int y(0); + int z(0); + id = atoi(currentPoint->FirstChildElement("id")->GetText()); + spec = (mitk::PointSpecificationType) atoi(currentPoint->FirstChildElement("specification")->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, spec, 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() { }