Page MenuHomePhabricator

mitk-source.patch

Authored By
sauer
Feb 4 2009, 6:22 PM
Size
51 KB
Referenced Files
None
Subscribers
None

mitk-source.patch

Index: mitk/Testing/mitkPointSetFileIOTest.cpp
===================================================================
--- mitk/Testing/mitkPointSetFileIOTest.cpp (revision 16063)
+++ mitk/Testing/mitkPointSetFileIOTest.cpp (working copy)
@@ -1,19 +1,19 @@
/*=========================================================================
-
-Program: Medical Imaging & Interaction Toolkit
-Language: C++
-Date: $Date$
-Version: $Revision$
-
-Copyright (c) German Cancer Research Center, Division of Medical and
-Biological Informatics. All rights reserved.
-See MITKCopyright.txt or http://www.mitk.org/copyright.html for details.
-
-This software is distributed WITHOUT ANY WARRANTY; without even
-the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
-PURPOSE. See the above copyright notices for more information.
-
-=========================================================================*/
+
+ Program: Medical Imaging & Interaction Toolkit
+ Language: C++
+ Date: $Date$
+ Version: $Revision$
+
+ Copyright (c) German Cancer Research Center, Division of Medical and
+ Biological Informatics. All rights reserved.
+ See MITKCopyright.txt or http://www.mitk.org/copyright.html for details.
+
+ This software is distributed WITHOUT ANY WARRANTY; without even
+ the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ PURPOSE. See the above copyright notices for more information.
+
+ =========================================================================*/
#include "mitkPointSet.h"
#include "mitkPointSetWriter.h"
@@ -24,32 +24,127 @@
unsigned int numberOfTestPointSets = 1;
// create one test PointSet
-mitk::PointSet::Pointer CreateTestPointSet(unsigned int which)
-{
+mitk::PointSet::Pointer CreateTestPointSet(unsigned int which) {
mitk::PointSet::Pointer pointSet = mitk::PointSet::New();
- switch (which)
- {
- case 0:
- {
- unsigned int position(0);
- mitk::Point3D point;
- mitk::FillVector3D(point, 1.0, 2.0, 3.0); pointSet->GetPointSet()->GetPoints()->InsertElement(position, point);
- mitk::FillVector3D(point, 2.0, 3.0, 4.0); ++position; pointSet->GetPointSet()->GetPoints()->InsertElement(position, point);
- mitk::FillVector3D(point, 3.0, 4.0, 5.0); ++position; pointSet->GetPointSet()->GetPoints()->InsertElement(position, point);
- }
+ switch (which) {
+ //3DPointSet
+ case 0: {
+// unsigned int position(0);
+// mitk::Point3D point;
+// mitk::FillVector3D(point, 1.0, 2.0, 3.0);
+// pointSet->GetPointSet()->GetPoints()->InsertElement(position, point);
+// mitk::FillVector3D(point, 2.0, 3.0, 4.0);
+// ++position;
+// pointSet->GetPointSet()->GetPoints()->InsertElement(position, point);
+// mitk::FillVector3D(point, 3.0, 4.0, 5.0);
+// ++position;
+// pointSet->GetPointSet()->GetPoints()->InsertElement(position, point);
+ unsigned int numberOfPoints = 1000;
+ for (unsigned int i = 0; i <= numberOfPoints; ++i) {
+ mitk::Point3D point;
+ point[0] = 940;
+ point[1] = 762;//(mitk::ScalarType) (rand() % 1000);
+ point[2] = 41;//(mitk::ScalarType) (rand() % 1000);
+ std::cout << "Point:" << point << std::endl;
+ pointSet->SetPoint(i, point);
+ }
+ }
break;
+ //4DPointSet
+ case 1: {
+ // unsigned int position(0);
+ // unsigned int timeStep(0);
+ // mitk::Point3D point;
+ //
+ // //timestep 1
+ // mitk::FillVector3D(point, 100.0, 200.0, 300.0);
+ // pointSet->SetPoint(position, point, 0);
+ // mitk::FillVector3D(point, 200.0, 300.0, 400.0);
+ // ++position;
+ // pointSet->SetPoint(position, point, 0);
+ // mitk::FillVector3D(point, 300.0, 400.0, 500.0);
+ // ++position;
+ // pointSet->SetPoint(position, point, 0);
+ //
+ // //timestep 2
+ // unsigned int position1(0);
+ // mitk::Point3D point1;
+ // mitk::FillVector3D(point1, 400.0, 500.0, 600.0);
+ // pointSet->SetPoint(position1, point1, 1);
+ // mitk::FillVector3D(point1, 500.0, 600.0, 700.0);
+ // ++position1;
+ // pointSet->SetPoint(position1, point1, 1);
+ // mitk::FillVector3D(point1, 600.0, 700.0, 800.0);
+ // ++position1;
+ // pointSet->SetPoint(position1, point1, 1);
+ //
+ // //timestep 3
+ // unsigned int position2(0);
+ // mitk::Point3D point2;
+ // mitk::FillVector3D(point2, 700.0, 800.0, 900.0);
+ // pointSet->SetPoint(position2, point2, 2);
+ // mitk::FillVector3D(point2, 800.0, 900.0, 1000.0);
+ // ++position2;
+ // pointSet->SetPoint(position2, point2, 2);
+ // mitk::FillVector3D(point2, 900.0, 1000.0, 1100.0);
+ // ++position2;
+ // pointSet->SetPoint(position2, point2, 2);
+ //
+ // //timestep 4
+ // unsigned int position3(0);
+ // mitk::Point3D point3;
+ // mitk::FillVector3D(point3, 71.0, 82.0, 93.0);
+ // pointSet->SetPoint(position3, point3, 3);
+ // mitk::FillVector3D(point3, 84.0, 95.0, 106.0);
+ // ++position3;
+ // pointSet->SetPoint(position3, point3, 3);
+ // mitk::FillVector3D(point3, 97.0, 18.0, 119.0);
+ // ++position3;
+ // pointSet->SetPoint(position3, point3, 3);
+ //
+ // //timestep 5
+ // unsigned int position4(0);
+ // mitk::Point3D point4;
+ // mitk::FillVector3D(point4, 77.0, 88.0, 99.0);
+ // pointSet->SetPoint(position2, point4, 4);
+ // mitk::FillVector3D(point4, 88.0, 99.0, 1010.0);
+ // ++position4;
+ // pointSet->SetPoint(position2, point4, 4);
+ // mitk::FillVector3D(point4, 99.0, 1010.0, 1111.0);
+ // ++position4;
+ // pointSet->SetPoint(position2, point4, 4);
- default:
- {
- unsigned int position(0);
- mitk::Point3D point;
- mitk::FillVector3D(point, 1.0, 2.0, 3.0); pointSet->GetPointSet()->GetPoints()->InsertElement(position, point);
- mitk::FillVector3D(point, 2.0, 3.0, 4.0); ++position; pointSet->GetPointSet()->GetPoints()->InsertElement(position, point);
- mitk::FillVector3D(point, 3.0, 4.0, 5.0); ++position; pointSet->GetPointSet()->GetPoints()->InsertElement(position, point);
+ unsigned int numberOfPoints = 5;
+ unsigned int numberOfTimeSteps = 34;
+ for (unsigned int timeStep = 0; timeStep <= numberOfTimeSteps; ++timeStep) {
+ std::cout << "timestep writer : " << timeStep << "\n" << std::endl;
+ for (unsigned int i = 0; i <= numberOfPoints; ++i) {
+ mitk::Point3D point;
+ point[0] = (mitk::ScalarType) (rand() % 1000);
+ point[1] = (mitk::ScalarType) (rand() % 1000);
+ point[2] = (mitk::ScalarType) (rand() % 1000);
+ std::cout << "Point:" << point << std::endl;
+ pointSet->SetPoint(i, point, timeStep);
+ }
}
}
+ break;
+ //3DPointSet
+ default: {
+ unsigned int position(0);
+ mitk::Point3D point;
+ mitk::FillVector3D(point, 1.0, 2.0, 3.0);
+ pointSet->GetPointSet()->GetPoints()->InsertElement(position, point);
+ mitk::FillVector3D(point, 2.0, 3.0, 4.0);
+ ++position;
+ pointSet->GetPointSet()->GetPoints()->InsertElement(position, point);
+ mitk::FillVector3D(point, 3.0, 4.0, 5.0);
+ ++position;
+ pointSet->GetPointSet()->GetPoints()->InsertElement(position, point);
+ }
+ }
return pointSet;
@@ -55,30 +150,35 @@
}
-void PointSetCompare( mitk::PointSet* pointSet2, mitk::PointSet* pointSet1, bool& identical )
-{
- if (pointSet1->GetSize() != pointSet2->GetSize())
- {
- std::cerr << "point sets differ in size" << std::endl;
+void PointSetCompare(mitk::PointSet* pointSet2, mitk::PointSet* pointSet1,
+ bool& identical) {
+ if (pointSet1->GetSize() != pointSet2->GetSize() || pointSet1->GetTimeSteps()
+ != pointSet2->GetTimeSteps()) {
+ std::cout << "Poinset1grösse: " << pointSet1->GetSize()
+ << " Seriessize: " << pointSet1->GetTimeSteps() << std::endl;
+ std::cout << "Poinset2grösse: " << pointSet2->GetSize()
+ << " Seriessize: " << pointSet2->GetTimeSteps() << std::endl;
+ std::cerr << "point sets differ in size or timeseries" << std::endl;
identical = false;
return;
}
+ for (unsigned int timeStep = 0; timeStep
+ < (unsigned int) pointSet1->GetTimeSteps(); ++timeStep) {
+ for (unsigned int i = 0; i < (unsigned int) pointSet1->GetSize(); ++i) {
+ mitk::Point3D p1 = pointSet1->GetPoint(i, timeStep);
+ mitk::Point3D p2 = pointSet2->GetPoint(i, timeStep);
- for (unsigned int i = 0; i < (unsigned int)pointSet1->GetSize(); ++i)
- {
- mitk::Point3D p1 = pointSet1->GetPoint(i);
- mitk::Point3D p2 = pointSet2->GetPoint(i);
+ double difference = (abs(p1[0] - p2[0]) + abs(p1[1] - p2[1]) + abs(p1[2]
+ - p2[2]));
- double difference = ( (p1[0] - p2[0])
- + (p1[1] - p2[1])
- + (p1[2] - p2[2])
- );
-
- if (difference > 0.0001)
- {
- std::cerr << "points not at the same position" << std::endl;
- identical = false;
- break;
+ if (difference > 0.0001) {
+ std::cerr << "points not at the same position" << std::endl;
+ std::cout << "TimeStep error:" << timeStep << std::endl;
+ std::cout << "Punkt1 error:" << p1 << std::endl;
+ std::cout << "Punkt2 error:" << p2 << std::endl;
+ identical = false;
+ break;
+ }
}
}
@@ -84,12 +184,10 @@
}
-int mitkPointSetFileIOTest(int, char*[])
-{
+int mitkPointSetFileIOTest(int, char*[]) {
unsigned int numberFailed(0);
- for (unsigned int i = 0; i < numberOfTestPointSets; ++i)
- {
+ for (unsigned int i = 0; i < numberOfTestPointSets; ++i) {
mitk::PointSet::Pointer originalPointSet = CreateTestPointSet(i);
mitk::PointSet::Pointer secondPointSet;
@@ -94,54 +192,54 @@
mitk::PointSet::Pointer secondPointSet;
// write
- try
- {
- mitk::PointSetWriter::Pointer pointSetWriter = mitk::PointSetWriter::New();
- pointSetWriter->SetInput(originalPointSet);
- pointSetWriter->SetFileName("test_pointset.mps");
- pointSetWriter->Write();
- }
- catch ( std::exception& e )
- {
- std::cerr << "Error during attempt to write 'test_pointset.mps' Exception says:" << std::endl;
- std::cerr << e.what() << std::endl;
- ++numberFailed;
- continue;
- }
+ try {
+ mitk::PointSetWriter::Pointer pointSetWriter =
+ mitk::PointSetWriter::New();
+ pointSetWriter->SetInput(originalPointSet);
+ pointSetWriter->SetFileName("test_pointset.mps");
+ pointSetWriter->Write();
+ } catch (std::exception& e) {
+ std::cerr
+ << "Error during attempt to write 'test_pointset.mps' Exception says:"
+ << std::endl;
+ std::cerr << e.what() << std::endl;
+ ++numberFailed;
+ continue;
+ }
// load
- try
- {
- mitk::PointSetReader::Pointer pointSetReader = mitk::PointSetReader::New();
-
- pointSetReader->SetFileName("test_pointset.mps");
- pointSetReader->Update();
+ try {
+ mitk::PointSetReader::Pointer pointSetReader =
+ mitk::PointSetReader::New();
+
+ pointSetReader->SetFileName("test_pointset.mps");
+ pointSetReader->Update();
+
+ secondPointSet = pointSetReader->GetOutput();
+ } catch (std::exception& e) {
+ std::cerr
+ << "Error during attempt to read 'test_pointset.mps' Exception says:"
+ << std::endl;
+ std::cerr << e.what() << std::endl;
+ ++numberFailed;
+ continue;
+ }
- secondPointSet = pointSetReader->GetOutput();
- }
- catch ( std::exception& e )
- {
- std::cerr << "Error during attempt to read 'test_pointset.mps' Exception says:" << std::endl;
- std::cerr << e.what() << std::endl;
- ++numberFailed;
- continue;
- }
+ if (secondPointSet.IsNull()) {
+ std::cerr << "Error reading 'test_pointset.mps'. No PointSet created."
+ << std::endl;
+ ++numberFailed;
+ continue;
+ }
- if (secondPointSet.IsNull())
- {
- std::cerr << "Error reading 'test_pointset.mps'. No PointSet created." << std::endl;
- ++numberFailed;
- continue;
- }
-
- std::remove( "test_pointset.mps" );
-
+ //std::remove("test_pointset.mps");
+
// compare
bool identical(true);
- PointSetCompare( secondPointSet.GetPointer(), originalPointSet.GetPointer(), identical );
+ PointSetCompare(secondPointSet.GetPointer(), originalPointSet.GetPointer(),
+ identical);
- if (!identical)
- {
+ if (!identical) {
std::cerr << "PointSets differ for testPointSet " << i << std::endl;
++numberFailed;
continue;
@@ -149,13 +247,11 @@
}
// if one fails, whole test fails
- if (numberFailed > 0)
- {
- std::cout << "[FAILED]: " << numberFailed << " of " << numberOfTestPointSets << " sub-tests failed." << std::endl;
+ if (numberFailed > 0) {
+ std::cout << "[FAILED]: " << numberFailed << " of "
+ << numberOfTestPointSets << " sub-tests failed." << std::endl;
return EXIT_FAILURE;
- }
- else
- {
+ } else {
std::cout << "[PASSED]" << std::endl;
return EXIT_SUCCESS;
}
Index: mitk/Core/DataStructures/mitkPointSet.cpp
===================================================================
--- mitk/Core/DataStructures/mitkPointSet.cpp (revision 16063)
+++ mitk/Core/DataStructures/mitkPointSet.cpp (working copy)
@@ -120,7 +120,7 @@
{
return -1;
}
-
+
// Out is the point which is checked to be the searched point
PointType out;
out.Fill( 0 );
@@ -135,7 +135,7 @@
end = m_PointSetSeries[t]->GetPoints()->End();
int bestIndex = -1;
distance = distance * distance;
-
+
// To correct errors from converting index to world and world to index
if (distance == 0.0)
{
@@ -146,7 +146,7 @@
ScalarType dist, tmp;
for ( it = m_PointSetSeries[t]->GetPoints()->Begin(), i = 0;
- it != end;
+ it != end;
++it, ++i )
{
bool ok = m_PointSetSeries[t]->GetPoints()
@@ -175,7 +175,7 @@
return bestIndex;
}
-mitk::PointSet::PointType
+mitk::PointSet::PointType
mitk::PointSet::GetPoint( int position, int t ) const
{
PointType out;
@@ -201,7 +201,7 @@
}
-bool
+bool
mitk::PointSet
::GetPointIfExists( PointIdentifier id, PointType* point, int t )
{
@@ -250,7 +250,7 @@
}
tempGeometry->WorldToIndex( point, indexPoint );
m_PointSetSeries[t]->GetPoints()->InsertElement( id, indexPoint );
-
+
//boundingbox has to be computed anyway
m_CalculateBoundingBox = true;
}
@@ -339,7 +339,7 @@
}
PointDataIterator it;
- for ( it = m_PointSetSeries[t]->GetPointData()->Begin();
+ for ( it = m_PointSetSeries[t]->GetPointData()->Begin();
it != m_PointSetSeries[t]->GetPointData()->End();
it++ )
{
@@ -374,7 +374,7 @@
case OpNOTHING:
break;
- case OpINSERT://inserts the point at the given position and selects it.
+ case OpINSERT://inserts the point at the given position and selects it.
{
int position = pointOp->GetIndex();
@@ -381,7 +381,7 @@
PointType pt;
pt.CastFrom(pointOp->GetPoint());
- //transfer from world to index coordinates
+ //transfer from world to index coordinates
mitk::Geometry3D* geometry = this->GetGeometry( timeStep );
if (geometry == NULL)
{
@@ -392,10 +392,10 @@
m_PointSetSeries[timeStep]->GetPoints()->InsertElement(position, pt);
- PointDataType pointData =
+ PointDataType pointData =
{
- pointOp->GetIndex(),
- pointOp->GetSelected(),
+ pointOp->GetIndex(),
+ pointOp->GetSelected(),
pointOp->GetPointType()
};
@@ -403,7 +403,7 @@
->InsertElement(position, pointData);
this->Modified();
-
+
//boundingbox has to be computed
m_CalculateBoundingBox = true;
@@ -416,8 +416,8 @@
{
PointType pt;
pt.CastFrom(pointOp->GetPoint());
-
- //transfer from world to index coordinates
+
+ //transfer from world to index coordinates
this->GetGeometry( timeStep )->WorldToIndex(pt, pt);
m_PointSetSeries[timeStep]->SetPoint(pointOp->GetIndex(), pt);
@@ -433,7 +433,7 @@
}
break;
- case OpREMOVE://removes the point at given by position
+ case OpREMOVE://removes the point at given by position
{
m_PointSetSeries[timeStep]->GetPoints()
->DeleteIndex((unsigned)pointOp->GetIndex());
@@ -480,13 +480,13 @@
}
break;
- case OpMOVEPOINTUP: // move point position within the pointset
+ case OpMOVEPOINTUP: // move point position within the pointset
{
int position = SearchPoint(pointOp->GetPoint(), 0.0, timeStep);
mitk::Point3D point1 = pointOp->GetPoint();
-
+
if(position >= 1)
- {
+ {
mitk::Point3D point2 = m_PointSetSeries[timeStep]->GetPoints()->GetElement(position-1);
m_PointSetSeries[timeStep]->GetPoints()->InsertElement(position-1,point1);
m_PointSetSeries[timeStep]->GetPoints()->InsertElement(position,point2);
@@ -492,10 +492,10 @@
m_PointSetSeries[timeStep]->GetPoints()->InsertElement(position,point2);
this->Modified();
}
-
+
}
break;
- case OpMOVEPOINTDOWN: // move point position within the pointset
+ case OpMOVEPOINTDOWN: // move point position within the pointset
{
int position = SearchPoint(pointOp->GetPoint(), 0.0, timeStep);
mitk::Point3D point1 = pointOp->GetPoint();
@@ -501,7 +501,7 @@
mitk::Point3D point1 = pointOp->GetPoint();
if(position >= 0 && GetSize(timeStep) > position)
- {
+ {
mitk::Point3D point2 = m_PointSetSeries[timeStep]->GetPoints()->GetElement(position+1);
m_PointSetSeries[timeStep]->GetPoints()->InsertElement(position+1,point1);
m_PointSetSeries[timeStep]->GetPoints()->InsertElement(position,point2);
@@ -514,8 +514,8 @@
itkWarningMacro("mitkPointSet could not understrand the operation. Please check!");
break;
}
-
- //to tell the mappers, that the data is modifierd and has to be updated
+
+ //to tell the mappers, that the data is modifierd and has to be updated
//only call modified if anything is done, so call in cases
//this->Modified();
@@ -555,7 +555,7 @@
{
const DataType::BoundingBoxType *bb = m_PointSetSeries[i]->GetBoundingBox();
BoundingBox::BoundsArrayType itkBounds = bb->GetBounds();
-
+
// Ensure minimal bounds of 1.0 in each dimension
for ( unsigned int j = 0; j < 3; ++j )
{
@@ -561,7 +561,7 @@
{
if ( itkBounds[j*2+1] - itkBounds[j*2] < 1.0 )
{
- BoundingBox::CoordRepType center =
+ BoundingBox::CoordRepType center =
(itkBounds[j*2] + itkBounds[j*2+1]) / 2.0;
itkBounds[j*2] = center - 0.5;
itkBounds[j*2+1] = center + 0.5;
@@ -598,7 +598,7 @@
std::string fileName = xmlWriter.GetRelativePath();
if(!xmlWriter.IsFileExtension(".mps", fileName))
fileName += ".mps";
-
+
if(xmlWriter.SaveSourceFiles()){
PointSetWriter::Pointer writer = PointSetWriter::New();
fileName = xmlWriter.GetAbsolutePath();
Index: mitk/Core/IO/vtkPointSetXMLParser.cpp
===================================================================
--- mitk/Core/IO/vtkPointSetXMLParser.cpp (revision 16063)
+++ mitk/Core/IO/vtkPointSetXMLParser.cpp (working copy)
@@ -5,146 +5,118 @@
#include "mitkInteractionConst.h"
#include "mitkPointOperation.h"
-namespace mitk
-{
-vtkStandardNewMacro(vtkPointSetXMLParser);
+namespace mitk {
+vtkStandardNewMacro(vtkPointSetXMLParser)
+;
}
-mitk::vtkPointSetXMLParser::vtkPointSetXMLParser()
-{
+mitk::vtkPointSetXMLParser::vtkPointSetXMLParser() {
+ m_TimeIndex = -1;
}
-mitk::vtkPointSetXMLParser::~vtkPointSetXMLParser()
-{
+mitk::vtkPointSetXMLParser::~vtkPointSetXMLParser() {
}
+void mitk::vtkPointSetXMLParser::StartElement(const char *name, const char ** /*atts */) {
+ std::string currentElement = name;
+ //
+ // when a new point set begins in the file, create a new
+ // mitk::point set and store it in m_PointSetList
+ //
+ if (currentElement == mitk::PointSetWriter::XML_POINT_SET) {
+ m_CurrentPointSet = PointSetType::New();
+ //when a new Pointset begins, the timeseriessize has to be increased
+ //when a new Timeseries begins in the file, create a new serie and store it in
+ } else if (currentElement == mitk::PointSetWriter::XML_TIME_SERIES) {
+ m_TimeIndex++;
+ m_CurrentPointSet->Expand(m_TimeIndex+1);
+ }
+ //
+ // when a new point begins, initialize it to zero.
+ //
+ else if (currentElement == mitk::PointSetWriter::XML_POINT) {
+ m_CurrentPoint.Fill(0.0f);
+ }
-void mitk::vtkPointSetXMLParser::StartElement ( const char *name, const char ** /*atts */)
-{
- std::string currentElement = name;
- //
- // when a new point set begins in the file, create a new
- // mitk::point set and store it in m_PointSetList
- //
- if ( currentElement == mitk::PointSetWriter::XML_POINT_SET )
- {
- m_CurrentPointSet = PointSetType::New();
- }
- //
- // when a new point begins, initialize it to zero.
- //
- else if ( currentElement == mitk::PointSetWriter::XML_POINT )
- {
- m_CurrentPoint[ 0 ] = 0.0f;
- m_CurrentPoint[ 1 ] = 0.0f;
- m_CurrentPoint[ 2 ] = 0.0f;
- m_CurId.clear();
- m_CurXString.clear();
- m_CurYString.clear();
- m_CurZString.clear();
- }
-
- //
- // the current element is pushed on to the stack
- // to be able to detect some errors in the xml file
- //
- m_ParseStack.push( currentElement );
+ //
+ // the current element is pushed on to the stack
+ // to be able to detect some errors in the xml file
+ //
+ m_ParseStack.push(currentElement);
}
-
+void mitk::vtkPointSetXMLParser::EndElement(const char *name) {
+ std::string currentElement = name;
+ //
+ // make sure, that the current end element matches with the
+ // last start tag
+ //
+ if (m_ParseStack.top() != currentElement) {
+ std::cerr << "Top of parse stack ( " << m_ParseStack.top()
+ << " ) is != currentEndElement ( " << currentElement << " )!"
+ << std::endl;
+ // TODO: error
+ }
+ m_ParseStack.pop();
-void mitk::vtkPointSetXMLParser::EndElement ( const char *name )
-{
- std::string currentElement = name;
-
- //
- // make sure, that the current end element matches with the
- // last start tag
- //
- if ( m_ParseStack.top() != currentElement )
- {
- std::cerr << "Top of parse stack ( " << m_ParseStack.top() << " ) is != currentEndElement ( " << currentElement << " )!" << std::endl;
- }
- m_ParseStack.pop();
-
-
- //
- // After a complete point set has been parsed, its
- // output information is updated and it is inserted into the list
- // of parsed point sets.
- //
- if (currentElement == mitk::PointSetWriter::XML_POINT_SET)
- {
- m_CurrentPointSet->UpdateOutputInformation();
- m_PointSetList.push_back( m_CurrentPointSet );
- }
- //
- // if we have finished parsing a point, insert it to the current
- // point set.
- //
- else if ( currentElement == mitk::PointSetWriter::XML_POINT )
- {
- m_CurrentPointId = ParsePointIdentifier( m_CurId );
- m_CurrentPoint[ 0 ] = ParseScalarType( m_CurXString );
- m_CurrentPoint[ 1 ] = ParseScalarType( m_CurYString );
- m_CurrentPoint[ 2 ] = ParseScalarType( m_CurZString );
-
- mitk::PointOperation popInsert( mitk::OpINSERT, m_CurrentPoint, m_CurrentPointId );
- mitk::PointOperation popDeactivate( mitk::OpDESELECTPOINT, m_CurrentPoint, m_CurrentPointId );
- assert( m_CurrentPointSet.IsNotNull() );
- m_CurrentPointSet->ExecuteOperation( &popInsert );
- m_CurrentPointSet->ExecuteOperation( &popDeactivate );
- }
+ //
+ // After a complete point set has been parsed, its
+ // output information is updated and it is inserted into the list
+ // of parsed currentElementpoint sets.
+ //
+ if (currentElement == mitk::PointSetWriter::XML_POINT_SET) {
+ m_CurrentPointSet->UpdateOutputInformation();
+ m_PointSetList.push_back(m_CurrentPointSet);
+ } else if (currentElement == mitk::PointSetWriter::XML_TIME_SERIES) {
+ //
+ // if we have finished parsing a point, insert it to the current
+ // point set.
+ //
+ } else if (currentElement == mitk::PointSetWriter::XML_POINT) {
+ mitk::PointOperation popInsert(mitk::OpINSERT, m_TimeIndex, m_CurrentPoint,
+ m_CurrentPointId);
+ mitk::PointOperation popDeactivate(mitk::OpDESELECTPOINT, m_TimeIndex,
+ m_CurrentPoint, m_CurrentPointId);
+ assert( m_CurrentPointSet.IsNotNull() );
+ m_CurrentPointSet->ExecuteOperation(&popInsert);
+ m_CurrentPointSet->ExecuteOperation(&popDeactivate);
+ }
}
+void mitk::vtkPointSetXMLParser::CharacterDataHandler(const char *inData,
+ int inLength) {
+ std::string currentElement = m_ParseStack.top();
+ std::string data;
+ data.append(inData, inLength);
-
-
-void mitk::vtkPointSetXMLParser::CharacterDataHandler ( const char *inData, int inLength )
-{
- std::string currentElement = m_ParseStack.top();
- if ( currentElement == mitk::PointSetWriter::XML_ID )
- {
- m_CurId.append( inData, inLength );
- }
- else if ( currentElement == mitk::PointSetWriter::XML_X )
- {
- m_CurXString.append(inData, inLength);
- }
- else if ( currentElement == mitk::PointSetWriter::XML_Y )
- {
- m_CurYString.append(inData, inLength);
- }
- else if ( currentElement == mitk::PointSetWriter::XML_Z )
- {
- m_CurZString.append(inData, inLength);
- }
+ if (currentElement == mitk::PointSetWriter::XML_ID) {
+ m_CurrentPointId = ParsePointIdentifier(data);
+ } else if (currentElement == mitk::PointSetWriter::XML_X) {
+ m_CurrentPoint[0] = ParseScalarType(data);
+ } else if (currentElement == mitk::PointSetWriter::XML_Y) {
+ m_CurrentPoint[1] = ParseScalarType(data);
+ } else if (currentElement == mitk::PointSetWriter::XML_Z) {
+ m_CurrentPoint[2] = ParseScalarType(data);
+ } else if (currentElement == mitk::PointSetWriter::XML_TIME_SERIES_ID) {
+ }
}
-
-
-
-mitk::ScalarType mitk::vtkPointSetXMLParser::ParseScalarType( const std::string &data )
-{
- return ( mitk::ScalarType ) atof( data.c_str() );
+mitk::ScalarType mitk::vtkPointSetXMLParser::ParseScalarType(
+ const std::string &data) {
+ return (mitk::ScalarType) atof(data.c_str());
}
-
-
+mitk::ScalarType mitk::vtkPointSetXMLParser::ParseSize(const std::string &data) {
+ return (mitk::ScalarType) atoi(data.c_str());
+}
-mitk::vtkPointSetXMLParser::PointIdentifier mitk::vtkPointSetXMLParser::ParsePointIdentifier( const std::string &data )
-{
- return ( mitk::vtkPointSetXMLParser::PointIdentifier ) atol( data.c_str() );
+mitk::vtkPointSetXMLParser::PointIdentifier mitk::vtkPointSetXMLParser::ParsePointIdentifier(
+ const std::string &data) {
+ return (mitk::vtkPointSetXMLParser::PointIdentifier) atol(data.c_str());
}
-
-
-
-mitk::vtkPointSetXMLParser::PointSetList mitk::vtkPointSetXMLParser::GetParsedPointSets()
-{
- return m_PointSetList;
+mitk::vtkPointSetXMLParser::PointSetList mitk::vtkPointSetXMLParser::GetParsedPointSets() {
+ return m_PointSetList;
}
-
-
Index: mitk/Core/IO/mitkPointSetReader.cpp
===================================================================
--- mitk/Core/IO/mitkPointSetReader.cpp (revision 16063)
+++ mitk/Core/IO/mitkPointSetReader.cpp (working copy)
@@ -66,7 +66,15 @@
unsigned int i = 0;
for ( mitk::vtkPointSetXMLParser::PointSetList::iterator it = pointSetList.begin(); it != pointSetList.end(); ++it, ++i )
{
- this->SetNthOutput( i, *it );
+
+ mitk::PointSet::Pointer pointSet = *it;
+ for(unsigned int j=0;j<pointSet->GetPointSetSeriesSize();j++){
+ std::cout<<"ReaderPointSetSeriesSize: "<<pointSet->GetPointSetSeriesSize()<<std::endl;
+ for(int i=0; i<pointSet->GetSize(j); i++){
+ std::cout<< "Pointset Reader: " <<pointSet->GetPoint(i,j)<<std::endl;
+ }}
+ this->SetNthOutput( i, *it );
+
}
parser->Delete();
m_Success = true;
@@ -92,7 +100,7 @@
}
}
-bool mitk::PointSetReader::CanReadFile(const std::string filename, const std::string filePrefix, const std::string filePattern)
+bool mitk::PointSetReader::CanReadFile(const std::string filename, const std::string filePrefix, const std::string filePattern)
{
// First check the extension
if( filename == "" )
@@ -142,5 +150,5 @@
bool mitk::PointSetReader::GetSuccess() const
{
- return m_Success;
+ return m_Success;
}
Index: mitk/Core/IO/mitkPointSetWriter.cpp
===================================================================
--- mitk/Core/IO/mitkPointSetWriter.cpp (revision 16063)
+++ mitk/Core/IO/mitkPointSetWriter.cpp (working copy)
@@ -1,20 +1,19 @@
/*=========================================================================
-Program: Medical Imaging & Interaction Toolkit
-Language: C++
-Date: $Date$
-Version: $Revision$
-
-Copyright (c) German Cancer Research Center, Division of Medical and
-Biological Informatics. All rights reserved.
-See MITKCopyright.txt or http://www.mitk.org/copyright.html for details.
+ Program: Medical Imaging & Interaction Toolkit
+ Language: C++
+ Date: $Date$
+ Version: $Revision$
-This software is distributed WITHOUT ANY WARRANTY; without even
-the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
-PURPOSE. See the above copyright notices for more information.
+ Copyright (c) German Cancer Research Center, Division of Medical and
+ Biological Informatics. All rights reserved.
+ See MITKCopyright.txt or http://www.mitk.org/copyright.html for details.
-=========================================================================*/
+ This software is distributed WITHOUT ANY WARRANTY; without even
+ the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ PURPOSE. See the above copyright notices for more information.
+ =========================================================================*/
#include "mitkPointSetWriter.h"
#include <iostream>
@@ -20,7 +19,6 @@
#include <iostream>
#include <fstream>
-
//
// Initialization of the xml tags.
//
@@ -25,326 +23,252 @@
// Initialization of the xml tags.
//
-const char* mitk::PointSetWriter::XML_POINT_SET_FILE = "point_set_file" ;
-
-const char* mitk::PointSetWriter::XML_FILE_VERSION = "file_version" ;
+const char* mitk::PointSetWriter::XML_POINT_SET_FILE = "point_set_file";
-const char* mitk::PointSetWriter::XML_POINT_SET = "point_set" ;
+const char* mitk::PointSetWriter::XML_FILE_VERSION = "file_version";
-const char* mitk::PointSetWriter::XML_POINT = "point" ;
+const char* mitk::PointSetWriter::XML_TIME_SERIES = "time_series";
-const char* mitk::PointSetWriter::XML_ID = "id" ;
+const char* mitk::PointSetWriter::XML_TIME_SERIES_ID= "time_series_id";
-const char* mitk::PointSetWriter::XML_X = "x" ;
+const char* mitk::PointSetWriter::XML_POINT_SET = "point_set";
-const char* mitk::PointSetWriter::XML_Y = "y" ;
+const char* mitk::PointSetWriter::XML_POINT = "point";
-const char* mitk::PointSetWriter::XML_Z = "z" ;
+const char* mitk::PointSetWriter::XML_ID = "id";
-const char* mitk::PointSetWriter::VERSION_STRING = "0.1" ;
+const char* mitk::PointSetWriter::XML_X = "x";
+const char* mitk::PointSetWriter::XML_Y = "y";
+const char* mitk::PointSetWriter::XML_Z = "z";
+const char* mitk::PointSetWriter::VERSION_STRING = "0.1";
-mitk::PointSetWriter::PointSetWriter()
- : m_FileName(""), m_FilePrefix(""), m_FilePattern("")
-{
- this->SetNumberOfRequiredInputs( 1 );
- this->SetNumberOfOutputs( 1 );
- this->SetNthOutput( 0, mitk::PointSet::New().GetPointer() );
- m_Indent = 2;
- m_IndentDepth = 0;
- m_Success = false;
+mitk::PointSetWriter::PointSetWriter() :
+ m_FileName(""), m_FilePrefix(""), m_FilePattern("") {
+ this->SetNumberOfRequiredInputs(1);
+ this->SetNumberOfOutputs(1);
+ this->SetNthOutput(0, mitk::PointSet::New().GetPointer());
+ m_Indent = 2;
+ m_IndentDepth = 0;
+ m_Success = false;
}
-
-
-
-mitk::PointSetWriter::~PointSetWriter()
-{}
-
-
+mitk::PointSetWriter::~PointSetWriter() {
+}
+void mitk::PointSetWriter::GenerateData() {
+ m_Success = false;
+ m_IndentDepth = 0;
-void mitk::PointSetWriter::GenerateData()
-{
- m_Success = false;
- m_IndentDepth = 0;
+ //
+ // Opening the file to write to
+ //
+ if (m_FileName == "") {
+ itkWarningMacro( << "Sorry, filename has not been set!" );
+ return;
+ }
+ std::ofstream out(m_FileName.c_str());
+ if (!out.good()) {
+ itkExceptionMacro(<< "File " << m_FileName << " could not be opened!");
+ itkWarningMacro( << "Sorry, file " << m_FileName << " could not be opened!" );
+ out.close();
+ return;
+ }
- //
- // Opening the file to write to
- //
- if ( m_FileName == "" )
- {
- itkWarningMacro( << "Sorry, filename has not been set!" );
- return ;
- }
- std::ofstream out( m_FileName.c_str() );
- if ( !out.good() )
- {
- itkExceptionMacro(<< "File " << m_FileName << " could not be opened!");
- itkWarningMacro( << "Sorry, file " << m_FileName << " could not be opened!" );
- out.close();
- return ;
- }
+ //
+ // Here the actual xml writing begins
+ //
+ WriteXMLHeader(out);
+ WriteStartElement(XML_POINT_SET_FILE, out);
+ WriteStartElement(XML_FILE_VERSION, out);
+ WriteCharacterData(VERSION_STRING, out);
+ WriteEndElement(XML_FILE_VERSION, out, false);
- //
- // Here the actual xml writing begins
- //
- WriteXMLHeader( out );
- WriteStartElement( XML_POINT_SET_FILE, out );
- WriteStartElement( XML_FILE_VERSION, out );
- WriteCharacterData( VERSION_STRING, out );
- WriteEndElement( XML_FILE_VERSION, out, false );
+ //
+ // for each input object write its xml representation to
+ // the stream
+ //
+ for (unsigned int i = 0; i < this->GetNumberOfInputs(); ++i) {
+ InputType::Pointer pointSet = this->GetInput(i);
+ assert( pointSet.IsNotNull() );
+ WriteXML(pointSet.GetPointer(), out);
+ }
- //
- // for each input object write its xml representation to
- // the stream
- //
- for ( unsigned int i = 0 ; i < this->GetNumberOfInputs(); ++i )
- {
- InputType::Pointer pointSet = this->GetInput( i );
- assert( pointSet.IsNotNull() );
- WriteXML( pointSet.GetPointer(), out );
- }
+ WriteEndElement(XML_POINT_SET_FILE, out);
- WriteEndElement( XML_POINT_SET_FILE, out );
+ if (!out.good()) // some error during output
+ {
+ out.close();
+ throw std::ios_base::failure("Some error during point set writing.");
+ }
- if ( !out.good() ) // some error during output
- {
- out.close();
- throw std::ios_base::failure("Some error during point set writing.");
- }
-
- out.close();
- m_Success = true;
- m_MimeType = "application/MITK.PointSet";
+ out.close();
+ m_Success = true;
+ m_MimeType = "application/MITK.PointSet";
}
-
-
+void mitk::PointSetWriter::WriteXML(mitk::PointSet* pointSet,
+ std::ofstream& out) {
+ WriteStartElement(XML_POINT_SET, out);
+ for (unsigned int t = 0; t < pointSet->GetPointSetSeriesSize(); ++t) {
+ WriteStartElement(XML_TIME_SERIES, out);
+ WriteStartElement(XML_TIME_SERIES_ID,out);
+ WriteCharacterData(ConvertToString(t).c_str(),out);
+ WriteEndElement(XML_TIME_SERIES_ID,out,false);
+ mitk::PointSet::PointsContainer* pointsContainer =
+ pointSet->GetPointSet(t)->GetPoints();
+ mitk::PointSet::PointsContainer::Iterator it;
+ for (it = pointsContainer->Begin(); it != pointsContainer->End(); ++it) {
+ WriteStartElement(XML_POINT, out);
-void mitk::PointSetWriter::WriteXML( mitk::PointSet* pointSet, std::ofstream& out )
-{
- 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 )
- {
- WriteStartElement( XML_POINT, out );
+ WriteStartElement(XML_ID, out);
+ WriteCharacterData(ConvertToString(it->Index()).c_str(), out);
+ WriteEndElement(XML_ID, out, false);
- WriteStartElement( XML_ID, out );
- WriteCharacterData( ConvertToString( it->Index() ).c_str() , out );
- WriteEndElement( XML_ID, out, false );
+ mitk::PointSet::PointType point = it->Value();
- mitk::PointSet::PointType point = it->Value();
+ WriteStartElement(XML_X, out);
+ WriteCharacterData(ConvertToString(point[0]).c_str(), out);
+ WriteEndElement(XML_X, out, false);
- WriteStartElement( XML_X, out );
- WriteCharacterData( ConvertToString( point[ 0 ] ).c_str(), out );
- WriteEndElement( XML_X, out, false );
+ WriteStartElement(XML_Y, out);
+ WriteCharacterData(ConvertToString(point[1]).c_str(), out);
+ WriteEndElement(XML_Y, out, false);
- 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);
- WriteStartElement( XML_Z, out );
- WriteCharacterData( ConvertToString( point[ 2 ] ).c_str(), out );
- WriteEndElement( XML_Z, out, false );
-
- WriteEndElement( XML_POINT, out );
- }
- WriteEndElement( XML_POINT_SET, out );
+ WriteEndElement(XML_POINT, out);
+ }
+ WriteEndElement(XML_TIME_SERIES, out);
+ }
+ WriteEndElement(XML_POINT_SET, out);
}
-
-
-
-
-void mitk::PointSetWriter::ResizeInputs( const unsigned int& num )
-{
- unsigned int prevNum = this->GetNumberOfInputs();
- this->SetNumberOfInputs( num );
- for ( unsigned int i = prevNum; i < num; ++i )
- {
- this->SetNthInput( i, mitk::PointSet::New().GetPointer() );
- }
+void mitk::PointSetWriter::ResizeInputs(const unsigned int& num) {
+ unsigned int prevNum = this->GetNumberOfInputs();
+ this->SetNumberOfInputs(num);
+ for (unsigned int i = prevNum; i < num; ++i) {
+ this->SetNthInput(i, mitk::PointSet::New().GetPointer());
+ }
}
-
-
-
-void mitk::PointSetWriter::SetInput( InputType* pointSet )
-{
- this->ProcessObject::SetNthInput( 0, pointSet );
+void mitk::PointSetWriter::SetInput(InputType* pointSet) {
+ this->ProcessObject::SetNthInput(0, pointSet);
}
-
-
-
-void mitk::PointSetWriter::SetInput( const unsigned int& id, InputType* pointSet )
-{
- if ( id >= this->GetNumberOfInputs() )
- this->ResizeInputs( id + 1 );
- this->ProcessObject::SetNthInput( id, pointSet );
+void mitk::PointSetWriter::SetInput(const unsigned int& id, InputType* pointSet) {
+ if (id >= this->GetNumberOfInputs())
+ this->ResizeInputs(id + 1);
+ this->ProcessObject::SetNthInput(id, pointSet);
}
-
-
-mitk::PointSet* mitk::PointSetWriter::GetInput()
-{
- if ( this->GetNumberOfInputs() < 1 )
- {
- return 0;
- }
- else
- {
- return dynamic_cast<InputType*> ( this->GetInput( 0 ) );
- }
+mitk::PointSet* mitk::PointSetWriter::GetInput() {
+ if (this->GetNumberOfInputs() < 1) {
+ return 0;
+ } else {
+ return dynamic_cast<InputType*> (this->GetInput(0));
+ }
}
-
-
-
-mitk::PointSet* mitk::PointSetWriter::GetInput( const unsigned int& num )
-{
- return dynamic_cast<InputType*> ( this->ProcessObject::GetInput( num ) );
+mitk::PointSet* mitk::PointSetWriter::GetInput(const unsigned int& num) {
+ return dynamic_cast<InputType*> (this->ProcessObject::GetInput(num));
}
-
-
-
-
-template < typename T>
-std::string mitk::PointSetWriter::ConvertToString( T value )
-{
- std::ostringstream o;
- if ( o << value )
- return o.str();
- else
- return "conversion error";
+template<typename T>
+std::string mitk::PointSetWriter::ConvertToString(T value) {
+ std::ostringstream o;
+ if (o << value)
+ return o.str();
+ else
+ return "conversion error";
}
-
-
-
-void mitk::PointSetWriter::WriteXMLHeader( std::ofstream &file )
-{
- file << "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>";
+void mitk::PointSetWriter::WriteXMLHeader(std::ofstream &file) {
+ file << "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>";
}
-
-
-
-void mitk::PointSetWriter::WriteStartElement( const char *const tag, std::ofstream &file )
-{
- file << std::endl;
- WriteIndent( file );
- file << '<' << tag << '>';
- m_IndentDepth++;
+void mitk::PointSetWriter::WriteStartElement(const char *const tag,
+ std::ofstream &file) {
+ file << std::endl;
+ WriteIndent(file);
+ file << '<' << tag << '>';
+ m_IndentDepth++;
}
-
-
-
-void mitk::PointSetWriter::WriteEndElement( const char *const tag, std::ofstream &file, const bool& indent )
-{
- m_IndentDepth--;
- if ( indent )
- {
- file << std::endl;
- WriteIndent( file );
- }
- file << '<' << '/' << tag << '>';
+void mitk::PointSetWriter::WriteEndElement(const char *const tag,
+ std::ofstream &file, const bool& indent) {
+ m_IndentDepth--;
+ if (indent) {
+ file << std::endl;
+ WriteIndent(file);
+ }
+ file << '<' << '/' << tag << '>';
}
-
-
-
-void mitk::PointSetWriter::WriteCharacterData( const char *const data, std::ofstream &file )
-{
- file << data;
+void mitk::PointSetWriter::WriteCharacterData(const char *const data,
+ std::ofstream &file) {
+ file << data;
}
-
-
-
-void mitk::PointSetWriter::WriteStartElement( std::string &tag, std::ofstream &file )
-{
- WriteStartElement( tag.c_str(), file );
+void mitk::PointSetWriter::WriteStartElement(std::string &tag,
+ std::ofstream &file) {
+ WriteStartElement(tag.c_str(), file);
}
-
-
-
-void mitk::PointSetWriter::WriteEndElement( std::string &tag, std::ofstream &file, const bool& indent )
-{
- WriteEndElement( tag.c_str(), file, indent );
+void mitk::PointSetWriter::WriteEndElement(std::string &tag,
+ std::ofstream &file, const bool& indent) {
+ WriteEndElement(tag.c_str(), file, indent);
}
-
-
-
-void mitk::PointSetWriter::WriteCharacterData( std::string &data, std::ofstream &file )
-{
- WriteCharacterData( data.c_str(), file );
+void mitk::PointSetWriter::WriteCharacterData(std::string &data,
+ std::ofstream &file) {
+ WriteCharacterData(data.c_str(), file);
}
-
-
-
-void mitk::PointSetWriter::WriteIndent( std::ofstream& file )
-{
- std::string spaces( m_IndentDepth * m_Indent, ' ' );
- file << spaces.c_str();
+void mitk::PointSetWriter::WriteIndent(std::ofstream& file) {
+ std::string spaces(m_IndentDepth * m_Indent, ' ');
+ file << spaces.c_str();
}
-
-
-bool mitk::PointSetWriter::GetSuccess() const
-{
- return m_Success;
+bool mitk::PointSetWriter::GetSuccess() const {
+ return m_Success;
}
-
-
-bool mitk::PointSetWriter::CanWriteDataType( DataTreeNode* input )
-{
- if ( input )
- {
- mitk::BaseData* data = input->GetData();
- if ( data )
- {
- mitk::PointSet::Pointer pointSet = dynamic_cast<mitk::PointSet*>( data );
- if( pointSet.IsNotNull() )
- {
- //this writer has no "SetDefaultExtension()" - function
- m_Extension = ".mps";
- return true;
- }
- }
- }
- return false;
+bool mitk::PointSetWriter::CanWriteDataType(DataTreeNode* input) {
+ if (input) {
+ mitk::BaseData* data = input->GetData();
+ if (data) {
+ mitk::PointSet::Pointer pointSet = dynamic_cast<mitk::PointSet*> (data);
+ if (pointSet.IsNotNull()) {
+ //this writer has no "SetDefaultExtension()" - function
+ m_Extension = ".mps";
+ return true;
+ }
+ }
+ }
+ return false;
}
-void mitk::PointSetWriter::SetInput( DataTreeNode* input )
-{
- if( input && CanWriteDataType( input ) )
- this->ProcessObject::SetNthInput( 0, dynamic_cast<mitk::PointSet*>( input->GetData() ) );
+void mitk::PointSetWriter::SetInput(DataTreeNode* input) {
+ if (input && CanWriteDataType(input))
+ this->ProcessObject::SetNthInput(0,
+ dynamic_cast<mitk::PointSet*> (input->GetData()));
}
-std::string mitk::PointSetWriter::GetWritenMIMEType()
-{
- return m_MimeType;
+std::string mitk::PointSetWriter::GetWritenMIMEType() {
+ return m_MimeType;
}
-std::vector<std::string> mitk::PointSetWriter::GetPossibleFileExtensions()
-{
- std::vector<std::string> possibleFileExtensions;
- possibleFileExtensions.push_back(".mps");
- return possibleFileExtensions;
+std::vector<std::string> mitk::PointSetWriter::GetPossibleFileExtensions() {
+ std::vector<std::string> possibleFileExtensions;
+ possibleFileExtensions.push_back(".mps");
+ return possibleFileExtensions;
}
-std::string mitk::PointSetWriter::GetFileExtension()
-{
- return m_Extension;
+std::string mitk::PointSetWriter::GetFileExtension() {
+ return m_Extension;
}
Index: mitk/Core/IO/vtkPointSetXMLParser.h
===================================================================
--- mitk/Core/IO/vtkPointSetXMLParser.h (revision 16063)
+++ mitk/Core/IO/vtkPointSetXMLParser.h (working copy)
@@ -10,7 +10,7 @@
namespace mitk
{
-
+
/**
* @brief Implementation of the vtkXMLParser interface for reading mitk::PointSets.
*
@@ -15,7 +15,7 @@
* @brief Implementation of the vtkXMLParser interface for reading mitk::PointSets.
*
* This class implements the XMLParser interface of the vtkXMLParser which is based
- * on expat. It is used by the mitk::PointSetReader and is NOT INTENDED TO BE USED
+ * on expat. It is used by the mitk::PointSetReader and is NOT INTENDED TO BE USED
* FROM THE END-USER. If you want to read point sets, use the mitk::PointSetReader.
* @ingroup Process
*/
@@ -29,27 +29,27 @@
typedef mitk::PointSet PointSetType;
typedef std::stack< std::string > ParseStack;
-
+
typedef std::list< PointSetType::Pointer > PointSetList;
-
+
typedef PointSetType::DataType::PointIdentifier PointIdentifier;
-
+
typedef PointSetType::PointType PointType;
/**
- * Handler function which is called, when a new xml start-tag
+ * Handler function which is called, when a new xml start-tag
* has been parsed.
*/
virtual void StartElement (const char *name, const char **atts);
-
+
/**
- * Handler function which is called, when a xml end-tag
+ * Handler function which is called, when a xml end-tag
* has been parsed.
*/
virtual void EndElement (const char *name);
-
+
/**
- * Handler function which is called, if characted data has been
+ * Handler function which is called, if characted data has been
* parsed by expat.
* @param inData a char array containing the parsed string data
* @param inLength the length of the parsed data string.
@@ -55,7 +55,7 @@
* @param inLength the length of the parsed data string.
*/
virtual void CharacterDataHandler (const char *inData, int inLength);
-
+
/**
* Converts the given data to mitk::ScalarType.
*/
@@ -60,7 +60,9 @@
* Converts the given data to mitk::ScalarType.
*/
virtual mitk::ScalarType ParseScalarType(const std::string &data);
-
+
+ virtual mitk::ScalarType ParseSize (const std::string &data);
+
/**
* Converts the given data to an PointIdentifier
*/
@@ -65,7 +67,7 @@
* Converts the given data to an PointIdentifier
*/
virtual PointIdentifier ParsePointIdentifier(const std::string &data);
-
+
/**
* @returns the list of point sets which have been read from file.
* NOTE: your have to call the Parse() function, before this function.
@@ -71,24 +73,24 @@
* NOTE: your have to call the Parse() function, before this function.
*/
virtual PointSetList GetParsedPointSets();
-
+
protected:
vtkPointSetXMLParser();
virtual ~vtkPointSetXMLParser();
-
+
/**
- * A stack containing the parsed start-tags.
+ * A stack containing the parsed start-tags.
* If an end tag is encountered, it is matched with the
- * top element of the stack.
+ * top element of the stack.
*/
ParseStack m_ParseStack;
-
+
/**
* Contains the parsed point sets.
*/
- PointSetList m_PointSetList;
-
- /**
+ PointSetList m_PointSetList;
+
+ /**
* The current point set which is processed
* by the parser.
*/
@@ -93,8 +95,8 @@
* by the parser.
*/
PointSetType::Pointer m_CurrentPointSet;
-
- /**
+
+ /**
* The current point which is processed
* by the parser.
*/
@@ -100,12 +102,12 @@
*/
PointType m_CurrentPoint;
- std::string m_CurId;
- std::string m_CurXString;
- std::string m_CurYString;
- std::string m_CurZString;
-
- /**
+ /**
+ * Time-Index
+ */
+ int m_TimeIndex;
+
+ /**
* The current point id which is processed
* by the parser.
*/
@@ -111,6 +113,6 @@
*/
PointIdentifier m_CurrentPointId;
-};
+};
}
#endif // _VTK_POINT_SET_XML_READER__H_
Index: mitk/Core/IO/mitkPointSetWriter.h
===================================================================
--- mitk/Core/IO/mitkPointSetWriter.h (revision 16063)
+++ mitk/Core/IO/mitkPointSetWriter.h (working copy)
@@ -27,10 +27,10 @@
{
/**
- * @brief XML-based writer for mitk::PointSets
+ * @brief XML-based writer for mitk::PointSets
*
* XML-based writer for mitk::PointSets. Multiple PointSets can be written in
- * a single XML file by simply setting multiple inputs to the filter.
+ * 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 Process
@@ -101,11 +101,11 @@
/**
* @param num the index of the desired output object.
- * @returns the n'th input object of the filter.
+ * @returns the n'th input object of the filter.
*/
PointSet* GetInput( const unsigned int& num );
-
+
/**
* @brief Return the possible file extensions for the data type associated with the writer
*/
@@ -117,7 +117,7 @@
virtual std::string GetFileExtension();
/**
- * @brief Check if the Writer can write the Content of the
+ * @brief Check if the Writer can write the Content of the
*/
virtual bool CanWriteDataType( DataTreeNode* );
@@ -135,7 +135,7 @@
* @returns whether the last write attempt was successful or not.
*/
bool GetSuccess() const;
-
+
protected:
/**
@@ -162,7 +162,7 @@
*/
virtual void ResizeInputs( const unsigned int& num );
-
+
/**
* Converts an arbitrary type to a string. The type has to
* support the << operator. This works fine at least for integral
@@ -172,9 +172,9 @@
*/
template < typename T>
std::string ConvertToString( T value );
-
+
/**
- * Writes an XML representation of the given point set to
+ * Writes an XML representation of the given point set to
* an outstream. The XML-Header an root node is not included!
* @param pointSet the point set to be converted to xml
* @param out the stream to write to.
@@ -186,7 +186,7 @@
* @param file the stream in which the header is written.
*/
void WriteXMLHeader( std::ofstream &file );
-
+
/** Write a start element tag */
void WriteStartElement( const char *const tag, std::ofstream &file );
@@ -224,29 +224,33 @@
unsigned int m_IndentDepth;
unsigned int m_Indent;
-
+
bool m_Success;
-
-
-
+
+
+
public:
static const char* XML_POINT_SET;
-
+
static const char* XML_POINT_SET_FILE;
-
+
static const char* XML_FILE_VERSION;
-
+
+ static const char* XML_TIME_SERIES;
+
+ static const char* XML_TIME_SERIES_ID;
+
static const char* XML_POINT;
-
+
static const char* XML_ID;
-
+
static const char* XML_X;
-
+
static const char* XML_Y;
-
+
static const char* XML_Z;
-
+
static const char* VERSION_STRING;
};

File Metadata

Mime Type
text/plain
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
131
Default Alt Text
mitk-source.patch (51 KB)

Event Timeline