updated polygon component to the cP/P behavior for access to elements

This commit is contained in:
Paolo Cignoni 2013-03-20 08:56:20 +00:00
parent 12543d68a2
commit f3337dcb7c
1 changed files with 58 additions and 62 deletions

View File

@ -48,8 +48,8 @@ public:
inline const int & VN() const { return _ns;} inline const int & VN() const { return _ns;}
inline int Prev(const int & i){ return (i+(VN()-1))%VN();} inline int Prev(const int & i){ return (i+(VN()-1))%VN();}
inline int Next(const int & i){ return (i+1)%VN();} inline int Next(const int & i){ return (i+1)%VN();}
inline void Alloc(const int & /*ns*/){} inline void Alloc(const int & /*ns*/){}
inline void Dealloc(){} inline void Dealloc(){}
// EmptyPFHAdj // EmptyPFHAdj
typename T::HEdgePointer &FHp(const int & ) { static typename T::HEdgePointer fp=0; assert(0); return fp; } typename T::HEdgePointer &FHp(const int & ) { static typename T::HEdgePointer fp=0; assert(0); return fp; }
@ -71,23 +71,23 @@ public:
inline typename T::CoordType & P( const int /*j*/ ) { assert(0); static typename T::CoordType coord(0, 0, 0); return coord; } 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 & 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; } 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> template <class LeftF>
void ImportData(const LeftF & leftF) {T::ImportData(leftF);} void ImportData(const LeftF & leftF) {T::ImportData(leftF);}
static bool HasFVAdjN() { return false; } static bool HasFVAdjN() { return false; }
static void Name(std::vector<std::string> & name){T::Name(name);} static void Name(std::vector<std::string> & name){T::Name(name);}
inline void Alloc(const int & /*ns*/){T::Alloc();} inline void Alloc(const int & /*ns*/){T::Alloc();}
inline void Dealloc(){T::Dealloc();} 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;
typedef typename T::VertexType::ScalarType ScalarType; typedef typename T::VertexType::ScalarType ScalarType;
typedef typename T::VertexType VertexType; typedef typename T::VertexType VertexType;
PFVAdj(){_vpoly = NULL;} PFVAdj(){_vpoly = NULL;}
inline typename T::VertexType * & V( const int j ) { assert(j>=0 && j<this->VN()); return _vpoly[j]; } inline typename T::VertexType * & V( const int j ) { assert(j>=0 && j<this->VN()); return _vpoly[j]; }
inline typename T::VertexType * const & V( const int j ) const { assert(j>=0 && j<this->VN()); return _vpoly[j]; } inline typename T::VertexType * const & V( const int j ) const { assert(j>=0 && j<this->VN()); return _vpoly[j]; }
inline typename T::VertexType * cV( const int j ) const { assert(j>=0 && j<this->VN()); return _vpoly[j]; } inline typename T::VertexType * cV( const int j ) const { assert(j>=0 && j<this->VN()); return _vpoly[j]; }
@ -105,20 +105,16 @@ public:
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 // 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 & P( const int j ) const { assert(j>=0 && j<this->VN()); return _vpoly[j]->cP(); } inline const CoordType cP( const int j ) const { assert(j>=0 && j<this->VN()); return _vpoly[j]->cP(); }
inline const CoordType &cP( const int j ) const { assert(j>=0 && j<this->VN()); return _vpoly[j]->cP(); }
/// Shortcut per accedere ai punti delle facce /// 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 & P0( const int j ) const { return V(j)->P();} inline const CoordType cP0( const int j ) const { return cV(j)->P();}
inline const CoordType & P1( const int j ) const { return V((j+1)%this->VN())->P();} inline const CoordType cP1( const int j ) const { return cV((j+1)%this->VN())->P();}
inline const CoordType & P2( const int j ) const { return V((j+2)%this->VN())->P();} inline const CoordType cP2( const int j ) const { return cV((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 <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);}
@ -137,17 +133,17 @@ 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 ------------------------------*/ /*----------------------------- PVFADJ ------------------------------*/
template <class T> class EmptyPVFAdj: public T { template <class T> class EmptyPVFAdj: public T {
public: public:
typedef typename T::VertexType VertexType; typedef typename T::VertexType VertexType;
typedef int VFAdjType; typedef int VFAdjType;
typename T::FacePointer &VFp(const int) { static typename T::FacePointer fp=0; assert(0); return fp; } 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 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 &FFp(const int) { static typename T::FacePointer fp=0; assert(0); return fp; }
@ -184,16 +180,16 @@ public:
typename T::FacePointer const VFp(const int j) const { assert(j>=0 && j<this->VN()); return _vfpP[j]; } typename T::FacePointer const VFp(const int j) const { assert(j>=0 && j<this->VN()); return _vfpP[j]; }
typename T::FacePointer const cVFp(const int j) const { assert(j>=0 && j<this->VN()); return _vfpP[j]; } typename T::FacePointer const cVFp(const int j) const { assert(j>=0 && j<this->VN()); return _vfpP[j]; }
char &VFi(const int j) {return _vfiP[j]; } char &VFi(const int j) {return _vfiP[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(_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;}
} }
T::Alloc(ns); T::Alloc(ns);
} }
unsigned int SizeNeigh(){ return this->VN();} unsigned int SizeNeigh(){ return this->VN();}
@ -219,8 +215,8 @@ private:
template <class T> class PFFAdj: public T { template <class T> class PFFAdj: public T {
public: 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 const 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 const 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]; }
@ -258,8 +254,8 @@ public:
template <class T> class PFEAdj: public T { template <class T> class PFEAdj: public T {
public: public:
typedef typename T::EdgeType EdgeType; typedef typename T::EdgeType EdgeType;
PFEAdj(){_fepP = NULL; } PFEAdj(){_fepP = NULL; }
typename T::EdgePointer &FEp(const int j) { assert(j>=0 && j<this->VN()); return _fepP[j]; } typename T::EdgePointer &FEp(const int j) { assert(j>=0 && j<this->VN()); return _fepP[j]; }
typename T::EdgePointer const FEp(const int j) const { assert(j>=0 && j<this->VN()); return _fepP[j]; } typename T::EdgePointer const FEp(const int j) const { assert(j>=0 && j<this->VN()); return _fepP[j]; }
typename T::EdgePointer const cFEp(const int j) const { assert(j>=0 && j<this->VN()); return _fepP[j]; } typename T::EdgePointer const cFEp(const int j) const { assert(j>=0 && j<this->VN()); return _fepP[j]; }