diff options
| author | Diederik van Lierop <mailat-signdiedenrezidotnl> | 2010-05-22 20:06:35 +0000 |
|---|---|---|
| committer | Diederik van Lierop <mailat-signdiedenrezidotnl> | 2010-05-22 20:06:35 +0000 |
| commit | f662576d876552dd6e910fbced6f077594c4e847 (patch) | |
| tree | 493503876b0f400ce23de4b463f20a197a316d2b /src/snapped-curve.cpp | |
| parent | Temporary build fix for not newest gtk versions. (diff) | |
| download | inkscape-f662576d876552dd6e910fbced6f077594c4e847.tar.gz inkscape-f662576d876552dd6e910fbced6f077594c4e847.zip | |
Snapping: get rid of the false positives when calculating intersections
(bzr r9442)
Diffstat (limited to 'src/snapped-curve.cpp')
| -rw-r--r-- | src/snapped-curve.cpp | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/src/snapped-curve.cpp b/src/snapped-curve.cpp index e7df3cfad..77bc8280c 100644 --- a/src/snapped-curve.cpp +++ b/src/snapped-curve.cpp @@ -12,8 +12,10 @@ #include <2geom/crossing.h> #include <2geom/path-intersection.h> -Inkscape::SnappedCurve::SnappedCurve(Geom::Point const &snapped_point, Geom::Coord const &snapped_distance, Geom::Coord const &snapped_tolerance, bool const &always_snap, bool const &fully_constrained, Geom::Curve const *curve, SnapSourceType source, long source_num, SnapTargetType target, Geom::OptRect target_bbox) +Inkscape::SnappedCurve::SnappedCurve(Geom::Point const &snapped_point, int num_path, int num_segm, Geom::Coord const &snapped_distance, Geom::Coord const &snapped_tolerance, bool const &always_snap, bool const &fully_constrained, Geom::Curve const *curve, SnapSourceType source, long source_num, SnapTargetType target, Geom::OptRect target_bbox) { + _num_path = num_path; + _num_segm = num_segm; _distance = snapped_distance; _tolerance = std::max(snapped_tolerance, 1.0); _always_snap = always_snap; @@ -32,6 +34,8 @@ Inkscape::SnappedCurve::SnappedCurve(Geom::Point const &snapped_point, Geom::Coo Inkscape::SnappedCurve::SnappedCurve() { + _num_path = 0; + _num_segm = 0; _distance = NR_HUGE; _tolerance = 1; _always_snap = false; @@ -68,6 +72,16 @@ Inkscape::SnappedPoint Inkscape::SnappedCurve::intersect(SnappedCurve const &cur for (Geom::Crossings::const_iterator i = cs.begin(); i != cs.end(); i++) { Geom::Point p_ix = this->_curve->pointAt((*i).ta); Geom::Coord dist = Geom::distance(p_ix, p); + + // Test if we have two segments (curves) from the same path.. + if (this->_num_path == curve._num_path) { + // Never try to intersect a segment with itself + if (this->_num_segm == curve._num_segm) continue; + // Two subsequent segments (curves) in a path will have a common node; this node is not considered to be an intersection + if (this->_num_segm == curve._num_segm + 1 && (*i).ta == 0 && (*i).tb == 1) continue; + if (this->_num_segm + 1 == curve._num_segm && (*i).ta == 1 && (*i).tb == 0) continue; + } + if (dist < best_dist) { best_dist = dist; best_p = p_ix; |
