anatomist 6.0.4
3D neuroimaging data viewer
Transformation.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#ifndef ANA_REFERENCE_TRANSFORMATION_H
36#define ANA_REFERENCE_TRANSFORMATION_H
37
38//--- header files ------------------------------------------------------------
39
40#include <aims/transformation/affinetransformation3d.h>
41
42
43//--- class declarations ------------------------------------------------------
44
45namespace aims
46{
47 class Quaternion;
48}
49
50namespace anatomist
51{
52
53 class Referential;
54
60
62 {
63 public:
64 Transformation( Referential *,Referential *, bool regist = false,
65 bool generated = false );
67 const Transformation & trans );
70 virtual ~Transformation();
71
76 // Transformation & operator += ( const Transformation & trans );
79 const aims::AffineTransformation3d & motion() const { return _motion; }
80
81 void setRotation( float** r );
82 void setTranslation( float* t );
84 void setMatrix( float** m );
86 void setMatrixT( float m[4][3] );
88 void SetRotation(int , int , float );
90 void SetTranslation(int , float );
92 float Rotation(int ,int );
96 float Translation(int );
97 Point3df translation() const;
98 Referential* source() const { return( _source ); }
99 Referential* destination() const { return( _dest ); }
101 void invert();
105 bool isDirect() const;
106
108 Point3df transform( const Point3df & pos ) const;
109 /* transforms cube (pmin1, pmin2) and builds the new bounding box
110 in the new ref */
111 void transformBoundingBox( const Point3df & pmin1, const Point3df & pmax1,
112 Point3df & pmin2, Point3df & pmax2 );
113
117 bool isGenerated() const { return( _generated ); }
118 void setGenerated( bool x ) { _generated = x; }
119
123 void undo();
125 void redo();
127 std::size_t motionHistorySize() const
128 {
129 return _motionHistory.size();
130 }
131
133 {
134 return _motionHistoryIndex;
135 }
136
143 static Point3df transform( const Point3df & pos, const Transformation* tra,
144 const Point3df & voxSizeOrg,
145 const Point3df & voxSizeDst );
147 static Point3df transform( const Point3df & pos, const Referential* orgRef,
148 const Referential* dstRef,
149 const Point3df & voxSizeOrg,
150 const Point3df & voxSizeDst );
152 static Point3df transform( const Point3df & pos,
153 const Point3df & voxSizeOrg,
154 const Point3df & voxSizeDst );
156 static Point3df transform( const Point3df & pos, const Transformation* tra,
157 const Point3df & voxSizeDst );
159 static Point3df transform( const Point3df & pos,
160 const Point3df & voxSizeOrg,
161 const Transformation* tra );
163 static Point3df transform( const Point3df & pos,
164 const Point3df & voxSizeOrg );
167 static Point3df transformDG( const Point3df & pos,
168 const Point3df & voxSizeDst );
170
171 protected:
176 std::vector <aims::AffineTransformation3d> _motionHistory;
178 };
179
180
181 // inline functions
182
183
184 inline Point3df
186 const Point3df & voxSizeOrg,
187 const Point3df & voxSizeDst )
188 {
189 Point3df pt = tra->transform( Point3df( pos[0] * voxSizeOrg[0],
190 pos[1] * voxSizeOrg[1],
191 pos[2] * voxSizeOrg[2] ) );
192 return( Point3df( pt[0] / voxSizeDst[0], pt[1] / voxSizeDst[1],
193 pt[2] / voxSizeDst[2] ) );
194 }
195
196
197 inline Point3df
199 const Point3df & voxSizeOrg,
200 const Point3df & voxSizeDst )
201 {
202 return( Point3df( pos[0] * voxSizeOrg[0] / voxSizeDst[0],
203 pos[1] * voxSizeOrg[1] / voxSizeDst[1],
204 pos[2] * voxSizeOrg[2] / voxSizeDst[2] ) );
205 }
206
207
208 inline Point3df
209 Transformation::transform( const Point3df & pos, const Point3df & voxSizeOrg,
210 const Transformation* tra )
211 {
212 return( tra->transform( Point3df( pos[0] * voxSizeOrg[0],
213 pos[1] * voxSizeOrg[1],
214 pos[2] * voxSizeOrg[2] ) ) );
215 }
216
217
218 inline Point3df
220 const Point3df & voxSizeDst )
221 {
222 Point3df pt = tra->transform( pos );
223 return( Point3df( pt[0] / voxSizeDst[0], pt[1] / voxSizeDst[1],
224 pt[2] / voxSizeDst[2] ) );
225 }
226
227
228 inline Point3df
230 const Point3df & voxSizeOrg )
231 {
232 return( Point3df( pos[0] * voxSizeOrg[0], pos[1] * voxSizeOrg[1],
233 pos[2] * voxSizeOrg[2] ) );
234 }
235
236
237 inline Point3df
239 const Point3df & voxSizeDst )
240 {
241 return( Point3df( pos[0] / voxSizeDst[0], pos[1] / voxSizeDst[1],
242 pos[2] / voxSizeDst[2] ) );
243 }
244
245 inline Point3df
247 {
248 return _motion.translation();
249 }
250
251}
252
253
254namespace carto
255{
257 DECLARE_GENERIC_OBJECT_TYPE( std::set<anatomist::Transformation *> )
258 DECLARE_GENERIC_OBJECT_TYPE( std::vector<anatomist::Transformation *> )
259 DECLARE_GENERIC_OBJECT_TYPE( std::list<anatomist::Transformation *> )
260}
261
262#endif
Referential: marker for transformations, with an associated color.
Definition Referential.h:56
Transformation between two referentials.
float Rotation(int, int)
Get the rotation.
std::vector< aims::AffineTransformation3d > _motionHistory
static Point3df transform(const Point3df &pos, const Referential *orgRef, const Referential *dstRef, const Point3df &voxSizeOrg, const Point3df &voxSizeDst)
slower than above: must find the transformation (not inline)
void registerTrans()
Registers the transformation to the TransformSet.
void redo()
Redoes last motion.
void setRotation(float **r)
Transformation & operator=(const Transformation &trans)
Operator = doesn't copy source / dest references.
static Point3df transformDG(const Point3df &pos, const Point3df &voxSizeDst)
no transformation, no org geometry but dest geometry.
Transformation & operator*=(const Transformation &trans)
void invertReferentials()
Inverts source and destination referentials.
Transformation operator-() const
Transformation(Referential *, Referential *, bool regist=false, bool generated=false)
void addMotionToHistory(const aims::AffineTransformation3d &)
Adds a new AffineTransformation3d to motion history.
const aims::AffineTransformation3d & motion() const
std::size_t motionHistorySize() const
Returns the motion history size.
aims::Quaternion quaternion() const
bool isDirect() const
true if the transformation is direct, false if it changes orientation
virtual ~Transformation()
Unregister from the TransformSet and other objects.
Referential * source() const
void SetRotation(int, int, float)
Set the rotation.
void setTranslation(float *t)
aims::AffineTransformation3d _motion
void setQuaternion(const aims::Quaternion &q)
float Translation(int)
Get the translation.
void setMatrixT(float m[4][3])
4x3 matrix in Vip/Aims file form (1st line:translation)
void transformBoundingBox(const Point3df &pmin1, const Point3df &pmax1, Point3df &pmin2, Point3df &pmax2)
Point3df transform(const Point3df &pos) const
Transforms a point.
int motionHistoryIndex() const
Returns the current motion history index.
void undo()
Undoes last motion.
Point3df translation() const
Referential * destination() const
void setMatrix(float **m)
4x4 matrix
Transformation(Referential *, Referential *, const Transformation &trans)
void SetTranslation(int, float)
Set the translation.
aims::AffineTransformation3d & motion()
void invert()
Inverts the transformation matrix.
#define DECLARE_GENERIC_OBJECT_TYPE(T)
AimsVector< float, 3 > Point3df