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_TETRA_PLUS
00034 #define __VCG_TETRA_PLUS
00035
00036 #include <vcg/space/point3.h>
00037 #include <vcg/space/texcoord2.h>
00038 #include <vcg/space/color4.h>
00039 #include <vcg/simplex/tetrahedron/component.h>
00040
00041 namespace vcg {
00042
00043
00044
00045
00046
00047
00048
00049 template <class BVT, class BET, class BFT, class BTT>
00050 class TetraTypeHolder{
00051 public:
00052 typedef BVT VertexType;
00053 typedef typename VertexType::CoordType CoordType;
00054 typedef typename VertexType::ScalarType ScalarType;
00055 typedef BET EdgeType;
00056 typedef BFT FaceType;
00057 typedef BTT TetraType;
00058 typedef BVT *VertPointer;
00059 typedef BET *EdgePointer;
00060 typedef BFT *FacePointer;
00061 typedef BTT *TetraPointer;
00062 static void Name(std::vector<std::string> & name){}
00063
00064
00065
00066
00067 };
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081 template <class BVT, class BET=DumET, class BFT=DumFT, class BTT=DumTT>
00082 class TetraBase: public tetra::EmptyVertexRef<
00083 tetra::EmptyAdj<
00084 TetraTypeHolder <BVT, BET, BFT, BTT> > > {
00085 };
00086
00087
00088
00089
00090
00091 template <class BVT, class BET, class BFT,class BTT,
00092 template <typename> class A>
00093 class TetraArity1: public A<TetraBase<BVT,BET,BFT,BTT> > {};
00094
00095 template <class BVT, class BET, typename BFT, class BTT,
00096 template <typename> class A, template <typename> class B>
00097 class TetraArity2: public B<TetraArity1<BVT,BET,BFT,BTT, A> > {};
00098
00099 template <class BVT, class BET, typename BFT,class BTT,
00100 template <typename> class A, template <typename> class B,
00101 template <typename> class C >
00102 class TetraArity3: public C<TetraArity2<BVT,BET,BFT,BTT, A, B> > {};
00103
00104 template <class BVT, class BET, typename BFT,class BTT,
00105 template <typename> class A, template <typename> class B,
00106 template <typename> class C, template <typename> class D>
00107 class TetraArity4: public D<TetraArity3<BVT,BET,BFT,BTT, A, B, C> > {};
00108
00109 template <class BVT, class BET, typename BFT,class BTT,
00110 template <typename> class A, template <typename> class B,
00111 template <typename> class C, template <typename> class D,
00112 template <typename> class E >
00113 class TetraArity5: public E<TetraArity4<BVT,BET,BFT,BTT, A, B, C, D> > {};
00114
00115 template <class BVT, class BET, typename BFT,class BTT,
00116 template <typename> class A, template <typename> class B,
00117 template <typename> class C, template <typename> class D,
00118 template <typename> class E, template <typename> class F >
00119 class TetraArity6: public F<TetraArity5<BVT,BET,BFT,BTT, A, B, C, D, E> > {};
00120
00121 template <class BVT, class BET, typename BFT,class BTT,
00122 template <typename> class A, template <typename> class B,
00123 template <typename> class C, template <typename> class D,
00124 template <typename> class E, template <typename> class F,
00125 template <typename> class G >
00126 class TetraArity7: public G<TetraArity6<BVT,BET,BFT,BTT, A, B, C, D, E, F> > {};
00127
00128 template <class BVT, class BET, typename BFT,class BTT,
00129 template <typename> class A, template <typename> class B,
00130 template <typename> class C, template <typename> class D,
00131 template <typename> class E, template <typename> class F,
00132 template <typename> class G, template <typename> class H >
00133 class TetraArity8: public H<TetraArity7<BVT,BET,BFT,BTT, A, B, C, D, E, F, G> > {};
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147 template <class BVT, class BET, typename BFT,class BTT,
00148 template <typename> class A, template <typename> class B,
00149 template <typename> class C, template <typename> class D,
00150 template <typename> class E, template <typename> class F,
00151 template <typename> class G, template <typename> class H,
00152 template <typename> class I >
00153 class TetraArityMax: public I<TetraArity8<BVT,BET,BFT,BTT, A, B, C, D, E, F, G, H> > {
00154
00155
00156 public:
00157
00158 enum {
00159
00160 DELETED = 0x00000001,
00161 NOTREAD = 0x00000002,
00162 NOTWRITE = 0x00000004,
00163 VISITED = 0x00000010,
00164 SELECTED = 0x00000020,
00165
00166 BORDER0 = 0x00000040,
00167 BORDER1 = 0x00000080,
00168 BORDER2 = 0x00000100,
00169 BORDER3 = 0x00000200,
00170
00171
00172 USER0 = 0x00004000
00173 };
00174
00175
00177 bool IsD() const {return (this->Flags() & DELETED) != 0;}
00179 bool IsR() const {return (this->Flags() & NOTREAD) == 0;}
00181 bool IsW() const {return (this->Flags() & NOTWRITE)== 0;}
00183 bool IsRW() const {return (this->Flags() & (NOTREAD | NOTWRITE)) == 0;}
00185 bool IsS() const {return (this->Flags() & SELECTED) != 0;}
00187 bool IsV() const {return (this->Flags() & VISITED) != 0;}
00188
00192 void SetFlags(int flagp) {this->Flags()=flagp;}
00193
00197 void ClearFlags() {this->Flags()=0;}
00198
00200 void SetD() {this->Flags() |=DELETED;}
00202 void ClearD() {this->Flags() &=(~DELETED);}
00204 void SetR() {this->Flags() &=(~NOTREAD);}
00206 void ClearR() {this->Flags() |=NOTREAD;}
00208 void SetW() {this->Flags() &=(~NOTWRITE);}
00210 void ClearW() {this->Flags() |=NOTWRITE;}
00212 void SetS() {this->Flags() |=SELECTED;}
00214 void ClearS() {this->Flags() &= ~SELECTED;}
00216 void SetV() {this->Flags() |=VISITED;}
00218 void ClearV() {this->Flags() &= ~VISITED;}
00219
00221 bool IsB(int i) const {return (this->Flags() & (BORDER0<<i)) != 0;}
00223 void SetB(int i) {this->Flags() |=(BORDER0<<i);}
00225 void ClearB(int i) {this->Flags() &= (~(BORDER0<<i));}
00226
00228 static int &FirstUnusedBitFlag()
00229 {
00230 static int b =USER0;
00231 return b;
00232 }
00233
00235 static inline int NewBitFlag()
00236 {
00237 int bitForTheUser = FirstUnusedBitFlag();
00238 FirstUnusedBitFlag()=FirstUnusedBitFlag()<<1;
00239 return bitForTheUser;
00240 }
00241
00243
00244 static inline bool DeleteBitFlag(int bitval)
00245 {
00246 if(FirstUnusedBitFlag()>>1==bitval) {
00247 FirstUnusedBitFlag() = FirstUnusedBitFlag()>>1;
00248 return true;
00249 }
00250 assert(0);
00251 return false;
00252 }
00253
00255 bool IsUserBit(int userBit){return (this->Flags() & userBit) != 0;}
00256
00258 void SetUserBit(int userBit){this->Flags() |=userBit;}
00259
00261 void ClearUserBit(int userBit){this->Flags() &= (~userBit);}
00262
00263 template<class BoxType>
00264 void GetBBox( BoxType & bb ) const
00265 {
00266 bb.Set(this->P(0));
00267 bb.Add(this->P(1));
00268 bb.Add(this->P(2));
00269 }
00270
00271
00272 };
00273
00274 template < typename T=int>
00275 class TetraDefaultDeriver : public T {};
00276
00277
00278
00279
00280
00281
00282
00283
00284
00285
00286
00287
00288
00289
00290
00291
00292
00293
00294
00295
00296
00297
00298
00299
00300
00301
00302
00303
00304
00305 template <class BVT, class BET, class BFT, class BTT,
00306 template <typename> class A = TetraDefaultDeriver, template <typename> class B = TetraDefaultDeriver,
00307 template <typename> class C = TetraDefaultDeriver, template <typename> class D = TetraDefaultDeriver,
00308 template <typename> class E = TetraDefaultDeriver, template <typename> class F = TetraDefaultDeriver,
00309 template <typename> class G = TetraDefaultDeriver, template <typename> class H = TetraDefaultDeriver,
00310 template <typename> class I = TetraDefaultDeriver >
00311 class TetraSimp3: public TetraArityMax<BVT,BET,BFT,BTT, A, B, C, D, E, F, G, H, I> {};
00312 class DumTT;
00313 template <class BVT, class BET, class BFT,
00314 template <typename> class A = TetraDefaultDeriver, template <typename> class B = TetraDefaultDeriver,
00315 template <typename> class C = TetraDefaultDeriver, template <typename> class D = TetraDefaultDeriver,
00316 template <typename> class E = TetraDefaultDeriver, template <typename> class F = TetraDefaultDeriver,
00317 template <typename> class G = TetraDefaultDeriver, template <typename> class H = TetraDefaultDeriver,
00318 template <typename> class I = TetraDefaultDeriver >
00319 class TetraSimp2: public TetraArityMax<BVT,BET,BFT,DumTT, A, B, C, D, E, F, G, H, I> {};
00320
00321
00322 }
00323 #endif
00324