geometry.h
1 /***************************************************************************
2  geometry.h - description
3  -------------------
4  begin : Wed Apr 17 2002
5  copyright : (C) 2000-2015 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 
93  RotMatrix& operator = (const RotMatrix& sct);
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 
123  RotMatrix& set_inplane_rotation(float phi);
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 
196  Geometry& operator = (const Geometry& ia);
197 
201  Geometry& set_Mode(geometryMode mode);
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 
247  Geometry& set_sliceDistance(double dist);
248 
252  double get_sliceDistance() const {return sliceDistance;}
253 
257  dvector get_readVector() const;
258 
262  dvector get_phaseVector() const;
263 
267  dvector get_sliceVector() const;
268 
272  dvector get_sliceOffsetVector() const;
273 
277  double get_sliceThickness() const {return sliceThickness;}
278 
279 
292  darray get_cornerPoints(const Geometry& background, unsigned int backgrslice) const;
293 
294 
298  Geometry& set_orientation(sliceOrientation orientation);
299 
300 
304  static sliceOrientation get_slice_orientation(const dvector& svec);
305 
309  sliceOrientation get_orientation() const {return get_slice_orientation(get_sliceVector());}
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 
339  dvector get_center() const;
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 
366  Geometry& reset();
367 
371  Geometry& update();
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
dvector & operator[](unsigned int index)
Definition: geometry.h:83
RotMatrix(const STD_string &object_label="unnamedRotMatrix")
RotMatrix & operator=(const RotMatrix &sct)
STD_string print() const
tjarray< fvector, float > farray
Definition: tjarray.h:374
double get_sliceThickness() const
Definition: geometry.h:277
tjvector< double > dvector
Definition: tjvector.h:451
Rotation Matrix.
Definition: geometry.h:67
double get_sliceDistance() const
Definition: geometry.h:252
Geometry Settings.
Definition: geometry.h:179
geometryMode
Definition: geometry.h:56
bool operator==(const RotMatrix &srm) const
sliceBoundary
Definition: geometry.h:39
dvector operator*(const dvector &vec) const
RotMatrix & set_inplane_rotation(float phi)
geometryMode get_Mode() const
Definition: geometry.h:206
direction
Definition: odinpara.h:38
sliceOrientation get_orientation() const
Definition: geometry.h:309
unsigned int get_nSlices() const
Definition: geometry.h:237
sliceOrientation
Definition: geometry.h:48