00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #ifndef __mitkVolumeResliceFilter_h
00012 #define __mitkVolumeResliceFilter_h
00013
00014 #include "mitkVolumeToVolumeFilter.h"
00015 #include "mitkRCPtr.h"
00016 #include "mitkPlane.h"
00017
00023 class MITK_COMMON_API mitkRectPlane
00024 {
00025 public:
00026 typedef double coord_type;
00027
00028 mitkRectPlane()
00029 {
00030 v0[0] = coord_type(0), v0[1] = coord_type(0); v0[2] = coord_type(0); v0[3] = coord_type(0);
00031 v1[0] = coord_type(1), v1[1] = coord_type(0); v1[2] = coord_type(0); v1[3] = coord_type(0);
00032 v2[0] = coord_type(2), v2[1] = coord_type(0); v2[2] = coord_type(0); v2[3] = coord_type(0);
00033 }
00034
00035 mitkRectPlane(coord_type pv0[4], coord_type pv1[4], coord_type pv2[4])
00036 {
00037 v0[0] = pv0[0], v0[1] = pv0[1]; v0[2] = pv0[2]; v0[3] = pv0[3];
00038 v1[0] = pv1[0], v1[1] = pv1[1]; v1[2] = pv1[2]; v1[3] = pv1[3];
00039 v2[0] = pv2[0], v2[1] = pv2[1]; v2[2] = pv2[2]; v2[3] = pv2[3];
00040 }
00041
00042 mitkRectPlane(coord_type v0x, coord_type v0y, coord_type v0z,
00043 coord_type v1x, coord_type v1y, coord_type v1z,
00044 coord_type v2x, coord_type v2y, coord_type v2z)
00045 {
00046 v0[0] = v0x, v0[1] = v0y; v0[2] = v0z; v0[3] = 1.0;
00047 v1[0] = v1x, v1[1] = v1y; v1[2] = v1z; v1[3] = 1.0;
00048 v2[0] = v2x, v2[1] = v2y; v2[2] = v2z; v2[3] = 1.0;
00049 }
00050
00051 ~mitkRectPlane() {};
00052
00053 mitkRectPlane& operator=(mitkRectPlane const &p)
00054 {
00055 v0[0] = p.v0[0]; v0[1] = p.v0[1]; v0[2] = p.v0[2]; v0[3] = p.v0[3];
00056 v1[0] = p.v1[0]; v1[1] = p.v1[1]; v1[2] = p.v1[2]; v1[3] = p.v1[3];
00057 v2[0] = p.v2[0]; v2[1] = p.v2[1]; v2[2] = p.v2[2]; v2[3] = p.v2[3];
00058 return *this;
00059 }
00060
00061 mitkRectPlane(mitkRectPlane const &p)
00062 {
00063 v0[0] = p.v0[0]; v0[1] = p.v0[1]; v0[2] = p.v0[2]; v0[3] = p.v0[3];
00064 v1[0] = p.v1[0]; v1[1] = p.v1[1]; v1[2] = p.v1[2]; v1[3] = p.v1[3];
00065 v2[0] = p.v2[0]; v2[1] = p.v2[1]; v2[2] = p.v2[2]; v2[3] = p.v2[3];
00066 }
00067
00073 bool CheckValidity()
00074 {
00075 double x1 = v1[0]-v0[0];
00076 double y1 = v1[1]-v0[1];
00077 double z1 = v1[2]-v0[2];
00078 double x2 = v2[0]-v0[0];
00079 double y2 = v2[1]-v0[1];
00080 double z2 = v2[2]-v0[2];
00081 double d = fabs(x1*x2 + y1*y2 + z1*z2) / (sqrt(x1*x1+y1*y1+z1*z1)*sqrt(x2*x2+y2*y2+z2*z2));
00082
00083 if (d<1e-6) return true;
00084 else return false;
00085 }
00086
00087 public:
00088 coord_type v0[4];
00089 coord_type v1[4];
00090 coord_type v2[4];
00091 };
00092
00100 class MITK_COMMON_API mitkVolumeResliceFilter : public mitkVolumeToVolumeFilter
00101 {
00102 public:
00103 MITK_TYPE(mitkVolumeResliceFilter, mitkVolumeToVolumeFilter)
00104
00105 virtual void PrintSelf(ostream &os);
00106
00110 mitkVolumeResliceFilter();
00111
00117 void SetStartPlane(mitkRectPlane const &p) { m_StartPlane = p; }
00118
00125 void SetStopPoint(double x, double y, double z)
00126 {
00127 m_StopPoint[0] = x;
00128 m_StopPoint[1] = y;
00129 m_StopPoint[2] = z;
00130 m_StopPoint[3] = 1.0;
00131 }
00132
00137 void SetSliceWidth(int w) { m_SliceWidth = w; m_SpacingXFirst = false; }
00138
00143 void SetSliceHeight(int h) { m_SliceHeight = h; m_SpacingYFirst = false; }
00144
00149 void SetSliceNumber(int num) { m_SliceNum = num; m_SpacingZFirst = false; }
00150
00155 void SetSpacingX(double sx) { m_SpacingX = fabs(sx); m_SpacingXFirst = true; }
00156
00161 void SetSpacingY(double sy) { m_SpacingY = fabs(sy); m_SpacingYFirst = true; }
00162
00167 void SetSpacingZ(double sz) { m_SpacingZ = fabs(sz); m_SpacingZFirst = true; }
00168
00169 protected:
00170 virtual ~mitkVolumeResliceFilter();
00171
00172 virtual bool Execute();
00173
00174 mitkRectPlane m_StartPlane;
00175
00176 double m_StopPoint[4];
00177
00178 double m_SpacingX;
00179 double m_SpacingY;
00180 double m_SpacingZ;
00181
00182 int m_SliceWidth;
00183 int m_SliceHeight;
00184 int m_SliceNum;
00185
00186 bool m_SpacingXFirst;
00187 bool m_SpacingYFirst;
00188 bool m_SpacingZFirst;
00189
00190 private:
00191 mitkVolumeResliceFilter(const mitkVolumeResliceFilter&);
00192 void operator = (const mitkVolumeResliceFilter&);
00193
00194 };
00195
00196
00197
00198
00199
00200
00201 #endif
00202