From fffb14c92df4ff0efb9271708984c75ca12b30d6 Mon Sep 17 00:00:00 2001 From: JF Barraud Date: Mon, 9 Mar 2009 01:47:39 +0000 Subject: 2geom update (bzr r7453) --- src/2geom/basic-intersection.cpp | 38 +++++++++++++++++++++++++++++++++++--- 1 file changed, 35 insertions(+), 3 deletions(-) (limited to 'src/2geom/basic-intersection.cpp') diff --git a/src/2geom/basic-intersection.cpp b/src/2geom/basic-intersection.cpp index 16b5c0240..c03023e6f 100644 --- a/src/2geom/basic-intersection.cpp +++ b/src/2geom/basic-intersection.cpp @@ -10,6 +10,28 @@ using std::vector; namespace Geom { +//#ifdef USE_RECURSIVE_INTERSECTOR + +// void find_intersections(std::vector > &xs, +// D2 const & A, +// D2 const & B) { +// vector BezA, BezB; +// sbasis_to_bezier(BezA, A); +// sbasis_to_bezier(BezB, B); + +// xs.clear(); + +// find_intersections_bezier_recursive(xs, BezA, BezB); +// } +// void find_intersections(std::vector< std::pair > & xs, +// std::vector const& A, +// std::vector const& B, +// double precision){ +// find_intersections_bezier_recursive(xs, A, B, precision); +// } + +//#else + namespace detail{ namespace bezier_clipping { void portion (std::vector & B, Interval const& I); }; }; @@ -20,12 +42,20 @@ void find_intersections(std::vector > &xs, vector BezA, BezB; sbasis_to_bezier(BezA, A); sbasis_to_bezier(BezB, B); - + xs.clear(); - find_intersections(xs, BezA, BezB); + find_intersections_bezier_clipping(xs, BezA, BezB); +} +void find_intersections(std::vector< std::pair > & xs, + std::vector const& A, + std::vector const& B, + double precision){ + find_intersections_bezier_clipping(xs, A, B, precision); } +//#endif + /* * split the curve at the midpoint, returning an array with the two parts * Temporary storage is minimized by using part of the storage for the result @@ -79,6 +109,7 @@ find_self_intersections(std::vector > &xs, in = r; } } + for(unsigned i = 0; i < dr.size()-1; i++) { for(unsigned j = i+1; j < dr.size()-1; j++) { std::vector > section; @@ -89,7 +120,8 @@ find_self_intersections(std::vector > &xs, double r = section[k].second; // XXX: This condition will prune out false positives, but it might create some false negatives. Todo: Confirm it is correct. if(j == i+1) - if((l == 1) && (r == 0)) + //if((l == 1) && (r == 0)) + if( ( l > 1-1e-4 ) && (r < 1e-4) )//FIXME: what precision should be used here??? continue; xs.push_back(std::make_pair((1-l)*dr[i] + l*dr[i+1], (1-r)*dr[j] + r*dr[j+1])); -- cgit v1.2.3