Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F145
ReaderWriter.patch
Public
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Authored By
•
vongruen
Apr 1 2010, 4:51 PM
2010-04-01 16:51:17 (UTC+2)
Size
8 KB
Referenced Files
None
Subscribers
None
ReaderWriter.patch
View Options
Index: mitkPointSetReader.cpp
===================================================================
--- mitkPointSetReader.cpp (revision 21972)
+++ 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,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()
{
}
Index: mitkPointSetReader.h
===================================================================
--- mitkPointSetReader.h (revision 21972)
+++ mitkPointSetReader.h (working copy)
@@ -35,8 +35,10 @@
* these are assigned to multiple outputs of the filter. The number of point
* sets which have be read can be retrieven by a call to GetNumberOfOutputs()
* after the pipeline update().
+ * The reader is able to read the old 3D Pointsets without the "specification" and "timeseries" tags and the new 4D Pointsets.
* @note loading point sets from multiple files according to a given file pattern
* is not yet supported!
+ * @ingroup PSIO
* @ingroup IO
*/
class MITK_CORE_EXPORT PointSetReader: public PointSetSource, public FileReader
Index: mitkPointSetWriter.cpp
===================================================================
--- mitkPointSetWriter.cpp (revision 21972)
+++ mitkPointSetWriter.cpp (working copy)
@@ -32,10 +32,16 @@
const char* mitk::PointSetWriter::XML_POINT_SET = "point_set" ;
+const char* mitk::PointSetWriter::XML_TIME_SERIES = "time_series";
+
+const char* mitk::PointSetWriter::XML_TIME_SERIES_ID = "time_series_id";
+
const char* mitk::PointSetWriter::XML_POINT = "point" ;
const char* mitk::PointSetWriter::XML_ID = "id" ;
+const char* mitk::PointSetWriter::XML_SPEC = "specification" ;
+
const char* mitk::PointSetWriter::XML_X = "x" ;
const char* mitk::PointSetWriter::XML_Y = "y" ;
@@ -134,30 +140,46 @@
WriteStartElement( XML_POINT_SET, out );
mitk::PointSet::PointsContainer* pointsContainer = pointSet->GetPointSet()->GetPoints();
mitk::PointSet::PointsContainer::Iterator it;
- for ( it = pointsContainer->Begin(); it != pointsContainer->End(); ++it )
+
+ for(unsigned int i=0; i< pointSet->GetTimeSteps(); i++)
{
- WriteStartElement( XML_POINT, out );
+ WriteStartElement( XML_TIME_SERIES, out );
+
+ WriteStartElement( XML_TIME_SERIES_ID, out );
+ WriteCharacterData( ConvertToString( i ).c_str() , out );
+ WriteEndElement( XML_TIME_SERIES_ID, out, false );
- WriteStartElement( XML_ID, out );
- WriteCharacterData( ConvertToString( it->Index() ).c_str() , out );
- WriteEndElement( XML_ID, out, false );
+ for ( it = pointsContainer->Begin(); it != pointsContainer->End(); ++it )
+ {
+ WriteStartElement( XML_POINT, out );
- mitk::PointSet::PointType point = it->Value();
+ WriteStartElement( XML_ID, out );
+ WriteCharacterData( ConvertToString( it->Index() ).c_str() , out );
+ WriteEndElement( XML_ID, out, false );
- WriteStartElement( XML_X, out );
- WriteCharacterData( ConvertToString( point[ 0 ] ).c_str(), out );
- WriteEndElement( XML_X, out, false );
+ mitk::PointSet::PointType point = it->Value();
- WriteStartElement( XML_Y, out );
- WriteCharacterData( ConvertToString( point[ 1 ] ).c_str(), out );
- WriteEndElement( XML_Y, out, false );
+ WriteStartElement( XML_SPEC, out );
+ WriteCharacterData( ConvertToString( pointSet->GetSpecificationTypeInfo(it->Index(), i) ).c_str() , out );
+ WriteEndElement( XML_SPEC, out, false );
- WriteStartElement( XML_Z, out );
- WriteCharacterData( ConvertToString( point[ 2 ] ).c_str(), out );
- WriteEndElement( XML_Z, out, false );
+ WriteStartElement( XML_X, out );
+ WriteCharacterData( ConvertToString( point[ 0 ] ).c_str(), out );
+ WriteEndElement( XML_X, out, false );
- WriteEndElement( XML_POINT, out );
+ WriteStartElement( XML_Y, out );
+ WriteCharacterData( ConvertToString( point[ 1 ] ).c_str(), out );
+ WriteEndElement( XML_Y, out, false );
+
+ WriteStartElement( XML_Z, out );
+ WriteCharacterData( ConvertToString( point[ 2 ] ).c_str(), out );
+ WriteEndElement( XML_Z, out, false );
+
+ WriteEndElement( XML_POINT, out );
+ }
+ WriteEndElement( XML_TIME_SERIES, out, false );
}
+
WriteEndElement( XML_POINT_SET, out );
}
Index: mitkPointSetWriter.h
===================================================================
--- mitkPointSetWriter.h (revision 21972)
+++ mitkPointSetWriter.h (working copy)
@@ -33,6 +33,7 @@
* a single XML file by simply setting multiple inputs to the filter.
* Writing of multiple XML files according to a given filename pattern is not
* yet supported.
+ * @ingroup PSIO
* @ingroup Process
*/
class MITK_CORE_EXPORT PointSetWriter : public mitk::FileWriter
@@ -233,12 +234,18 @@
static const char* XML_POINT_SET;
+ static const char* XML_TIME_SERIES;
+
+ static const char* XML_TIME_SERIES_ID;
+
static const char* XML_POINT_SET_FILE;
static const char* XML_FILE_VERSION;
static const char* XML_POINT;
+ static const char* XML_SPEC;
+
static const char* XML_ID;
static const char* XML_X;
File Metadata
Details
Attached
Mime Type
text/plain
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
137
Default Alt Text
ReaderWriter.patch (8 KB)
Attached To
Mode
T1571: IO for 4D PointSets
Attached
Detach File
Event Timeline
•
vongruen
added a comment.
Apr 1 2010, 4:51 PM
2010-04-01 16:51:17 (UTC+2)
Comment Actions
All changed class files with documentation
Log In to Comment