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_HEDGE_
00025 #define __VCG_HEDGE_
00026
00027
00028
00029
00030 #include <vcg/complex/all_types.h>
00031
00032 #include <vcg/connectors/hedge_component.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 HEdgeTypeHolder: public UserTypes{
00045 public:
00046
00047 template < class LeftV>
00048 void ImportData(const LeftV & ) { }
00049 static void Name(std::vector<std::string> & name){}
00050
00051 };
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065 template <class UserTypes>
00066 class HEdgeBase: public
00067 hedge::EmptyHEdgeData<
00068 hedge::EmptyBitFlags<
00069 HEdgeTypeHolder < UserTypes> > > {
00070 };
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085 template <class UserTypes,
00086 template <typename> class A, template <typename> class B,
00087 template <typename> class C, template <typename> class D,
00088 template <typename> class E, template <typename> class F,
00089 template <typename> class G, template <typename> class H,
00090 template <typename> class I, template <typename> class J,
00091 template <typename> class K>
00092 class HEdgeArityMax: public K<Arity10<HEdgeBase<UserTypes>, A, B, C, D, E, F, G, H, I, J> > {
00093
00094
00095 public:
00096
00097
00098 enum {
00099
00100 DELETED = 0x0001,
00101 NOTREAD = 0x0002,
00102 NOTWRITE = 0x0004,
00103 MODIFIED = 0x0008,
00104 VISITED = 0x0010,
00105 SELECTED = 0x0020,
00106 BORDER = 0x0100,
00107 USER0 = 0x0200
00108 };
00109
00110 inline int & UberFlags () { return this->Flags(); }
00111 inline int UberFlags() const { return this->Flags(); }
00112
00113 bool IsD() const {return (this->Flags() & DELETED) != 0;}
00114 bool IsR() const {return (this->Flags() & NOTREAD) == 0;}
00115 bool IsW() const {return (this->Flags() & NOTWRITE)== 0;}
00116 bool IsRW() const {return (this->Flags() & (NOTREAD | NOTWRITE)) == 0;}
00117 bool IsS() const {return (this->Flags() & SELECTED) != 0;}
00118 bool IsB() const {return (this->Flags() & BORDER) != 0;}
00119 bool IsV() const {return (this->Flags() & VISITED) != 0;}
00120
00121
00125 void SetFlags(int flagp) {this->Flags()=flagp;}
00126
00130 void ClearFlags() {this->Flags()=0;}
00131 void SetD() {this->Flags() |=DELETED;}
00132 void ClearD() {this->Flags() &=(~DELETED);}
00133 void SetR() {this->Flags() &=(~NOTREAD);}
00134 void ClearR() {this->Flags() |=NOTREAD;}
00135 void ClearW() {this->Flags() |=NOTWRITE;}
00136 void SetW() {this->Flags() &=(~NOTWRITE);}
00137 void SetS() {this->Flags() |=SELECTED;}
00138 void ClearS() {this->Flags() &= ~SELECTED;}
00139 void SetB() {this->Flags() |=BORDER;}
00140 void ClearB() {this->Flags() &=~BORDER;}
00141 void SetV() {this->Flags() |=VISITED;}
00142 void ClearV() {this->Flags() &=~VISITED;}
00143
00145 static int &LastBitFlag()
00146 {
00147 static int b =USER0;
00148 return b;
00149 }
00150
00152 static inline int NewBitFlag()
00153 {
00154 LastBitFlag()=LastBitFlag()<<1;
00155 return LastBitFlag();
00156 }
00157
00158 static inline bool DeleteBitFlag(int bitval)
00159 {
00160 if(LastBitFlag()==bitval) {
00161 LastBitFlag()= LastBitFlag()>>1;
00162 return true;
00163 }
00164 assert(0);
00165 return false;
00166 }
00168 bool IsUserBit(int userBit){return (this->Flags() & userBit) != 0;}
00170 void SetUserBit(int userBit){this->Flags() |=userBit;}
00172 void ClearUserBit(int userBit){this->Flags() &= (~userBit);}
00173
00174 template<class BoxType>
00175 void GetBBox( BoxType & bb ) const {
00176 bb.SetNull();
00177 bb.Add(this->cP(0));
00178 bb.Add(this->cP(1));
00179 }
00180
00181 };
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199
00200
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210
00211
00212
00213 template <class UserTypes,
00214 template <typename> class A = DefaultDeriver, template <typename> class B = DefaultDeriver,
00215 template <typename> class C = DefaultDeriver, template <typename> class D = DefaultDeriver,
00216 template <typename> class E = DefaultDeriver, template <typename> class F = DefaultDeriver,
00217 template <typename> class G = DefaultDeriver, template <typename> class H = DefaultDeriver,
00218 template <typename> class I = DefaultDeriver, template <typename> class J = DefaultDeriver,
00219 template <typename> class K = DefaultDeriver>
00220 class HEdge: public HEdgeArityMax<UserTypes, A, B, C, D, E, F, G, H, I, J, K> {
00221 public: typedef AllTypes::AHEdgeType IAm; typedef UserTypes TypesPool;};
00222
00223 }
00224 #endif