ODIN
geometry.h
1 /***************************************************************************
2  geometry.h - description
3  -------------------
4  begin : Wed Apr 17 2002
5  copyright : (C) 2000-2021 by Thies H. Jochimsen
6  email : thies@jochimsen.de
7  ***************************************************************************/
8 
9 /***************************************************************************
10  * *
11  * This program is free software; you can redistribute it and/or modify *
12  * it under the terms of the GNU General Public License as published by *
13  * the Free Software Foundation; either version 2 of the License, or *
14  * (at your option) any later version. *
15  * *
16  ***************************************************************************/
17 
18 #ifndef GEOMETRY_H
19 #define GEOMETRY_H
20 
21 
22 #include <odinpara/ldrblock.h>
23 #include <odinpara/ldrnumbers.h>
24 #include <odinpara/ldrarrays.h>
25 
26 #include <odinpara/odinpara.h>
27 
28 
39 enum sliceBoundary {lowerBound=0,upperBound,n_boundaries};
40 
41 
48 enum sliceOrientation {sagittal=0,coronal,axial,n_orientations};
49 
50 
56 enum geometryMode {slicepack=0,voxel_3d,n_geometry_modes};
57 
58 
60 
61 
67 class RotMatrix : public virtual Labeled {
68  public:
69 
73  RotMatrix(const STD_string& object_label = "unnamedRotMatrix" );
74 
78  RotMatrix(const RotMatrix& sct);
79 
83  dvector& operator [] (unsigned int index) {return matrix[index%3];} // make sure index is lower than 3
84 
88  const dvector& operator [] (unsigned int index) const {return matrix[index%3];} // make sure index is lower than 3
89 
94 
100  bool operator == (const RotMatrix& srm) const;
101 
102  // dummy comparison operator for lists
103  bool operator < (const RotMatrix& srm) const;
104 
108  dvector operator * (const dvector& vec) const;
109 
113  RotMatrix operator * (const RotMatrix& matrix) const;
114 
118  operator farray () const;
119 
124 
125 
129  STD_string print() const;
130 
131  private:
132  friend class RotMatrixVector;
133 
134  class rowVec : public dvector {
135  public:
136  rowVec() : dvector(3) {};
137  ~rowVec() {};
138  };
139 
140 // bool check_and_correct();
141 
142  rowVec matrix[3];
143 
144 // static dvector returndummy;
145 };
146 
147 
149 
150 
179 class Geometry : public LDRblock {
180 
181 public:
182 
186  Geometry(const STD_string& label="unnamedGeometry");
187 
191  Geometry(const Geometry& ia);
192 
197 
202 
206  geometryMode get_Mode() const {return geometryMode(int(Mode));}
207 
208 
212  Geometry& set_FOV(direction dir,double fov);
213 
217  double get_FOV(direction dir) const;
218 
222  Geometry& set_offset(direction dir,double offset);
223 
227  double get_offset(direction dir) const;
228 
232  Geometry& set_nSlices(unsigned int nslices);
233 
237  unsigned int get_nSlices() const {return nSlices;};
238 
242  Geometry& set_sliceThickness(double thick);
243 
248 
252  double get_sliceDistance() const {return sliceDistance;}
253 
258 
263 
268 
273 
277  double get_sliceThickness() const {return sliceThickness;}
278 
279 
292  darray get_cornerPoints(const Geometry& background, unsigned int backgrslice) const;
293 
294 
299 
300 
305 
310 
311 
317  void get_orientation(double& heightAng, double& azimutAng, double& inplaneAng, bool& revSlice) const;
318 
324  Geometry& set_orientation(double heightAng, double azimutAng, double inplaneAng, bool revSlice=false);
325 
332  Geometry& set_orientation_and_offset(const dvector& readvec, const dvector& phasevec, const dvector& slicevec, const dvector& centervec);
333 
334 
335 
340 
346  RotMatrix get_gradrotmatrix(bool transpose=false) const;
347 
348 
354  dvector transform(const dvector& rpsvec, bool inverse=false) const;
355 
360  Geometry& transpose_inplane(bool reverse_read=false, bool reverse_phase=false);
361 
362 
367 
372 
373 
374 
375  private:
376 
377  dvector get_readVector_inplane() const;
378  dvector get_phaseVector_inplane() const;
379 
380  void append_all_members();
381 
382  double deg2rad(double degree) const {return degree/180.0*PII;}
383 
384  LDRenum Mode;
385 
386  LDRdouble FOVread;
387  LDRdouble offsetRead;
388  LDRdouble FOVphase;
389  LDRdouble offsetPhase;
390  LDRdouble FOVslice;
391  LDRdouble offsetSlice;
392 
393  LDRdouble heightAngle;
394  LDRdouble azimutAngle;
395  LDRdouble inplaneAngle;
396  LDRbool reverseSlice;
397 
398  LDRint nSlices;
399  LDRdouble sliceDistance;
400  LDRdouble sliceThickness;
401  LDRintArr sliceOrder;
402 
403  LDRaction Reset;
404  LDRaction Transpose;
405 
406 
407  // cache to speed up repetitive calls to transform()
408  mutable bool cache_up2date;
409  mutable bool inv_trans_cache;
410  mutable double rotmat_cache[3][3];
411  mutable double offset_cache[3];
412 };
413 
414 
419 #endif
Geometry Settings.
Definition: geometry.h:179
Geometry & set_nSlices(unsigned int nslices)
double get_offset(direction dir) const
Geometry & set_orientation(sliceOrientation orientation)
Geometry & set_sliceDistance(double dist)
dvector get_phaseVector() const
Geometry & set_offset(direction dir, double offset)
double get_sliceDistance() const
Definition: geometry.h:252
darray get_cornerPoints(const Geometry &background, unsigned int backgrslice) const
Geometry(const Geometry &ia)
Geometry & transpose_inplane(bool reverse_read=false, bool reverse_phase=false)
RotMatrix get_gradrotmatrix(bool transpose=false) const
Geometry & set_orientation_and_offset(const dvector &readvec, const dvector &phasevec, const dvector &slicevec, const dvector &centervec)
Geometry & update()
double get_sliceThickness() const
Definition: geometry.h:277
Geometry & set_FOV(direction dir, double fov)
dvector get_sliceVector() const
Geometry(const STD_string &label="unnamedGeometry")
dvector get_readVector() const
dvector get_center() const
sliceOrientation get_orientation() const
Definition: geometry.h:309
geometryMode get_Mode() const
Definition: geometry.h:206
Geometry & operator=(const Geometry &ia)
unsigned int get_nSlices() const
Definition: geometry.h:237
double get_FOV(direction dir) const
Geometry & reset()
Geometry & set_orientation(double heightAng, double azimutAng, double inplaneAng, bool revSlice=false)
static sliceOrientation get_slice_orientation(const dvector &svec)
void get_orientation(double &heightAng, double &azimutAng, double &inplaneAng, bool &revSlice) const
Geometry & set_Mode(geometryMode mode)
dvector transform(const dvector &rpsvec, bool inverse=false) const
Geometry & set_sliceThickness(double thick)
dvector get_sliceOffsetVector() const
Rotation Matrix.
Definition: geometry.h:67
dvector operator*(const dvector &vec) const
bool operator==(const RotMatrix &srm) const
RotMatrix(const RotMatrix &sct)
STD_string print() const
RotMatrix & set_inplane_rotation(float phi)
RotMatrix & operator=(const RotMatrix &sct)
dvector & operator[](unsigned int index)
Definition: geometry.h:83
RotMatrix(const STD_string &object_label="unnamedRotMatrix")
geometryMode
Definition: geometry.h:56
sliceBoundary
Definition: geometry.h:39
direction
Definition: odinpara.h:41
sliceOrientation
Definition: geometry.h:48
tjarray< fvector, float > farray
Definition: tjarray.h:374