aimsdata  5.1.2
Neuroimaging data handling
affinetransformation3d.h
Go to the documentation of this file.
1 /* This software and supporting documentation are distributed by
2  * Institut Federatif de Recherche 49
3  * CEA/NeuroSpin, Batiment 145,
4  * 91191 Gif-sur-Yvette cedex
5  * France
6  *
7  * This software is governed by the CeCILL-B license under
8  * French law and abiding by the rules of distribution of free software.
9  * You can use, modify and/or redistribute the software under the
10  * terms of the CeCILL-B license as circulated by CEA, CNRS
11  * and INRIA at the following URL "http://www.cecill.info".
12  *
13  * As a counterpart to the access to the source code and rights to copy,
14  * modify and redistribute granted by the license, users are provided only
15  * with a limited warranty and the software's author, the holder of the
16  * economic rights, and the successive licensors have only limited
17  * liability.
18  *
19  * In this respect, the user's attention is drawn to the risks associated
20  * with loading, using, modifying and/or developing or reproducing the
21  * software by the user in light of its specific status of free software,
22  * that may mean that it is complicated to manipulate, and that also
23  * therefore means that it is reserved for developers and experienced
24  * professionals having in-depth computer knowledge. Users are therefore
25  * encouraged to load and test the software's suitability as regards their
26  * requirements in conditions enabling the security of their systems and/or
27  * data to be ensured and, more generally, to use and operate it in the
28  * same conditions as regards security.
29  *
30  * The fact that you are presently reading this means that you have had
31  * knowledge of the CeCILL-B license and that you accept its terms.
32  */
33 
34 /*
35  * Non elastic AffineTransformation3d ( rotation + translation )
36  */
37 #ifndef AIMS_TRANSFORMATION_AFFINETRANSFORMATION3D_H
38 #define AIMS_TRANSFORMATION_AFFINETRANSFORMATION3D_H
39 
43 #include <iosfwd>
44 
45 namespace aims
46 {
47  class AffineTransformation3d;
48  class PythonHeader;
49  class Quaternion;
50 
53  const Point3df & pmin1, const Point3df & pmax1, Point3df & pmin2,
54  Point3df & pmax2 );
55 
56  //---------------------------------------------------------------------------
57 
58  //--------------------------//
59  // AffineTransformation3d //
60  //--------------------------//
61  //--------------------------------------------------------------------------
148  {
149  public:
150 
156  explicit AffineTransformation3d( const std::vector<float> & mat );
158  explicit AffineTransformation3d( const carto::Object mat );
161  virtual AffineTransformation3d &
163  virtual AffineTransformation3d &
164  operator = ( const std::vector<float> & mat );
165  virtual AffineTransformation3d &
167  virtual AffineTransformation3d &
168  operator = ( const aims::Quaternion & quat );
169 
170  virtual bool operator == ( const AffineTransformation3d & ) const;
171  virtual bool operator != ( const AffineTransformation3d & ) const;
172 
175  // AffineTransformation3d & operator += ( const AffineTransformation3d & trans );
177 
179  std::unique_ptr<Transformation3d> getInverse() const CARTO_OVERRIDE;
180 
181  inline Point3df translation();
182  inline Point3df translation() const;
183 
184  inline carto::VolumeRef<float> rotation();
185  inline const carto::VolumeRef<float> rotation() const;
186 
187  // get the matrix as a volume
188  inline carto::VolumeRef<float> affine();
189  inline const carto::VolumeRef<float> affine() const;
190 
191  virtual void setMatrix(const carto::VolumeRef<float> & mat);
192  virtual void setRotationAffine( float rx, float ry, float rz,
193  const Point3df &cg = Point3df( 0.0 ) );
194  //virtual void setRotationVectorial( const Point3df& v1, const Point3df& v2 );
195 
196  static carto::VolumeRef<float> rotationaroundx(float rx) ;
197  static carto::VolumeRef<float> rotationaroundy(float ry) ;
198  static carto::VolumeRef<float> rotationaroundz(float rz) ;
199 
200  };
201 
202  // Compose AffineTransformation3d
204  operator * ( const AffineTransformation3d& affineTransformation3d1,
205  const AffineTransformation3d& affineTransformation3d2 );
206 
208  {
209  return Point3df( _matrix[12], _matrix[13], _matrix[14] );
210  }
211 
213  {
214  return Point3df( _matrix[12], _matrix[13], _matrix[14] );
215  }
216 
218  {
219  // return a 3x3 view into the 4x4 matrix
221  new carto::Volume<float>( 4, 4, 1, 1, &*_matrix.begin() ) );
222 
225  carto::Volume<float>::Position4Di( 3, 3, 1, 1 ) );
226 
227  return view;
228  }
229 
231  {
232  // return a 3x3 view into the 4x4 matrix
234  new carto::Volume<float>( 4, 4, 1, 1,
235  const_cast<float *>( &*_matrix.begin() ) ) );
238  carto::Volume<float>::Position4Di( 3, 3, 1, 1 ) );
239 
240  return view;
241  }
242 
244  {
246  new carto::Volume<float>( 4, 4, 1, 1, &*_matrix.begin() ) );
247  return matrix;
248  }
249 
251  {
253  new carto::Volume<float>( 4, 4, 1, 1,
254  const_cast<float *>( &*_matrix.begin() ) ) );
255  return matrix;
256  }
257 
258 }
259 
260 
261 
262 
263 #ifndef DOXYGEN_HIDE_INTERNAL_CLASSES
264 
265 namespace carto
266 {
267 
268  template <> class DataTypeCode< aims::AffineTransformation3d >
269  {
270  public:
271  static std::string objectType()
272  { return "AffineTransformation3d"; }
273  static std::string dataType()
274  { return "VOID"; }
275  static std::string name()
276  {
277  return "AffineTransformation3d";
278  }
279  };
280 
281 }
282 
283 #endif // DOXYGEN_HIDE_INTERNAL_CLASSES
284 
285 #endif
std::unique_ptr< Transformation3d > getInverse() const CARTO_OVERRIDE
static carto::VolumeRef< float > rotationaroundz(float rz)
AffineTransformation3d & operator*=(const AffineTransformation3dBase &trans)
virtual void setRotationAffine(float rx, float ry, float rz, const Point3df &cg=Point3df(0.0))
carto::VolumeRef< float > affine()
virtual AffineTransformation3d operator-() const
static carto::VolumeRef< float > rotationaroundx(float rx)
virtual bool operator!=(const AffineTransformation3d &) const
AffineTransformation3d()
Create an identity transformation.
AffineTransformation3d(const carto::Object mat)
Create a AffineTransformation3d from a 4x4 matrix given as a line vector in an Object.
AffineTransformation3d(const aims::Quaternion &quat)
AffineTransformation3d(const AffineTransformation3dBase &other)
carto::VolumeRef< float > rotation()
AffineTransformation3d(const AffineTransformation3d &other)
virtual AffineTransformation3d & operator=(const AffineTransformation3d &other)
virtual void setMatrix(const carto::VolumeRef< float > &mat)
AffineTransformation3d inverse() const
virtual bool operator==(const AffineTransformation3d &) const
static carto::VolumeRef< float > rotationaroundy(float ry)
AffineTransformation3d(const std::vector< float > &mat)
Create a AffineTransformation3d from a 4x4 matrix given as a line vector.
The class for EcatSino data write operation.
Definition: borderfiller.h:13
void transformBoundingBox(const AffineTransformation3d &AffineTransformation3d, const Point3df &pmin1, const Point3df &pmax1, Point3df &pmin2, Point3df &pmax2)