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...
This commit is contained in:
Paolo Cignoni 2012-07-18 09:37:32 +00:00
parent 36d9030955
commit 45b0deb7eb
6 changed files with 151 additions and 121 deletions

View File

@ -245,7 +245,7 @@ static void FaceBorderFromVF(MeshType &m)
vfi.f->Flags() |= BORDERFLAG[(vfi.z+2)%3];
}
}
VertexType::DeleteBitFlag(VertexType::LastBitFlag());
VertexType::DeleteBitFlag(visitedBit);
}

View File

@ -142,32 +142,38 @@ public:
void ClearV() {this->Flags() &=~VISITED;}
/// Return the first bit that is not still used
static int &LastBitFlag()
static int &FirstUnusedBitFlag()
{
static int b =USER0;
return b;
}
/// allocate a bit among the flags that can be used by user.
/// Allocate a bit among the flags that can be used by user. It updates the FirstUnusedBitFlag.
static inline int NewBitFlag()
{
LastBitFlag()=LastBitFlag()<<1;
return LastBitFlag();
int bitForTheUser = FirstUnusedBitFlag();
FirstUnusedBitFlag()=FirstUnusedBitFlag()<<1;
return bitForTheUser;
}
// de-allocate a bit among the flags that can be used by user.
/// 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(LastBitFlag()==bitval) {
LastBitFlag()= LastBitFlag()>>1;
if(FirstUnusedBitFlag()>>1==bitval) {
FirstUnusedBitFlag() = FirstUnusedBitFlag()>>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
void SetUserBit(int userBit){this->Flags() |=userBit;}
/// This function clear the given user bit
void ClearUserBit(int userBit){this->Flags() &= (~userBit);}

View File

@ -144,32 +144,38 @@ public:
void ClearV() {this->Flags() &=~VISITED;}
/// Return the first bit that is not still used
static int &LastBitFlag()
static int &FirstUnusedBitFlag()
{
static int b =USER0;
return b;
}
/// allocate a bit among the flags that can be used by user.
/// Allocate a bit among the flags that can be used by user. It updates the FirstUnusedBitFlag.
static inline int NewBitFlag()
{
LastBitFlag()=LastBitFlag()<<1;
return LastBitFlag();
int bitForTheUser = FirstUnusedBitFlag();
FirstUnusedBitFlag()=FirstUnusedBitFlag()<<1;
return bitForTheUser;
}
// de-allocate a bit among the flags that can be used by user.
/// 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(LastBitFlag()==bitval) {
LastBitFlag()= LastBitFlag()>>1;
if(FirstUnusedBitFlag()>>1==bitval) {
FirstUnusedBitFlag() = FirstUnusedBitFlag()>>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
void SetUserBit(int userBit){this->Flags() |=userBit;}
/// This function clear the given user bit
void ClearUserBit(int userBit){this->Flags() &= (~userBit);}

View File

@ -207,32 +207,38 @@ public:
void ClearAllF() { this->Flags() &= (~(FAUX0|FAUX1|FAUX2)); }
/// Return the first bit that is not still used
static int &LastBitFlag()
static int &FirstUnusedBitFlag()
{
static int b =USER0;
return b;
}
/// allocate a bit among the flags that can be used by user.
/// Allocate a bit among the flags that can be used by user. It updates the FirstUnusedBitFlag.
static inline int NewBitFlag()
{
LastBitFlag()=LastBitFlag()<<1;
return LastBitFlag();
int bitForTheUser = FirstUnusedBitFlag();
FirstUnusedBitFlag()=FirstUnusedBitFlag()<<1;
return bitForTheUser;
}
// de-allocate a bit among the flags that can be used by user.
/// 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(LastBitFlag()==bitval) {
LastBitFlag()= LastBitFlag()>>1;
if(FirstUnusedBitFlag()>>1==bitval) {
FirstUnusedBitFlag() = FirstUnusedBitFlag()>>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
void SetUserBit(int userBit){this->Flags() |=userBit;}
/// This function clear the given user bit
void ClearUserBit(int userBit){this->Flags() &= (~userBit);}

View File

@ -233,32 +233,38 @@ public:
void ClearB(int i) {this->Flags() &= (~(BORDER0<<i));}
/// Return the first bit that is not still used
static int &LastBitFlag()
static int &FirstUnusedBitFlag()
{
static int b =USER0;
return b;
}
/// allocate a bit among the flags that can be used by user.
/// Allocate a bit among the flags that can be used by user. It updates the FirstUnusedBitFlag.
static inline int NewBitFlag()
{
LastBitFlag()=LastBitFlag()<<1;
return LastBitFlag();
int bitForTheUser = FirstUnusedBitFlag();
FirstUnusedBitFlag()=FirstUnusedBitFlag()<<1;
return bitForTheUser;
}
// de-allocate a bit among the flags that can be used by user.
/// 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(LastBitFlag()==bitval) {
LastBitFlag()= LastBitFlag()>>1;
if(FirstUnusedBitFlag()>>1==bitval) {
FirstUnusedBitFlag() = FirstUnusedBitFlag()>>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
void SetUserBit(int userBit){this->Flags() |=userBit;}
/// This function clear the given user bit
void ClearUserBit(int userBit){this->Flags() &= (~userBit);}

View File

@ -191,32 +191,38 @@ public:
void ClearV() {this->Flags() &=~VISITED;}
/// Return the first bit that is not still used
static int &LastBitFlag()
static int &FirstUnusedBitFlag()
{
static int b =USER0;
return b;
}
/// allocate a bit among the flags that can be used by user.
/// Allocate a bit among the flags that can be used by user. It updates the FirstUnusedBitFlag.
static inline int NewBitFlag()
{
LastBitFlag()=LastBitFlag()<<1;
return LastBitFlag();
int bitForTheUser = FirstUnusedBitFlag();
FirstUnusedBitFlag()=FirstUnusedBitFlag()<<1;
return bitForTheUser;
}
// de-allocate a bit among the flags that can be used by user.
/// 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(LastBitFlag()==bitval) {
LastBitFlag()= LastBitFlag()>>1;
if(FirstUnusedBitFlag()>>1==bitval) {
FirstUnusedBitFlag() = FirstUnusedBitFlag()>>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
void SetUserBit(int userBit){this->Flags() |=userBit;}
/// This function clear the given user bit
void ClearUserBit(int userBit){this->Flags() &= (~userBit);}