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 cIMark() const {return 0;}
inline bool IsMarkEnabled() const { return T::TetraType::HasMark(); }
static bool HasMark() { return false; }
static bool HasMarkOcc() { return false; }
//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 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
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
@param MTTYPE (Template Parameter) Specifies the type of the tetrahedron.
*/
@ -65,35 +87,35 @@ public:
~VTIterator(){};
/// Return the tetrahedron stored in the half edge
inline TetraType* & Vt()
{
inline TetraType* & Vt()
{
return _vt;
}
}
/// Return the index of vertex as seen from the tetrahedron
inline int & Vi()
{
inline int & Vi()
{
return _vi;
}
}
/// Return the index of vertex as seen from the tetrahedron
inline const int & Vi() const
{
/// Return the index of vertex as seen from the tetrahedron
inline const int & Vi() const
{
return _vi;
}
}
inline bool End(){return (Vt()==NULL);}
inline bool End(){return (Vt()==NULL);}
/// move on the next tetrahedron that share the vertex
void operator++()
{
void operator++()
{
int vi=Vi();
TetraType * tw = Vt();
Vt() = tw->TVp(vi);
Vi() = tw->TVi(vi);
Vt() = tw->VTp(vi);
Vi() = tw->VTi(vi);
assert((Vt()==NULL)||((tw->V(vi))==(Vt()->V(Vi()))));
}
}
};
@ -171,7 +193,7 @@ public:
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()
{
return _v;
@ -322,19 +344,19 @@ public:
///returns the next half edge on the same edge
void NextT( )
{
#ifdef _DEBUG
#ifdef _DEBUG
VertexType *vold=T()->V(V());
#endif
#endif
FlipT();
FlipF();
#ifdef _DEBUG
#ifdef _DEBUG
VertexType *vnew=T()->V(V());
assert(vold==vnew);
#endif
#endif
}
void Assert()
#ifdef _DEBUG
#ifdef _DEBUG
{
HETYPE ht=*this;
ht.FlipT();
@ -356,9 +378,9 @@ public:
ht.FlipV();
assert(ht==*this);
}
#else
#else
{}
#endif
#endif
};
///this pos structure jump on next tetrahedron if find an external face
@ -386,10 +408,10 @@ public :
while (this->T()!=_t_initial)
{
Pos<MTTYPE>::NextT();
#ifdef _DEBUG
#ifdef _DEBUG
cont++;
assert (cont<500);
#endif
#endif
}
_back++;
if (_back==1)
@ -410,7 +432,7 @@ private:
bool _loop;
public :
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;}
bool LoopEnd()
@ -465,7 +487,7 @@ PosLoop(TetraType* tp,const int fap,const int ep,
};
//@}
}//end namespace tetra
}//end namespace tetra
}//end namespace vcg
#endif

View File

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