7 #include "PlusConfigure.h" 9 #include "vtkObjectFactory.h" 10 #include "vtkTransform.h" 12 #include "vtkDoubleArray.h" 16 #include "vtkIGSIOTransformRepository.h" 17 #include "vtkIGSIOTrackedFrameList.h" 18 #include "igsioTrackedFrame.h" 20 #include "vtkXMLDataElement.h" 21 #include "vtkXMLUtilities.h" 45 this->Superclass::PrintSelf(os, indent);
67 LOG_ERROR(
"Tracker input data verification failed: no tracker data is set");
73 LOG_ERROR(
"Tracker input data verification failed: tracker data set is empty");
82 vtkSmartPointer<vtkIGSIOTransformRepository> transformRepository = vtkSmartPointer<vtkIGSIOTransformRepository>::New();
84 vtkSmartPointer<vtkMatrix4x4> pivotToReferenceTransform = vtkSmartPointer<vtkMatrix4x4>::New();
86 itk::Point<double, 3> stylusTip;
87 stylusTip[0] = stylusTip[1] = stylusTip[2] = 0.0;
88 itk::Point<double, 3> zeroRef;
89 zeroRef[0] = zeroRef[1] = zeroRef[2] = 0.0;
97 itk::Point<double, 3> trackerPositionSum;
98 trackerPositionSum[0] = trackerPositionSum[1] = trackerPositionSum[2] = 0.0;
100 std::deque< itk::Point<double, 3> > trackerPositions;
101 int numberOfValidFrames = 0;
103 double previousStylusTipPosition = 0.0;
104 for (
unsigned int frame = 0; frame <
m_TrackerFrames->GetNumberOfTrackedFrames(); ++frame)
106 igsioTrackedFrame* trackedFrame =
m_TrackerFrames->GetTrackedFrame(frame);
114 transformRepository->SetTransforms(*trackedFrame);
116 vtkSmartPointer<vtkMatrix4x4> probeToReferenceTransform = vtkSmartPointer<vtkMatrix4x4>::New();
117 ToolStatus toolStatus(TOOL_INVALID);
118 transformRepository->GetTransform(transformName, probeToReferenceTransform, &toolStatus);
119 if (toolStatus != TOOL_OK)
122 LOG_INFO(
"There is no available transform for this frame; skip frame " << trackedFrame->GetTimestamp() <<
" [s]")
127 itk::Point<double, 3> currTrackerPosition;
128 currTrackerPosition[0] = probeToReferenceTransform->GetElement(0, 3);
129 currTrackerPosition[1] = probeToReferenceTransform->GetElement(1, 3);
130 currTrackerPosition[2] = probeToReferenceTransform->GetElement(2, 3);
131 trackerPositions.push_back(currTrackerPosition);
134 trackerPositionSum[0] = trackerPositionSum[0] + probeToReferenceTransform->GetElement(0, 3);
135 trackerPositionSum[1] = trackerPositionSum[1] + probeToReferenceTransform->GetElement(1, 3);
136 trackerPositionSum[2] = trackerPositionSum[2] + probeToReferenceTransform->GetElement(2, 3);
137 ++numberOfValidFrames;
143 stylusTip[0] = pivotToReferenceTransform->GetElement(0, 3);
144 stylusTip[1] = pivotToReferenceTransform->GetElement(1, 3);
145 stylusTip[2] = pivotToReferenceTransform->GetElement(2, 3);
149 previousStylusTipPosition = stylusTip.EuclideanDistanceTo(zeroRef);
158 XML_FIND_NESTED_ELEMENT_REQUIRED(pivotCalibrationElement, aConfig,
"vtkPlusPivotCalibrationAlgo");
163 vtkSmartPointer<vtkIGSIOTransformRepository> transformRepositoryCalibration = vtkSmartPointer<vtkIGSIOTransformRepository>::New();
165 if (transformRepositoryCalibration->ReadConfiguration(aConfig) !=
PLUS_SUCCESS)
167 LOG_ERROR(
"Failed to read CoordinateDefinitions!");
173 if (transformRepositoryCalibration->GetTransform(StylusTipToStylusTransformName, this->StylusTipToStylusTransform) !=
PLUS_SUCCESS)
175 LOG_ERROR(
"Failed to read StylusTipToStylu Coordinate Definition!");
char * ReferenceCoordinateFrame
char * ObjectMarkerCoordinateFrame
std::deque< double > m_SignalStylusRef
double m_SignalTimeRangeMin
std::deque< double > m_SignalStylusTipSpeed
virtual ~vtkPlusReadTrackedSignals()
vtkPlusReadTrackedSignals()
PlusStatus ReadConfiguration(vtkXMLDataElement *aConfig)
vtkStandardNewMacro(vtkPlusReadTrackedSignals)
vtkSmartPointer< vtkMatrix4x4 > StylusTipToStylusTransform
vtkIGSIOTrackedFrameList * m_TrackerFrames
void SetTrackerFrames(vtkIGSIOTrackedFrameList *trackerFrames)
void GetTimestamps(std::deque< double > ×tamps)
std::deque< double > m_SignalTimestamps
PlusStatus VerifyInputFrames()
virtual void PrintSelf(ostream &os, vtkIndent indent) VTK_OVERRIDE
PlusStatus ComputeTrackerPositionMetric()
char * ObjectPivotPointCoordinateFrame
Extract the motion component along the the principal axis of the motion. Used for computing a positio...
std::deque< double > m_SignalStylusTipRef
void GetSignalStylusRef(std::deque< double > &signalComponent)
void GetSignalStylusTipSpeed(std::deque< double > &signalComponent)
void GetSignalStylusTipRef(std::deque< double > &signalComponent)
void SetSignalTimeRange(double rangeMin, double rangeMax)
double m_SignalTimeRangeMax