From f6b548061e924a5c8e9ed03035112c4d6d7f43fc Mon Sep 17 00:00:00 2001 From: Basile Sauvage Date: Tue, 12 Jul 2011 14:46:18 +0200 Subject: [PATCH] correction du filtre de Taubin --- include/Algo/Filtering/functors.h | 10 +++++----- include/Algo/Filtering/taubin.h | 16 ++++++++++------ 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/include/Algo/Filtering/functors.h b/include/Algo/Filtering/functors.h index 0debce05..8f7fb508 100644 --- a/include/Algo/Filtering/functors.h +++ b/include/Algo/Filtering/functors.h @@ -71,14 +71,14 @@ protected: T sum ; unsigned int count ; public: - FunctorAverageOnSphereBorder(typename PFP::MAP& map, const AttributeHandler& a, const AttributeHandler& p, VEC3& c = VEC3(0), typename PFP::REAL r = 0) : - FunctorMap(map), attr(a), position(p), center(c), radius(r), sum(0), count(0) - {} + FunctorAverageOnSphereBorder(typename PFP::MAP& map, const AttributeHandler& a, const AttributeHandler& p) : + FunctorMap(map), attr(a), position(p), sum(0), count(0) + {center = VEC3(0); radius = 0;} bool operator()(Dart d) { typename PFP::REAL alpha = 0; - Algo::Geometry::intersectionSphereEdge(this->map, center, radius, d, position, alpha); - sum += (1 - alpha) * attr[d] + alpha * attr[this->map.phi1(d)] ; + Algo::Geometry::intersectionSphereEdge(this->m_map, center, radius, d, position, alpha); + sum += (1 - alpha) * attr[d] + alpha * attr[this->m_map.phi1(d)] ; ++count ; return false ; } diff --git a/include/Algo/Filtering/taubin.h b/include/Algo/Filtering/taubin.h index d51ba023..8573f9fd 100644 --- a/include/Algo/Filtering/taubin.h +++ b/include/Algo/Filtering/taubin.h @@ -94,6 +94,7 @@ void filterTaubin_modified(typename PFP::MAP& map, typename PFP::TVEC3& position const float lambda = 0.6307 ; const float mu = -0.6732 ; + FunctorAverageOnSphereBorder fa1(map, position, position) ; Algo::Selection::Collector_WithinSphere c1(map, position, radius) ; CellMarkerNoUnmark mv(map, VERTEX) ; 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 mv.mark(d); c1.collectBorder(d) ; + VEC3 center = position[d] ; - FunctorAverageOnSphereBorder fa(map, position, position, center, radius) ; - c1.applyOnBorder(fa) ; - VEC3 displ = fa.getAverage() - center ; + fa1.reset (center, radius) ; + + c1.applyOnBorder(fa1) ; + VEC3 displ = fa1.getAverage() - center ; displ *= lambda ; position2[d] = center + displ ; } } // unshrinking step + FunctorAverageOnSphereBorder fa2(map, position2, position2) ; Algo::Selection::Collector_WithinSphere c2(map, position2, radius) ; 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 c2.collectBorder(d) ; VEC3 center = position2[d] ; - FunctorAverageOnSphereBorder fa(map, position2, position2, center, radius) ; - c2.applyOnBorder(fa) ; - VEC3 displ = fa.getAverage() - center ; + fa2.reset(center, radius) ; + c2.applyOnBorder(fa2) ; + VEC3 displ = fa2.getAverage() - center ; displ *= mu ; position[d] = center + displ ; } -- GitLab