PolygonalMesh Debugging: renamed the SetVN function to __SetVN (it is internal and should not never be called by the users)

This commit is contained in:
Paolo Cignoni 2014-02-18 10:58:12 +00:00
parent 0d6c673a9b
commit 1a4c5ef80d
1 changed files with 135 additions and 192 deletions

View File

@ -25,23 +25,20 @@
#define __VCG_POLYGON_COMPONENT #define __VCG_POLYGON_COMPONENT
namespace vcg { namespace vcg {
namespace face { namespace face {
/*
Some naming Rules
All the Components that can be added to a vertex should be defined in the namespace vert:
*/
/*-------------------------- PolInfo -------------------------------------------*/ /*-------------------------- PolInfo -------------------------------------------*/
template <class T> class PolyInfo: public T { template <class T> class PolyInfo: public T {
protected: protected:
inline void SetVN(const int & n) {_ns = n;} inline void __SetVN(const int & n) {
assert((_ns==-1) || (_ns==n) || (n==-1));
_ns = n;
}
public: public:
PolyInfo(){ _ns = -1; } PolyInfo(){ _ns = -1; }
/* Note: the destructor will not be called in general because there are no virtual destructors. /* Note: the destructor will not be called in general because there are no virtual destructors.
Instead, the job of deallocating the memory will be done bu the face allocator. Instead, the job of deallocating the memory will be done by the face allocator.
This destructor is only done for those who istance a face alone (outside a mesh) This destructor is only done for those who istance a face alone (outside a mesh)
*/ */
static bool HasPolyInfo() { return true; } static bool HasPolyInfo() { return true; }
@ -51,34 +48,10 @@ public:
inline void Alloc(const int & /*ns*/){} inline void Alloc(const int & /*ns*/){}
inline void Dealloc(){} inline void Dealloc(){}
// EmptyPFHAdj
typename T::HEdgePointer &FHp() { static typename T::HEdgePointer fp=0; assert(0); return fp; }
typename T::HEdgePointer const cFHp() const { return 0; }
static bool HasFHAdjacency() { return false; }
private: private:
int _ns; int _ns;
}; };
/*-------------------------- VERTEX ----------------------------------------*/
template <class T> class PEmptyFVAdj: public T {
public:
typedef typename T::VertexType::CoordType CoordType;
typedef typename T::VertexType::ScalarType ScalarType;
// typedef typename T::CoordType CoordType;
inline typename T::VertexType * & V( const int /*j*/ ) { assert(0); static typename T::VertexType *vp=0; return vp; }
inline typename T::VertexType * const & V( const int /*j*/ ) const { assert(0); static typename T::VertexType *vp=0; return vp; }
inline typename T::VertexType * cV( const int /*j*/ ) const { assert(0); static typename T::VertexType *vp=0; return vp; }
inline typename T::CoordType & P( const int /*j*/ ) { assert(0); static typename T::CoordType coord(0, 0, 0); return coord; }
inline const typename T::CoordType & P( const int /*j*/ ) const { assert(0); static typename T::CoordType coord(0, 0, 0); return coord; }
inline const typename T::CoordType &cP( const int /*j*/ ) const { assert(0); static typename T::CoordType coord(0, 0, 0); return coord; }
template <class LeftF>
void ImportData(const LeftF & leftF) {T::ImportData(leftF);}
static bool HasFVAdjN() { return false; }
static void Name(std::vector<std::string> & name){T::Name(name);}
inline void Alloc(const int & /*ns*/){T::Alloc();}
inline void Dealloc(){T::Dealloc();}
};
template <class T> class PFVAdj: public T { template <class T> class PFVAdj: public T {
public: public:
typedef typename T::VertexType::CoordType CoordType; typedef typename T::VertexType::CoordType CoordType;
@ -104,30 +77,31 @@ public:
inline const VertexType * const & cV1( const int j ) const { return cV((j+1)%this->VN());} inline const VertexType * const & cV1( const int j ) const { return cV((j+1)%this->VN());}
inline const VertexType * const & cV2( const int j ) const { return cV((j+2)%this->VN());} inline const VertexType * const & cV2( const int j ) const { return cV((j+2)%this->VN());}
// Shortcut per accedere ai punti delle facce
inline CoordType &P( const int j ) { assert(j>=0 && j<this->VN()); return _vpoly[j]->P(); } inline CoordType &P( const int j ) { assert(j>=0 && j<this->VN()); return _vpoly[j]->P(); }
inline const CoordType cP( const int j ) const { assert(j>=0 && j<this->VN()); return _vpoly[j]->cP(); } inline CoordType cP( const int j ) const { assert(j>=0 && j<this->VN()); return _vpoly[j]->cP(); }
/// Shortcut per accedere ai punti delle facce
inline CoordType & P0( const int j ) { return V(j)->P();} inline CoordType & P0( const int j ) { return V(j)->P();}
inline CoordType & P1( const int j ) { return V((j+1)%this->VN())->P();} inline CoordType & P1( const int j ) { return V((j+1)%this->VN())->P();}
inline CoordType & P2( const int j ) { return V((j+2)%this->VN())->P();} inline CoordType & P2( const int j ) { return V((j+2)%this->VN())->P();}
inline const CoordType cP0( const int j ) const { return cV(j)->P();} inline CoordType cP0( const int j ) const { return cV(j)->P();}
inline const CoordType cP1( const int j ) const { return cV((j+1)%this->VN())->P();} inline CoordType cP1( const int j ) const { return cV((j+1)%this->VN())->P();}
inline const CoordType cP2( const int j ) const { return cV((j+2)%this->VN())->P();} inline CoordType cP2( const int j ) const { return cV((j+2)%this->VN())->P();}
template <class LeftF> template <class LeftF>
void ImportData(const LeftF & leftF){ for(int i =0; i < this->VN(); ++i) V(i) = NULL; T::ImportData(leftF);} void ImportData(const LeftF & leftF){ for(int i =0; i < this->VN(); ++i) V(i) = NULL; T::ImportData(leftF);}
inline void Alloc(const int & ns) { inline void Alloc(const int & ns) {
if(_vpoly == NULL){this->SetVN(ns); if(_vpoly == NULL){
this->__SetVN(ns);
_vpoly = new typename T::VertexType*[this->VN()]; _vpoly = new typename T::VertexType*[this->VN()];
for(int i = 0; i < this->VN(); ++i) _vpoly[i] = 0; for(int i = 0; i < this->VN(); ++i) _vpoly[i] = 0;
} }
T::Alloc(ns); T::Alloc(ns);
} }
inline void Dealloc() { if(_vpoly!=NULL){ inline void Dealloc() {
if(_vpoly!=NULL){
delete [] _vpoly; delete [] _vpoly;
_vpoly = NULL; _vpoly = NULL;
this->__SetVN(-1);
} }
T::Dealloc(); T::Dealloc();
} }
@ -135,37 +109,10 @@ public:
static bool HasFVAdjacency() { return true; } static bool HasFVAdjacency() { return true; }
static void Name(std::vector<std::string> & name){name.push_back(std::string("PFVAdj"));T::Name(name);} static void Name(std::vector<std::string> & name){name.push_back(std::string("PFVAdj"));T::Name(name);}
private: private:
typename T::VertexPointer *_vpoly; typename T::VertexPointer *_vpoly;
}; };
/*----------------------------- PVFADJ ------------------------------*/
template <class T> class EmptyPVFAdj: public T {
public:
typedef typename T::VertexType VertexType;
typedef int VFAdjType;
typename T::FacePointer &VFp(const int) { static typename T::FacePointer fp=0; assert(0); return fp; }
typename T::FacePointer cVFp(const int) const { return 0; }
typename T::FacePointer &FFp(const int) { static typename T::FacePointer fp=0; assert(0); return fp; }
typename T::FacePointer cFFp(const int) const { return 0; }
char &VFi(const int /*j*/){static char z=0; assert(0); return z;}
char &FFi(const int /*j*/){static char z=0; assert(0); return z;}
char cVFi(const int /*j*/) const { return 0;}
char cFFi(const int /*j*/) const { return 0;}
unsigned int SizeNeigh(){assert(0); return 0;}
template <class LeftF>
void ImportData(const LeftF & leftF){ T::ImportData(leftF);}
void Alloc(const int & ns){T::Alloc(ns);}
void Dealloc(){T::Dealloc();}
static bool HasVFAdjacency() { return false; }
static bool HasFFAdjacency() { return false; }
static bool HasFFAdjacencyOcc() { return false; }
static bool HasVFAdjacencyOcc() { return false; }
static void Name(std::vector<std::string> & name){T::Name(name);}
};
template <class T> class PVFAdj: public T { template <class T> class PVFAdj: public T {
public: public:
@ -184,7 +131,7 @@ public:
void ImportData(const LeftF & leftF){T::ImportData(leftF);} void ImportData(const LeftF & leftF){T::ImportData(leftF);}
inline void Alloc(const int & ns) { inline void Alloc(const int & ns) {
if(_vfpP == NULL){ if(_vfpP == NULL){
this->SetVN(ns); this->__SetVN(ns);
_vfpP = new FaceType*[this->VN()]; _vfpP = new FaceType*[this->VN()];
_vfiP = new char[this->VN()]; _vfiP = new char[this->VN()];
for(int i = 0; i < this->VN(); ++i) {_vfpP[i] = 0;_vfiP[i] = -1;} for(int i = 0; i < this->VN(); ++i) {_vfpP[i] = 0;_vfiP[i] = -1;}
@ -194,7 +141,8 @@ public:
} }
unsigned int SizeNeigh(){ return this->VN();} unsigned int SizeNeigh(){ return this->VN();}
inline void Dealloc() { if(_vfpP!=NULL){ inline void Dealloc() {
if(_vfpP!=NULL){
delete [] _vfpP; _vfpP = NULL; delete [] _vfpP; _vfpP = NULL;
delete [] _vfiP; _vfiP = NULL; delete [] _vfiP; _vfiP = NULL;
} }
@ -202,7 +150,6 @@ public:
} }
static bool HasVFAdjacency() { return true; } static bool HasVFAdjacency() { return true; }
static bool HasVFAdjacencyOcc() { return false; }
static void Name(std::vector<std::string> & name){name.push_back(std::string("PVFAdj"));T::Name(name);} static void Name(std::vector<std::string> & name){name.push_back(std::string("PVFAdj"));T::Name(name);}
private: private:
@ -217,23 +164,24 @@ public:
typedef typename T::FaceType FaceType; typedef typename T::FaceType FaceType;
PFFAdj(){_ffpP = NULL; _ffiP = NULL; } PFFAdj(){_ffpP = NULL; _ffiP = NULL; }
typename T::FacePointer &FFp(const int j) { assert(j>=0 && j<this->VN()); return _ffpP[j]; } typename T::FacePointer &FFp(const int j) { assert(j>=0 && j<this->VN()); return _ffpP[j]; }
typename T::FacePointer const FFp(const int j) const { assert(j>=0 && j<this->VN()); return _ffpP[j]; } typename T::FacePointer FFp(const int j) const { assert(j>=0 && j<this->VN()); return _ffpP[j]; }
typename T::FacePointer const cFFp(const int j) const { assert(j>=0 && j<this->VN()); return _ffpP[j]; } typename T::FacePointer cFFp(const int j) const { assert(j>=0 && j<this->VN()); return _ffpP[j]; }
char &FFi(const int j) { return _ffiP[j]; } char &FFi(const int j) { return _ffiP[j]; }
const char &cFFi(const int j) const { return _ffiP[j]; } char cFFi(const int j) const { return _ffiP[j]; }
template <class LeftF> template <class LeftF>
void ImportData(const LeftF & leftF){T::ImportData(leftF);} void ImportData(const LeftF & leftF){T::ImportData(leftF);}
inline void Alloc(const int & ns) { inline void Alloc(const int & ns) {
if( _ffpP == NULL){ if( _ffpP == NULL){
this->SetVN(ns); this->__SetVN(ns);
_ffpP = new FaceType*[this->VN()]; _ffpP = new FaceType*[this->VN()];
_ffiP = new char[this->VN()]; _ffiP = new char[this->VN()];
for(int i = 0; i < this->VN(); ++i) {_ffpP[i] = 0;_ffiP[i] = 0;} for(int i = 0; i < this->VN(); ++i) {_ffpP[i] = 0;_ffiP[i] = 0;}
} }
T::Alloc(ns); T::Alloc(ns);
} }
inline void Dealloc() { if(_ffpP!=NULL){ inline void Dealloc() {
if(_ffpP!=NULL){
delete [] _ffpP; _ffpP = NULL; delete [] _ffpP; _ffpP = NULL;
delete [] _ffiP; _ffiP = NULL; delete [] _ffiP; _ffiP = NULL;
} }
@ -241,10 +189,9 @@ public:
} }
static bool HasFFAdjacency() { return true; } static bool HasFFAdjacency() { return true; }
static bool HasFFAdjacencyOcc() { return false; }
static void Name(std::vector<std::string> & name){name.push_back(std::string("PFFAdj"));T::Name(name);} static void Name(std::vector<std::string> & name){name.push_back(std::string("PFFAdj"));T::Name(name);}
//private: private:
typename T::FacePointer *_ffpP ; typename T::FacePointer *_ffpP ;
char *_ffiP ; char *_ffiP ;
}; };
@ -263,7 +210,7 @@ public:
void ImportData(const LeftF & leftF){T::ImportData(leftF);} void ImportData(const LeftF & leftF){T::ImportData(leftF);}
inline void Alloc(const int & ns) { inline void Alloc(const int & ns) {
if( _fepP == NULL){ if( _fepP == NULL){
this->SetVN(ns); this->__SetVN(ns);
_fepP = new EdgeType *[this->VN()]; _fepP = new EdgeType *[this->VN()];
for(int i = 0; i < this->VN(); ++i) {_fepP[i] = 0;} for(int i = 0; i < this->VN(); ++i) {_fepP[i] = 0;}
} }
@ -272,10 +219,9 @@ public:
inline void Dealloc() { if(_fepP!=NULL) {delete [] _fepP; _fepP = NULL;} T::Dealloc();} inline void Dealloc() { if(_fepP!=NULL) {delete [] _fepP; _fepP = NULL;} T::Dealloc();}
static bool HasFEAdjacency() { return true; } static bool HasFEAdjacency() { return true; }
static bool HasFEAdjacencyOcc() { return false; }
static void Name(std::vector<std::string> & name){name.push_back(std::string("PFEAdj"));T::Name(name);} static void Name(std::vector<std::string> & name){name.push_back(std::string("PFEAdj"));T::Name(name);}
//private: private:
typename T::EdgePointer *_fepP ; typename T::EdgePointer *_fepP ;
}; };
@ -297,15 +243,12 @@ public:
inline void Dealloc() { T::Dealloc();} inline void Dealloc() { T::Dealloc();}
static bool HasFHAdjacency() { return true; } static bool HasFHAdjacency() { return true; }
static bool HasFHAdjacencyOcc() { return false; }
static void Name(std::vector<std::string> & name){name.push_back(std::string("PFHAdj"));T::Name(name);} static void Name(std::vector<std::string> & name){name.push_back(std::string("PFHAdj"));T::Name(name);}
//private: private:
typename T::HEdgePointer _fhP ; typename T::HEdgePointer _fhP ;
}; };
} // end namespace face
} // end namespace vcg
} // end namespace face
}// end namespace vcg
#endif #endif