Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members

mitkTetra.h

00001 /*=========================================================================
00002 
00003   Program:   3DMed
00004   Date:      $Date: 2014-02-25 18:30:00 +0800 $
00005   Version:   $Version: 4.6.0 $
00006   Copyright: MIPG, Institute of Automation, Chinese Academy of Sciences
00007 
00008 =========================================================================*/
00009 
00010 
00011 #ifndef _mitkTetra_h
00012 #define _mitkTetra_h
00013 
00014 #include "mitkDataObject.h"
00015 //需要在mitkGlobal.h中添加  #define MITK_TETRA                      4000
00016 
00017 //重新定义类型,该类型为变量所指向的内容不能更改
00018 typedef  const float (*TetraVertex)[3];
00019 typedef  const int (*TetraTet)[4];
00020 typedef  const int (*TetraQtet)[6];
00021 typedef  const int (*TetraTetNei)[4];
00022 
00023 //在类名前加上MITK_COMMON_API
00024 class  mitkTetra : public mitkDataObject
00025 {
00026 public:
00027 
00028    MITK_TYPE(mitkTetra,mitkDataObject);
00029 
00030    virtual void PrintSelf(ostream& os);
00031 
00035     virtual void Initialize();
00036 
00041     virtual int GetDataObjectType() const {return MITK_TETRA;}
00042 
00043   virtual unsigned long long GetActualMemorySize() const;
00044 
00048   virtual void ShallowCopy(mitkDataObject *src);
00049 
00053   virtual void DeepCopy(mitkDataObject *src);
00054 
00055   mitkTetra();
00056   
00057 
00058   bool SetVertexN(int vN)   
00059   { 
00060       if(vN < 1)
00061           return false;//参数非法
00062       m_VertexN = vN; 
00063       m_Vertex = new float[vN][3]; 
00064       return true;
00065   }
00066 
00067    int GetVertexN() const   {   return m_VertexN; }
00068 
00069   bool SetTetN(int tN);
00070   int GetTetN() const { return m_TetN; }
00071 
00072   bool SetQtetN(int tN);
00073 
00074   void SetVertex(int i, float v[3]);
00075   TetraVertex GetVertex() const { return m_Vertex; }
00076   void GetVertex( int i,float v[3] ) const;
00077 
00078   void SetTet(int i, int t[4]);
00079   TetraTet GetTet() const { return m_Tet;}
00080   void GetTet(int i, int t[4] );
00081   
00082   void SetQtet(int i, int qt[6]);
00083   TetraQtet GetQtet() const { return m_Qtet; }
00084   void GetQtet(int i, int qt[6])  const;
00085   
00086   bool SetMaxId(int n);
00087   unsigned char GetMaxId() const { return m_MaxId; }
00088   void GetVisId(bool visid[]) const;
00089    
00090   void GetVisible(bool vis[]) const;
00091 
00092   TetraTetNei GetTetNei() const { return m_TetNei; }
00093   void GetTetNei( int i, int tn[4] ) const;
00094   
00095   void SetId(int i, int m)      {   m_Id[i] = m;    }
00096   void GetId(unsigned char m_Id[]) const;
00097 
00098   inline int CountId(int t) {   return m_IdN[t];        }
00099   void GetIdN(int m_IdN[]) const;
00100 
00101   void DoneSetting()        {   ComputeNeighbor();  }
00102   
00103   void NormalizeBox(float max_size);
00104   
00105   void UpdateVisible();
00106   
00107   float VolDiff(int i);
00108   static  inline void AreaNormal(float n[3],float p0[3], float p1[3], float p2[3])
00109  {
00110     float a[3], b[3];
00111     Vector(a, p0, p1);
00112     Vector(b, p0, p2);
00113     n[0] = a[1]*b[2] - a[2]*b[1];
00114     n[1] = a[2]*b[0] - a[0]*b[2];
00115     n[2] = a[0]*b[1] - a[1]*b[0];
00116   };
00117   
00118   static inline bool Normalize(float e[3], float a[3])
00119 {
00120     double l = sqrt(a[0]*a[0] + a[1]*a[1] + a[2]*a[2]);
00121     if((float)l != 0)
00122     {
00123       e[0] = (float)(a[0]/l);
00124       e[1] = (float)(a[1]/l);
00125       e[2] = (float)(a[2]/l);
00126       return true;
00127     }
00128     else
00129       return false;
00130   }
00131   //vector pq
00132   static inline void Vector(float v[3], float p[3], float q[3])
00133 {
00134     v[0] = q[0] - p[0];
00135     v[1] = q[1] - p[1];
00136     v[2] = q[2] - p[2];
00137   }
00138 
00139   float GetClipX1 () const { return m_ClipX1; }
00140   float GetClipX2 () const { return m_ClipX2; }
00141   float GetClipY1 () const { return m_ClipY1; }
00142   float GetClipY2 () const { return m_ClipY2; }
00143   float GetClipZ1 () const { return m_ClipZ1; }
00144   float GetClipZ2 () const { return m_ClipZ2; }
00145 
00146   void GetMinB (float min_b[]) const
00147   {
00148       min_b[0] = m_MinB[0];
00149       min_b[1] = m_MinB[1];
00150       min_b[2] = m_MinB[2];
00151   }
00152 
00153   void GetMaxB (float max_b[]) const
00154   {
00155       max_b[0] = m_MaxB[0];
00156       max_b[1] = m_MaxB[1];
00157       max_b[2] = m_MaxB[2];
00158   }
00159 
00160 protected:
00161     
00162     virtual ~mitkTetra();
00163     //the number of vertices
00164   int m_VertexN;
00165   //the coordinates of vertices
00166   float (*m_Vertex)[3];
00167   //the number of elements
00168   int m_TetN;
00169   //indecies of elements
00170   int (*m_Tet)[4];
00171   int (*m_Qtet)[6];
00172   //the number of materials
00173   unsigned char m_MaxId;
00174   int* m_IdN;
00175   //material ID for elements
00176   unsigned char *m_Id;
00177   //neighbor for each face of an element
00178   int (*m_TetNei)[4];
00179   //visible or not by clipping
00180   bool *m_Visible;
00181   //visible material ID
00182   bool *m_VisId;
00183   //Bounding box
00184   float m_ClipX1, m_ClipX2;
00185   float m_ClipY1, m_ClipY2;
00186   float m_ClipZ1, m_ClipZ2;
00187   float m_MinB[3], m_MaxB[3];
00188 
00189   void ComputeNeighbor();
00190   inline float Volume(int i);
00191 
00192  private:
00193   mitkTetra(const mitkTetra&);
00194   void operator=(const mitkTetra&);
00195 };
00196 
00197 #endif

Generated on Tue Feb 25 15:00:37 2014 for MITK (Medical Imaging ToolKit) by  doxygen 1.4.3