00001
00015 #ifndef MDS_TETRASCALING_H
00016 #define MDS_TETRASCALING_H
00017
00018
00019 #include <MDSTk/Base/mdsTypes.h>
00020 #include <MDSTk/Base/mdsAssert.h>
00021 #include <MDSTk/Math/mdsBase.h>
00022
00023
00024 #include <VectorEntity/mccoordinate3d.h>
00025
00026
00027 namespace mds
00028 {
00029 namespace seg
00030 {
00031
00032
00037 class CTetraScaling
00038 {
00039 public:
00041 typedef vctl::MCCoordinate3D<double> tCoordinates;
00042
00043 public:
00045 CTetraScaling()
00046 : m_dDX(1.0)
00047 , m_dDY(1.0)
00048 , m_dDZ(1.0)
00049 , m_dMin(1.0)
00050 , m_dInvMin(1.0)
00051 , m_dInvDX(1.0)
00052 , m_dInvDY(1.0)
00053 , m_dInvDZ(1.0)
00054 {
00055 }
00056
00058 CTetraScaling(double dDX, double dDY, double dDZ)
00059 : m_dDX(dDX)
00060 , m_dDY(dDY)
00061 , m_dDZ(dDZ)
00062 , m_dMin(mds::math::getMin(dDX, dDY, dDZ))
00063 {
00064 MDS_ASSERT(dDX > 0.0 && dDY > 0.0 && dDZ > 0.0);
00065
00066 m_dInvDX = 1.0 / dDX;
00067 m_dInvDY = 1.0 / dDY;
00068 m_dInvDZ = 1.0 / dDZ;
00069
00070 m_dInvMin = 1.0 / m_dMin;
00071 }
00072
00074 ~CTetraScaling() {}
00075
00077 void setVoxelSize(double dDX, double dDY, double dDZ)
00078 {
00079 MDS_ASSERT(dDX > 0.0 && dDY > 0.0 && dDZ > 0.0);
00080
00081 m_dDX = dDX;
00082 m_dDY = dDY;
00083 m_dDZ = dDZ;
00084
00085 m_dMin = mds::math::getMin(dDX, dDY, dDZ);
00086 m_dInvMin = 1.0 / m_dMin;
00087
00088 m_dInvDX = 1.0 / dDX;
00089 m_dInvDY = 1.0 / dDY;
00090 m_dInvDZ = 1.0 / dDZ;
00091 }
00092
00093
00096 double getRealX(double x) const { return x * m_dDX; }
00097 double getRealY(double y) const { return y * m_dDY; }
00098 double getRealZ(double z) const { return z * m_dDZ; }
00099
00101 double getMinRealSize(double Value) const { return Value * m_dMin; }
00102
00105 void conv2Real(mds::tSize x, mds::tSize y, mds::tSize z,
00106 double& dX,
00107 double& dY,
00108 double& dZ
00109 ) const
00110 {
00111 dX = x * m_dDX;
00112 dY = y * m_dDY;
00113 dZ = z * m_dDZ;
00114 }
00115
00118 void conv2Real(mds::tSize x, mds::tSize y, mds::tSize z, tCoordinates *pPoint) const
00119 {
00120 pPoint->SetX(x * m_dDX);
00121 pPoint->SetY(y * m_dDY);
00122 pPoint->SetZ(z * m_dDZ);
00123 }
00124
00127 void conv2Real(double dX, double dY, double dZ, tCoordinates *pPoint) const
00128 {
00129 pPoint->SetX(dX * m_dDX);
00130 pPoint->SetY(dY * m_dDY);
00131 pPoint->SetZ(dZ * m_dDZ);
00132 }
00133
00136 void conv2Real(tCoordinates *pPoint) const
00137 {
00138 pPoint->x() *= m_dDX;
00139 pPoint->y() *= m_dDY;
00140 pPoint->z() *= m_dDZ;
00141 }
00142
00143
00146 mds::tSize getVolumeX(double x) const { return mds::math::round2Int(x * m_dInvDX); }
00147 mds::tSize getVolumeY(double y) const { return mds::math::round2Int(y * m_dInvDY); }
00148 mds::tSize getVolumeZ(double z) const { return mds::math::round2Int(z * m_dInvDZ); }
00149
00151 double getMinVolumeSize(double Value) const { return Value * m_dInvMin; }
00152
00155 void conv2Volume(double dX, double dY, double dZ,
00156 mds::tSize& x,
00157 mds::tSize& y,
00158 mds::tSize& z
00159 ) const
00160 {
00161 x = mds::math::round2Int(dX * m_dInvDX);
00162 y = mds::math::round2Int(dY * m_dInvDY);
00163 z = mds::math::round2Int(dZ * m_dInvDZ);
00164 }
00165
00168 void conv2Volume(tCoordinates *pPoint, mds::tSize& x, mds::tSize& y, mds::tSize& z) const
00169 {
00170 x = mds::math::round2Int(pPoint->x() * m_dInvDX);
00171 y = mds::math::round2Int(pPoint->y() * m_dInvDY);
00172 z = mds::math::round2Int(pPoint->z() * m_dInvDZ);
00173 }
00174
00177 void conv2Volume(tCoordinates *pPoint, double& x, double& y, double& z) const
00178 {
00179 x = pPoint->x() * m_dInvDX;
00180 y = pPoint->y() * m_dInvDY;
00181 z = pPoint->z() * m_dInvDZ;
00182 }
00183
00186 void conv2Volume(tCoordinates *pPoint) const
00187 {
00188 pPoint->x() *= m_dInvDX;
00189 pPoint->y() *= m_dInvDY;
00190 pPoint->z() *= m_dInvDZ;
00191 }
00192
00193 protected:
00195 double m_dDX, m_dDY, m_dDZ;
00196
00198 double m_dMin, m_dInvMin;
00199
00201 double m_dInvDX, m_dInvDY, m_dInvDZ;
00202 };
00203
00204
00205 }
00206 }
00207
00208 #endif // MDS_TETRASCALING_H
00209