IGSTK
igstkCoordinateSystem.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Image Guided Surgery Software Toolkit
4  Module: $RCSfile: igstkCoordinateSystem.h,v $
5  Language: C++
6  Date: $Date: 2009-02-02 17:32:03 $
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 __igstkCoordinateSystem_h
19 #define __igstkCoordinateSystem_h
20 
21 #include "igstkObject.h"
22 #include "igstkStateMachine.h"
23 #include "igstkTransform.h"
24 
25 namespace igstk
26 {
27 
52 class CoordinateSystem;
53 
54 namespace Friends
55 {
56 
68 {
69 public:
74  template <class T>
75  static const CoordinateSystem*
76  GetCoordinateSystem( const T & input )
77  {
78  return input->GetCoordinateSystem(); // private
79  }
80 };
81 
82 } // end of Friends namespace
83 
84 
85 class CoordinateSystem : public Object
86 {
87 public:
88 
91 
92 
96  void RequestSetTransformAndParent(const Transform & t,
98 
99  // Tries to update the transform to its parents
101 
104 
115  void RequestComputeTransformTo(const
116  CoordinateSystem* targetCoordSys);
117 
121 
126  igstkSetStringMacro( Name );
127  igstkGetStringMacro( Name );
128 
130  igstkSetStringMacro( Type );
131  igstkGetStringMacro( Type );
132 
133 protected:
134 
136  CoordinateSystem( void );
137 
139  ~CoordinateSystem( void );
140 
142  virtual void PrintSelf( std::ostream& os, itk::Indent indent ) const;
143 
144 private:
146  CoordinateSystem(const Self&);
147 
149  void operator=(const Self&);
150 
152  Self::ConstPointer m_Parent;
153 
158  Transform m_TransformToParent;
159 
161  std::string m_Name;
162 
164  std::string m_Type;
165 
171  igstkDeclareStateMacro( Initialized );
172 
174  igstkDeclareStateMacro( ParentSet );
175 
177  igstkDeclareStateMacro( AttemptingComputeTransformTo );
178  igstkDeclareStateMacro( AttemptingComputeTransformToInInitialized );
179 
185  igstkDeclareInputMacro( NullCoordinateSystem );
186  igstkDeclareInputMacro( ThisCoordinateSystem );
187  igstkDeclareInputMacro( ValidCoordinateSystem );
188 
190  igstkDeclareInputMacro( NullParent );
191  igstkDeclareInputMacro( ThisParent );
192  igstkDeclareInputMacro( ValidParent );
193  igstkDeclareInputMacro( ParentCausesCycle );
194 
198  igstkDeclareInputMacro( AncestorFound );
199  igstkDeclareInputMacro( Disconnected );
200 
203  igstkDeclareInputMacro( DetachFromParent );
204 
206  igstkDeclareInputMacro( UpdateTransformToParent );
207 
211  Transform m_TransformFromRequestSetTransformAndParent;
212  Self::ConstPointer m_ParentFromRequestSetTransformAndParent;
213 
215  void SetTransformAndParentNullParentProcessing();
216 
218  void SetTransformAndParentThisParentProcessing();
219 
223  void SetTransformAndParentCycleProcessing();
224 
226  void SetTransformAndParentProcessing();
227 
229  void UpdateTransformToParentProcessing();
230 
235  Self::ConstPointer m_TargetFromRequestComputeTransformTo;
236 
240  void ComputeTransformToThisTargetProcessing();
241 
245  void ComputeTransformToNullTargetProcessing();
246 
250  void ComputeTransformToValidTargetProcessing();
251 
255  void ComputeTransformToDisconnectedProcessing();
256 
261  void ComputeTransformToAncestorFoundProcessing();
262 
268  void FindLowestCommonAncestor(const Self* targetCoordinateSystem);
269 
276  Self::ConstPointer m_LowestCommonAncestor;
277 
282  Transform ComputeTransformTo(const CoordinateSystem* ancestor) const;
283 
288  bool CanReach(const CoordinateSystem* target) const;
289 
293  void InvalidRequestProcessing();
294 
296  void DoNothingProcessing();
297 
299  void DetachFromParentProcessing();
300 
304  const CoordinateSystem* GetCoordinateSystem() const;
305 
308 
309 }; // class CoordinateSystem
310 
311 
312 //
313 // Macros defining events related to the CoordinateSystem.
314 //
315 igstkEventMacro( CoordinateSystemErrorEvent, IGSTKErrorEvent );
316 igstkEventMacro( CoordinateSystemSetParentError, CoordinateSystemErrorEvent );
317 
321 igstkEventMacro( CoordinateSystemNullParentEvent,
322  CoordinateSystemSetParentError );
323 
327 igstkEventMacro( CoordinateSystemThisParentEvent,
328  CoordinateSystemSetParentError );
329 
333 igstkLoadedConstObjectEventMacro( CoordinateSystemParentCycleEvent,
334  CoordinateSystemSetParentError,
336 
337 } // end namespace igstk
338 
339 #endif // __igstkCoordinateSystem_h
void RequestUpdateTransformToParent(const Transform &t)
CoordinateSystem(void)
Constructor.
#define igstkFriendClassMacro(type)
Create a Macro for friend class.
Definition: igstkMacros.h:137
static const CoordinateSystem * GetCoordinateSystem(const T &input)
Templated method to extract the CoordinateSystem from a holder class.
void RequestComputeTransformTo(const CoordinateSystem *targetCoordSys)
Request that a transform is computed to targetCoordSys This method generates three possible events: C...
Base class for all the IGSTK classes.
Definition: igstkObject.h:40
virtual void PrintSelf(std::ostream &os, itk::Indent indent) const
Print object information.
igstkEventMacro(AuroraTrackerToolEvent, StringEvent)
A proxy that ensures the encapsulation of the CoordinateSystem.
void RequestDetachFromParent()
Request that the coordinate system be detached from its parent.
igstkStandardClassTraitsMacro(CoordinateSystem, Object) void RequestSetTransformAndParent(const Transform &t
Macro with standard traits declarations.
igstkLoadedConstObjectEventMacro(CoordinateSystemParentCycleEvent, CoordinateSystemSetParentError, CoordinateSystem)
This event should be invoked when RequestSetTransformAndParent is called with a parent that causes a ...
void RequestGetTransformToParent()
Request the transform to parent.
~CoordinateSystem(void)
Destructor.
const CoordinateSystem * parent
A class representing a 3D Rigid transform.
igstkSetStringMacro(Name)
Coordinate systems have a name to facilitate future export of the scene graph as a diagram...
This class represents the frame of a coordinate reference system.
::itk::SmartPointer< const Self > ConstPointer
Definition: igstkObject.h:51