cartodata 6.0.0
referential.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#ifndef CARTODATA_TRANSFORMATION_REFERENTIAL_H
35#define CARTODATA_TRANSFORMATION_REFERENTIAL_H
36
37#include <soma-io/transformation/affinetransformation3d_base.h>
38#include <cartobase/smart/rcobject.h>
39
40
41namespace carto
42{
43
78 {
79 public:
106
108 Referential( unsigned ndim = 3 );
112
114
116 unsigned order() const { return _orientation.size(); }
118 void ensureOrder( unsigned ndim );
120 const std::string & uuid() const { return _uuid; }
121 std::string & uuid() { return _uuid; }
123 std::string orientationStr() const;
125 std::string orientationStr( const std::string & orient ) const;
128 std::vector<int> axesOrientation() const { return _orientation; }
129 bool isDirect() const;
144 const std::string & orient,
145 const std::vector<float> & transl = std::vector<float>(),
146 bool allow_resize = false ) const;
150 const std::string & orient,
151 const std::vector<int> & transl,
152 bool allow_resize = false ) const
153 {
154 return toOrientation( orient,
155 std::vector<float>( transl.begin(),
156 transl.end() ),
157 allow_resize );
158 }
159
166 const std::vector<int> & orient,
167 const std::vector<float> & transl = std::vector<float>() ) const;
174 std::string lpiReferentialUuid() const
175 {
176 if( isLpiOriented() && _uuid != _lpi_uuid )
177 _lpi_uuid = _uuid;
178 return _lpi_uuid;
179 }
180
182 void setUuid( const std::string & uuid );
191 void setOrientation( const std::string & orient,
192 bool allow_resize = false );
194 void setOrientation( const std::vector<int> & orient );
196 void setLpiReferential( const std::string & lpi_uuid );
197
199 Object header() const { return _header; }
200 void setHeader( const Object header );
206 bool is3DOriented() const;
208 bool is3DOriented( const std::string & orient ) const;
210 bool isLpiOriented() const;
214 std::vector<int> orientationFromTransform(
215 const AffineTransformationBase & tr ) const;
216
218 static std::string orientationStr( Orientation orient );
220 static std::string orientationStr( const std::vector<int> & orient );
222 static Orientation orientationCode( const std::string & orient );
228 static std::vector<int> orientationVector( const std::string & orient,
229 unsigned dim = 0 );
236 static void setAxisTransform( AffineTransformationBase & tr,
237 int src_axis, int dst_axis, int inv_mult,
238 const std::vector<float> & transl
239 = std::vector<float>() );
241 static bool is3DOriented( const std::vector<int> & orient );
248 bool except_if_undefined = false );
249
250 private:
251 std::string _uuid;
252 mutable std::string _lpi_uuid;
253 std::vector<int> _orientation;
254 Object _header;
255 };
256
257}
258
259#endif
260
friend friend class ref
Orientation
Axis orientation enum.
Definition referential.h:83
void setHeader(const Object header)
static std::string orientationStr(Orientation orient)
orientation string for a single axis orientation (1 char)
bool is3DOriented() const
tells if the orientation is comatible with a 3D transformation (all axes after the 3th are the defaul...
static Referential fromHeader(const Object header, bool except_if_undefined=false)
Build a Referential object from a header.
void setLpiReferential(const std::string &lpi_uuid)
set the LPI original referential UUID
static std::vector< int > orientationVector(const std::string &orient, unsigned dim=0)
build an orientation vector from a string.
void setUuid(const std::string &uuid)
force a new UUID
std::string & uuid()
static bool is3DOriented(const std::vector< int > &orient)
tells if the given orientation is 3D compatible
static void setAxisTransform(AffineTransformationBase &tr, int src_axis, int dst_axis, int inv_mult, const std::vector< float > &transl=std::vector< float >())
Build one line of transformation matrix.
rc_ptr< Transformation > toOrientation(const std::vector< int > &orient, const std::vector< float > &transl=std::vector< float >()) const
Build a transformation matrix to go from this referential to a given orientation.
std::string orientationStr(const std::string &orient) const
extended orientation information according to the needed number of axes
Referential(unsigned ndim=3)
Build a referential with the given number of dimensions.
static Orientation orientationCode(const std::string &orient)
orientation constant for a single orientation axis character
Referential(Object ref)
unsigned order() const
number of axes (or space dimensions)
std::string orientationStr() const
orientation of the referential, as a string of one letter per axis
rc_ptr< Transformation > toOrientation(const std::string &orient, const std::vector< int > &transl, bool allow_resize=false) const
same as above but translation is given as ints
std::string lpiReferentialUuid() const
LPI oriented referential.
Referential & operator=(const Referential &ref)
std::vector< int > axesOrientation() const
orientation of the referential, as a vector of constants.
void setOrientation(const std::string &orient, bool allow_resize=false)
set a new orientation for the referential.
void ensureOrder(unsigned ndim)
update the order, keeping existing orientation information
Referential(const Referential &ref)
void setOrientation(const std::vector< int > &orient)
set a new orientation for the referential.
const std::string & uuid() const
a referential has an unique identifier
Object header() const
referential header, may contain anything useful
bool isDirect() const
Object exportedHeader() const
export a ready-to-save version of the header, where, especially, the axes_orientation property is an ...
rc_ptr< Transformation > toOrientation(const std::string &orient, const std::vector< float > &transl=std::vector< float >(), bool allow_resize=false) const
Build a transformation matrix to go from this referential to a given orientation.
bool isLpiOriented() const
tells if the orientation is the default LPI one.
std::vector< int > orientationFromTransform(const AffineTransformationBase &tr) const
target orientation for a given transform matrix.
static std::string orientationStr(const std::vector< int > &orient)
build the orientation string from a vector of constants
bool is3DOriented(const std::string &orient) const
tells if the given orientation is 3D compatible