From 15bec03c89a7fd2fb304040789bc2962b0c99c35 Mon Sep 17 00:00:00 2001 From: cignoni Date: Thu, 13 Feb 2014 13:16:09 +0000 Subject: [PATCH] Corrected the FHp member of the polygon. --- vcg/simplex/face/component_polygon.h | 232 +++++++++++++-------------- 1 file changed, 116 insertions(+), 116 deletions(-) diff --git a/vcg/simplex/face/component_polygon.h b/vcg/simplex/face/component_polygon.h index e89922dc..4f47f214 100644 --- a/vcg/simplex/face/component_polygon.h +++ b/vcg/simplex/face/component_polygon.h @@ -37,33 +37,33 @@ All the Components that can be added to a vertex should be defined in the namesp template class PolyInfo: public T { protected: - inline void SetVN(const int & n) {_ns = n;} + inline void SetVN(const int & n) {_ns = n;} public: - PolyInfo(){ _ns = -1; } - /* 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. - This destructor is only done for those who istance a face alone (outside a mesh) - */ - static bool HasPolyInfo() { return true; } - inline const int & VN() const { return _ns;} - inline int Prev(const int & i){ return (i+(VN()-1))%VN();} - inline int Next(const int & i){ return (i+1)%VN();} - inline void Alloc(const int & /*ns*/){} - inline void Dealloc(){} + PolyInfo(){ _ns = -1; } + /* 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. + This destructor is only done for those who istance a face alone (outside a mesh) + */ + static bool HasPolyInfo() { return true; } + inline const int & VN() const { return _ns;} + inline int Prev(const int & i){ return (i+(VN()-1))%VN();} + inline int Next(const int & i){ return (i+1)%VN();} + inline void Alloc(const int & /*ns*/){} + inline void Dealloc(){} - // EmptyPFHAdj - typename T::HEdgePointer &FHp(const int & ) { static typename T::HEdgePointer fp=0; assert(0); return fp; } - typename T::HEdgePointer const cFHp(const int & ) const { static typename T::HEdgePointer const fp=0; return fp; } - static bool HasFHAdjacency() { return false; } + // 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: - int _ns; + int _ns; }; /*-------------------------- VERTEX ----------------------------------------*/ template class PEmptyFVAdj: public T { public: - typedef typename T::VertexType::CoordType CoordType; - typedef typename T::VertexType::ScalarType ScalarType; + 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; } @@ -91,46 +91,46 @@ public: inline typename T::VertexType * cV( const int j ) const { assert(j>=0 && jVN()); return _vpoly[j]; } - /** Return the pointer to the ((j+1)%3)-th vertex of the face. - @param j Index of the face vertex. - */ - inline VertexType * & V0( const int j ) { return V(j);} - inline VertexType * & V1( const int j ) { return V((j+1)%this->VN());} - inline VertexType * & V2( const int j ) { return V((j+2)%this->VN());} - inline const VertexType * const & V0( const int j ) const { return V(j);} - inline const VertexType * const & V1( const int j ) const { return V((j+1)%this->VN());} - inline const VertexType * const & V2( const int j ) const { return V((j+2)%this->VN());} - inline const VertexType * const & cV0( const int j ) const { return cV(j);} - 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());} + /** Return the pointer to the ((j+1)%3)-th vertex of the face. + @param j Index of the face vertex. + */ + inline VertexType * & V0( const int j ) { return V(j);} + inline VertexType * & V1( const int j ) { return V((j+1)%this->VN());} + inline VertexType * & V2( const int j ) { return V((j+2)%this->VN());} + inline const VertexType * const & V0( const int j ) const { return V(j);} + inline const VertexType * const & V1( const int j ) const { return V((j+1)%this->VN());} + inline const VertexType * const & V2( const int j ) const { return V((j+2)%this->VN());} + inline const VertexType * const & cV0( const int j ) const { return cV(j);} + 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());} - // Shortcut per accedere ai punti delle facce - inline CoordType &P( const int j ) { assert(j>=0 && jVN()); return _vpoly[j]->P(); } - inline const CoordType cP( const int j ) const { assert(j>=0 && jVN()); return _vpoly[j]->cP(); } + // Shortcut per accedere ai punti delle facce + inline CoordType &P( const int j ) { assert(j>=0 && jVN()); return _vpoly[j]->P(); } + inline const CoordType cP( const int j ) const { assert(j>=0 && jVN()); return _vpoly[j]->cP(); } - /// Shortcut per accedere ai punti delle facce - 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 & P2( const int j ) { return V((j+2)%this->VN())->P();} - inline const 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 const CoordType cP2( const int j ) const { return cV((j+2)%this->VN())->P();} + /// Shortcut per accedere ai punti delle facce + 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 & P2( const int j ) { return V((j+2)%this->VN())->P();} + inline const 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 const CoordType cP2( const int j ) const { return cV((j+2)%this->VN())->P();} - template - 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) { - if(_vpoly == NULL){this->SetVN(ns); - _vpoly = new typename T::VertexType*[this->VN()]; - for(int i = 0; i < this->VN(); ++i) _vpoly[i] = 0; - } - T::Alloc(ns); - } - inline void Dealloc() { if(_vpoly!=NULL){ - delete [] _vpoly; - _vpoly = NULL; - } - T::Dealloc(); - } + template + 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) { + if(_vpoly == NULL){this->SetVN(ns); + _vpoly = new typename T::VertexType*[this->VN()]; + for(int i = 0; i < this->VN(); ++i) _vpoly[i] = 0; + } + T::Alloc(ns); + } + inline void Dealloc() { if(_vpoly!=NULL){ + delete [] _vpoly; + _vpoly = NULL; + } + T::Dealloc(); + } static bool HasFVAdjacency() { return true; } static void Name(std::vector & name){name.push_back(std::string("PFVAdj"));T::Name(name);} @@ -154,10 +154,10 @@ public: char cFFi(const int /*j*/) const { return 0;} unsigned int SizeNeigh(){assert(0); return 0;} - template - void ImportData(const LeftF & leftF){ T::ImportData(leftF);} - void Alloc(const int & ns){T::Alloc(ns);} - void Dealloc(){T::Dealloc();} + template + 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; } @@ -169,11 +169,11 @@ public: template class PVFAdj: public T { public: - PVFAdj(){_vfiP = NULL; _vfiP = NULL;} - /* 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 edge allocator. - This destructor is only done for those who istance a face alone (outside a mesh) - */ + PVFAdj(){_vfiP = NULL; _vfiP = NULL;} + /* 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 edge allocator. + This destructor is only done for those who istance a face alone (outside a mesh) + */ typedef typename T::VertexType VertexType; typedef typename T::FaceType FaceType; typename T::FacePointer &VFp(const int j) { assert(j>=0 && jVN()); return _vfpP[j]; } @@ -191,15 +191,15 @@ public: } T::Alloc(ns); - } - unsigned int SizeNeigh(){ return this->VN();} + } + unsigned int SizeNeigh(){ return this->VN();} - inline void Dealloc() { if(_vfpP!=NULL){ - delete [] _vfpP; _vfpP = NULL; - delete [] _vfiP; _vfiP = NULL; - } - T::Dealloc(); - } + inline void Dealloc() { if(_vfpP!=NULL){ + delete [] _vfpP; _vfpP = NULL; + delete [] _vfiP; _vfiP = NULL; + } + T::Dealloc(); + } static bool HasVFAdjacency() { return true; } static bool HasVFAdjacencyOcc() { return false; } @@ -222,23 +222,23 @@ public: char &FFi(const int j) { return _ffiP[j]; } const char &cFFi(const int j) const { return _ffiP[j]; } - template - void ImportData(const LeftF & leftF){T::ImportData(leftF);} - inline void Alloc(const int & ns) { - if( _ffpP == NULL){ - this->SetVN(ns); - _ffpP = new FaceType*[this->VN()]; - _ffiP = new char[this->VN()]; - for(int i = 0; i < this->VN(); ++i) {_ffpP[i] = 0;_ffiP[i] = 0;} - } - T::Alloc(ns); - } - inline void Dealloc() { if(_ffpP!=NULL){ - delete [] _ffpP; _ffpP = NULL; - delete [] _ffiP; _ffiP = NULL; - } - T::Dealloc(); - } + template + void ImportData(const LeftF & leftF){T::ImportData(leftF);} + inline void Alloc(const int & ns) { + if( _ffpP == NULL){ + this->SetVN(ns); + _ffpP = new FaceType*[this->VN()]; + _ffiP = new char[this->VN()]; + for(int i = 0; i < this->VN(); ++i) {_ffpP[i] = 0;_ffiP[i] = 0;} + } + T::Alloc(ns); + } + inline void Dealloc() { if(_ffpP!=NULL){ + delete [] _ffpP; _ffpP = NULL; + delete [] _ffiP; _ffiP = NULL; + } + T::Dealloc(); + } static bool HasFFAdjacency() { return true; } static bool HasFFAdjacencyOcc() { return false; } @@ -259,24 +259,24 @@ public: typename T::EdgePointer const FEp(const int j) const { assert(j>=0 && jVN()); return _fepP[j]; } typename T::EdgePointer const cFEp(const int j) const { assert(j>=0 && jVN()); return _fepP[j]; } - template - void ImportData(const LeftF & leftF){T::ImportData(leftF);} - inline void Alloc(const int & ns) { - if( _fepP == NULL){ - this->SetVN(ns); - _fepP = new EdgeType *[this->VN()]; - for(int i = 0; i < this->VN(); ++i) {_fepP[i] = 0;} - } - T::Alloc(ns); - } - inline void Dealloc() { if(_fepP!=NULL) {delete [] _fepP; _fepP = NULL;} T::Dealloc();} + template + void ImportData(const LeftF & leftF){T::ImportData(leftF);} + inline void Alloc(const int & ns) { + if( _fepP == NULL){ + this->SetVN(ns); + _fepP = new EdgeType *[this->VN()]; + for(int i = 0; i < this->VN(); ++i) {_fepP[i] = 0;} + } + T::Alloc(ns); + } + inline void Dealloc() { if(_fepP!=NULL) {delete [] _fepP; _fepP = NULL;} T::Dealloc();} - static bool HasFEAdjacency() { return true; } - static bool HasFEAdjacencyOcc() { return false; } - static void Name(std::vector & name){name.push_back(std::string("PFEAdj"));T::Name(name);} + static bool HasFEAdjacency() { return true; } + static bool HasFEAdjacencyOcc() { return false; } + static void Name(std::vector & name){name.push_back(std::string("PFEAdj"));T::Name(name);} //private: - typename T::EdgePointer *_fepP ; + typename T::EdgePointer *_fepP ; }; @@ -287,21 +287,21 @@ public: typedef typename T::HEdgeType HEdgeType; typedef typename T::HEdgePointer HEdgePointer; - PFHAdj(){_fhP = NULL; } - typename T::HEdgePointer &FHp() { return _fhP; } - typename T::HEdgePointer const cFHp() const { return _fhP; } + PFHAdj(){_fhP = NULL; } + typename T::HEdgePointer &FHp() { return _fhP; } + typename T::HEdgePointer const cFHp() const { return _fhP; } - template - void ImportData(const LeftF & leftF){T::ImportData(leftF);} - inline void Alloc(const int & ns) {T::Alloc(ns);} - inline void Dealloc() { T::Dealloc();} + template + void ImportData(const LeftF & leftF){T::ImportData(leftF);} + inline void Alloc(const int & ns) {T::Alloc(ns);} + inline void Dealloc() { T::Dealloc();} - static bool HasFHAdjacency() { return true; } - static bool HasFHAdjacencyOcc() { return false; } - static void Name(std::vector & name){name.push_back(std::string("PFHAdj"));T::Name(name);} + static bool HasFHAdjacency() { return true; } + static bool HasFHAdjacencyOcc() { return false; } + static void Name(std::vector & name){name.push_back(std::string("PFHAdj"));T::Name(name);} //private: - typename T::HEdgePointer _fhP ; + typename T::HEdgePointer _fhP ; };