2008-12-19 11:30:51 +01:00
|
|
|
/****************************************************************************
|
|
|
|
* VCGLib o o *
|
|
|
|
* Visual and Computer Graphics Library o o *
|
|
|
|
* _ O _ *
|
|
|
|
* Copyright(C) 2004 \/)\/ *
|
|
|
|
* Visual Computing Lab /\/| *
|
|
|
|
* ISTI - Italian National Research Council | *
|
|
|
|
* \ *
|
|
|
|
* All rights reserved. *
|
|
|
|
* *
|
2013-03-20 09:56:20 +01:00
|
|
|
* This program is free software; you can redistribute it and/or modify *
|
2008-12-19 11:30:51 +01:00
|
|
|
* it under the terms of the GNU General Public License as published by *
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or *
|
|
|
|
* (at your option) any later version. *
|
|
|
|
* *
|
|
|
|
* This program is distributed in the hope that it will be useful, *
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
|
|
|
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt) *
|
|
|
|
* for more details. *
|
|
|
|
* *
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#ifndef __VCG_POLYGON_COMPONENT
|
|
|
|
#define __VCG_POLYGON_COMPONENT
|
|
|
|
|
|
|
|
namespace vcg {
|
2014-02-18 11:58:12 +01:00
|
|
|
namespace face {
|
2008-12-19 11:30:51 +01:00
|
|
|
|
|
|
|
/*-------------------------- PolInfo -------------------------------------------*/
|
2010-03-25 17:52:18 +01:00
|
|
|
|
2008-12-19 11:30:51 +01:00
|
|
|
template <class T> class PolyInfo: public T {
|
|
|
|
protected:
|
2014-02-18 11:58:12 +01:00
|
|
|
inline void __SetVN(const int & n) {
|
|
|
|
assert((_ns==-1) || (_ns==n) || (n==-1));
|
|
|
|
_ns = n;
|
|
|
|
}
|
2008-12-19 11:30:51 +01:00
|
|
|
public:
|
2014-02-18 11:58:12 +01:00
|
|
|
PolyInfo(){ _ns = -1; }
|
|
|
|
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();}
|
2014-12-15 16:36:37 +01:00
|
|
|
inline void Alloc(const int & ns){
|
|
|
|
T::Alloc(ns);
|
|
|
|
__SetVN(ns);
|
|
|
|
}
|
|
|
|
inline void Dealloc(){
|
|
|
|
T::Dealloc();
|
|
|
|
__SetVN(-1);
|
|
|
|
}
|
2014-02-18 11:58:12 +01:00
|
|
|
|
2008-12-19 11:30:51 +01:00
|
|
|
private:
|
2014-02-18 11:58:12 +01:00
|
|
|
int _ns;
|
2008-12-19 11:30:51 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
template <class T> class PFVAdj: public T {
|
|
|
|
public:
|
2014-02-18 11:58:12 +01:00
|
|
|
typedef typename T::VertexType::CoordType CoordType;
|
|
|
|
typedef typename T::VertexType::ScalarType ScalarType;
|
|
|
|
typedef typename T::VertexType VertexType;
|
2010-03-25 17:52:18 +01:00
|
|
|
|
2014-12-15 16:36:37 +01:00
|
|
|
PFVAdj(){ _vpoly = 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 by the face allocator.
|
|
|
|
* This destructor is only done for those who istance a face alone (outside a mesh)
|
|
|
|
*/
|
|
|
|
// ~PFVAdj(){ __Dealloc(); }
|
|
|
|
|
2014-02-18 11:58:12 +01:00
|
|
|
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 * cV( const int j ) const { assert(j>=0 && j<this->VN()); return _vpoly[j]; }
|
2008-12-19 11:30:51 +01:00
|
|
|
|
|
|
|
|
2014-02-18 11:58:12 +01:00
|
|
|
/** Return the pointer to the ((j+1)%3)-th vertex of the face.
|
2014-02-13 14:16:09 +01:00
|
|
|
@param j Index of the face vertex.
|
|
|
|
*/
|
2014-02-18 11:58:12 +01:00
|
|
|
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());}
|
|
|
|
|
|
|
|
inline CoordType &P( const int j ) { assert(j>=0 && j<this->VN()); return _vpoly[j]->P(); }
|
|
|
|
inline CoordType cP( const int j ) const { assert(j>=0 && j<this->VN()); return _vpoly[j]->cP(); }
|
|
|
|
|
|
|
|
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 CoordType cP0( const int j ) const { return cV(j)->P();}
|
|
|
|
inline CoordType cP1( const int j ) const { return cV((j+1)%this->VN())->P();}
|
|
|
|
inline CoordType cP2( const int j ) const { return cV((j+2)%this->VN())->P();}
|
|
|
|
|
|
|
|
template <class LeftF>
|
2014-02-18 15:08:28 +01:00
|
|
|
void ImportData(const LeftF & leftF){ T::ImportData(leftF);}
|
2014-02-18 11:58:12 +01:00
|
|
|
inline void Alloc(const int & ns) {
|
2014-12-15 16:36:37 +01:00
|
|
|
__Dealloc();
|
|
|
|
_vpoly = new typename T::VertexType*[ns];
|
|
|
|
for(int i = 0; i < ns; ++i) _vpoly[i] = 0;
|
2014-02-18 11:58:12 +01:00
|
|
|
T::Alloc(ns);
|
|
|
|
}
|
|
|
|
inline void Dealloc() {
|
2014-12-15 16:36:37 +01:00
|
|
|
__Dealloc();
|
2014-02-18 11:58:12 +01:00
|
|
|
T::Dealloc();
|
2014-12-15 16:36:37 +01:00
|
|
|
}
|
2008-12-19 11:30:51 +01:00
|
|
|
|
|
|
|
static bool HasFVAdjacency() { return true; }
|
2014-02-18 11:58:12 +01:00
|
|
|
static void Name(std::vector<std::string> & name){name.push_back(std::string("PFVAdj"));T::Name(name);}
|
2008-12-19 11:30:51 +01:00
|
|
|
|
2014-02-18 11:58:12 +01:00
|
|
|
private:
|
2014-12-15 16:36:37 +01:00
|
|
|
inline void __Dealloc(){
|
|
|
|
delete [] _vpoly;
|
|
|
|
_vpoly = NULL;
|
|
|
|
}
|
|
|
|
|
2014-02-18 11:58:12 +01:00
|
|
|
typename T::VertexPointer *_vpoly;
|
2008-12-19 11:30:51 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
template <class T> class PVFAdj: public T {
|
|
|
|
public:
|
|
|
|
|
2014-12-15 16:36:37 +01:00
|
|
|
PVFAdj(){ _vfiP = NULL; _vfiP = NULL; }
|
2014-02-18 11:58:12 +01:00
|
|
|
/* Note: the destructor will not be called in general because there are no virtual destructors.
|
2014-12-15 16:36:37 +01:00
|
|
|
* 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)
|
|
|
|
*/
|
|
|
|
// ~PVFAdj(){ __Dealloc(); }
|
2014-02-18 11:58:12 +01:00
|
|
|
typedef typename T::VertexType VertexType;
|
|
|
|
typedef typename T::FaceType FaceType;
|
2008-12-19 11:30:51 +01:00
|
|
|
typename T::FacePointer &VFp(const int j) { 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]; }
|
|
|
|
char &VFi(const int j) {return _vfiP[j]; }
|
2014-02-18 11:58:12 +01:00
|
|
|
template <class LeftF>
|
|
|
|
void ImportData(const LeftF & leftF){T::ImportData(leftF);}
|
|
|
|
inline void Alloc(const int & ns) {
|
2014-12-15 16:36:37 +01:00
|
|
|
_vfpP = new FaceType*[ns];
|
|
|
|
_vfiP = new char[ns];
|
|
|
|
for(int i = 0; i < ns; ++i) {_vfpP[i] = 0;_vfiP[i] = -1;}
|
2014-02-18 11:58:12 +01:00
|
|
|
T::Alloc(ns);
|
|
|
|
}
|
|
|
|
unsigned int SizeNeigh(){ return this->VN();}
|
|
|
|
inline void Dealloc() {
|
2014-12-15 16:36:37 +01:00
|
|
|
__Dealloc();
|
2014-02-18 11:58:12 +01:00
|
|
|
T::Dealloc();
|
|
|
|
}
|
2008-12-19 11:30:51 +01:00
|
|
|
|
|
|
|
static bool HasVFAdjacency() { return true; }
|
|
|
|
static void Name(std::vector<std::string> & name){name.push_back(std::string("PVFAdj"));T::Name(name);}
|
|
|
|
|
|
|
|
private:
|
2014-12-15 16:36:37 +01:00
|
|
|
inline void __Dealloc(){
|
|
|
|
delete [] _vfpP; _vfpP = NULL;
|
|
|
|
delete [] _vfiP; _vfiP = NULL;
|
|
|
|
}
|
|
|
|
|
2013-03-20 09:56:20 +01:00
|
|
|
typename T::FacePointer *_vfpP ;
|
|
|
|
char *_vfiP ;
|
2008-12-19 11:30:51 +01:00
|
|
|
};
|
|
|
|
|
2013-03-20 09:56:20 +01:00
|
|
|
/*----------------------------- FFADJ ------------------------------*/
|
2008-12-19 11:30:51 +01:00
|
|
|
|
|
|
|
template <class T> class PFFAdj: public T {
|
|
|
|
public:
|
2014-02-18 11:58:12 +01:00
|
|
|
typedef typename T::FaceType FaceType;
|
2014-12-15 16:36:37 +01:00
|
|
|
PFFAdj(){ _ffpP = NULL; _ffiP = 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 by the face allocator.
|
|
|
|
* This destructor is only done for those who istance a face alone (outside a mesh)
|
|
|
|
*/
|
|
|
|
// ~PFFAdj(){ __Dealloc(); }
|
2014-02-18 11:58:12 +01:00
|
|
|
typename T::FacePointer &FFp(const int j) { 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 cFFp(const int j) const { assert(j>=0 && j<this->VN()); return _ffpP[j]; }
|
|
|
|
char &FFi(const int j) { return _ffiP[j]; }
|
|
|
|
char cFFi(const int j) const { return _ffiP[j]; }
|
|
|
|
|
|
|
|
template <class LeftF>
|
|
|
|
void ImportData(const LeftF & leftF){T::ImportData(leftF);}
|
|
|
|
inline void Alloc(const int & ns) {
|
2014-12-15 16:36:37 +01:00
|
|
|
_ffpP = new FaceType*[ns];
|
|
|
|
_ffiP = new char[ns];
|
|
|
|
for(int i = 0; i < ns; ++i) {_ffpP[i] = 0;_ffiP[i] = 0;}
|
2014-02-18 11:58:12 +01:00
|
|
|
T::Alloc(ns);
|
|
|
|
}
|
|
|
|
inline void Dealloc() {
|
2014-12-15 16:36:37 +01:00
|
|
|
__Dealloc();
|
2014-02-18 11:58:12 +01:00
|
|
|
T::Dealloc();
|
|
|
|
}
|
2008-12-19 11:30:51 +01:00
|
|
|
|
|
|
|
static bool HasFFAdjacency() { return true; }
|
|
|
|
static void Name(std::vector<std::string> & name){name.push_back(std::string("PFFAdj"));T::Name(name);}
|
|
|
|
|
2014-02-18 11:58:12 +01:00
|
|
|
private:
|
2014-12-15 16:36:37 +01:00
|
|
|
inline void __Dealloc(){
|
|
|
|
delete [] _ffpP; _ffpP = NULL;
|
|
|
|
delete [] _ffiP; _ffiP = NULL;
|
|
|
|
}
|
|
|
|
|
2013-03-20 09:56:20 +01:00
|
|
|
typename T::FacePointer *_ffpP ;
|
|
|
|
char *_ffiP ;
|
2008-12-19 11:30:51 +01:00
|
|
|
};
|
|
|
|
|
2013-03-20 09:56:20 +01:00
|
|
|
/*----------------------------- PFEADJ ------------------------------*/
|
2008-12-19 11:30:51 +01:00
|
|
|
|
|
|
|
template <class T> class PFEAdj: public T {
|
|
|
|
public:
|
2014-02-18 11:58:12 +01:00
|
|
|
typedef typename T::EdgeType EdgeType;
|
2014-12-15 16:36:37 +01:00
|
|
|
PFEAdj(){ _fepP = 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 by the face allocator.
|
|
|
|
* This destructor is only done for those who istance a face alone (outside a mesh)
|
|
|
|
*/
|
|
|
|
// ~PFEAdj(){ __Dealloc(); }
|
2014-02-18 11:58:12 +01:00
|
|
|
typename T::EdgePointer &FEp(const int j) { assert(j>=0 && j<this->VN()); return _fepP[j]; }
|
2008-12-19 11:30:51 +01:00
|
|
|
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]; }
|
2013-03-20 09:56:20 +01:00
|
|
|
|
2014-02-18 11:58:12 +01:00
|
|
|
template <class LeftF>
|
|
|
|
void ImportData(const LeftF & leftF){T::ImportData(leftF);}
|
|
|
|
inline void Alloc(const int & ns) {
|
2014-12-15 16:36:37 +01:00
|
|
|
_fepP = new EdgeType *[ns];
|
|
|
|
for(int i = 0; i < ns; ++i) {_fepP[i] = 0;}
|
2014-02-18 11:58:12 +01:00
|
|
|
T::Alloc(ns);
|
|
|
|
}
|
2014-12-15 16:36:37 +01:00
|
|
|
inline void Dealloc() {
|
|
|
|
T::Dealloc();
|
|
|
|
}
|
2014-02-13 14:16:09 +01:00
|
|
|
|
2014-02-18 11:58:12 +01:00
|
|
|
static bool HasFEAdjacency() { return true; }
|
|
|
|
static void Name(std::vector<std::string> & name){name.push_back(std::string("PFEAdj"));T::Name(name);}
|
2008-12-19 11:30:51 +01:00
|
|
|
|
2014-02-18 11:58:12 +01:00
|
|
|
private:
|
2014-12-15 16:36:37 +01:00
|
|
|
inline void __Dealloc(){
|
|
|
|
delete [] _fepP; _fepP = NULL;
|
|
|
|
}
|
|
|
|
|
2014-02-18 11:58:12 +01:00
|
|
|
typename T::EdgePointer *_fepP ;
|
2008-12-19 11:30:51 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2010-03-25 17:52:18 +01:00
|
|
|
/*----------------------------- PFHADJ ------------------------------*/
|
|
|
|
|
|
|
|
template <class T> class PFHAdj: public T {
|
2008-12-19 11:30:51 +01:00
|
|
|
public:
|
2014-02-18 11:58:12 +01:00
|
|
|
typedef typename T::HEdgeType HEdgeType;
|
|
|
|
typedef typename T::HEdgePointer HEdgePointer;
|
2010-03-25 17:52:18 +01:00
|
|
|
|
2014-12-15 16:36:37 +01:00
|
|
|
PFHAdj(){ _fhP = NULL; }
|
2014-02-18 11:58:12 +01:00
|
|
|
typename T::HEdgePointer &FHp() { return _fhP; }
|
|
|
|
typename T::HEdgePointer const cFHp() const { return _fhP; }
|
2010-03-25 17:52:18 +01:00
|
|
|
|
2014-02-18 11:58:12 +01:00
|
|
|
template <class LeftF>
|
|
|
|
void ImportData(const LeftF & leftF){T::ImportData(leftF);}
|
|
|
|
inline void Alloc(const int & ns) {T::Alloc(ns);}
|
|
|
|
inline void Dealloc() { T::Dealloc();}
|
2008-12-19 11:30:51 +01:00
|
|
|
|
2014-02-18 11:58:12 +01:00
|
|
|
static bool HasFHAdjacency() { return true; }
|
|
|
|
static void Name(std::vector<std::string> & name){name.push_back(std::string("PFHAdj"));T::Name(name);}
|
2008-12-19 11:30:51 +01:00
|
|
|
|
2014-02-18 11:58:12 +01:00
|
|
|
private:
|
|
|
|
typename T::HEdgePointer _fhP ;
|
2008-12-19 11:30:51 +01:00
|
|
|
};
|
|
|
|
|
2014-02-18 11:58:12 +01:00
|
|
|
} // end namespace face
|
|
|
|
} // end namespace vcg
|
2008-12-19 11:30:51 +01:00
|
|
|
#endif
|