00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033 #ifndef __VCG_TETRAHEDRON_PLUS_COMPONENT
00034 #define __VCG_TETRAHEDRON_PLUS_COMPONENT
00035
00036 #include <vector>
00037 #include <vcg/space/tetra3.h>
00038
00039 namespace vcg {
00040 namespace tetra {
00041
00042
00043
00044
00045
00046
00047
00048 template <class T> class EmptyVertexRef: public T {
00049 public:
00050
00051
00052 inline typename T::VertexType * & V( const int j ) { assert(0); static typename T::VertexType *vp=0; return vp; }
00053 inline typename T::VertexType * const & V( const int j ) const { assert(0); static typename T::VertexType *vp=0; return vp; }
00054 inline typename T::VertexType * const cV( const int j ) const { assert(0); static typename T::VertexType *vp=0; return vp; }
00055 inline typename T::CoordType & P( const int j ) { assert(0); static typename T::CoordType coord(0, 0, 0); return coord; }
00056 inline const typename T::CoordType & P( const int j ) const { assert(0); static typename T::CoordType coord(0, 0, 0); return coord; }
00057 inline const typename T::CoordType &cP( const int j ) const { assert(0); static typename T::CoordType coord(0, 0, 0); return coord; }
00058 static bool HasVertexRef() { return false; }
00059 static void Name(std::vector<std::string> & name){T::Name(name);}
00060
00061 };
00062 template <class T> class VertexRef: public T {
00063 public:
00064 VertexRef(){
00065 v[0]=0;
00066 v[1]=0;
00067 v[2]=0;
00068 }
00069
00070 inline typename T::VertexType * & V( const int j ) { assert(j>=0 && j<4); return v[j]; }
00071 inline typename T::VertexType * const & V( const int j ) const { assert(j>=0 && j<4); return v[j]; }
00072 inline typename T::VertexType * const cV( const int j ) const { assert(j>=0 && j<4); return v[j]; }
00073
00074
00075 inline typename T::CoordType & P( const int j ) { assert(j>=0 && j<4); return v[j]->P(); }
00076 inline const typename T::CoordType & P( const int j ) const { assert(j>=0 && j<4); return v[j]->cP(); }
00077 inline const typename T::CoordType &cP( const int j ) const { assert(j>=0 && j<4); return v[j]->cP(); }
00078
00082 inline typename T::VertexType * & V0( const int j ) { return V(j);}
00083 inline typename T::VertexType * & V1( const int j ) { return V((j+1)%4);}
00084 inline typename T::VertexType * & V2( const int j ) { return V((j+2)%4);}
00085 inline const typename T::VertexType * const & V0( const int j ) const { return V(j);}
00086 inline const typename T::VertexType * const & V1( const int j ) const { return V((j+1)%4);}
00087 inline const typename T::VertexType * const & V2( const int j ) const { return V((j+2)%4);}
00088 inline const typename T::VertexType * const & cV0( const int j ) const { return cV(j);}
00089 inline const typename T::VertexType * const & cV1( const int j ) const { return cV((j+1)%4);}
00090 inline const typename T::VertexType * const & cV2( const int j ) const { return cV((j+2)%4);}
00091
00093 inline typename T::CoordType & P0( const int j ) { return V(j)->P();}
00094 inline typename T::CoordType & P1( const int j ) { return V((j+1)%4)->P();}
00095 inline typename T::CoordType & P2( const int j ) { return V((j+2)%4)->P();}
00096 inline const typename T::CoordType & P0( const int j ) const { return V(j)->P();}
00097 inline const typename T::CoordType & P1( const int j ) const { return V((j+1)%4)->P();}
00098 inline const typename T::CoordType & P2( const int j ) const { return V((j+2)%4)->P();}
00099 inline const typename T::CoordType & cP0( const int j ) const { return cV(j)->P();}
00100 inline const typename T::CoordType & cP1( const int j ) const { return cV((j+1)%4)->P();}
00101 inline const typename T::CoordType & cP2( const int j ) const { return cV((j+2)%4)->P();}
00102
00103 inline typename T::VertexType * & UberV( const int j ) { assert(j>=0 && j<4); return v[j]; }
00104 inline const typename T::VertexType * const & UberV( const int j ) const { assert(j>=0 && j<4); return v[j]; }
00105 static bool HasVertexRef() { return true; }
00106 static void Name(std::vector<std::string> & name){name.push_back(std::string("VertexRef"));T::Name(name);}
00107
00108
00109 private:
00110 typename T::VertexType *v[4];
00111 };
00112
00113
00114
00115 template <class A, class T> class EmptyFaceNormal: public T {
00116 public:
00117 typedef ::vcg::Point3<A> NormalType;
00119 NormalType N(const int & ){ static int dummynormal(0); return dummynormal; }
00120 const NormalType cN(const int & ) const { return 0; }
00121 static bool HasFaceNormal() { return false; }
00122 static bool HasFaceNormalOcc() { return false; }
00123 static void Name(std::vector<std::string> & name){T::Name(name);}
00124
00125 };
00126
00127 template <class A, class T> class FaceNormal: public T {
00128 public:
00129 typedef ::vcg::Point3<A> NormalType;
00130
00131 NormalType N(const int & i){ assert((i>=0)&&(i < 4)); return _facenormals[i]; }
00132 const NormalType cN(const int & i) const { assert((i>=0)&&(i < 4)); return _facenormals[i]; }
00133 static bool HasFaceNormals() { return true; }
00134 static bool HasFaceNormalOcc() { return false; }
00135 static void Name(std::vector<std::string> & name){name.push_back(std::string("FaceNormal"));T::Name(name);}
00136
00137 private:
00138 NormalType _facenormals[4];
00139 };
00140
00141 template <class T> class FaceNormal3f: public FaceNormal<float,T>{
00142 public:static void Name(std::vector<std::string> & name){name.push_back(std::string("FaceNormal3f"));T::Name(name);} };
00143
00144 template <class T> class FaceNormal3d: public FaceNormal<double,T>{
00145 public:static void Name(std::vector<std::string> & name){name.push_back(std::string("FaceNormal3d"));T::Name(name);} };
00146
00147
00148 template <class T> class EmptyBitFlags: public T {
00149 public:
00151 int &Flags() { static int dummyflags(0); return dummyflags; }
00152 const int Flags() const { return 0; }
00153 static bool HasFlags() { return false; }
00154 static bool HasFlagsOcc() { return false; }
00155 static void Name(std::vector<std::string> & name){T::Name(name);}
00156
00157 };
00158
00159 template <class T> class BitFlags: public T {
00160 public:
00161 BitFlags(){_flags=0;}
00162 int &Flags() {return _flags; }
00163 const int Flags() const {return _flags; }
00164 static bool HasFlags() { return true; }
00165 static void Name(std::vector<std::string> & name){name.push_back(std::string("BitFlags"));T::Name(name);}
00166
00167
00168 private:
00169 int _flags;
00170 };
00171
00172
00173 template <class T> class EmptyMark: public T {
00174 public:
00175 typedef int MarkType;
00176 static bool HasMark() { return false; }
00177 static bool HasMarkOcc() { return false; }
00178 inline void InitIMark() { }
00179 inline int & IMark() { assert(0); static int tmp=-1; return tmp;}
00180 inline const int IMark() const {return 0;}
00181 static void Name(std::vector<std::string> & name){T::Name(name);}
00182
00183 };
00184 template <class T> class Mark: public T {
00185 public:
00186 static bool HasMark() { return true; }
00187 static bool HasMarkOcc() { return true; }
00188 inline void InitIMark() { _imark = 0; }
00189 inline int & IMark() { return _imark;}
00190 inline const int & IMark() const {return _imark;}
00191 static void Name(std::vector<std::string> & name){name.push_back(std::string("Mark"));T::Name(name);}
00192
00193 private:
00194 int _imark;
00195 };
00196
00197
00198
00199
00200 template <class T> class EmptyAdj: public T {
00201 public:
00202 typedef int VFAdjType;
00203 typename T::TetraPointer & VTp( const int ) { static typename T::TetraPointer tp=0; return tp; }
00204 typename T::TetraPointer const cVTp( const int ) const { static typename T::TetraPointer const tp=0; return tp; }
00205 typename T::TetraPointer & TTp( const int ) { static typename T::TetraPointer tp=0; return tp; }
00206 typename T::TetraPointer const cTTp( const int ) const { static typename T::TetraPointer const tp=0; return tp; }
00207 char & VTi( const int j ) { static char z=0; return z; }
00208 char & TTi( const int j ) { static char z=0; return z; }
00209 static bool HasVTAdjacency() { return false; }
00210 static bool HasTTAdjacency() { return false; }
00211 static bool HasTTAdjacencyOcc() { return false; }
00212 static bool HasVTAdjacencyOcc() { return false; }
00213 static void Name( std::vector< std::string > & name ){ T::Name(name); }
00214 };
00215
00216 template <class T> class VTAdj: public T {
00217 public:
00218 VTAdj() { _vtp[0]=0; _vtp[1]=0; _vtp[2]=0; _vtp[3]=0; }
00219 typename T::TetraPointer & VTp( const int j ) { assert( j >= 0 && j < 4 ); return _vtp[j]; }
00220 typename T::TetraPointer const VTp( const int j ) const { assert( j >= 0 && j < 4 ); return _vtp[j]; }
00221 typename T::TetraPointer const cVTp( const int j ) const { assert( j >= 0 && j < 4 ); return _vtp[j]; }
00222 char & VTi( const int j ) { return _vti[j]; }
00223 const char & cVTi( const int j ) const { return _vti[j]; }
00224 static bool HasVTAdjacency() { return true; }
00225 static bool HasVTAdjacencyOcc() { return false; }
00226 static void Name( std::vector< std::string > & name ) { name.push_back( std::string("VTAdj") ); T::Name(name); }
00227
00228 private:
00229 typename T::TetraPointer _vtp[4];
00230 char _vti[4];
00231 };
00232
00233
00234
00235 template <class T> class TTAdj: public T {
00236 public:
00237 TTAdj(){
00238 _ttp[0]=0;
00239 _ttp[1]=0;
00240 _ttp[2]=0;
00241 _ttp[3]=0;
00242 }
00243 typename T::TetraPointer &TTp(const int j) { assert(j>=0 && j<4); return _ttp[j]; }
00244 typename T::TetraPointer const TTp(const int j) const { assert(j>=0 && j<4); return _ttp[j]; }
00245 typename T::TetraPointer const cTTp(const int j) const { assert(j>=0 && j<4); return _ttp[j]; }
00246 char &TTi(const int j) { return _tti[j]; }
00247 const char &cTTi(const int j) const { return _tti[j]; }
00248
00249 typename T::TetraPointer &TTp1( const int j ) { return TTp((j+1)%4);}
00250 typename T::TetraPointer &TTp2( const int j ) { return TTp((j+2)%4);}
00251 typename T::TetraPointer const TTp1( const int j ) const { return TTp((j+1)%4);}
00252 typename T::TetraPointer const TTp2( const int j ) const { return TTp((j+2)%4);}
00253
00254 bool IsBorderF(const int & i) const { assert( (i>=0) && (i < 4)); { return TTp(i) == this;}}
00255
00256 static bool HasTTAdjacency() { return true; }
00257 static bool HasTTAdjacencyOcc() { return false; }
00258 static void Name(std::vector<std::string> & name){name.push_back(std::string("TTAdj"));T::Name(name);}
00259
00260 private:
00261 typename T::TetraPointer _ttp[4] ;
00262 char _tti[4] ;
00263 };
00264
00265 }
00266 }
00267 #endif