37 #include "vtkObjectFactory.h"
38 #include "vtkPolyLine.h"
39 #include "vtkCellArray.h"
40 #include "vtkPolyData.h"
41 #include "vtkIntArray.h"
42 #include "vtkDoubleArray.h"
43 #include "vtkPointData.h"
66 vtkSmartPointer< vtkPolyData >
69 std::stringstream str(iString);
78 std::map< unsigned int, double * > orderedPoints =
GetMap(iString);
80 vtkSmartPointer< vtkIntArray > temporalArray = vtkSmartPointer< vtkIntArray >::New();
81 temporalArray->SetNumberOfComponents(1);
82 temporalArray->SetName(
"TemporalInformation");
85 vtkSmartPointer< vtkPoints > points = vtkSmartPointer< vtkPoints >::New();
86 std::map< unsigned int, double * >::iterator it = orderedPoints.begin();
88 while ( it != orderedPoints.end() )
90 temporalArray->InsertNextValue(it->first);
91 points->InsertNextPoint(it->second);
96 it = orderedPoints.begin();
97 while ( it != orderedPoints.end() )
102 orderedPoints.clear();
105 vtkSmartPointer< vtkPolyLine > polyLine =
106 vtkSmartPointer< vtkPolyLine >::New();
108 polyLine->GetPointIds()->SetNumberOfIds( points->GetNumberOfPoints() );
109 for ( vtkIdType i = 0; i < points->GetNumberOfPoints(); i++ )
111 polyLine->GetPointIds()->SetId(i, i);
115 vtkSmartPointer< vtkCellArray > cells =
116 vtkSmartPointer< vtkCellArray >::New();
117 cells->InsertNextCell(polyLine);
120 vtkSmartPointer< vtkPolyData > polyData =
121 vtkSmartPointer< vtkPolyData >::New();
124 polyData->SetPoints(points);
127 polyData->SetLines(cells);
130 polyData->GetPointData()->AddArray(temporalArray);
132 vtkSmartPointer< vtkDoubleArray > speedArray =
133 vtkSmartPointer< vtkDoubleArray >::New();
134 speedArray->SetNumberOfComponents(1);
135 speedArray->SetName(
"SpeedInformation");
136 polyData->GetPointData()->AddArray(speedArray);
147 std::map< unsigned int, double * >
150 std::stringstream str(iString);
152 std::map< unsigned int, double * > orderedPoints;
161 unsigned int time = 0;
164 for ( vtkIdType i = 0; i < N; i++ )
167 str >> pt[0] >> pt[1] >> pt[2];
169 orderedPoints.insert( std::pair< unsigned int, double * >(time, pt) );
172 return orderedPoints;
vtkSmartPointer< vtkPolyData > GetPolyData(const std::string &iString)
Reads a string and convert it into a track polydata.
vtkCxxRevisionMacro(vtkPolyDataMySQLTrackReader,"$Revision$")
vtkPolyDataMySQLTrackReader()
std::map< unsigned int, double * > GetMap(const std::string &iString)
vtkStandardNewMacro(vtkPolyDataMySQLTrackReader)
virtual ~vtkPolyDataMySQLTrackReader()