Merge branch 'devel' of https://github.com/cnr-isti-vclab/vcglib into devel
This commit is contained in:
commit
22311c5340
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -27,10 +27,10 @@
|
||||||
#define __VCG_EDGE_PLUS_COMPONENT
|
#define __VCG_EDGE_PLUS_COMPONENT
|
||||||
|
|
||||||
namespace vcg {
|
namespace vcg {
|
||||||
namespace edge {
|
namespace edge {
|
||||||
|
|
||||||
/** \addtogroup EdgeComponentGroup
|
/** \addtogroup EdgeComponentGroup
|
||||||
@{
|
@{
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -38,120 +38,122 @@ Some naming Rules
|
||||||
All the Components that can be added to a vertex should be defined in the namespace edge:
|
All the Components that can be added to a vertex should be defined in the namespace edge:
|
||||||
|
|
||||||
*/
|
*/
|
||||||
/*------------------------- EMPTY CORE COMPONENTS -----------------------------------------*/
|
/*------------------------- EMPTY CORE COMPONENTS -----------------------------------------*/
|
||||||
|
|
||||||
template <class T> class EmptyCore: public T
|
template <class T> class EmptyCore: public T
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
inline typename T::VertexType * & V( const int j ) { (void)j; assert(0); static typename T::VertexType *vp=0; return vp; }
|
inline typename T::VertexType * & V( const int j ) { (void)j; assert(0); static typename T::VertexType *vp=0; return vp; }
|
||||||
inline typename T::VertexType * const & V( const int j ) const { (void)j; assert(0); static typename T::VertexType *vp=0; return vp; }
|
inline typename T::VertexType * const & V( const int j ) const { (void)j; assert(0); static typename T::VertexType *vp=0; return vp; }
|
||||||
inline typename T::VertexType * cV( const int j ) const { (void)j; assert(0); static typename T::VertexType *vp=0; return vp; }
|
inline typename T::VertexType * cV( const int j ) const { (void)j; assert(0); static typename T::VertexType *vp=0; return vp; }
|
||||||
inline typename T::CoordType & P( const int j ) { (void)j; assert(0); static typename T::CoordType coord(0, 0, 0); return coord; }
|
inline typename T::CoordType & P( const int j ) { (void)j; assert(0); static typename T::CoordType coord(0, 0, 0); return coord; }
|
||||||
inline const typename T::CoordType & P( const int j ) const { (void)j; assert(0); static typename T::CoordType coord(0, 0, 0); return coord; }
|
inline const typename T::CoordType & P( const int j ) const { (void)j; assert(0); static typename T::CoordType coord(0, 0, 0); return coord; }
|
||||||
inline const typename T::CoordType & cP( const int j ) const { (void)j; assert(0); static typename T::CoordType coord(0, 0, 0); return coord; }
|
inline const typename T::CoordType & cP( const int j ) const { (void)j; assert(0); static typename T::CoordType coord(0, 0, 0); return coord; }
|
||||||
static bool HasEVAdjacency() { return false; }
|
static bool HasEVAdjacency() { return false; }
|
||||||
static bool HasVertexRef() { return false; }
|
static bool HasVertexRef() { return false; }
|
||||||
|
|
||||||
typedef vcg::Color4b ColorType;
|
typedef vcg::Color4b ColorType;
|
||||||
ColorType &C() { static ColorType dumcolor(vcg::Color4b::White); assert(0); return dumcolor; }
|
ColorType &C() { static ColorType dumcolor(vcg::Color4b::White); assert(0); return dumcolor; }
|
||||||
ColorType cC() const { static ColorType dumcolor(vcg::Color4b::White); assert(0); return dumcolor; }
|
ColorType cC() const { static ColorType dumcolor(vcg::Color4b::White); assert(0); return dumcolor; }
|
||||||
static bool HasColor() { return false; }
|
static bool HasColor() { return false; }
|
||||||
|
|
||||||
typedef float QualityType;
|
typedef float QualityType;
|
||||||
QualityType &Q() { static QualityType dummyQuality(0); assert(0); return dummyQuality; }
|
QualityType &Q() { static QualityType dummyQuality(0); assert(0); return dummyQuality; }
|
||||||
QualityType cQ() const { static QualityType dummyQuality(0); assert(0); return dummyQuality; }
|
QualityType cQ() const { static QualityType dummyQuality(0); assert(0); return dummyQuality; }
|
||||||
static bool HasQuality() { return false; }
|
static bool HasQuality() { return false; }
|
||||||
|
|
||||||
typedef int MarkType;
|
typedef int MarkType;
|
||||||
inline void InitIMark() { }
|
inline void InitIMark() { }
|
||||||
inline int cIMark() const { assert(0); static int tmp=-1; return tmp;}
|
inline int cIMark() const { assert(0); static int tmp=-1; return tmp;}
|
||||||
inline int &IMark() { assert(0); static int tmp=-1; return tmp;}
|
inline int &IMark() { assert(0); static int tmp=-1; return tmp;}
|
||||||
static bool HasMark() { return false; }
|
static bool HasMark() { return false; }
|
||||||
|
inline bool IsMarkEnabled( ) const { return T::EdgeType::HasMark(); }
|
||||||
|
|
||||||
typedef int FlagType;
|
|
||||||
int &Flags() { static int dummyflags(0); assert(0); return dummyflags; }
|
|
||||||
int Flags() const { return 0; }
|
|
||||||
static bool HasFlags() { return false; }
|
|
||||||
|
|
||||||
typename T::EdgePointer &VEp(const int & ) { static typename T::EdgePointer ep=0; assert(0); return ep; }
|
typedef int FlagType;
|
||||||
typename T::EdgePointer cVEp(const int & ) const { static typename T::EdgePointer ep=0; assert(0); return ep; }
|
int &Flags() { static int dummyflags(0); assert(0); return dummyflags; }
|
||||||
int &VEi(const int &){static int z=0; assert(0); return z;}
|
int Flags() const { return 0; }
|
||||||
int cVEi(const int &) const {static int z=0; assert(0); return z;}
|
static bool HasFlags() { return false; }
|
||||||
static bool HasVEAdjacency() { return false; }
|
|
||||||
|
|
||||||
typename T::EdgePointer &EEp(const int & ) { static typename T::EdgePointer ep=0; assert(0); return ep; }
|
typename T::EdgePointer &VEp(const int & ) { static typename T::EdgePointer ep=0; assert(0); return ep; }
|
||||||
typename T::EdgePointer cEEp(const int & ) const { static typename T::EdgePointer ep=0; assert(0); return ep; }
|
typename T::EdgePointer cVEp(const int & ) const { static typename T::EdgePointer ep=0; assert(0); return ep; }
|
||||||
int &EEi(const int &){static int z=0; assert(0); return z;}
|
int &VEi(const int &){static int z=0; assert(0); return z;}
|
||||||
int cEEi(const int &) const {static int z=0; assert(0); return z;}
|
int cVEi(const int &) const {static int z=0; assert(0); return z;}
|
||||||
static bool HasEEAdjacency() { return false; }
|
static bool HasVEAdjacency() { return false; }
|
||||||
|
|
||||||
typename T::HEdgePointer &EHp( ) { static typename T::HEdgePointer hp=0; assert(0); return hp; }
|
typename T::EdgePointer &EEp(const int & ) { static typename T::EdgePointer ep=0; assert(0); return ep; }
|
||||||
typename T::HEdgePointer cEHp( ) const { static typename T::HEdgePointer hp=0; assert(0); return hp; }
|
typename T::EdgePointer cEEp(const int & ) const { static typename T::EdgePointer ep=0; assert(0); return ep; }
|
||||||
static bool HasEHAdjacency() { return false; }
|
int &EEi(const int &){static int z=0; assert(0); return z;}
|
||||||
|
int cEEi(const int &) const {static int z=0; assert(0); return z;}
|
||||||
|
static bool HasEEAdjacency() { return false; }
|
||||||
|
|
||||||
typename T::FacePointer &EFp() { static typename T::FacePointer fp=0; assert(0); return fp; }
|
typename T::HEdgePointer &EHp( ) { static typename T::HEdgePointer hp=0; assert(0); return hp; }
|
||||||
typename T::FacePointer cEFp() const { static typename T::FacePointer fp=0; assert(0); return fp; }
|
typename T::HEdgePointer cEHp( ) const { static typename T::HEdgePointer hp=0; assert(0); return hp; }
|
||||||
int &EFi() {static int z=0; return z;}
|
static bool HasEHAdjacency() { return false; }
|
||||||
int &cEFi() const {static int z=0; return z;}
|
|
||||||
static bool HasEFAdjacency() { return false; }
|
|
||||||
|
|
||||||
template <class LeftF>
|
typename T::FacePointer &EFp() { static typename T::FacePointer fp=0; assert(0); return fp; }
|
||||||
void ImportData(const LeftF & leftF) {T::ImportData(leftF);}
|
typename T::FacePointer cEFp() const { static typename T::FacePointer fp=0; assert(0); return fp; }
|
||||||
static void Name(std::vector<std::string> & name){T::Name(name);}
|
int &EFi() {static int z=0; return z;}
|
||||||
};
|
int &cEFi() const {static int z=0; return z;}
|
||||||
|
static bool HasEFAdjacency() { return false; }
|
||||||
|
|
||||||
/*-------------------------- VertexRef ----------------------------------------*/
|
template <class LeftF>
|
||||||
/*! \brief The references to the two vertexes of a edge
|
void ImportData(const LeftF & leftF) {T::ImportData(leftF);}
|
||||||
|
static void Name(std::vector<std::string> & name){T::Name(name);}
|
||||||
|
};
|
||||||
|
|
||||||
|
/*-------------------------- VertexRef ----------------------------------------*/
|
||||||
|
/*! \brief The references to the two vertexes of a edge
|
||||||
*
|
*
|
||||||
* Stored as pointers to the VertexType
|
* Stored as pointers to the VertexType
|
||||||
*/
|
*/
|
||||||
|
|
||||||
template <class T> class VertexRef: public T {
|
template <class T> class VertexRef: public T {
|
||||||
public:
|
public:
|
||||||
VertexRef(){
|
VertexRef(){
|
||||||
v[0]=0;
|
v[0]=0;
|
||||||
v[1]=0;
|
v[1]=0;
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef typename T::VertexType::CoordType CoordType;
|
typedef typename T::VertexType::CoordType CoordType;
|
||||||
typedef typename T::VertexType::ScalarType ScalarType;
|
typedef typename T::VertexType::ScalarType ScalarType;
|
||||||
|
|
||||||
inline typename T::VertexType * & V( const int j ) { assert(j>=0 && j<2); return v[j]; }
|
inline typename T::VertexType * & V( const int j ) { assert(j>=0 && j<2); return v[j]; }
|
||||||
inline typename T::VertexType * const & V( const int j ) const { assert(j>=0 && j<2); return v[j]; }
|
inline typename T::VertexType * const & V( const int j ) const { assert(j>=0 && j<2); return v[j]; }
|
||||||
inline typename T::VertexType * cV( const int j ) const { assert(j>=0 && j<2); return v[j]; }
|
inline typename T::VertexType * cV( const int j ) const { assert(j>=0 && j<2); return v[j]; }
|
||||||
|
|
||||||
// Shortcut per accedere ai punti delle facce
|
// Shortcut per accedere ai punti delle facce
|
||||||
inline CoordType & P( const int j ) { assert(j>=0 && j<2); return v[j]->P(); }
|
inline CoordType & P( const int j ) { assert(j>=0 && j<2); return v[j]->P(); }
|
||||||
inline const CoordType &cP( const int j ) const { assert(j>=0 && j<2); return v[j]->P(); }
|
inline const CoordType &cP( const int j ) const { assert(j>=0 && j<2); return v[j]->P(); }
|
||||||
|
|
||||||
/** Return the pointer to the ((j+1)%3)-th vertex of the face.
|
/** Return the pointer to the ((j+1)%3)-th vertex of the face.
|
||||||
@param j Index of the face vertex.
|
@param j Index of the face vertex.
|
||||||
*/
|
*/
|
||||||
inline typename T::VertexType * & V0( const int j ) { return V(j);}
|
inline typename T::VertexType * & V0( const int j ) { return V(j);}
|
||||||
inline typename T::VertexType * & V1( const int j ) { return V((j+1)%2);}
|
inline typename T::VertexType * & V1( const int j ) { return V((j+1)%2);}
|
||||||
inline const typename T::VertexType * const & V0( const int j ) const { return V(j);}
|
inline const typename T::VertexType * const & V0( const int j ) const { return V(j);}
|
||||||
inline const typename T::VertexType * const & V1( const int j ) const { return V((j+1)%2);}
|
inline const typename T::VertexType * const & V1( const int j ) const { return V((j+1)%2);}
|
||||||
inline const typename T::VertexType * const & cV0( const int j ) const { return cV(j);}
|
inline const typename T::VertexType * const & cV0( const int j ) const { return cV(j);}
|
||||||
inline const typename T::VertexType * const & cV1( const int j ) const { return cV((j+1)%2);}
|
inline const typename T::VertexType * const & cV1( const int j ) const { return cV((j+1)%2);}
|
||||||
|
|
||||||
/// 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)%2)->P();}
|
inline CoordType & P1( const int j ) { return V((j+1)%2)->P();}
|
||||||
inline const CoordType & P0( const int j ) const { return V(j)->P();}
|
inline const CoordType & P0( const int j ) const { return V(j)->P();}
|
||||||
inline const CoordType & P1( const int j ) const { return V((j+1)%2)->P();}
|
inline const CoordType & P1( const int j ) const { return V((j+1)%2)->P();}
|
||||||
inline const CoordType & cP0( const int j ) const { return cV(j)->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)%2)->P();}
|
inline const CoordType & cP1( const int j ) const { return cV((j+1)%2)->P();}
|
||||||
|
|
||||||
template <class LeftF>
|
template <class LeftF>
|
||||||
void ImportData(const LeftF & leftF){ T::ImportData(leftF);}
|
void ImportData(const LeftF & leftF){ T::ImportData(leftF);}
|
||||||
|
|
||||||
static bool HasEVAdjacency() { return true; }
|
static bool HasEVAdjacency() { return true; }
|
||||||
static bool HasVertexRef() { return true; }
|
static bool HasVertexRef() { return true; }
|
||||||
static void Name(std::vector<std::string> & name){name.push_back(std::string("VertexRef"));T::Name(name);}
|
static void Name(std::vector<std::string> & name){name.push_back(std::string("VertexRef"));T::Name(name);}
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
typename T::VertexType *v[2];
|
typename T::VertexType *v[2];
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class T> class EVAdj : public VertexRef<T>{};
|
template <class T> class EVAdj : public VertexRef<T>{};
|
||||||
|
@ -165,68 +167,74 @@ template <class T> class EVAdj : public VertexRef<T>{};
|
||||||
*/
|
*/
|
||||||
template <class T> class Mark: public T {
|
template <class T> class Mark: public T {
|
||||||
public:
|
public:
|
||||||
Mark():_imark(0){}
|
Mark():_imark(0){}
|
||||||
static bool HasMark() { return true; }
|
static bool HasMark() { return true; }
|
||||||
static bool HasMarkOcc() { return true; }
|
static bool HasMarkOcc() { return true; }
|
||||||
inline void InitIMark() { _imark = 0; }
|
inline void InitIMark() { _imark = 0; }
|
||||||
inline int & IMark() { return _imark;}
|
inline int & IMark() { return _imark;}
|
||||||
inline const int & IMark() const {return _imark;}
|
inline int cIMark() const { return _imark;}
|
||||||
template < class LeftV>
|
|
||||||
void ImportData(const LeftV & left ) { IMark() = left.IMark(); T::ImportData( left); }
|
|
||||||
static void Name(std::vector<std::string> & name){name.push_back(std::string("Mark"));T::Name(name);}
|
|
||||||
|
|
||||||
private:
|
template < class RightValueType>
|
||||||
int _imark;
|
void ImportData(const RightValueType & rightE )
|
||||||
|
{
|
||||||
|
if(rightE.IsMarkEnabled())
|
||||||
|
IMark() = rightE.cIMark();
|
||||||
|
T::ImportData(rightE);
|
||||||
|
}
|
||||||
|
static void Name(std::vector<std::string> & name){name.push_back(std::string("Mark"));T::Name(name);}
|
||||||
|
|
||||||
|
private:
|
||||||
|
int _imark;
|
||||||
};
|
};
|
||||||
|
|
||||||
/*------------------------- FLAGS -----------------------------------------*/
|
/*------------------------- FLAGS -----------------------------------------*/
|
||||||
/*! \brief \em Component: Per edge \b Flags
|
/*! \brief \em Component: Per edge \b Flags
|
||||||
*
|
*
|
||||||
* This component stores a 32 bit array of bit flags. These bit flags are used for keeping track of selection, deletion, visiting etc. \sa \ref flags for more details on common uses of flags.
|
* This component stores a 32 bit array of bit flags. These bit flags are used for keeping track of selection, deletion, visiting etc. \sa \ref flags for more details on common uses of flags.
|
||||||
*/
|
*/
|
||||||
template <class T> class BitFlags: public T {
|
template <class T> class BitFlags: public T {
|
||||||
public:
|
public:
|
||||||
BitFlags(){_flags=0;}
|
BitFlags(){_flags=0;}
|
||||||
typedef int FlagType;
|
typedef int FlagType;
|
||||||
int &Flags() {return _flags; }
|
int &Flags() {return _flags; }
|
||||||
int Flags() const {return _flags; }
|
int Flags() const {return _flags; }
|
||||||
template < class LeftV>
|
template < class LeftV>
|
||||||
void ImportData(const LeftV & left ) { Flags() = left.Flags(); T::ImportData( left); }
|
void ImportData(const LeftV & left ) { Flags() = left.Flags(); T::ImportData( left); }
|
||||||
static bool HasFlags() { return true; }
|
static bool HasFlags() { return true; }
|
||||||
static void Name(std::vector<std::string> & name){name.push_back(std::string("BitFlags"));T::Name(name);}
|
static void Name(std::vector<std::string> & name){name.push_back(std::string("BitFlags"));T::Name(name);}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int _flags;
|
int _flags;
|
||||||
};
|
};
|
||||||
|
|
||||||
/*-------------------------- Color ----------------------------------*/
|
/*-------------------------- Color ----------------------------------*/
|
||||||
/*! \brief \em Component: Per edge \b Color
|
/*! \brief \em Component: Per edge \b Color
|
||||||
*
|
*
|
||||||
* Usually most of the library expects a color stored as 4 unsigned chars (so the component you use is a \c vertex::Color4b)
|
* Usually most of the library expects a color stored as 4 unsigned chars (so the component you use is a \c vertex::Color4b)
|
||||||
* but you can also use float for the color components.
|
* but you can also use float for the color components.
|
||||||
*/
|
*/
|
||||||
template <class A, class T> class Color: public T {
|
template <class A, class T> class Color: public T {
|
||||||
public:
|
public:
|
||||||
Color():_color(vcg::Color4b::White) {}
|
Color():_color(vcg::Color4b::White) {}
|
||||||
typedef A ColorType;
|
typedef A ColorType;
|
||||||
ColorType &C() { return _color; }
|
ColorType &C() { return _color; }
|
||||||
const ColorType &C() const { return _color; }
|
const ColorType &C() const { return _color; }
|
||||||
const ColorType &cC() const { return _color; }
|
const ColorType &cC() const { return _color; }
|
||||||
template < class LeftV>
|
template < class LeftV>
|
||||||
void ImportData(const LeftV & left ) { C() = left.cC(); T::ImportData( left); }
|
void ImportData(const LeftV & left ) { C() = left.cC(); T::ImportData( left); }
|
||||||
static bool HasColor() { return true; }
|
static bool HasColor() { return true; }
|
||||||
static void Name(std::vector<std::string> & name){name.push_back(std::string("Color"));T::Name(name);}
|
static void Name(std::vector<std::string> & name){name.push_back(std::string("Color"));T::Name(name);}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ColorType _color;
|
ColorType _color;
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class TT> class Color4b: public edge::Color<vcg::Color4b, TT> {
|
template <class TT> class Color4b: public edge::Color<vcg::Color4b, TT> {
|
||||||
public: static void Name(std::vector<std::string> & name){name.push_back(std::string("Color4b"));TT::Name(name);}
|
public: static void Name(std::vector<std::string> & name){name.push_back(std::string("Color4b"));TT::Name(name);}
|
||||||
};
|
};
|
||||||
|
|
||||||
/*-------------------------- Quality ----------------------------------*/
|
/*-------------------------- Quality ----------------------------------*/
|
||||||
/*! \brief \em Component: Per edge \b quality
|
/*! \brief \em Component: Per edge \b quality
|
||||||
*
|
*
|
||||||
* The Quality Component is a generic place for storing a float. The term 'quality' is a bit misleading and it is due to its original storic meaning. You should intend it as a general purpose container.
|
* The Quality Component is a generic place for storing a float. The term 'quality' is a bit misleading and it is due to its original storic meaning. You should intend it as a general purpose container.
|
||||||
* \sa vcg::tri::UpdateColor for methods transforming quality into colors
|
* \sa vcg::tri::UpdateColor for methods transforming quality into colors
|
||||||
|
@ -234,16 +242,16 @@ template <class TT> class Color4b: public edge::Color<vcg::Color4b, TT> {
|
||||||
*/
|
*/
|
||||||
template <class A, class TT> class Quality: public TT {
|
template <class A, class TT> class Quality: public TT {
|
||||||
public:
|
public:
|
||||||
typedef A QualityType;
|
typedef A QualityType;
|
||||||
QualityType &Q() { return _quality; }
|
QualityType &Q() { return _quality; }
|
||||||
const QualityType & cQ() const {return _quality; }
|
const QualityType & cQ() const {return _quality; }
|
||||||
template < class LeftV>
|
template < class LeftV>
|
||||||
void ImportData(const LeftV & left ) { Q() = left.cQ(); TT::ImportData( left); }
|
void ImportData(const LeftV & left ) { Q() = left.cQ(); TT::ImportData( left); }
|
||||||
static bool HasQuality() { return true; }
|
static bool HasQuality() { return true; }
|
||||||
static void Name(std::vector<std::string> & name){name.push_back(std::string("Quality"));TT::Name(name);}
|
static void Name(std::vector<std::string> & name){name.push_back(std::string("Quality"));TT::Name(name);}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QualityType _quality;
|
QualityType _quality;
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class TT> class Qualitys: public Quality<short, TT> {
|
template <class TT> class Qualitys: public Quality<short, TT> {
|
||||||
|
@ -257,34 +265,34 @@ public: static void Name(std::vector<std::string> & name){name.push_back(std::st
|
||||||
};
|
};
|
||||||
|
|
||||||
/*----------------------------- VEADJ ------------------------------*/
|
/*----------------------------- VEADJ ------------------------------*/
|
||||||
/*! \brief \em Component: Per vertex \b Vertex-Edge adjacency relation companion component
|
/*! \brief \em Component: Per vertex \b Vertex-Edge adjacency relation companion component
|
||||||
This component implement one element of the list of edges incident on a vertex.
|
This component implement one element of the list of edges incident on a vertex.
|
||||||
You must use this component only toghether with the corresponding \ref vcg::vertex::VEAdj component in the vertex type
|
You must use this component only toghether with the corresponding \ref vcg::vertex::VEAdj component in the vertex type
|
||||||
|
|
||||||
\sa vcg::tri::UpdateTopology for functions that compute this relation
|
\sa vcg::tri::UpdateTopology for functions that compute this relation
|
||||||
\sa iterators
|
\sa iterators
|
||||||
*/
|
*/
|
||||||
template <class T> class VEAdj: public T {
|
template <class T> class VEAdj: public T {
|
||||||
public:
|
public:
|
||||||
VEAdj(){_ep[0]=0;_ep[1]=0;_zp[0]=-1;_zp[1]=-1;}
|
VEAdj(){_ep[0]=0;_ep[1]=0;_zp[0]=-1;_zp[1]=-1;}
|
||||||
typename T::EdgePointer &VEp(const int & i) {return _ep[i]; }
|
typename T::EdgePointer &VEp(const int & i) {return _ep[i]; }
|
||||||
typename T::EdgePointer cVEp(const int & i) const {return _ep[i]; }
|
typename T::EdgePointer cVEp(const int & i) const {return _ep[i]; }
|
||||||
int &VEi(const int & i){ return _zp[i];}
|
int &VEi(const int & i){ return _zp[i];}
|
||||||
int cVEi(const int &i )const {return _zp[i];}
|
int cVEi(const int &i )const {return _zp[i];}
|
||||||
|
|
||||||
template < class LeftV>
|
template < class LeftV>
|
||||||
void ImportData(const LeftV & left ) { T::ImportData( left); }
|
void ImportData(const LeftV & left ) { T::ImportData( left); }
|
||||||
static bool HasVEAdjacency() { return true; }
|
static bool HasVEAdjacency() { return true; }
|
||||||
static bool HasVEAdjacencyOcc() { return true; }
|
static bool HasVEAdjacencyOcc() { return true; }
|
||||||
static void Name(std::vector<std::string> & name){name.push_back(std::string("VEAdj"));T::Name(name);}
|
static void Name(std::vector<std::string> & name){name.push_back(std::string("VEAdj"));T::Name(name);}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
typename T::EdgePointer _ep[2] ;
|
typename T::EdgePointer _ep[2] ;
|
||||||
int _zp[2] ;
|
int _zp[2] ;
|
||||||
};
|
};
|
||||||
|
|
||||||
/*----------------------------- EEADJ ------------------------------*/
|
/*----------------------------- EEADJ ------------------------------*/
|
||||||
/*! \brief \em Component: \b Edge-Edge adjacency relation
|
/*! \brief \em Component: \b Edge-Edge adjacency relation
|
||||||
This component implement store the pointer (and index) of the adjacent edges.
|
This component implement store the pointer (and index) of the adjacent edges.
|
||||||
If the vertex is 1-manifold (as in a classical polyline)
|
If the vertex is 1-manifold (as in a classical polyline)
|
||||||
it holds that:
|
it holds that:
|
||||||
|
@ -299,42 +307,42 @@ public: static void Name(std::vector<std::string> & name){name.push_back(std::st
|
||||||
|
|
||||||
template <class T> class EEAdj: public T {
|
template <class T> class EEAdj: public T {
|
||||||
public:
|
public:
|
||||||
EEAdj(){_ep[0]=0;_ep[1]=0;_zp[0]=-1;_zp[1]=-1;}
|
EEAdj(){_ep[0]=0;_ep[1]=0;_zp[0]=-1;_zp[1]=-1;}
|
||||||
typename T::EdgePointer &EEp(const int & i) {return _ep[i]; }
|
typename T::EdgePointer &EEp(const int & i) {return _ep[i]; }
|
||||||
typename T::EdgePointer cEEp(const int & i) const {return _ep[i]; }
|
typename T::EdgePointer cEEp(const int & i) const {return _ep[i]; }
|
||||||
int &EEi(const int & i){ return _zp[i];}
|
int &EEi(const int & i){ return _zp[i];}
|
||||||
int cEEi(const int &i )const {return _zp[i];}
|
int cEEi(const int &i )const {return _zp[i];}
|
||||||
|
|
||||||
template < class LeftV>
|
template < class LeftV>
|
||||||
void ImportData(const LeftV & left ) { T::ImportData( left); }
|
void ImportData(const LeftV & left ) { T::ImportData( left); }
|
||||||
static bool HasEEAdjacency() { return true; }
|
static bool HasEEAdjacency() { return true; }
|
||||||
static bool HasEEAdjacencyOcc() { return true; }
|
static bool HasEEAdjacencyOcc() { return true; }
|
||||||
static void Name(std::vector<std::string> & name){name.push_back(std::string("EEAdj"));T::Name(name);}
|
static void Name(std::vector<std::string> & name){name.push_back(std::string("EEAdj"));T::Name(name);}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
typename T::EdgePointer _ep[2] ;
|
typename T::EdgePointer _ep[2] ;
|
||||||
int _zp[2] ;
|
int _zp[2] ;
|
||||||
};
|
};
|
||||||
|
|
||||||
/*----------------------------- EHADJ ------------------------------*/
|
/*----------------------------- EHADJ ------------------------------*/
|
||||||
template <class T> class EHAdj: public T {
|
template <class T> class EHAdj: public T {
|
||||||
public:
|
public:
|
||||||
EHAdj(){_hp=0;}
|
EHAdj(){_hp=0;}
|
||||||
typename T::HEdgePointer &EHp( ) {return _hp ; }
|
typename T::HEdgePointer &EHp( ) {return _hp ; }
|
||||||
const typename T::HEdgePointer cEHp( ) const {return _hp ; }
|
const typename T::HEdgePointer cEHp( ) const {return _hp ; }
|
||||||
|
|
||||||
template < class LeftV>
|
template < class LeftV>
|
||||||
void ImportData(const LeftV & left ) { T::ImportData( left); }
|
void ImportData(const LeftV & left ) { T::ImportData( left); }
|
||||||
static bool HasEHAdjacency() { return true; }
|
static bool HasEHAdjacency() { return true; }
|
||||||
static bool HasEHAdjacencyOcc() { return true; }
|
static bool HasEHAdjacencyOcc() { return true; }
|
||||||
static void Name(std::vector<std::string> & name){name.push_back(std::string("EHAdj"));T::Name(name);}
|
static void Name(std::vector<std::string> & name){name.push_back(std::string("EHAdj"));T::Name(name);}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
typename T::HEdgePointer _hp ;
|
typename T::HEdgePointer _hp ;
|
||||||
};
|
};
|
||||||
|
|
||||||
/*----------------------------- EFADJ ------------------------------*/
|
/*----------------------------- EFADJ ------------------------------*/
|
||||||
/*! \brief \em Component: \b Edge-Face adjacency relation
|
/*! \brief \em Component: \b Edge-Face adjacency relation
|
||||||
This component implement store the pointer to a face sharing this edge.
|
This component implement store the pointer to a face sharing this edge.
|
||||||
|
|
||||||
\sa vcg::tri::UpdateTopology for functions that compute this relation
|
\sa vcg::tri::UpdateTopology for functions that compute this relation
|
||||||
|
@ -343,23 +351,23 @@ private:
|
||||||
|
|
||||||
template <class T> class EFAdj: public T {
|
template <class T> class EFAdj: public T {
|
||||||
public:
|
public:
|
||||||
EFAdj(){_fp=0;}
|
EFAdj(){_fp=0;}
|
||||||
typename T::FacePointer &EFp() {return _fp; }
|
typename T::FacePointer &EFp() {return _fp; }
|
||||||
typename T::FacePointer cEFp() const {return _fp; }
|
typename T::FacePointer cEFp() const {return _fp; }
|
||||||
int &EFi() {return _zp; }
|
int &EFi() {return _zp; }
|
||||||
int cEFi() const {return _zp; }
|
int cEFi() const {return _zp; }
|
||||||
template < class LeftV>
|
template < class LeftV>
|
||||||
void ImportData(const LeftV & left ) { T::ImportData( left); }
|
void ImportData(const LeftV & left ) { T::ImportData( left); }
|
||||||
static bool HasEFAdjacency() { return true; }
|
static bool HasEFAdjacency() { return true; }
|
||||||
static bool HasEFAdjacencyOcc() { return true; }
|
static bool HasEFAdjacencyOcc() { return true; }
|
||||||
static void Name(std::vector<std::string> & name){name.push_back(std::string("EFAdj"));T::Name(name);}
|
static void Name(std::vector<std::string> & name){name.push_back(std::string("EFAdj"));T::Name(name);}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
typename T::FacePointer _fp ;
|
typename T::FacePointer _fp ;
|
||||||
int _zp ;
|
int _zp ;
|
||||||
};
|
};
|
||||||
|
|
||||||
/** @} */ // End Doxygen EdgeComponentGroup
|
/** @} */ // End Doxygen EdgeComponentGroup
|
||||||
} // end namespace edge
|
} // end namespace edge
|
||||||
}// end namespace vcg
|
}// end namespace vcg
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -46,6 +46,7 @@ class VTIterator
|
||||||
public:
|
public:
|
||||||
/// The tetrahedron type
|
/// The tetrahedron type
|
||||||
typedef MTTYPE TetraType;
|
typedef MTTYPE TetraType;
|
||||||
|
typedef typename TetraType::VertexType VertexType;
|
||||||
private:
|
private:
|
||||||
/// Pointer to a tetrahedron
|
/// Pointer to a tetrahedron
|
||||||
TetraType *_vt;
|
TetraType *_vt;
|
||||||
|
@ -54,11 +55,16 @@ private:
|
||||||
/// Default Constructor
|
/// Default Constructor
|
||||||
public:
|
public:
|
||||||
VTIterator() : _vt(0), _vi(-1){}
|
VTIterator() : _vt(0), _vi(-1){}
|
||||||
/// Constructor which associates the EdgePos elementet with a face and its edge
|
/// Constructor
|
||||||
VTIterator(TetraType * const tp, int const zp)
|
VTIterator(TetraType * const tp, int const zp)
|
||||||
{
|
{
|
||||||
_vt=tp;
|
_vt=tp->V(zp)->VTp();
|
||||||
_vi=zp;
|
_vi=tp->V(zp)->VTi();
|
||||||
|
}
|
||||||
|
VTIterator(VertexType * const vp)
|
||||||
|
{
|
||||||
|
_vt = vp->VTp();
|
||||||
|
_vi = vp->VTi();
|
||||||
}
|
}
|
||||||
|
|
||||||
~VTIterator(){};
|
~VTIterator(){};
|
||||||
|
@ -118,6 +124,7 @@ void VVStarVT( typename TetraType::VertexPointer vp, std::vector<typename TetraT
|
||||||
starVec.resize(new_end - starVec.begin());
|
starVec.resize(new_end - starVec.begin());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/** Templated over the class tetrahedron, it stores a \em position over a tetrahedron in a mesh.
|
/** Templated over the class tetrahedron, it stores a \em position over a tetrahedron in a mesh.
|
||||||
It contain a pointer to the current tetrahedron,
|
It contain a pointer to the current tetrahedron,
|
||||||
the index of one face,edge and a edge's incident vertex.
|
the index of one face,edge and a edge's incident vertex.
|
||||||
|
|
|
@ -0,0 +1,146 @@
|
||||||
|
/****************************************************************************
|
||||||
|
* VCGLib o o *
|
||||||
|
* Visual and Computer Graphics Library o o *
|
||||||
|
* _ O _ *
|
||||||
|
* Copyright(C) 2004-2016 \/)\/ *
|
||||||
|
* Visual Computing Lab /\/| *
|
||||||
|
* ISTI - Italian National Research Council | *
|
||||||
|
* \ *
|
||||||
|
* All rights reserved. *
|
||||||
|
* *
|
||||||
|
* This program is free software; you can redistribute it and/or modify *
|
||||||
|
* 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. *
|
||||||
|
* *
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/**
|
||||||
|
@name Load and Save in Tetgen File format
|
||||||
|
*/
|
||||||
|
//@{
|
||||||
|
|
||||||
|
#ifndef __VCGLIB_TETRAEXPORT_VTK
|
||||||
|
#define __VCGLIB_TETRAEXPORT_VTK
|
||||||
|
|
||||||
|
#include <wrap/io_trimesh/precision.h>
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
namespace vcg
|
||||||
|
{
|
||||||
|
namespace tetra
|
||||||
|
{
|
||||||
|
namespace io
|
||||||
|
{
|
||||||
|
|
||||||
|
template <class SaveMeshType>
|
||||||
|
class ExporterVTK
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
typedef ::vcg::ply::PropDescriptor PropDescriptor;
|
||||||
|
typedef typename SaveMeshType::VertexPointer VertexPointer;
|
||||||
|
typedef typename SaveMeshType::ScalarType ScalarType;
|
||||||
|
typedef typename SaveMeshType::VertexType VertexType;
|
||||||
|
typedef typename SaveMeshType::TetraType TetraType;
|
||||||
|
typedef typename SaveMeshType::TetraPointer TetraPointer;
|
||||||
|
typedef typename SaveMeshType::VertexIterator VertexIterator;
|
||||||
|
typedef typename SaveMeshType::TetraIterator TetraIterator;
|
||||||
|
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
VTK_VERTEX = 1,
|
||||||
|
VTK_POLY_VERTEX,
|
||||||
|
VTK_LINE,
|
||||||
|
VTK_POLY_LINE,
|
||||||
|
VTK_TRIANGLE,
|
||||||
|
VTK_TRIANGLE_STRIP,
|
||||||
|
VTK_POLYGON,
|
||||||
|
VTK_PIXEL,
|
||||||
|
VTK_QUAD,
|
||||||
|
VTK_TETRA,
|
||||||
|
VTK_VOXEL,
|
||||||
|
VTK_HEXAHEDRON,
|
||||||
|
VTK_WEDGE,
|
||||||
|
VTK_PYRAMID
|
||||||
|
};
|
||||||
|
|
||||||
|
static bool Save(SaveMeshType &m, const char *filename) // V1.0
|
||||||
|
{
|
||||||
|
FILE *vtkFile;
|
||||||
|
|
||||||
|
const int DGT = vcg::tri::io::Precision<ScalarType>::digits();
|
||||||
|
const char* vttp = vcg::tri::io::Precision<ScalarType>::typeName();
|
||||||
|
|
||||||
|
std::string vtkName(filename);
|
||||||
|
|
||||||
|
vtkFile = fopen(vtkName.c_str(), "wb");
|
||||||
|
if (vtkFile == NULL)
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
fprintf(vtkFile, "# vtk DataFile Version 2.0\n");
|
||||||
|
fprintf(vtkFile, "VCG_mesh\n");
|
||||||
|
fprintf(vtkFile, "ASCII\n");
|
||||||
|
fprintf(vtkFile, "DATASET UNSTRUCTURED_GRID\n");
|
||||||
|
fprintf(vtkFile, "POINTS %d %s\n", m.VN(), vttp);
|
||||||
|
|
||||||
|
int vi = 0;
|
||||||
|
SimpleTempData<typename SaveMeshType::VertContainer, int> indices(m.vert);
|
||||||
|
|
||||||
|
int maxQ = 0;
|
||||||
|
ForEachVertex(m, [&](VertexType &v) {
|
||||||
|
indices[&v] = vi++;
|
||||||
|
fprintf(vtkFile, "%g %g %g\n", v.P().X(), v.P().Y(), v.P().Z());
|
||||||
|
});
|
||||||
|
|
||||||
|
fprintf(vtkFile, "CELLS %d %d\n", m.TN(), m.TN()*5);
|
||||||
|
|
||||||
|
int ti = 0;
|
||||||
|
ForEachTetra(m, [&](SaveMeshType::TetraType &t) {
|
||||||
|
++ti;
|
||||||
|
fprintf(vtkFile, "%d %d %d %d %d\n", 4, indices[t.V(0)], indices[t.V(1)], indices[t.V(2)], indices[t.V(3)]);
|
||||||
|
});
|
||||||
|
|
||||||
|
fprintf(vtkFile, "CELL_TYPES %d\n", m.TN());
|
||||||
|
ForEachTetra(m, [&](SaveMeshType::TetraType &t) {
|
||||||
|
fprintf(vtkFile, "%d\n", VTK_TETRA);
|
||||||
|
});
|
||||||
|
|
||||||
|
if( HasPerVertexQuality(m))
|
||||||
|
{
|
||||||
|
fprintf(vtkFile, "POINT_DATA %d\n", m.VN());
|
||||||
|
fprintf(vtkFile, "SCALARS vquality %s 1\n", vttp);
|
||||||
|
fprintf(vtkFile, "LOOKUP_TABLE default\n");
|
||||||
|
ForEachVertex(m, [&](VertexType &v) {
|
||||||
|
fprintf(vtkFile, "%g\n", v.Q());
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if( HasPerTetraQuality(m))
|
||||||
|
{
|
||||||
|
fprintf(vtkFile, "CELL_DATA %d\n", m.TN());
|
||||||
|
fprintf(vtkFile, "SCALARS tquality %s 1\n", vttp);
|
||||||
|
fprintf(vtkFile, "LOOKUP_TABLE default\n");
|
||||||
|
ForEachTetra(m, [&](TetraType &t) {
|
||||||
|
fprintf(vtkFile, "%g\n", t.Q());
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
fclose(vtkFile);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
}; // end class
|
||||||
|
|
||||||
|
} // namespace io
|
||||||
|
} // namespace tetra
|
||||||
|
} // end namespace vcg
|
||||||
|
|
||||||
|
#endif
|
Loading…
Reference in New Issue