00001 #ifndef FrameManager_h 00002 #define FrameManager_h 1 00003 00004 #ifdef _MSC_VER 00005 #pragma warning( disable : 4786 ) 00006 #endif 00007 #include "geometry\frame.h" 00008 #include <set> 00009 #include <vector> 00010 00011 class Matrix4x4; 00012 00013 class FrameManager 00014 { 00015 public: 00016 FrameManager (); 00017 FrameManager (const FrameManager& right); 00018 virtual ~FrameManager(); 00019 00020 // this operation creates a new frame and returns an index 00021 // to which frame this is in the overall frame manager. 00022 int AddFrame (); 00023 00024 // returns the total number of frames controlled by this 00025 // frame manager 00026 unsigned int GetNumberOfFrames () const; 00027 00028 // allows access to the tool frame 00029 Matrix4x4 GetToolFrame( const int index ) const; 00030 00031 // Marks a particular frame as a tool frame 00032 void MarkToolFrame( const int index ); 00033 00034 // returns a specific frame 00035 Frame operator [] (const unsigned int index) const; 00036 00037 // check this frame, and all its parents to see if there is 00038 // a path to the baseframe, frame 0. THis prevents 00039 // circular frame definitions and such. 00040 bool ValidateFrame (const unsigned int frame) const; 00041 00042 // returns a reference to a frame. THis is a fast way to 00043 // access the contents of a frame, but care must be taken 00044 // because a pointer is returned, and this pointer should 00045 // not be stored, because the memory it points to is 00046 // controlled by the frame manager 00047 Frame* GetFrameRef (const unsigned int number); 00048 00049 FrameManager& operator = (const FrameManager& right); 00050 00051 // returns the transformation matrix relating frame a, and b 00052 Matrix4x4 GetTransformRelative (const unsigned int frame, const unsigned int base) const; 00053 static Matrix4x4 GetTransformRelative (const Matrix4x4& frame, const Matrix4x4& base ); 00054 00055 // returns the base frame of the frame in question. 00056 unsigned int BaseFrame (const unsigned int frame) const; 00057 00058 // Alters the base frame of the frame in question. 00059 void SetBaseFrame (const unsigned int frame, const unsigned int baseFrame); 00060 00061 void Clear (); 00062 00063 // mark this frame, and all frames that depend on it as 00064 // having changed, and the cached frames will need 00065 // recomputing. 00066 void MarkFrameChanged (unsigned int frameNum); 00067 00068 Frame GetFrame (const unsigned int frameNum) const; 00069 00070 // Returns the transformation between frame0 and this 00071 // frame. This is a highly optimized, caching operation. 00072 Matrix4x4 GetWorldFrame (const unsigned int frameNum) const; 00073 00074 // Marks all the frames in the frame manager as having 00075 // changed. 00076 void MarkAllFramesChanged (); 00077 00078 // Data Members for Associations 00079 00080 std::vector<Frame> allFrames; 00081 mutable std::vector< Matrix4x4 > allWorldFrames; 00082 00083 // Additional Public Declarations 00084 00085 protected: 00086 // Additional Protected Declarations 00087 00088 private: 00089 // Data Members for Class Attributes 00090 00091 mutable std::vector< bool > worldFrameValid; 00092 std::set< int > m_ToolFrames; 00093 00094 // Additional Private Declarations 00095 00096 private: 00097 // Additional Implementation Declarations 00098 00099 }; 00100 00101 // Class FrameManager 00102 00103 #endif