From 6a3d2ddd53e852dee84e6efc70f6d511798bef9c Mon Sep 17 00:00:00 2001 From: salinasd Date: Tue, 27 Jan 2015 12:01:58 +0000 Subject: correct problem priority contraction git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/trunk@430 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 16f49b81d6aa01bbfb6e11afa579ac574a87bdaa --- src/GudhUI/utils/Edge_contractor.h | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'src/GudhUI/utils') diff --git a/src/GudhUI/utils/Edge_contractor.h b/src/GudhUI/utils/Edge_contractor.h index c7a86e0b..d0a1f866 100644 --- a/src/GudhUI/utils/Edge_contractor.h +++ b/src/GudhUI/utils/Edge_contractor.h @@ -37,6 +37,23 @@ private: } }; + + /** + * @brief return a cost corresponding to the squared length of the edge + */ + template< typename EdgeProfile> class Middle_placement : public contraction::Placement_policy{ + public: + typedef typename contraction::Placement_policy::Placement_type Placement_type; + typedef typename EdgeProfile::Point Point; + Placement_type operator()(const EdgeProfile& profile) const override{ + std::vector mid_coords(profile.p0().dimension(),0); + for (size_t i = 0; i < profile.p0().dimension(); ++i){ + mid_coords[i] = (profile.p0()[i] + profile.p1()[i]) / 2.; + } + return Point(profile.p0().dimension(),mid_coords.begin(), mid_coords.end()); + } + }; + public: typedef typename SkBlComplex::Vertex_handle Vertex_handle; typedef typename SkBlComplex::Edge_handle Edge_handle; @@ -53,7 +70,7 @@ private: contraction::Skeleton_blocker_contractor contractor( complex_, new Length_cost>(), - contraction::make_first_vertex_placement(), + new Middle_placement>(), contraction::make_link_valid_contraction(), contraction::make_remove_popable_blockers_visitor() ); -- cgit v1.2.3