_pos.V(i) become _pos.F()->V(i); TriEdgeFlip now access members of parent class with this->...

This commit is contained in:
Paolo Cignoni 2008-03-01 11:16:30 +00:00
parent d14283e619
commit 9841c8db32
1 changed files with 84 additions and 79 deletions

View File

@ -49,8 +49,8 @@ namespace vcg
typedef typename TRIMESH_TYPE::FacePointer FacePointer; typedef typename TRIMESH_TYPE::FacePointer FacePointer;
typedef typename TRIMESH_TYPE::FaceIterator FaceIterator; typedef typename TRIMESH_TYPE::FaceIterator FaceIterator;
typedef typename TRIMESH_TYPE::VertexType VertexType; typedef typename TRIMESH_TYPE::VertexType VertexType;
typedef typename TRIMESH_TYPE::VertexPointer VertexPointer;
typedef typename TRIMESH_TYPE::ScalarType ScalarType; typedef typename TRIMESH_TYPE::ScalarType ScalarType;
typedef typename TRIMESH_TYPE::VertexPointer VertexPointer;
typedef typename TRIMESH_TYPE::CoordType CoordType; typedef typename TRIMESH_TYPE::CoordType CoordType;
typedef vcg::face::Pos<FaceType> PosType; typedef vcg::face::Pos<FaceType> PosType;
typedef typename LocalOptimization<TRIMESH_TYPE>::HeapElem HeapElem; typedef typename LocalOptimization<TRIMESH_TYPE>::HeapElem HeapElem;
@ -78,7 +78,7 @@ namespace vcg
{ {
static int im = 0; static int im = 0;
return im; return im;
}; }
public: public:
@ -86,7 +86,7 @@ namespace vcg
* Default constructor * Default constructor
*/ */
inline PlanarEdgeFlip() inline PlanarEdgeFlip()
{}; {}
/*! /*!
* Constructor with <I>pos</I> type * Constructor with <I>pos</I> type
@ -96,7 +96,7 @@ namespace vcg
_pos = pos; _pos = pos;
_localMark = mark; _localMark = mark;
_priority = ComputePriority(); _priority = ComputePriority();
}; }
/*! /*!
* Copy Constructor * Copy Constructor
@ -106,20 +106,21 @@ namespace vcg
_pos = par.GetPos(); _pos = par.GetPos();
_localMark = par.GetMark(); _localMark = par.GetMark();
_priority = par.Priority(); _priority = par.Priority();
}; }
/*! /*!
*/ */
~PlanarEdgeFlip() ~PlanarEdgeFlip()
{ {
}; }
/*! /*!
* Parameter * Parameter
*/ */
static ScalarType &CoplanarAngleThresholdDeg() { static ScalarType &CoplanarAngleThresholdDeg()
{
static ScalarType _CoplanarAngleThresholdDeg = 0.01f; static ScalarType _CoplanarAngleThresholdDeg = 0.01f;
return _CoplanarAngleThresholdDeg; return _CoplanarAngleThresholdDeg;
} }
@ -134,19 +135,19 @@ namespace vcg
ModifierType IsOfType() ModifierType IsOfType()
{ {
return TriEdgeFlipOp; return TriEdgeFlipOp;
}; }
/*! /*!
* Check if the pos is updated * Check if the pos is updated
*/ */
bool IsUpToDate() bool IsUpToDate()
{ {
int MostRecentVertexMark = _pos.V(0)->IMark(); int MostRecentVertexMark = _pos.F()->V(0)->IMark();
MostRecentVertexMark = vcg::math::Max<ScalarType>(MostRecentVertexMark, _pos.V(1)->IMark()); MostRecentVertexMark = vcg::math::Max<ScalarType>(MostRecentVertexMark, _pos.F()->V(1)->IMark());
MostRecentVertexMark = vcg::math::Max<ScalarType>(MostRecentVertexMark, _pos.V(2)->IMark()); MostRecentVertexMark = vcg::math::Max<ScalarType>(MostRecentVertexMark, _pos.F()->V(2)->IMark());
return ( _localMark >= MostRecentVertexMark ); return ( _localMark >= MostRecentVertexMark );
}; }
/*! /*!
* *
@ -157,7 +158,7 @@ namespace vcg
{ {
if( math::ToDeg( Angle( _pos.FFlip()->cN() , _pos.F()->cN() ) ) > CoplanarAngleThresholdDeg() ) return false; if( math::ToDeg( Angle( _pos.FFlip()->cN() , _pos.F()->cN() ) ) > CoplanarAngleThresholdDeg() ) return false;
return vcg::face::CheckFlipEdge(*_pos.f, _pos.z); return vcg::face::CheckFlipEdge(*_pos.f, _pos.z);
}; }
@ -172,7 +173,8 @@ namespace vcg
\ | / \ | /
\|/ \|/
2 2
*/ virtual ScalarType ComputePriority() */
virtual ScalarType ComputePriority()
{ {
CoordType v0,v1,v2,v3; CoordType v0,v1,v2,v3;
@ -198,7 +200,7 @@ namespace vcg
_priority = vcg::math::Max<ScalarType>(QaAfter,QbAfter) - vcg::math::Min<ScalarType>(Qa,Qb) ; _priority = vcg::math::Max<ScalarType>(QaAfter,QbAfter) - vcg::math::Min<ScalarType>(Qa,Qb) ;
_priority *=-1; _priority *=-1;
return _priority; return _priority;
}; }
/*! /*!
* Return the priority of this optimization * Return the priority of this optimization
@ -206,27 +208,25 @@ namespace vcg
virtual ScalarType Priority() const virtual ScalarType Priority() const
{ {
return _priority; return _priority;
}; }
/*! /*!
* Execute the flipping of the edge * Execute the flipping of the edge
*/ */
void Execute(TRIMESH_TYPE &m) void Execute(TRIMESH_TYPE &m)
{ {
int z = _pos.z; int z = _pos.z;
vcg::face::FlipEdge(*_pos.f, z); vcg::face::FlipEdge(*_pos.f, z);
}; }
/*! /*!
*/ */
const char* Info(TRIMESH_TYPE &m) const char* Info(TRIMESH_TYPE &m)
{ {
static char dump[60]; static char dump[60];
sprintf(dump,"%i -> %i %g\n", _pos.V(0)-&m.vert[0], _pos.V(1)-&m.vert[0],-_priority); sprintf(dump,"%i -> %i %g\n", _pos.F()->V(0)-&m.vert[0], _pos.F()->V(1)-&m.vert[0],-_priority);
return dump; return dump;
}; }
/*! /*!
*/ */
@ -256,7 +256,7 @@ namespace vcg
} }
} // endif } // endif
} //endfor } //endfor
}; }
/*! /*!
*/ */
@ -266,10 +266,10 @@ namespace vcg
PosType pos(_pos.f, _pos.z); PosType pos(_pos.f, _pos.z);
pos.FlipF(); pos.FlipF();
_pos.V(0)->IMark() = GlobalMark(); _pos.F()->V(0)->IMark() = GlobalMark();
_pos.V(1)->IMark() = GlobalMark(); _pos.F()->V(1)->IMark() = GlobalMark();
_pos.V(2)->IMark() = GlobalMark(); _pos.F()->V(2)->IMark() = GlobalMark();
pos.V(2)->IMark() = GlobalMark(); pos.F()->V(2)->IMark() = GlobalMark();
PosType poss(_pos.f, _pos.z); PosType poss(_pos.f, _pos.z);
poss.FlipE(); poss.FlipE();
@ -297,47 +297,57 @@ namespace vcg
} }
std::push_heap(heap.begin(),heap.end()); std::push_heap(heap.begin(),heap.end());
}; }
}; // end of PlanarEdgeFlip class }; // end of PlanarEdgeFlip class
template <class TRIMESH_TYPE, class MYTYPE> template <class TRIMESH_TYPE, class MYTYPE>
class TriEdgeFlip : public PlanarEdgeFlip<TRIMESH_TYPE, MYTYPE> class TriEdgeFlip : public PlanarEdgeFlip<TRIMESH_TYPE, MYTYPE>
{ {
protected:
typedef typename TRIMESH_TYPE::FaceType FaceType;
typedef typename TRIMESH_TYPE::FacePointer FacePointer;
typedef typename TRIMESH_TYPE::FaceIterator FaceIterator;
typedef typename TRIMESH_TYPE::VertexType VertexType;
typedef typename TRIMESH_TYPE::VertexPointer VertexPointer;
typedef typename TRIMESH_TYPE::ScalarType ScalarType;
typedef typename TRIMESH_TYPE::CoordType CoordType;
typedef vcg::face::Pos<FaceType> PosType;
typedef typename LocalOptimization<TRIMESH_TYPE>::HeapElem HeapElem;
typedef typename LocalOptimization<TRIMESH_TYPE>::HeapType HeapType;
public: public:
/*!
* Default constructor
*/
inline TriEdgeFlip() {}
/*! /*!
* Constructor with <I>pos</I> type * Constructor with <I>pos</I> type
*/ */
inline TriEdgeFlip(const PosType pos, int mark) //: PlanarEdgeFlip<TRIMESH_TYPE,MYTYPE>( pos, mark) inline TriEdgeFlip(const PosType pos, int mark)
{ {
_pos = pos; this->_pos = pos;
_localMark = mark; this->_localMark = mark;
_priority = ComputePriority(); this->_priority = ComputePriority();
}; }
/*! /*!
* Copy Constructor * Copy Constructor
*/ */
inline TriEdgeFlip(const TriEdgeFlip &par) inline TriEdgeFlip(const TriEdgeFlip &par)
{ {
_pos = par.GetPos(); this->_pos = par.GetPos();
_localMark = par.GetMark(); this->_localMark = par.GetMark();
_priority = par.Priority(); this->_priority = par.Priority();
}; }
inline TriEdgeFlip(const PlanarEdgeFlip &par)
{
_pos = par.GetPos();
_localMark = par.GetMark();
_priority = ComputePriority();
};
//only topology check //only topology check
bool IsFeasible() bool IsFeasible()
{ {
return vcg::face::CheckFlipEdge(*_pos.f, _pos.z); return vcg::face::CheckFlipEdge(*this->_pos.f, this->_pos.z);
}; }
ScalarType ComputePriority() ScalarType ComputePriority()
@ -352,7 +362,7 @@ namespace vcg
2 2
*/ */
CoordType v0,v1,v2,v3; CoordType v0,v1,v2,v3;
PosType app = _pos; PosType app = this->_pos;
v0 = app.v->P(); v0 = app.v->P();
app.FlipE(); app.FlipV(); app.FlipE(); app.FlipV();
@ -395,19 +405,14 @@ namespace vcg
assert( fabs(Radius-Radius2) < 0.1 ); assert( fabs(Radius-Radius2) < 0.1 );
///Return the difference of radius and the distance of v3 and the CircumCenter ///Return the difference of radius and the distance of v3 and the CircumCenter
_priority = (Radius - Distance(v3,CircumCenter)); this->_priority = (Radius - Distance(v3,CircumCenter));
this->_priority *=-1;
return this->_priority;
_priority *=-1;
return _priority;
} }
}; };
/*! @} */ /*! @} */
}; // end of namespace tri }; // end of namespace tri
}; // end of namespace vcg }; // end of namespace vcg