00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef __VCG_MESH
00024 #error "This file should not be included alone. It is automatically included by complex.h"
00025 #endif
00026 #ifndef __VCG_FACE_PLUS
00027 #define __VCG_FACE_PLUS
00028
00029 namespace vcg {
00030
00031
00032
00033
00034
00035
00036
00037 template <class UserTypes>
00038 class FaceTypeHolder: public UserTypes {
00039 public:
00040
00041 template <class LeftF>
00042 void ImportData(const LeftF & ){}
00043 static void Name(std::vector<std::string> & ){}
00044
00045
00046
00047 inline int VN() const { return 3;}
00048 inline int Prev(const int & i) const { return (i+(3-1))%3;}
00049 inline int Next(const int & i) const { return (i+1)%3;}
00050 inline void Alloc(const int & ){}
00051 inline void Dealloc(){}
00052 };
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066 template <class UserTypes>
00067 class FaceBase: public
00068 face::EmptyCore< FaceTypeHolder <UserTypes> > {
00069 };
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084 template < class UserTypes,
00085 template <typename> class A, template <typename> class B,
00086 template <typename> class C, template <typename> class D,
00087 template <typename> class E, template <typename> class F,
00088 template <typename> class G, template <typename> class H,
00089 template <typename> class I, template <typename> class J,
00090 template <typename> class K, template <typename> class L >
00091 class FaceArityMax: public L<Arity11<FaceBase<UserTypes>, A, B, C, D, E, F, G, H, I, J, K> > {
00092
00093 public:
00094 typedef typename FaceArityMax::ScalarType ScalarType;
00095
00096
00097 enum {
00098
00099 DELETED = 0x00000001,
00100 NOTREAD = 0x00000002,
00101 NOTWRITE = 0x00000004,
00102 VISITED = 0x00000010,
00103 SELECTED = 0x00000020,
00104
00105 BORDER0 = 0x00000040,
00106 BORDER1 = 0x00000080,
00107 BORDER2 = 0x00000100,
00108 BORDER012 = BORDER0 | BORDER1 | BORDER2 ,
00109
00110 NORMX = 0x00000200,
00111 NORMY = 0x00000400,
00112 NORMZ = 0x00000800,
00113
00114 CREASE0 = 0x00008000,
00115 CREASE1 = 0x00010000,
00116 CREASE2 = 0x00020000,
00117
00118 FAUX0 = 0x00040000,
00119 FAUX1 = 0x00080000,
00120 FAUX2 = 0x00100000,
00121 FAUX012 = FAUX0 | FAUX1 | FAUX2 ,
00122
00123 USER0 = 0x00200000
00124 };
00125
00126
00128 bool IsD() const {return (this->cFlags() & DELETED) != 0;}
00130 bool IsR() const {return (this->cFlags() & NOTREAD) == 0;}
00132 bool IsW() const {return (this->cFlags() & NOTWRITE)== 0;}
00134 bool IsRW() const {return (this->cFlags() & (NOTREAD | NOTWRITE)) == 0;}
00136 bool IsS() const {return (this->cFlags() & SELECTED) != 0;}
00138 bool IsV() const {return (this->cFlags() & VISITED) != 0;}
00139
00143 void SetFlags(int flagp) {this->Flags()=flagp;}
00144
00148 void ClearFlags() {this->Flags()=0;}
00149
00151 void SetD() {this->Flags() |=DELETED;}
00153 void ClearD() {this->Flags() &=(~DELETED);}
00155 void SetR() {this->Flags() &=(~NOTREAD);}
00157 void ClearR() {this->Flags() |=NOTREAD;}
00159 void SetW() {this->Flags() &=(~NOTWRITE);}
00161 void ClearW() {this->Flags() |=NOTWRITE;}
00163 void SetS() {this->Flags() |=SELECTED;}
00165 void ClearS() {this->Flags() &= ~SELECTED;}
00167 void SetV() {this->Flags() |=VISITED;}
00169 void ClearV() {this->Flags() &= ~VISITED;}
00170
00172 bool IsB(int i) const {return (this->cFlags() & (BORDER0<<i)) != 0;}
00174 void SetB(int i) {this->Flags() |=(BORDER0<<i);}
00176 void ClearB(int i) {this->Flags() &= (~(BORDER0<<i));}
00177
00179 bool IsCrease(int i) const {return (this->cFlags() & (CREASE0<<i)) != 0;}
00181 void SetCrease(int i){this->Flags() |=(CREASE0<<i);}
00183 void ClearCrease(int i) {this->Flags() &= (~(CREASE0<<i));}
00184
00188 bool IsF(int i) const {return (this->cFlags() & (FAUX0<<i) ) != 0;}
00189 bool IsAnyF() const {return (this->cFlags() & (FAUX0|FAUX1|FAUX2)) != 0;}
00191 void SetF(int i) {this->Flags() |=(FAUX0<<i);}
00193 void ClearF(int i) {this->Flags() &= (~(FAUX0<<i));}
00194 void ClearAllF() { this->Flags() &= (~(FAUX0|FAUX1|FAUX2)); }
00195
00197 static int &FirstUnusedBitFlag()
00198 {
00199 static int b =USER0;
00200 return b;
00201 }
00202
00204 static inline int NewBitFlag()
00205 {
00206 int bitForTheUser = FirstUnusedBitFlag();
00207 FirstUnusedBitFlag()=FirstUnusedBitFlag()<<1;
00208 return bitForTheUser;
00209 }
00210
00212
00213 static inline bool DeleteBitFlag(int bitval)
00214 {
00215 if(FirstUnusedBitFlag()>>1==bitval) {
00216 FirstUnusedBitFlag() = FirstUnusedBitFlag()>>1;
00217 return true;
00218 }
00219 assert(0);
00220 return false;
00221 }
00222
00224 bool IsUserBit(int userBit){return (this->Flags() & userBit) != 0;}
00225
00227 void SetUserBit(int userBit){this->Flags() |=userBit;}
00228
00230 void ClearUserBit(int userBit){this->Flags() &= (~userBit);}
00231
00232
00233 void GetBBox(Box3<ScalarType>& bb ) const
00234 {
00235 if(this->IsD()) {
00236 bb.SetNull();
00237 return;
00238 }
00239 bb.Set(this->cP(0));
00240 bb.Add(this->cP(1));
00241 bb.Add(this->cP(2));
00242 }
00243
00244
00245 };
00246
00247
00248
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 template <class UserTypes,
00283 template <typename> class A = DefaultDeriver, template <typename> class B = DefaultDeriver,
00284 template <typename> class C = DefaultDeriver, template <typename> class D = DefaultDeriver,
00285 template <typename> class E = DefaultDeriver, template <typename> class F = DefaultDeriver,
00286 template <typename> class G = DefaultDeriver, template <typename> class H = DefaultDeriver,
00287 template <typename> class I = DefaultDeriver, template <typename> class J = DefaultDeriver,
00288 template <typename> class K = DefaultDeriver, template <typename> class L = DefaultDeriver >
00289 class Face: public FaceArityMax<UserTypes, A, B, C, D, E, F, G, H, I, J, K, L> {
00290 public: typedef AllTypes::AFaceType IAm; typedef UserTypes TypesPool;};
00291
00292
00293 }
00294 #endif
00295