vert tetra iterator

This commit is contained in:
T.Alderighi 2018-06-07 10:56:14 +02:00
parent bb2d190b88
commit d37d9cdbfc
3 changed files with 390 additions and 365 deletions

View File

@ -98,11 +98,13 @@ public:
inline int & IMark() { assert(0); static int tmp=-1; return tmp;} inline int & IMark() { assert(0); static int tmp=-1; return tmp;}
inline int cIMark() const {return 0;} inline int cIMark() const {return 0;}
inline bool IsMarkEnabled() const { return T::TetraType::HasMark(); }
static bool HasMark() { return false; } static bool HasMark() { return false; }
static bool HasMarkOcc() { return false; } static bool HasMarkOcc() { return false; }
//Empty Adjacency //Empty Adjacency
typedef int VFAdjType; typedef int VTAdjType;
typename T::TetraPointer & VTp ( const int ) { static typename T::TetraPointer tp=0; assert(0); return tp; } typename T::TetraPointer & VTp ( const int ) { static typename T::TetraPointer tp=0; assert(0); return tp; }
typename T::TetraPointer const cVTp( const int ) const { static typename T::TetraPointer const tp=0; assert(0); return tp; } typename T::TetraPointer const cVTp( const int ) const { static typename T::TetraPointer const tp=0; assert(0); return tp; }

View File

@ -31,13 +31,35 @@
#define __VCG_TETRA_POS #define __VCG_TETRA_POS
namespace vcg { namespace vcg {
namespace tetra { namespace tetra {
/** \addtogroup tetra */ /** \addtogroup tetra */
/*@{*/ /*@{*/
/** Class VTIterator. template <class TetraType>
void VVStarVT( typename TetraType::VertexPointer vp, std::vector<typename TetraType::VertexPointer> & starVec)
{
typedef typename TetraType::VertexPointer VertexPointer;
starVec.clear();
tetra::VTIterator<TetraType> vti(vp->VTp(), vp->VTi());
while (!vti.End())
{
starVec.push_back(vti.Vt()->V1(vti.Vi()));
starVec.push_back(vti.Vt()->V2(vti.Vi()));
starVec.push_back(vti.Vt()->V3(vti.Vi()));
++vti;
}
std::sort(starVec.begin(), starVec.end());
typename std::vector<VertexPointer>::iterator new_end = std::unique(starVec.begin(),starVec.end());
starVec.resize(new_end - starVec.begin());
}
/** Class VTIterator.
This is a vertex - tetrahedron iterator This is a vertex - tetrahedron iterator
@param MTTYPE (Template Parameter) Specifies the type of the tetrahedron. @param MTTYPE (Template Parameter) Specifies the type of the tetrahedron.
*/ */
@ -65,35 +87,35 @@ public:
~VTIterator(){}; ~VTIterator(){};
/// Return the tetrahedron stored in the half edge /// Return the tetrahedron stored in the half edge
inline TetraType* & Vt() inline TetraType* & Vt()
{ {
return _vt; return _vt;
} }
/// Return the index of vertex as seen from the tetrahedron /// Return the index of vertex as seen from the tetrahedron
inline int & Vi() inline int & Vi()
{ {
return _vi; return _vi;
} }
/// Return the index of vertex as seen from the tetrahedron /// Return the index of vertex as seen from the tetrahedron
inline const int & Vi() const inline const int & Vi() const
{ {
return _vi; return _vi;
} }
inline bool End(){return (Vt()==NULL);} inline bool End(){return (Vt()==NULL);}
/// move on the next tetrahedron that share the vertex /// move on the next tetrahedron that share the vertex
void operator++() void operator++()
{ {
int vi=Vi(); int vi=Vi();
TetraType * tw = Vt(); TetraType * tw = Vt();
Vt() = tw->TVp(vi); Vt() = tw->VTp(vi);
Vi() = tw->TVi(vi); Vi() = tw->VTi(vi);
assert((Vt()==NULL)||((tw->V(vi))==(Vt()->V(Vi())))); assert((Vt()==NULL)||((tw->V(vi))==(Vt()->V(Vi()))));
} }
}; };
@ -171,7 +193,7 @@ public:
return _e; return _e;
} }
/// Return the index of vertex as seen from the tetrahedron /// Return the index of vertex as seen from the tetrahedron
inline char & V() inline char & V()
{ {
return _v; return _v;
@ -322,19 +344,19 @@ public:
///returns the next half edge on the same edge ///returns the next half edge on the same edge
void NextT( ) void NextT( )
{ {
#ifdef _DEBUG #ifdef _DEBUG
VertexType *vold=T()->V(V()); VertexType *vold=T()->V(V());
#endif #endif
FlipT(); FlipT();
FlipF(); FlipF();
#ifdef _DEBUG #ifdef _DEBUG
VertexType *vnew=T()->V(V()); VertexType *vnew=T()->V(V());
assert(vold==vnew); assert(vold==vnew);
#endif #endif
} }
void Assert() void Assert()
#ifdef _DEBUG #ifdef _DEBUG
{ {
HETYPE ht=*this; HETYPE ht=*this;
ht.FlipT(); ht.FlipT();
@ -356,9 +378,9 @@ public:
ht.FlipV(); ht.FlipV();
assert(ht==*this); assert(ht==*this);
} }
#else #else
{} {}
#endif #endif
}; };
///this pos structure jump on next tetrahedron if find an external face ///this pos structure jump on next tetrahedron if find an external face
@ -386,10 +408,10 @@ public :
while (this->T()!=_t_initial) while (this->T()!=_t_initial)
{ {
Pos<MTTYPE>::NextT(); Pos<MTTYPE>::NextT();
#ifdef _DEBUG #ifdef _DEBUG
cont++; cont++;
assert (cont<500); assert (cont<500);
#endif #endif
} }
_back++; _back++;
if (_back==1) if (_back==1)
@ -410,7 +432,7 @@ private:
bool _loop; bool _loop;
public : public :
typedef MTTYPE TetraType; typedef MTTYPE TetraType;
PosLoop(TetraType* tp,const int fap,const int ep, PosLoop(TetraType* tp,const int fap,const int ep,
int vp){this->T()=tp;this->F()=fap;this->E()=ep;this->V()=vp;_t_initial=tp;_jump=false;_loop=false;} int vp){this->T()=tp;this->F()=fap;this->E()=ep;this->V()=vp;_t_initial=tp;_jump=false;_loop=false;}
bool LoopEnd() bool LoopEnd()
@ -465,7 +487,7 @@ PosLoop(TetraType* tp,const int fap,const int ep,
}; };
//@} //@}
}//end namespace tetra }//end namespace tetra
}//end namespace vcg }//end namespace vcg
#endif #endif

View File

@ -315,7 +315,8 @@ class Tetra
return edgesface[indexE0][indexE1]; return edgesface[indexE0][indexE1];
} }
// compute the barycenter /** @brief Computes the tetrahedron barycenter
*/
template <class TetraType> template <class TetraType>
static Point3<typename TetraType::ScalarType> Barycenter(const TetraType &t) static Point3<typename TetraType::ScalarType> Barycenter(const TetraType &t)
{ {