00001 #ifndef __Header_plane__
00002 #define __Header_plane__
00003
00004 #include "planev.h"
00005
00006 enum ImagePlaneHeadFeet { HeadFirst,FeetFirst };
00007
00008 enum ImagePlanePosition {
00009 Supine,Prone,LeftLateralDecubitus,RightLateralDecubitus };
00010
00011 enum ImagePlaneAxis { AnteriorPosterior,HeadFeet,LeftRight };
00012
00013 enum ImagePlanePlane { Axial,Sagittal,Coronal,
00014 AxialLP, AxialRP,
00015 SagittalPF,SagittalIP,
00016 CoronalLI };
00017
00018 class AbstractImagePlane {
00019 Point3D center;
00020 Point3D tlhc;
00021 Vector3D rowvec;
00022 Vector3D colvec;
00023
00024 friend class ImagePlane;
00025
00026 Point3D _get_center (void) { return center; }
00027 void _set_center (Point3D p) { center=p; }
00028 void _rotate_center (Rotation3D r) { center=center*r; }
00029 void _shift_center (Vector3D shift) { center=center+shift; }
00030
00031 Point3D _get_tlhc (void) { return tlhc; }
00032 void _set_tlhc (Point3D p) { tlhc=p; }
00033 void _rotate_tlhc (Rotation3D r) { tlhc=tlhc*r; }
00034 void _shift_tlhc (Vector3D shift) { tlhc=tlhc+shift; }
00035
00036 void _scale_tlhc (double factor)
00037 {
00038 Point3D origin(0,0,0);
00039 Vector3D v = (origin-tlhc)*factor;
00040 tlhc=origin-v;
00041 }
00042
00043 Vector3D _get_rowvec (void) { return rowvec; }
00044 void _set_rowvec (Vector3D v) { rowvec=v; }
00045 void _rotate_rowvec (Rotation3D r) { rowvec=rowvec*r; }
00046
00047 Vector3D _get_colvec (void) { return colvec; }
00048 void _set_colvec (Vector3D v) { colvec=v; }
00049 void _rotate_colvec (Rotation3D r) { colvec=colvec*r; }
00050
00051 public:
00052 AbstractImagePlane(void) {}
00053 AbstractImagePlane(ImagePlanePlane plane,double hfov,double vfov);
00054
00055 #ifdef DEBUGPLANE
00056 void put(ostream &);
00057 #endif
00058 };
00059
00060
00061 class DerivedImagePlane
00062 {
00063 Rotation3D rotation;
00064 Rotation3D unrotation;
00065
00066 char *getOrientation(Vector3D vector);
00067
00068
00069
00070 virtual Point3D _get_center (void) = 0;
00071 virtual void _set_center (Point3D p) = 0;
00072 virtual void _rotate_center (Rotation3D r) = 0;
00073 virtual void _shift_center (Vector3D shift) = 0;
00074
00075 virtual Point3D _get_tlhc (void) = 0;
00076 virtual void _set_tlhc (Point3D p) = 0;
00077 virtual void _rotate_tlhc (Rotation3D r) = 0;
00078 virtual void _shift_tlhc (Vector3D shift) = 0;
00079 virtual void _scale_tlhc (double factor) = 0;
00080
00081 virtual Vector3D _get_rowvec (void) = 0;
00082 virtual void _set_rowvec (Vector3D v) = 0;
00083 virtual void _rotate_rowvec (Rotation3D r) = 0;
00084
00085 virtual Vector3D _get_colvec (void) = 0;
00086 virtual void _set_colvec (Vector3D v) = 0;
00087 virtual void _rotate_colvec (Rotation3D r) = 0;
00088
00089 public:
00090 DerivedImagePlane(ImagePlaneHeadFeet hfff,ImagePlanePosition posn);
00091
00092 char *getRowOrientation(void)
00093 {
00094 return getOrientation(getRowVector());
00095 }
00096 char *getColOrientation(void)
00097 {
00098 return getOrientation(getColVector());
00099 }
00100
00101 Point3D getTLHC(void) { return _get_tlhc()*rotation; }
00102 Point3D getCenter(void) { return _get_center()*rotation; }
00103 Vector3D getRowVector(void) { return _get_rowvec()*rotation; }
00104 Vector3D getColVector(void) { return _get_colvec()*rotation; }
00105
00106 void setCorners(Point3D tlhc,Vector3D row,Vector3D col);
00107 void angle(ImagePlaneAxis axis,double angle);
00108 void shift(Vector3D shift);
00109 void scale(double factor);
00110
00111 #ifdef DEBUGPLANE
00112 void put(ostream &);
00113 #endif
00114 };
00115
00116 class PatientPlane : public DerivedImagePlane
00117 {
00118 public:
00119 PatientPlane(ImagePlaneHeadFeet hfff,ImagePlanePosition posn) :
00120 DerivedImagePlane(hfff,posn)
00121 {
00122 #ifdef DEBUGPLANE
00123 cerr << "PatientPlane::PatientPlane(void)" << endl;
00124 #endif
00125 }
00126 #ifdef DEBUGPLANE
00127 void put(ostream &);
00128 #endif
00129 };
00130
00131 class MachinePlane : public DerivedImagePlane
00132 {
00133 public:
00134 MachinePlane(void) :
00135 DerivedImagePlane(HeadFirst,Supine)
00136 {
00137 #ifdef DEBUGPLANE
00138 cerr << "MachinePlane::MachinePlane(void)" << endl;
00139 #endif
00140 }
00141 #ifdef DEBUGPLANE
00142 void put(ostream &);
00143 #endif
00144 };
00145
00146 class ImagePlane : public virtual AbstractImagePlane,
00147 public PatientPlane,
00148 public MachinePlane
00149 {
00150
00151
00152
00153 Point3D _get_center (void)
00154 {
00155 return AbstractImagePlane::_get_center();
00156 }
00157
00158 void _set_center (Point3D p)
00159 {
00160 AbstractImagePlane::_set_center(p);
00161 }
00162
00163 void _rotate_center (Rotation3D r)
00164 {
00165 AbstractImagePlane::_rotate_center(r);
00166 }
00167
00168 void _shift_center (Vector3D shift)
00169 {
00170 AbstractImagePlane::_shift_center(shift);
00171 }
00172
00173
00174 Point3D _get_tlhc (void)
00175 {
00176 return AbstractImagePlane::_get_tlhc();
00177 }
00178
00179 void _set_tlhc (Point3D p)
00180 {
00181 AbstractImagePlane::_set_tlhc(p);
00182 }
00183
00184 void _rotate_tlhc (Rotation3D r)
00185 {
00186 AbstractImagePlane::_rotate_tlhc(r);
00187 }
00188
00189 void _shift_tlhc (Vector3D shift)
00190 {
00191 AbstractImagePlane::_shift_tlhc(shift);
00192 }
00193
00194 void _scale_tlhc (double factor)
00195 {
00196 AbstractImagePlane::_scale_tlhc(factor);
00197 }
00198
00199
00200
00201 Vector3D _get_rowvec (void)
00202 {
00203 return AbstractImagePlane::_get_rowvec();
00204 }
00205
00206 void _set_rowvec (Vector3D v)
00207 {
00208 AbstractImagePlane::_set_rowvec(v);
00209 }
00210
00211 void _rotate_rowvec (Rotation3D r)
00212 {
00213 AbstractImagePlane::_rotate_rowvec(r);
00214 }
00215
00216
00217 Vector3D _get_colvec (void)
00218 {
00219 return AbstractImagePlane::_get_colvec();
00220 }
00221
00222 void _set_colvec (Vector3D v)
00223 {
00224 AbstractImagePlane::_set_colvec(v);
00225 }
00226
00227 void _rotate_colvec (Rotation3D r)
00228 {
00229 AbstractImagePlane::_rotate_colvec(r);
00230 }
00231 public:
00232 ImagePlane(
00233 ImagePlanePlane plane,
00234 double fov,
00235 ImagePlaneHeadFeet hfff,
00236 ImagePlanePosition posn
00237 ) :
00238 AbstractImagePlane(plane,fov,fov),
00239 PatientPlane(hfff,posn),
00240 MachinePlane()
00241 {
00242 #ifdef DEBUGPLANE
00243 cerr << "ImagePlane::ImagePlane(plane,fov,hfff,posn)" << endl;
00244 #endif
00245 }
00246
00247 ImagePlane(
00248 ImagePlanePlane plane,
00249 double hfov,
00250 double vfov,
00251 ImagePlaneHeadFeet hfff,
00252 ImagePlanePosition posn
00253 ) :
00254 AbstractImagePlane(plane,hfov,vfov),
00255 PatientPlane(hfff,posn),
00256 MachinePlane()
00257 {
00258 #ifdef DEBUGPLANE
00259 cerr << "ImagePlane::ImagePlane(plane,hfov,vfov,hfff,posn)" << endl;
00260 #endif
00261 }
00262
00263 ImagePlane(
00264 ImagePlaneHeadFeet hfff,
00265 ImagePlanePosition posn
00266 ) :
00267 AbstractImagePlane(),
00268 PatientPlane(hfff,posn),
00269 MachinePlane()
00270 {
00271 #ifdef DEBUGPLANE
00272 cerr << "ImagePlane::ImagePlane(hfff,posn)" << endl;
00273 #endif
00274 }
00275
00276 #ifdef DEBUGPLANE
00277 void put(ostream &);
00278 #endif
00279 };
00280
00281 #endif