IGSTK
igstkPivotCalibrationAlgorithm.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Image Guided Surgery Software Toolkit
4  Module: $RCSfile: igstkPivotCalibrationAlgorithm.h,v $
5  Language: C++
6  Date: $Date: 2009-07-05 19:53:19 $
7  Version: $Revision: 1.5 $
8 
9  Copyright (c) ISC Insight Software Consortium. All rights reserved.
10  See IGSTKCopyright.txt or http://www.igstk.org/copyright.htm for details.
11 
12  This software is distributed WITHOUT ANY WARRANTY; without even
13  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14  PURPOSE. See the above copyright notices for more information.
15 
16 =========================================================================*/
17 
18 #ifndef __igstkPivotCalibrationAlgorithm_h
19 #define __igstkPivotCalibrationAlgorithm_h
20 
21 #include <vector>
22 #include "igstkStateMachine.h"
23 #include "igstkMacros.h"
24 #include "igstkObject.h"
25 #include "igstkTransform.h"
26 
27 namespace igstk
28 {
29 
69 class PivotCalibrationAlgorithm : public Object
70 {
71 
72 public:
73 
76  igstkStandardClassTraitsMacro( PivotCalibrationAlgorithm, Object )
77 
78  typedef itk::Point< double, 3 > PointType;
79  typedef igstk::Transform TransformType;
80  typedef std::vector<TransformType> TransformContainerType;
81 
87  void RequestAddTransform( const TransformType & t );
88 
94  void RequestAddTransforms( std::vector< TransformType > & t );
95 
98  void RequestResetCalibration();
99 
107  void RequestComputeCalibration();
108 
114  void RequestCalibrationTransform();
115 
120  void RequestPivotPoint();
121 
128  void RequestCalibrationRMSE();
129 
137  void RequestSetSingularValueThreshold( double threshold );
138 
140  igstkEventMacro( CalibrationFailureEvent, IGSTKEvent );
141 
143  igstkEventMacro( CalibrationSuccessEvent, IGSTKEvent );
144 
147  static const double DEFAULT_SINGULAR_VALUE_THRESHOLD;
148 
149 protected:
150 
151  PivotCalibrationAlgorithm ( void );
152  virtual ~PivotCalibrationAlgorithm ( void );
153 
155  void PrintSelf( std::ostream& os, itk::Indent indent ) const;
156 
157 private:
158 
161  bool CheckCalibrationDataValidity();
162 
164  igstkDeclareStateMacro( Idle );
165  igstkDeclareStateMacro( AttemptingToComputeCalibration );
166  igstkDeclareStateMacro( CalibrationComputed );
167 
169  igstkDeclareInputMacro( AddTransform );
170  igstkDeclareInputMacro( SetSingularValueThreshold );
171  igstkDeclareInputMacro( ComputeCalibration );
172  igstkDeclareInputMacro( GetTransform );
173  igstkDeclareInputMacro( GetPivotPoint );
174  igstkDeclareInputMacro( GetRMSE );
175  igstkDeclareInputMacro( ResetCalibration );
176  igstkDeclareInputMacro( CalibrationComputationSuccess );
177  igstkDeclareInputMacro( CalibrationComputationFailure );
178 
180  void ReportInvalidRequestProcessing();
181  void AddTransformProcessing();
182  void SetSingularValueThresholdProcessing();
183  void ComputeCalibrationProcessing();
184  void ResetCalibrationProcessing();
185  void ReportSuccessInCalibrationComputationProcessing();
186  void ReportFailureInCalibrationComputationProcessing();
187  void GetTransformProcessing();
188  void GetPivotPointProcessing();
189  void GetRMSEProcessing();
190 
191  //transformations used for pivot calibration
192  TransformContainerType m_Transforms;
193  //transformations the user wants to add, because of the way the
194  //state machine works we need to first store them in
195  //a temporary variable. They will be moved to the m_Transforms
196  //container only if the state machine is in a state that
197  //enables adding transformations
198  TransformContainerType m_TmpTransforms;
199 
200  //computed translation between tracked coordinate system and pivot
201  //point
202  TransformType m_Transform;
203 
204  //computed pivot point in the tracker's coordinate system
205  itk::Point< double,3 > m_PivotPoint;
206 
207  //root mean squared error of the vector [Ax-b]
208  double m_RMSE;
209 
210  //below this threshold the singular values of SVD(A) are set to zero
211  double m_SingularValueThreshold;
212  double m_TmpSingularValueThreshold;
213 
214 };
215 
216 } // end namespace igstk
217 
218 #endif //__igstkPivotCalibrationAlgorithm_h
igstkEventMacro(AuroraTrackerToolEvent, StringEvent)
#define igstkStandardClassTraitsMacro(classname, superclassname)
Convenience macro for traits of a non-templated class.
Definition: igstkMacros.h:275
#define igstkDeclareInputMacro(inputname)
Convenience macro for declaring Inputs to the State Machine.
Definition: igstkMacros.h:223
defines standard system-wide macros, constants, and other common parameters in the IGSTK Library...
itk::Point< double, 3 > PointType
Definition: igstkEvents.h:59
#define igstkDeclareStateMacro(inputname)
Convenience macro for declaring States of the State Machine.
Definition: igstkMacros.h:228