36 #include "vtkImageData.h"
37 #include <vtkPointData.h>
38 #include <vtkUnsignedCharArray.h>
39 #include <vtkPolyData.h>
40 #include <vtkPolyDataMapper.h>
42 #include <vtkCellArray.h>
43 #include <vtkFloatArray.h>
44 #include <vtkProperty.h>
46 #include <vtkMatrix4x4.h>
67 mPolyData = vtkPolyDataPtr::New();
68 mActor = vtkActorPtr::New();
69 mPolyDataMapper = vtkPolyDataMapperPtr::New();
71 mPolyDataMapper->SetInputData(mPolyData);
72 mActor->SetMapper(mPolyDataMapper);
74 mProperty = vtkPropertyPtr::New();
75 mActor->SetProperty( mProperty );
76 mProperty->SetPointSize(4);
80 mPoints = vtkPointsPtr::New();
81 mLines = vtkCellArrayPtr::New();
83 mPolyData->SetPoints(mPoints);
84 mPolyData->SetLines(mLines);
85 mPolyData->SetVerts(mLines);
90 mSpaceListener = mSpaceProvider->createListener();
93 this->onSpaceChanged();
110 this->disconnectTool();
118 mPolyData->Modified();
121 void ToolTracer::connectTool()
123 if (mTool && mRunning)
125 connect(mTool.get(), SIGNAL(toolTransformAndTimestamp(
Transform3D,
double)),
this, SLOT(receiveTransforms(
Transform3D,
double)));
130 void ToolTracer::disconnectTool()
132 if (mTool && mRunning)
134 disconnect(mTool.get(), SIGNAL(toolTransformAndTimestamp(
Transform3D,
double)),
this, SLOT(receiveTransforms(
Transform3D,
double)));
141 mActor->GetProperty()->SetColor(color.redF(), color.greenF(), color.blueF());
146 this->disconnectTool();
161 void ToolTracer::onSpaceChanged()
165 mActor->SetUserMatrix(rMpr.getVtkMatrix());
173 void ToolTracer::receiveTransforms(
Transform3D prMt,
double timestamp)
181 if (mMinDistance > 0.0)
183 if (!mFirstPoint && (mPreviousPoint - p).
length() < mMinDistance)
191 mPoints->InsertNextPoint(p.begin());
193 if (mPoints->GetNumberOfPoints() > 1)
197 mLines->Initialize();
198 std::vector<vtkIdType> ids(mPoints->GetNumberOfPoints());
199 for (
unsigned i=0; i<ids.size(); ++i)
201 mLines->InsertNextCell(ids.size(), &(*ids.begin()));
203 mPolyData->Modified();
209 for(TimedTransformMap::iterator iter=trackerRecordedData_prMt.begin(); iter!=trackerRecordedData_prMt.end(); ++iter)
211 double timestamp = iter->first;
213 this->receiveTransforms(prMt, timestamp);
boost::shared_ptr< class SpaceProvider > SpaceProviderPtr
vtkSmartPointer< class vtkActor > vtkActorPtr
Transform3D Transform3D
Transform3D is a representation of an affine 3D transform.
boost::shared_ptr< class ToolTracer > ToolTracerPtr
vtkSmartPointer< class vtkPolyData > vtkPolyDataPtr
cxLogicManager_EXPORT SpaceProviderPtr spaceProvider()
Eigen::Vector3d Vector3D
Vector3D is a representation of a point or vector in 3D.
RealScalar length() const
static CoordinateSystem patientReference()
std::map< double, Transform3D > TimedTransformMap
boost::shared_ptr< class Tool > ToolPtr