summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 304e894)
raw | patch | inline | side by side (parent: 304e894)
author | Diederik van Lierop <mailat-signdiedenrezidotnl> | |
Sat, 22 May 2010 20:06:35 +0000 (22:06 +0200) | ||
committer | Diederik van Lierop <mailat-signdiedenrezidotnl> | |
Sat, 22 May 2010 20:06:35 +0000 (22:06 +0200) |
src/object-snapper.cpp | patch | blob | history | |
src/snapped-curve.cpp | patch | blob | history | |
src/snapped-curve.h | patch | blob | history |
diff --git a/src/object-snapper.cpp b/src/object-snapper.cpp
index 5c0ea419b0ba6535ab96a5607dd5baa27ceae793..bced0ac44d22989a8f8faa8667e7694e319dc26f 100644 (file)
--- a/src/object-snapper.cpp
+++ b/src/object-snapper.cpp
}
}
+ int num_path = 0;
+ int num_segm = 0;
+
for (std::vector<Inkscape::SnapCandidatePath >::const_iterator it_p = _paths_to_snap_to->begin(); it_p != _paths_to_snap_to->end(); it_p++) {
bool const being_edited = node_tool_active && (*it_p).currently_being_edited;
//if true then this pathvector it_pv is currently being edited in the node tool
if (!being_edited || (c1 && c2)) {
Geom::Coord const dist = Geom::distance(sp_doc, p_doc);
if (dist < getSnapperTolerance()) {
- sc.curves.push_back(Inkscape::SnappedCurve(sp_dt, dist, getSnapperTolerance(), getSnapperAlwaysSnap(), false, curve, p.getSourceType(), p.getSourceNum(), it_p->target_type, it_p->target_bbox));
+ sc.curves.push_back(Inkscape::SnappedCurve(sp_dt, num_path, num_segm, dist, getSnapperTolerance(), getSnapperAlwaysSnap(), false, curve, p.getSourceType(), p.getSourceNum(), it_p->target_type, it_p->target_bbox));
}
}
}
+ num_segm++;
} // End of: for (Geom::PathVector::iterator ....)
+ num_path++;
}
}
diff --git a/src/snapped-curve.cpp b/src/snapped-curve.cpp
index e7df3cfade8faa07661a138a4666bf3f2ae1e4c1..77bc8280cbb87919feade40435a2301e1da3a7a5 100644 (file)
--- a/src/snapped-curve.cpp
+++ b/src/snapped-curve.cpp
#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;
Inkscape::SnappedCurve::SnappedCurve()
{
+ _num_path = 0;
+ _num_segm = 0;
_distance = NR_HUGE;
_tolerance = 1;
_always_snap = false;
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;
diff --git a/src/snapped-curve.h b/src/snapped-curve.h
index 21124c67814127585f7d951c19826dfb01285b40..595f844110f16404758ce4bd67836f31d086d874 100644 (file)
--- a/src/snapped-curve.h
+++ b/src/snapped-curve.h
{
public:
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);
+ 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);
~SnappedCurve();
Inkscape::SnappedPoint intersect(SnappedCurve const &curve, Geom::Point const &p, Geom::Matrix dt2doc) const; //intersect with another SnappedCurve
private:
Geom::Curve const *_curve;
+ int _num_path; // Unique id of the path to which this segment belongs too
+ int _num_segm; // Sequence number of this segment in the path
};
}