00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef __igstkCoordinateSystem_h
00019 #define __igstkCoordinateSystem_h
00020
00021 #include "igstkObject.h"
00022 #include "igstkStateMachine.h"
00023 #include "igstkTransform.h"
00024 #include "itkTimeProbe.h"
00025
00026 namespace igstk
00027 {
00028
00053 class CoordinateSystem;
00054
00055 namespace Friends
00056 {
00057
00068 class CoordinateSystemHelper
00069 {
00070 public:
00075 template <class T>
00076 static const CoordinateSystem*
00077 GetCoordinateSystem( const T & input )
00078 {
00079 return input->GetCoordinateSystem();
00080 }
00081 };
00082
00083 }
00084
00085
00086 class CoordinateSystem : public Object
00087 {
00088 public:
00089
00091 igstkStandardClassTraitsMacro( CoordinateSystem, Object )
00092
00093
00097 void RequestSetTransformAndParent(const Transform & t,
00098 const CoordinateSystem* parent);
00099
00100
00101 void RequestUpdateTransformToParent(const Transform & t);
00102
00104 void RequestGetTransformToParent();
00105
00116 void RequestComputeTransformTo(const
00117 CoordinateSystem* targetCoordSys);
00118
00121 void RequestDetachFromParent();
00122
00127 igstkSetStringMacro( Name );
00128 igstkGetStringMacro( Name );
00129
00130 protected:
00131
00133 CoordinateSystem( void );
00134
00136 ~CoordinateSystem( void );
00137
00139 virtual void PrintSelf( std::ostream& os, itk::Indent indent ) const;
00140
00141 private:
00143 CoordinateSystem(const Self&);
00144
00146 void operator=(const Self&);
00147
00149 Self::ConstPointer m_Parent;
00150
00155 Transform m_TransformToParent;
00156
00158 std::string m_Name;
00159
00165 igstkDeclareStateMacro( Initialized );
00166
00168 igstkDeclareStateMacro( ParentSet );
00169
00171 igstkDeclareStateMacro( AttemptingComputeTransformTo );
00172 igstkDeclareStateMacro( AttemptingComputeTransformToInInitialized );
00173
00179 igstkDeclareInputMacro( NullCoordinateSystem );
00180 igstkDeclareInputMacro( ThisCoordinateSystem );
00181 igstkDeclareInputMacro( ValidCoordinateSystem );
00182
00184 igstkDeclareInputMacro( NullParent );
00185 igstkDeclareInputMacro( ThisParent );
00186 igstkDeclareInputMacro( ValidParent );
00187 igstkDeclareInputMacro( ParentCausesCycle );
00188
00192 igstkDeclareInputMacro( AncestorFound );
00193 igstkDeclareInputMacro( Disconnected );
00194
00197 igstkDeclareInputMacro( DetachFromParent );
00198
00201 igstkDeclareInputMacro( UpdateTransformToParent );
00202
00206 Transform m_TransformFromRequestSetTransformAndParent;
00207 Self::ConstPointer m_ParentFromRequestSetTransformAndParent;
00208
00210 void SetTransformAndParentNullParentProcessing();
00211
00213 void SetTransformAndParentThisParentProcessing();
00214
00218 void SetTransformAndParentCycleProcessing();
00219
00221 void SetTransformAndParentProcessing();
00222
00224 void UpdateTransformToParentProcessing();
00225
00230 Self::ConstPointer m_TargetFromRequestComputeTransformTo;
00231
00235 void ComputeTransformToThisTargetProcessing();
00236
00240 void ComputeTransformToNullTargetProcessing();
00241
00245 void ComputeTransformToValidTargetProcessing();
00246
00250 void ComputeTransformToDisconnectedProcessing();
00251
00256 void ComputeTransformToAncestorFoundProcessing();
00257
00263 void FindLowestCommonAncestor(const Self* targetCoordinateSystem);
00264
00271 Self::ConstPointer m_LowestCommonAncestor;
00272
00277 Transform ComputeTransformTo(const CoordinateSystem* ancestor) const;
00278
00283 bool CanReach(const CoordinateSystem* target) const;
00284
00288 void InvalidRequestProcessing();
00289
00291 void DoNothingProcessing();
00292
00294 void DetachFromParentProcessing();
00295
00299 const CoordinateSystem* GetCoordinateSystem() const;
00300
00302 igstkFriendClassMacro( igstk::Friends::CoordinateSystemHelper );
00303
00304 };
00305
00306
00307
00308
00309
00310 igstkEventMacro( CoordinateSystemErrorEvent, IGSTKErrorEvent );
00311 igstkEventMacro( CoordinateSystemSetParentError, CoordinateSystemErrorEvent );
00312
00316 igstkEventMacro( CoordinateSystemNullParentEvent,
00317 CoordinateSystemSetParentError );
00318
00322 igstkEventMacro( CoordinateSystemThisParentEvent,
00323 CoordinateSystemSetParentError );
00324
00328 igstkLoadedConstObjectEventMacro( CoordinateSystemParentCycleEvent,
00329 CoordinateSystemSetParentError,
00330 CoordinateSystem );
00331
00332 }
00333
00334 #endif // __igstkCoordinateSystem_h