aimsdata  5.0.5
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 
42 #include <aims/data/data.h>
43 #include <iosfwd>
44 
45 namespace aims
46 {
47  class AffineTransformation3d;
48  class PythonHeader;
49  class Quaternion;
50 
52  ( const AffineTransformation3d &AffineTransformation3d,
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 );
160  virtual ~AffineTransformation3d();
161  virtual AffineTransformation3d &
162  operator = ( const AffineTransformation3d& other );
163  virtual AffineTransformation3d &
164  operator = ( const std::vector<float> & mat );
165  virtual AffineTransformation3d &
166  operator = ( const carto::Object mat );
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 
174  operator *= ( const AffineTransformation3dBase & trans );
175  // AffineTransformation3d & operator += ( const AffineTransformation3d & trans );
176  virtual AffineTransformation3d operator - () const;
177 
179  std::unique_ptr<Transformation3d> getInverse() const CARTO_OVERRIDE;
180 
182  const aims::PythonHeader* header() const { return _header; }
183  void setHeader( aims::PythonHeader* ph );
184 
185  inline Point3df translation();
186  inline Point3df translation() const;
187 
188  inline AimsData<float> rotation();
189  inline const AimsData<float> rotation() const;
190 
191  // get the matrix as a volume
193  inline const carto::VolumeRef<float> affine() const;
194 
195  virtual void setMatrix(const carto::VolumeRef<float> & mat);
196  virtual void setMatrix(const AimsData<float> & mat);
197  virtual void setRotationAffine( float rx, float ry, float rz,
198  const Point3df &cg = Point3df( 0.0 ) );
199  //virtual void setRotationVectorial( const Point3df& v1, const Point3df& v2 );
200 
201  static AimsData<float> rotationaroundx(float rx) ;
202  static AimsData<float> rotationaroundy(float ry) ;
203  static AimsData<float> rotationaroundz(float rz) ;
204 
205 
206  protected:
208  };
209 
210  // Compose AffineTransformation3d
212  operator * ( const AffineTransformation3d& affineTransformation3d1,
213  const AffineTransformation3d& affineTransformation3d2 );
214 
216  {
217  return Point3df( _matrix[12], _matrix[13], _matrix[14] );
218  }
219 
221  {
222  return Point3df( _matrix[12], _matrix[13], _matrix[14] );
223  }
224 
226  {
227  // return a 3x3 view into the 4x4 matrix
229  new carto::Volume<float>( 4, 4, 1, 1, &*_matrix.begin() ) );
230 
232  matrix, carto::Volume<float>::Position4Di( 0, 0, 0, 0 ),
233  carto::Volume<float>::Position4Di( 3, 3, 1, 1 ) );
234 
235  return AimsData<float>( view );
236  }
237 
239  {
240  // return a 3x3 view into the 4x4 matrix
242  new carto::Volume<float>( 4, 4, 1, 1,
243  const_cast<float *>( &*_matrix.begin() ) ) );
246  carto::Volume<float>::Position4Di( 3, 3, 1, 1 ) );
247 
248  return AimsData<float>( view );
249  }
250 
252  {
254  new carto::Volume<float>( 4, 4, 1, 1, &*_matrix.begin() ) );
255  return matrix;
256  }
257 
259  {
261  new carto::Volume<float>( 4, 4, 1, 1,
262  const_cast<float *>( &*_matrix.begin() ) ) );
263  return matrix;
264  }
265 
266 }
267 
268 
269 
270 
271 #ifndef DOXYGEN_HIDE_INTERNAL_CLASSES
272 
273 namespace carto
274 {
275 
277  {
278  public:
279  static std::string objectType()
280  { return "AffineTransformation3d"; }
281  static std::string dataType()
282  { return "VOID"; }
283  static std::string name()
284  {
285  return "AffineTransformation3d";
286  }
287  };
288 
289 }
290 
291 #endif // DOXYGEN_HIDE_INTERNAL_CLASSES
292 
293 #endif
void setHeader(aims::PythonHeader *ph)
Attributed python-like header, stores all needed information about an object, currently used for volu...
Definition: pheader.h:51
static AimsData< float > rotationaroundy(float ry)
std::unique_ptr< Transformation3d > getInverse() const CARTO_OVERRIDE
AffineTransformation3d & operator*=(const AffineTransformation3dBase &trans)
static AimsData< float > rotationaroundx(float rx)
The class for EcatSino data write operation.
Definition: border.h:44
virtual void setMatrix(const carto::VolumeRef< float > &mat)
virtual bool operator==(const AffineTransformation3d &) const
carto::VolumeRef< float > affine()
const aims::PythonHeader * header() const
AffineTransformation3d()
Create an identity transformation.
virtual AffineTransformation3d & operator=(const AffineTransformation3d &other)
virtual AffineTransformation3d operator-() const
virtual bool operator!=(const AffineTransformation3d &) const
static AimsData< float > rotationaroundz(float rz)
virtual void setRotationAffine(float rx, float ry, float rz, const Point3df &cg=Point3df(0.0))
#define CARTO_OVERRIDE
void transformBoundingBox(const AffineTransformation3d &AffineTransformation3d, const Point3df &pmin1, const Point3df &pmax1, Point3df &pmin2, Point3df &pmax2)
Affine 3D transformation.
Quaternion operator*(const Quaternion &a, const Quaternion &b)
AffineTransformation3d inverse() const