From 45b0deb7eba8ec99db3b6e9f63c9bec6d162ab10 Mon Sep 17 00:00:00 2001 From: cignoni Date: Wed, 18 Jul 2012 09:37:32 +0000 Subject: [PATCH] Important Change: ** LastBitFlag ** now is named ** FirstUnusedBitFlag ** Corrected the name of the function allocating a user bit among the flags of the simplexes. Changed in ALL the simplexes (vertex, edge, face, etc) and updating functions. Note that the LastBitFlag should never be used by common users... --- vcg/complex/algorithms/update/flag.h | 2 +- vcg/connectors/hedge.h | 54 +++++++++++++++------------- vcg/simplex/edge/base.h | 54 +++++++++++++++------------- vcg/simplex/face/base.h | 54 +++++++++++++++------------- vcg/simplex/tetrahedron/base.h | 54 +++++++++++++++------------- vcg/simplex/vertex/base.h | 54 +++++++++++++++------------- 6 files changed, 151 insertions(+), 121 deletions(-) diff --git a/vcg/complex/algorithms/update/flag.h b/vcg/complex/algorithms/update/flag.h index 3d258cba..83667988 100644 --- a/vcg/complex/algorithms/update/flag.h +++ b/vcg/complex/algorithms/update/flag.h @@ -245,7 +245,7 @@ static void FaceBorderFromVF(MeshType &m) vfi.f->Flags() |= BORDERFLAG[(vfi.z+2)%3]; } } - VertexType::DeleteBitFlag(VertexType::LastBitFlag()); + VertexType::DeleteBitFlag(visitedBit); } diff --git a/vcg/connectors/hedge.h b/vcg/connectors/hedge.h index 61506881..06af2230 100644 --- a/vcg/connectors/hedge.h +++ b/vcg/connectors/hedge.h @@ -141,34 +141,40 @@ public: void SetV() {this->Flags() |=VISITED;} void ClearV() {this->Flags() &=~VISITED;} -/// Return the first bit that is not still used -static int &LastBitFlag() - { - static int b =USER0; - return b; - } + /// Return the first bit that is not still used + static int &FirstUnusedBitFlag() + { + static int b =USER0; + return b; + } + + /// Allocate a bit among the flags that can be used by user. It updates the FirstUnusedBitFlag. + static inline int NewBitFlag() + { + int bitForTheUser = FirstUnusedBitFlag(); + FirstUnusedBitFlag()=FirstUnusedBitFlag()<<1; + return bitForTheUser; + } + + /// De-allocate a pre allocated bit. It updates the FirstUnusedBitFlag. + // Note you must deallocate bit in the inverse order of the allocation (as in a stack) + static inline bool DeleteBitFlag(int bitval) + { + if(FirstUnusedBitFlag()>>1==bitval) { + FirstUnusedBitFlag() = FirstUnusedBitFlag()>>1; + return true; + } + assert(0); + return false; + } -/// allocate a bit among the flags that can be used by user. -static inline int NewBitFlag() - { - LastBitFlag()=LastBitFlag()<<1; - return LastBitFlag(); - } -// de-allocate a bit among the flags that can be used by user. -static inline bool DeleteBitFlag(int bitval) - { - if(LastBitFlag()==bitval) { - LastBitFlag()= LastBitFlag()>>1; - return true; - } - assert(0); - return false; - } /// This function checks if the given user bit is true bool IsUserBit(int userBit){return (this->Flags() & userBit) != 0;} - /// This function set the given user bit + + /// This function set the given user bit void SetUserBit(int userBit){this->Flags() |=userBit;} - /// This function clear the given user bit + + /// This function clear the given user bit void ClearUserBit(int userBit){this->Flags() &= (~userBit);} template diff --git a/vcg/simplex/edge/base.h b/vcg/simplex/edge/base.h index ad539421..c0c2f164 100644 --- a/vcg/simplex/edge/base.h +++ b/vcg/simplex/edge/base.h @@ -143,34 +143,40 @@ public: void SetV() {this->Flags() |=VISITED;} void ClearV() {this->Flags() &=~VISITED;} -/// Return the first bit that is not still used -static int &LastBitFlag() - { - static int b =USER0; - return b; - } + /// Return the first bit that is not still used + static int &FirstUnusedBitFlag() + { + static int b =USER0; + return b; + } + + /// Allocate a bit among the flags that can be used by user. It updates the FirstUnusedBitFlag. + static inline int NewBitFlag() + { + int bitForTheUser = FirstUnusedBitFlag(); + FirstUnusedBitFlag()=FirstUnusedBitFlag()<<1; + return bitForTheUser; + } + + /// De-allocate a pre allocated bit. It updates the FirstUnusedBitFlag. + // Note you must deallocate bit in the inverse order of the allocation (as in a stack) + static inline bool DeleteBitFlag(int bitval) + { + if(FirstUnusedBitFlag()>>1==bitval) { + FirstUnusedBitFlag() = FirstUnusedBitFlag()>>1; + return true; + } + assert(0); + return false; + } -/// allocate a bit among the flags that can be used by user. -static inline int NewBitFlag() - { - LastBitFlag()=LastBitFlag()<<1; - return LastBitFlag(); - } -// de-allocate a bit among the flags that can be used by user. -static inline bool DeleteBitFlag(int bitval) - { - if(LastBitFlag()==bitval) { - LastBitFlag()= LastBitFlag()>>1; - return true; - } - assert(0); - return false; - } /// This function checks if the given user bit is true bool IsUserBit(int userBit){return (this->Flags() & userBit) != 0;} - /// This function set the given user bit + + /// This function set the given user bit void SetUserBit(int userBit){this->Flags() |=userBit;} - /// This function clear the given user bit + + /// This function clear the given user bit void ClearUserBit(int userBit){this->Flags() &= (~userBit);} template diff --git a/vcg/simplex/face/base.h b/vcg/simplex/face/base.h index 9f63333c..640144fa 100644 --- a/vcg/simplex/face/base.h +++ b/vcg/simplex/face/base.h @@ -206,34 +206,40 @@ public: void ClearF(int i) {this->Flags() &= (~(FAUX0<Flags() &= (~(FAUX0|FAUX1|FAUX2)); } -/// Return the first bit that is not still used -static int &LastBitFlag() - { - static int b =USER0; - return b; - } + /// Return the first bit that is not still used + static int &FirstUnusedBitFlag() + { + static int b =USER0; + return b; + } + + /// Allocate a bit among the flags that can be used by user. It updates the FirstUnusedBitFlag. + static inline int NewBitFlag() + { + int bitForTheUser = FirstUnusedBitFlag(); + FirstUnusedBitFlag()=FirstUnusedBitFlag()<<1; + return bitForTheUser; + } + + /// De-allocate a pre allocated bit. It updates the FirstUnusedBitFlag. + // Note you must deallocate bit in the inverse order of the allocation (as in a stack) + static inline bool DeleteBitFlag(int bitval) + { + if(FirstUnusedBitFlag()>>1==bitval) { + FirstUnusedBitFlag() = FirstUnusedBitFlag()>>1; + return true; + } + assert(0); + return false; + } - /// allocate a bit among the flags that can be used by user. - static inline int NewBitFlag() - { - LastBitFlag()=LastBitFlag()<<1; - return LastBitFlag(); - } - // de-allocate a bit among the flags that can be used by user. - static inline bool DeleteBitFlag(int bitval) - { - if(LastBitFlag()==bitval) { - LastBitFlag()= LastBitFlag()>>1; - return true; - } - assert(0); - return false; - } /// This function checks if the given user bit is true bool IsUserBit(int userBit){return (this->Flags() & userBit) != 0;} - /// This function set the given user bit + + /// This function set the given user bit void SetUserBit(int userBit){this->Flags() |=userBit;} - /// This function clear the given user bit + + /// This function clear the given user bit void ClearUserBit(int userBit){this->Flags() &= (~userBit);} diff --git a/vcg/simplex/tetrahedron/base.h b/vcg/simplex/tetrahedron/base.h index ee4ae5f6..3c236366 100644 --- a/vcg/simplex/tetrahedron/base.h +++ b/vcg/simplex/tetrahedron/base.h @@ -232,34 +232,40 @@ public: /// This funcion execute the inverse operation of SetS() void ClearB(int i) {this->Flags() &= (~(BORDER0<>1==bitval) { + FirstUnusedBitFlag() = FirstUnusedBitFlag()>>1; + return true; + } + assert(0); + return false; + } - /// allocate a bit among the flags that can be used by user. - static inline int NewBitFlag() - { - LastBitFlag()=LastBitFlag()<<1; - return LastBitFlag(); - } - // de-allocate a bit among the flags that can be used by user. - static inline bool DeleteBitFlag(int bitval) - { - if(LastBitFlag()==bitval) { - LastBitFlag()= LastBitFlag()>>1; - return true; - } - assert(0); - return false; - } /// This function checks if the given user bit is true bool IsUserBit(int userBit){return (this->Flags() & userBit) != 0;} - /// This function set the given user bit + + /// This function set the given user bit void SetUserBit(int userBit){this->Flags() |=userBit;} - /// This function clear the given user bit + + /// This function clear the given user bit void ClearUserBit(int userBit){this->Flags() &= (~userBit);} template diff --git a/vcg/simplex/vertex/base.h b/vcg/simplex/vertex/base.h index c8486db3..f4cb465c 100644 --- a/vcg/simplex/vertex/base.h +++ b/vcg/simplex/vertex/base.h @@ -190,34 +190,40 @@ public: void SetV() {this->Flags() |=VISITED;} void ClearV() {this->Flags() &=~VISITED;} -/// Return the first bit that is not still used -static int &LastBitFlag() - { - static int b =USER0; - return b; - } + /// Return the first bit that is not still used + static int &FirstUnusedBitFlag() + { + static int b =USER0; + return b; + } + + /// Allocate a bit among the flags that can be used by user. It updates the FirstUnusedBitFlag. + static inline int NewBitFlag() + { + int bitForTheUser = FirstUnusedBitFlag(); + FirstUnusedBitFlag()=FirstUnusedBitFlag()<<1; + return bitForTheUser; + } + + /// De-allocate a pre allocated bit. It updates the FirstUnusedBitFlag. + // Note you must deallocate bit in the inverse order of the allocation (as in a stack) + static inline bool DeleteBitFlag(int bitval) + { + if(FirstUnusedBitFlag()>>1==bitval) { + FirstUnusedBitFlag() = FirstUnusedBitFlag()>>1; + return true; + } + assert(0); + return false; + } -/// allocate a bit among the flags that can be used by user. -static inline int NewBitFlag() - { - LastBitFlag()=LastBitFlag()<<1; - return LastBitFlag(); - } -// de-allocate a bit among the flags that can be used by user. -static inline bool DeleteBitFlag(int bitval) - { - if(LastBitFlag()==bitval) { - LastBitFlag()= LastBitFlag()>>1; - return true; - } - assert(0); - return false; - } /// This function checks if the given user bit is true bool IsUserBit(int userBit){return (this->Flags() & userBit) != 0;} - /// This function set the given user bit + + /// This function set the given user bit void SetUserBit(int userBit){this->Flags() |=userBit;} - /// This function clear the given user bit + + /// This function clear the given user bit void ClearUserBit(int userBit){this->Flags() &= (~userBit);} template