00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef __VCG_FACE_PLUS
00025 #define __VCG_FACE_PLUS
00026
00027 #include <vcg/space/point3.h>
00028 #include <vcg/space/texcoord2.h>
00029 #include <vcg/space/color4.h>
00030 #include <vcg/complex/all_types.h>
00031 #include <vcg/simplex/face/component.h>
00032 #include <vcg/simplex/face/component_polygon.h>
00033 #include <vcg/container/derivation_chain.h>
00034
00035 namespace vcg {
00036
00037
00038
00039
00040
00041
00042
00043 template <class UserTypes>
00044 class FaceTypeHolder: public UserTypes {
00045 public:
00046
00047 template <class LeftF>
00048 void ImportData(const LeftF & ){}
00049 static void Name(std::vector<std::string> & ){}
00050
00051
00052
00053 int VN() const { return 3;}
00054 inline int Prev(const int & i) const { return (i+(3-1))%3;}
00055 inline int Next(const int & i) const { return (i+1)%3;}
00056 inline void Alloc(const int & ){}
00057 inline void Dealloc(){}
00058 };
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072 template <class UserTypes>
00073 class FaceBase: public face::EmptyPolyInfo<
00074 face::EmptyVertexRef<
00075 face::EmptyAdj<
00076 face::EmptyColorMarkQuality<
00077 face::EmptyNormal<
00078 face::EmptyBitFlags<
00079 face::EmptyWedgeTexCoord<
00080 FaceTypeHolder <UserTypes> > > > > > > > {
00081
00082 };
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097 template < class UserTypes,
00098 template <typename> class A, template <typename> class B,
00099 template <typename> class C, template <typename> class D,
00100 template <typename> class E, template <typename> class F,
00101 template <typename> class G, template <typename> class H,
00102 template <typename> class I, template <typename> class J >
00103 class FaceArityMax: public J<Arity9<FaceBase<UserTypes>, A, B, C, D, E, F, G, H, I> > {
00104
00105 public:
00106 typedef typename FaceArityMax::ScalarType ScalarType;
00107
00108
00109 inline int & UberFlags ()
00110 {
00111 return this->Flags();
00112 }
00113 inline int UberFlags() const
00114 {
00115 return this->Flags();
00116 }
00117 enum {
00118
00119 DELETED = 0x00000001,
00120 NOTREAD = 0x00000002,
00121 NOTWRITE = 0x00000004,
00122 VISITED = 0x00000010,
00123 SELECTED = 0x00000020,
00124
00125 BORDER0 = 0x00000040,
00126 BORDER1 = 0x00000080,
00127 BORDER2 = 0x00000100,
00128 BORDER012 = BORDER0 | BORDER1 | BORDER2 ,
00129
00130 NORMX = 0x00000200,
00131 NORMY = 0x00000400,
00132 NORMZ = 0x00000800,
00133
00134 CREASE0 = 0x00008000,
00135 CREASE1 = 0x00010000,
00136 CREASE2 = 0x00020000,
00137
00138 FAUX0 = 0x00040000,
00139 FAUX1 = 0x00080000,
00140 FAUX2 = 0x00100000,
00141 FAUX012 = FAUX0 | FAUX1 | FAUX2 ,
00142
00143 USER0 = 0x00200000
00144 };
00145
00146
00148 bool IsD() const {return (this->Flags() & DELETED) != 0;}
00150 bool IsR() const {return (this->Flags() & NOTREAD) == 0;}
00152 bool IsW() const {return (this->Flags() & NOTWRITE)== 0;}
00154 bool IsRW() const {return (this->Flags() & (NOTREAD | NOTWRITE)) == 0;}
00156 bool IsS() const {return (this->Flags() & SELECTED) != 0;}
00158 bool IsV() const {return (this->Flags() & VISITED) != 0;}
00159
00163 void SetFlags(int flagp) {this->Flags()=flagp;}
00164
00168 void ClearFlags() {this->Flags()=0;}
00169
00171 void SetD() {this->Flags() |=DELETED;}
00173 void ClearD() {this->Flags() &=(~DELETED);}
00175 void SetR() {this->Flags() &=(~NOTREAD);}
00177 void ClearR() {this->Flags() |=NOTREAD;}
00179 void SetW() {this->Flags() &=(~NOTWRITE);}
00181 void ClearW() {this->Flags() |=NOTWRITE;}
00183 void SetS() {this->Flags() |=SELECTED;}
00185 void ClearS() {this->Flags() &= ~SELECTED;}
00187 void SetV() {this->Flags() |=VISITED;}
00189 void ClearV() {this->Flags() &= ~VISITED;}
00190
00192 bool IsB(int i) const {return (this->Flags() & (BORDER0<<i)) != 0;}
00194 void SetB(int i) {this->Flags() |=(BORDER0<<i);}
00196 void ClearB(int i) {this->Flags() &= (~(BORDER0<<i));}
00197
00201 bool IsF(int i) const {return (this->Flags() & (FAUX0<<i) ) != 0;}
00202 bool IsAnyF() const {return (this->Flags() & (FAUX0|FAUX1|FAUX2)) != 0;}
00204 void SetF(int i) {this->Flags() |=(FAUX0<<i);}
00206 void ClearF(int i) {this->Flags() &= (~(FAUX0<<i));}
00207 void ClearAllF() { this->Flags() &= (~(FAUX0|FAUX1|FAUX2)); }
00208
00210 static int &LastBitFlag()
00211 {
00212 static int b =USER0;
00213 return b;
00214 }
00215
00217 static inline int NewBitFlag()
00218 {
00219 LastBitFlag()=LastBitFlag()<<1;
00220 return LastBitFlag();
00221 }
00222
00223 static inline bool DeleteBitFlag(int bitval)
00224 {
00225 if(LastBitFlag()==bitval) {
00226 LastBitFlag()= LastBitFlag()>>1;
00227 return true;
00228 }
00229 assert(0);
00230 return false;
00231 }
00233 bool IsUserBit(int userBit){return (this->Flags() & userBit) != 0;}
00235 void SetUserBit(int userBit){this->Flags() |=userBit;}
00237 void ClearUserBit(int userBit){this->Flags() &= (~userBit);}
00238
00239
00240 void GetBBox(Box3<ScalarType>& bb ) const
00241 {
00242 if(this->IsD()) {
00243 bb.SetNull();
00244 return;
00245 }
00246 bb.Set(this->cP(0));
00247 bb.Add(this->cP(1));
00248 bb.Add(this->cP(2));
00249 }
00250
00251
00252 };
00253
00254
00255
00256
00257
00258
00259
00260
00261
00262
00263
00264
00265
00266
00267
00268
00269
00270
00271
00272
00273
00274
00275
00276
00277
00278
00279
00280
00281
00282
00283
00284
00285
00286
00287
00288
00289 template <class UserTypes,
00290 template <typename> class A = DefaultDeriver, template <typename> class B = DefaultDeriver,
00291 template <typename> class C = DefaultDeriver, template <typename> class D = DefaultDeriver,
00292 template <typename> class E = DefaultDeriver, template <typename> class F = DefaultDeriver,
00293 template <typename> class G = DefaultDeriver, template <typename> class H = DefaultDeriver,
00294 template <typename> class I = DefaultDeriver, template <typename> class J = DefaultDeriver >
00295 class Face: public FaceArityMax<UserTypes, A, B, C, D, E, F, G, H, I, J> {
00296 public: typedef AllTypes::AFaceType IAm; typedef UserTypes TypesPool;};
00297
00298
00299 }
00300 #endif
00301