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 enum sliceBoundary {lowerBound=0,upperBound,n_boundaries};
00040
00041
00048 enum sliceOrientation {sagittal=0,coronal,axial,n_orientations};
00049
00050
00056 enum geometryMode {slicepack=0,voxel_3d,n_geometry_modes};
00057
00058
00060
00061
00067 class RotMatrix : public virtual Labeled {
00068 public:
00069
00073 RotMatrix(const STD_string& object_label = "unnamedRotMatrix" );
00074
00078 RotMatrix(const RotMatrix& sct);
00079
00083 dvector& operator [] (unsigned int index) {return matrix[index%3];}
00084
00088 const dvector& operator [] (unsigned int index) const {return matrix[index%3];}
00089
00093 RotMatrix& operator = (const RotMatrix& sct);
00094
00100 bool operator == (const RotMatrix& srm) const;
00101
00102
00103 bool operator < (const RotMatrix& srm) const;
00104
00108 dvector operator * (const dvector& vec) const;
00109
00113 RotMatrix operator * (const RotMatrix& matrix) const;
00114
00118 operator farray () const;
00119
00123 RotMatrix& set_inplane_rotation(float phi);
00124
00125
00129 STD_string print() const;
00130
00131 private:
00132 friend class RotMatrixVector;
00133
00134 class rowVec : public dvector {
00135 public:
00136 rowVec() : dvector(3) {};
00137 ~rowVec() {};
00138 };
00139
00140
00141
00142 rowVec matrix[3];
00143
00144
00145 };
00146
00147
00149
00150
00179 class Geometry : public JcampDxBlock {
00180
00181 public:
00182
00186 Geometry(const STD_string& label="unnamedGeometry");
00187
00191 Geometry(const Geometry& ia);
00192
00196 Geometry& operator = (const Geometry& ia);
00197
00201 Geometry& set_Mode(geometryMode mode);
00202
00206 geometryMode get_Mode() const {return geometryMode(int(Mode));}
00207
00208
00212 Geometry& set_FOV(direction dir,double fov);
00213
00217 double get_FOV(direction dir) const;
00218
00222 Geometry& set_offset(direction dir,double offset);
00223
00227 double get_offset(direction dir) const;
00228
00232 Geometry& set_nSlices(unsigned int nslices);
00233
00237 unsigned int get_nSlices() const {return nSlices;};
00238
00242 Geometry& set_sliceThickness(double thick);
00243
00247 Geometry& set_sliceDistance(double dist);
00248
00252 double get_sliceDistance() const {return sliceDistance;}
00253
00257 dvector get_readVector() const;
00258
00262 dvector get_phaseVector() const;
00263
00267 dvector get_sliceVector() const;
00268
00272 dvector get_sliceOffsetVector() const;
00273
00277 double get_sliceThickness() const {return sliceThickness;}
00278
00279
00280
00293 darray get_cornerPoints(const Geometry& background, unsigned int backgrslice) const;
00294
00295
00299 Geometry& set_orientation(sliceOrientation orientation);
00300
00304 sliceOrientation get_orientation() const;
00305
00306
00312 void get_orientation(double& heightAng, double& azimutAng, double& inplaneAng, bool& revSlice) const;
00313
00319 Geometry& set_orientation(double heightAng, double azimutAng, double inplaneAng, bool revSlice=false);
00320
00327 Geometry& set_orientation_and_offset(const dvector& readvec, const dvector& phasevec, const dvector& slicevec, const dvector& centervec);
00328
00329
00330
00334 dvector get_center() const;
00335
00341 RotMatrix get_gradrotmatrix(bool transpose=false) const;
00342
00343
00349 dvector transform(const dvector& rpsvec, bool inverse=false) const;
00350
00355 Geometry& transpose_inplane(bool reverse_read=false, bool reverse_phase=false);
00356
00357
00361 Geometry& reset();
00362
00366 Geometry& update();
00367
00368
00369
00370 private:
00371
00372 dvector get_readVector_inplane() const;
00373 dvector get_phaseVector_inplane() const;
00374
00375 void append_all_members();
00376
00377 double deg2rad(double degree) const {return degree/180.0*PII;}
00378
00379 JDXenum Mode;
00380
00381 JDXdouble FOVread;
00382 JDXdouble offsetRead;
00383 JDXdouble FOVphase;
00384 JDXdouble offsetPhase;
00385 JDXdouble FOVslice;
00386 JDXdouble offsetSlice;
00387
00388 JDXdouble heightAngle;
00389 JDXdouble azimutAngle;
00390 JDXdouble inplaneAngle;
00391 JDXbool reverseSlice;
00392
00393 JDXint nSlices;
00394 JDXdouble sliceDistance;
00395 JDXdouble sliceThickness;
00396
00397 JDXaction Reset;
00398 JDXaction Transpose;
00399
00400
00401
00402 mutable bool cache_up2date;
00403 mutable bool inv_trans_cache;
00404 mutable double rotmat_cache[3][3];
00405 mutable double offset_cache[3];
00406 };
00407
00408
00413 #endif