00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef GEOMETRY_H
00019 #define GEOMETRY_H
00020
00021
00022 #include <odinpara/jdxblock.h>
00023 #include <odinpara/jdxnumbers.h>
00024 #include <odinpara/jdxarrays.h>
00025
00026 #include <odinpara/odinpara.h>
00027
00028
00039 typedef enum sliceBoundary {lowerBound=0,upperBound,n_boundaries};
00040
00041
00045 typedef enum sliceOrientation {sagittal=0,coronal,axial,n_orientations};
00046
00047
00051 typedef enum geometryMode {slicepack=0,voxel_3d,n_geometry_modes};
00052
00053
00055
00056
00062 class RotMatrix : public virtual Labeled {
00063 public:
00064
00068 RotMatrix(const STD_string& object_label = "unnamedRotMatrix" );
00069
00073 RotMatrix(const RotMatrix& sct);
00074
00078 dvector& operator [] (unsigned int index) {return matrix[index%3];}
00079
00083 const dvector& operator [] (unsigned int index) const {return matrix[index%3];}
00084
00088 RotMatrix& operator = (const RotMatrix& sct);
00089
00095 bool operator == (const RotMatrix& srm) const;
00096
00097
00098 bool operator < (const RotMatrix& srm) const;
00099
00103 dvector operator * (const dvector& vec) const;
00104
00108 RotMatrix operator * (const RotMatrix& matrix) const;
00109
00113 operator farray () const;
00114
00118 RotMatrix& set_inplane_rotation(float phi);
00119
00120
00124 STD_string print() const;
00125
00126 private:
00127 friend class RotMatrixVector;
00128
00129 class rowVec : public dvector {
00130 public:
00131 rowVec() : dvector(3) {};
00132 ~rowVec() {};
00133 };
00134
00135
00136
00137 rowVec matrix[3];
00138
00139
00140 };
00141
00142
00144
00145
00174 class Geometry : public JcampDxBlock {
00175
00176 public:
00177
00181 Geometry(const STD_string& label="unnamedGeometry");
00182
00186 Geometry(const Geometry& ia);
00187
00191 Geometry& operator = (const Geometry& ia);
00192
00196 Geometry& set_Mode(geometryMode mode);
00197
00201 geometryMode get_Mode() const {return geometryMode(int(Mode));}
00202
00203
00207 Geometry& set_FOV(channelNo dir,double fov);
00208
00212 double get_FOV(channelNo dir) const;
00213
00217 Geometry& set_offset(channelNo dir,double offset);
00218
00222 double get_offset(channelNo dir) const;
00223
00227 Geometry& set_nSlices(unsigned int nslices);
00228
00232 unsigned int get_nSlices() const {return nSlices;};
00233
00237 Geometry& set_sliceThickness(double thick);
00238
00242 Geometry& set_sliceDistance(double dist);
00243
00247 double get_sliceDistance() const {return sliceDistance;}
00248
00252 dvector get_readVector() const;
00253
00257 dvector get_phaseVector() const;
00258
00262 dvector get_sliceVector() const;
00263
00267 dvector get_sliceOffsetVector() const;
00268
00272 double get_sliceThickness() const {return sliceThickness;}
00273
00274
00275
00288 darray get_cornerPoints(const Geometry& background, unsigned int backgrslice) const;
00289
00290
00294 Geometry& set_orientation(sliceOrientation orientation);
00295
00299 sliceOrientation get_orientation() const;
00300
00304 void get_orientation(double& heightAng, double& azimutAng, double& inplaneAng) const;
00305
00309 Geometry& set_orientation(double heightAng, double azimutAng, double inplaneAng);
00310
00317 Geometry& set_orientation_and_offset(const dvector& readvec, const dvector& phasevec, const dvector& slicevec, const dvector& centervec);
00318
00319
00320
00324 dvector get_center() const;
00325
00331 RotMatrix get_gradrotmatrix(bool transpose=false) const;
00332
00333
00339 dvector transform(const dvector& rpsvec, bool inverse=false) const;
00340
00345 Geometry& transpose_inplane(bool reverse_read=false, bool reverse_phase=false);
00346
00347
00351 Geometry& reset();
00352
00356 Geometry& update();
00357
00358
00359
00360 private:
00361
00362 dvector get_readVector_inplane() const;
00363 dvector get_phaseVector_inplane() const;
00364
00365 void append_all_members();
00366
00367 double deg2rad(double degree) const {return degree/180.0*PII;}
00368
00369 JDXenum Mode;
00370
00371 JDXdouble FOVread;
00372 JDXdouble offsetRead;
00373 JDXdouble FOVphase;
00374 JDXdouble offsetPhase;
00375 JDXdouble FOVslice;
00376 JDXdouble offsetSlice;
00377
00378 JDXdouble heightAngle;
00379 JDXdouble azimutAngle;
00380 JDXdouble inplaneAngle;
00381
00382 JDXint nSlices;
00383 JDXdouble sliceDistance;
00384 JDXdouble sliceThickness;
00385
00386 JDXaction Reset;
00387 JDXaction Transpose;
00388
00389
00390
00391 mutable bool cache_up2date;
00392 mutable bool inv_trans_cache;
00393 mutable double rotmat_cache[3][3];
00394 mutable double offset_cache[3];
00395 };
00396
00397
00402 #endif