diff options
| author | JF Barraud <jf.barraud@gmail.com> | 2009-03-09 01:47:39 +0000 |
|---|---|---|
| committer | jfbarraud <jfbarraud@users.sourceforge.net> | 2009-03-09 01:47:39 +0000 |
| commit | fffb14c92df4ff0efb9271708984c75ca12b30d6 (patch) | |
| tree | 04a75637990939efdd4da28826357ff214bafc22 /src/2geom/basic-intersection.cpp | |
| parent | part of bug #339660; can not use Add/Rename dialog to create layer with no pr... (diff) | |
| download | inkscape-fffb14c92df4ff0efb9271708984c75ca12b30d6.tar.gz inkscape-fffb14c92df4ff0efb9271708984c75ca12b30d6.zip | |
2geom update
(bzr r7453)
Diffstat (limited to 'src/2geom/basic-intersection.cpp')
| -rw-r--r-- | src/2geom/basic-intersection.cpp | 38 |
1 files changed, 35 insertions, 3 deletions
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<std::pair<double, double> > &xs, +// D2<SBasis> const & A, +// D2<SBasis> const & B) { +// vector<Point> 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<double, double> > & xs, +// std::vector<Point> const& A, +// std::vector<Point> const& B, +// double precision){ +// find_intersections_bezier_recursive(xs, A, B, precision); +// } + +//#else + namespace detail{ namespace bezier_clipping { void portion (std::vector<Point> & B, Interval const& I); }; }; @@ -20,12 +42,20 @@ void find_intersections(std::vector<std::pair<double, double> > &xs, vector<Point> 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<double, double> > & xs, + std::vector<Point> const& A, + std::vector<Point> 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<std::pair<double, double> > &xs, in = r; } } + for(unsigned i = 0; i < dr.size()-1; i++) { for(unsigned j = i+1; j < dr.size()-1; j++) { std::vector<std::pair<double, double> > section; @@ -89,7 +120,8 @@ find_self_intersections(std::vector<std::pair<double, double> > &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])); |
