Commit f6b54806 authored by Basile Sauvage's avatar Basile Sauvage

correction du filtre de Taubin

parent 21f73349
...@@ -71,14 +71,14 @@ protected: ...@@ -71,14 +71,14 @@ protected:
T sum ; T sum ;
unsigned int count ; unsigned int count ;
public: public:
FunctorAverageOnSphereBorder(typename PFP::MAP& map, const AttributeHandler<T>& a, const AttributeHandler<VEC3>& p, VEC3& c = VEC3(0), typename PFP::REAL r = 0) : FunctorAverageOnSphereBorder(typename PFP::MAP& map, const AttributeHandler<T>& a, const AttributeHandler<VEC3>& p) :
FunctorMap<typename PFP::MAP>(map), attr(a), position(p), center(c), radius(r), sum(0), count(0) FunctorMap<typename PFP::MAP>(map), attr(a), position(p), sum(0), count(0)
{} {center = VEC3(0); radius = 0;}
bool operator()(Dart d) bool operator()(Dart d)
{ {
typename PFP::REAL alpha = 0; typename PFP::REAL alpha = 0;
Algo::Geometry::intersectionSphereEdge<PFP>(this->map, center, radius, d, position, alpha); Algo::Geometry::intersectionSphereEdge<PFP>(this->m_map, center, radius, d, position, alpha);
sum += (1 - alpha) * attr[d] + alpha * attr[this->map.phi1(d)] ; sum += (1 - alpha) * attr[d] + alpha * attr[this->m_map.phi1(d)] ;
++count ; ++count ;
return false ; return false ;
} }
......
...@@ -94,6 +94,7 @@ void filterTaubin_modified(typename PFP::MAP& map, typename PFP::TVEC3& position ...@@ -94,6 +94,7 @@ void filterTaubin_modified(typename PFP::MAP& map, typename PFP::TVEC3& position
const float lambda = 0.6307 ; const float lambda = 0.6307 ;
const float mu = -0.6732 ; const float mu = -0.6732 ;
FunctorAverageOnSphereBorder<PFP, typename PFP::VEC3> fa1(map, position, position) ;
Algo::Selection::Collector_WithinSphere<PFP> c1(map, position, radius) ; Algo::Selection::Collector_WithinSphere<PFP> c1(map, position, radius) ;
CellMarkerNoUnmark mv(map, VERTEX) ; CellMarkerNoUnmark mv(map, VERTEX) ;
for(Dart d = map.begin(); d != map.end(); map.next(d)) for(Dart d = map.begin(); d != map.end(); map.next(d))
...@@ -103,16 +104,19 @@ void filterTaubin_modified(typename PFP::MAP& map, typename PFP::TVEC3& position ...@@ -103,16 +104,19 @@ void filterTaubin_modified(typename PFP::MAP& map, typename PFP::TVEC3& position
mv.mark(d); mv.mark(d);
c1.collectBorder(d) ; c1.collectBorder(d) ;
VEC3 center = position[d] ; VEC3 center = position[d] ;
FunctorAverageOnSphereBorder<PFP, typename PFP::VEC3> fa(map, position, position, center, radius) ; fa1.reset (center, radius) ;
c1.applyOnBorder(fa) ;
VEC3 displ = fa.getAverage() - center ; c1.applyOnBorder(fa1) ;
VEC3 displ = fa1.getAverage() - center ;
displ *= lambda ; displ *= lambda ;
position2[d] = center + displ ; position2[d] = center + displ ;
} }
} }
// unshrinking step // unshrinking step
FunctorAverageOnSphereBorder<PFP, typename PFP::VEC3> fa2(map, position2, position2) ;
Algo::Selection::Collector_WithinSphere<PFP> c2(map, position2, radius) ; Algo::Selection::Collector_WithinSphere<PFP> c2(map, position2, radius) ;
for(Dart d = map.begin(); d != map.end(); map.next(d)) for(Dart d = map.begin(); d != map.end(); map.next(d))
{ {
...@@ -122,9 +126,9 @@ void filterTaubin_modified(typename PFP::MAP& map, typename PFP::TVEC3& position ...@@ -122,9 +126,9 @@ void filterTaubin_modified(typename PFP::MAP& map, typename PFP::TVEC3& position
c2.collectBorder(d) ; c2.collectBorder(d) ;
VEC3 center = position2[d] ; VEC3 center = position2[d] ;
FunctorAverageOnSphereBorder<PFP, typename PFP::VEC3> fa(map, position2, position2, center, radius) ; fa2.reset(center, radius) ;
c2.applyOnBorder(fa) ; c2.applyOnBorder(fa2) ;
VEC3 displ = fa.getAverage() - center ; VEC3 displ = fa2.getAverage() - center ;
displ *= mu ; displ *= mu ;
position[d] = center + displ ; position[d] = center + displ ;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment