CoordinateSystem.h
Go to the documentation of this file.
1 
22 #ifndef _utl_CoordinateSystem_h_
23 #define _utl_CoordinateSystem_h_
24 
25 #include <utl/CoordinateSystemPtr.h>
26 #include <utl/TransformationMatrix.h>
27 #include <utl/TransformerConstructor.h>
28 #include <utl/GeometryException.h>
29 #ifdef OFFLINE_GEOMETRY_IS_COUNTED
30 # include <utl/CountedObject.h>
31 #endif
32 
33 #include <boost/enable_shared_from_this.hpp>
34 #include <boost/weak_ptr.hpp>
35 
36 
37 namespace io {
38  class CoordinateSystem_ROOT;
39 }
40 
41 
42 namespace utl {
43 
44  inline
45  void
46  CoordinateSystemValid(const CoordinateSystemPtr& theCoordinateSystem)
47  {
48  if (!theCoordinateSystem)
49  throw CoordinateSystemException("nullptr coordinate system pointer;");
50  }
51 
52 
81  class CoordinateTransformer : public boost::enable_shared_from_this<CoordinateTransformer> {
82  protected:
83  typedef boost::weak_ptr<const CoordinateTransformer> WeakCoordinateSystemPtr;
84 
85  public:
96 
97  // Getters
104 
107  { return fTransformation; }
108 
110  const TransformationMatrix&
111  GetTransformationTo(const CoordinateSystemPtr& target) const;
112 
114  const TransformationMatrix&
115  GetInverseTransformationTo(const CoordinateSystemPtr& target) const;
116 
118  virtual CoordinateSystemPtr GetReferenceForNewCS() const = 0;
119 
121  virtual TransformationMatrix
122  GetTransformationForNewCS(const TransformationMatrix& theTransformation) const = 0;
123 
125 
126  protected:
127  // Default constructor - used only to construct the root CS
129 
130  CoordinateTransformer(const TransformationMatrix& theTransformation,
131  const CoordinateSystemPtr& theReferenceCS);
132 
133  virtual ~CoordinateTransformer();
134 
137 
138  private:
139  // Copy constructor private and not implemented
141 
142  // Assignement private and not implemented
144 
146  FindCommonBase(const CoordinateSystemPtr& other) const;
147 
149  CollectTransformationFrom(const CoordinateSystemPtr& target) const;
150 
159 
162 
163  // for the transformation cache
167 
170  };
171 
172 
189 #ifdef OFFLINE_GEOMETRY_IS_COUNTED
190  , private CountedObject<DerivedCSPolicy>
191 #endif
192  {
193  protected:
195 
196  DerivedCSPolicy(const TransformationMatrix& theTransformation,
197  const CoordinateSystemPtr& theReferenceCS)
198  : CoordinateTransformer(theTransformation, theReferenceCS)
199  { }
200 
203 
204  virtual TransformationMatrix
205  GetTransformationForNewCS(const TransformationMatrix& theTransformation) const;
206 
208  static type FromTransformation(const TransformationMatrix& theTrafo,
209  const CoordinateSystemPtr& theCS);
210 
212  };
213 
214 
231 #ifdef OFFLINE_GEOMETRY_IS_COUNTED
232  , private CountedObject<BaseCSPolicy>
233 #endif
234  {
235  friend class CoordinateTransformer;
236 
237  protected:
239 
240  BaseCSPolicy(const TransformationMatrix& theTransformation,
241  const CoordinateSystemPtr& theReferenceCS)
242  : CoordinateTransformer(theTransformation, theReferenceCS)
243  { }
244 
247 
248  virtual TransformationMatrix
249  GetTransformationForNewCS(const TransformationMatrix& theTransformation) const;
250 
252  static type FromTransformation(const TransformationMatrix& theTrafo,
253  const CoordinateSystemPtr& theCS);
254  };
255 
256 
262 
265 
266 }
267 
268 
269 #endif
DerivedCSPolicy(const TransformationMatrix &theTransformation, const CoordinateSystemPtr &theReferenceCS)
CoordinateSystemPtr fReferenceSystem
The base system - 0 for default base.
TransformationMatrix CollectTransformationFrom(const CoordinateSystemPtr &target) const
Policy for base coordinate systems.
CoordinateSystemPtr FindCommonBase(const CoordinateSystemPtr &other) const
Constructors for Transformer classes.
TransformationMatrix * fLastInverseTransformation
CoordinateTransformer & operator=(const CoordinateTransformer &theSystem)
BaseCSPolicy(const TransformationMatrix &theTransformation, const CoordinateSystemPtr &theReferenceCS)
WeakCoordinateSystemPtr fLastTarget
TransformerConstructor< BaseCSPolicy > BaseCoordinateSystem
For base coordinate systems.
TransformerConstructor< DerivedCSPolicy > CoordinateSystem
The normal coordinate system type.
ROOT streamer implementation for utl::CoordinateSystem.
const TransformationMatrix & GetTransformation() const
Get the transformation matrix relative to reference system.
virtual CoordinateSystemPtr GetReferenceForNewCS() const
Get reference system for the creation of new coordinate systems.
Transformations matrices for afine transformations.
boost::shared_ptr< const CoordinateTransformer > CoordinateSystemPtr
Shared pointer for coordinate systems.
CoordinateSystemPtr type
Type to use to hold objects of this type.
static CoordinateSystemPtr RootCoordinateSystem
The root coordinate system - the unique, ultimate reference system.
const TransformationMatrix & GetTransformationTo(const CoordinateSystemPtr &target) const
Get the transformation to other coordinate system (with caching)
CoordinateSystemPtr GetReferenceSystem() const
Get the reference system for this coordinate system.
Bottom part of Coordinate system class.
static type FromTransformation(const TransformationMatrix &theTrafo, const CoordinateSystemPtr &theCS)
Generic factory for post-processing.
boost::weak_ptr< const CoordinateTransformer > WeakCoordinateSystemPtr
static CoordinateSystemPtr GetRootCoordinateSystem()
const TransformationMatrix & GetInverseTransformationTo(const CoordinateSystemPtr &target) const
Get the inverse transformation to other coordinate system (w/ caching)
virtual TransformationMatrix GetTransformationForNewCS(const TransformationMatrix &theTransformation) const
Calculate the correct transformation for the new CS.
virtual CoordinateSystemPtr GetReferenceForNewCS() const =0
Get reference system for the creation of new coordinate systems.
CoordinateSystemPtr GetThis() const
Get a CoordinateSystemPointer for this.
TransformationMatrix * fLastTransformation
virtual CoordinateSystemPtr GetReferenceForNewCS() const
Get reference system for the creation of new coordinate systems.
Exception dealing with coordinate systems.
Policy for derived coordinate systems.
void CoordinateSystemValid(const CoordinateSystemPtr &theCoordinateSystem)
virtual TransformationMatrix GetTransformationForNewCS(const TransformationMatrix &theTransformation) const
Calculate the correct transformation for the new CS.
static type FromTransformation(const TransformationMatrix &theTrafo, const CoordinateSystemPtr &theCS)
Generic factory for post-processing.
Mix-in class for counting creation and destruction of objects.
Definition: CountedObject.h:30
virtual TransformationMatrix GetTransformationForNewCS(const TransformationMatrix &theTransformation) const =0
Calculate the correct transformation for the new CS.
TransformationMatrix fTransformation
Transformation of the components of a vector or point.

, generated on Tue Sep 26 2023.