From: Diederik v. L. <ma...@di...> - 2011-09-22 19:24:08
|
=== modified file 'src/2geom/bezier-curve.cpp' --- src/2geom/bezier-curve.cpp 2011-07-25 01:06:47 +0000 +++ src/2geom/bezier-curve.cpp 2011-09-21 21:10:45 +0000 @@ -166,6 +166,7 @@ template<> Coord BezierCurveN<1>::nearestPoint(Point const& p, Coord from, Coord to) const { + std::cout << "(entering nearestPoint in bezier-curve.cpp, line 169)" << std::endl; if ( from > to ) std::swap(from, to); Point ip = pointAt(from); Point fp = pointAt(to); @@ -173,9 +174,18 @@ Coord l2v = L2sq(v); if (l2v == 0) return 0; Coord t = dot( p - ip, v ) / l2v; - if ( t <= 0 ) return from; - else if ( t >= 1 ) return to; - else return from + t*(to-from); + if ( t <= 0 ) { + std::cout << " zero nr. 0 | t -> " << from << std::endl; + return from; + } + else if ( t >= 1 ) { + std::cout << " zero nr. 0 | t -> " << to << std::endl; + return to; + } + else { + std::cout << " zero nr. 0 | t -> " << from + t*(to-from) << std::endl; + return from + t*(to-from); + } } === modified file 'src/2geom/nearest-point.cpp' --- src/2geom/nearest-point.cpp 2008-11-21 05:24:08 +0000 +++ src/2geom/nearest-point.cpp 2011-09-21 19:42:11 +0000 @@ -54,6 +54,7 @@ D2<SBasis> const& dc, double from, double to ) { + std::cout << "(entering nearest_point in nearest-point.cpp, line 57)" << std::endl; if ( from > to ) std::swap(from, to); if ( from < 0 || to > 1 ) { @@ -66,6 +67,9 @@ double closest = from; double min_dist_sq = L2sq(c(from) - p); double distsq; + if (zeros.size() == 0) { + std::cout << " No zeroes found; how can there possibly be NO nearest points for any segment?" << std::endl; + } for ( unsigned int i = 0; i < zeros.size(); ++i ) { distsq = L2sq(c(zeros[i]) - p); @@ -74,9 +78,12 @@ closest = zeros[i]; min_dist_sq = distsq; } + std::cout << " zero nr. " << i << " | t -> " << zeros[i] << std::endl; } if ( min_dist_sq > L2sq( c(to) - p ) ) closest = to; + + std::cout << "All zeros have been examined; closest t = " << closest; return closest; } === modified file 'src/2geom/nearest-point.h' --- src/2geom/nearest-point.h 2008-10-28 04:45:31 +0000 +++ src/2geom/nearest-point.h 2011-09-21 19:42:11 +0000 @@ -77,7 +77,7 @@ D2<SBasis> const& c, double from = 0, double to = 1 ) { - return nearest_point(p, c, Geom::derivative(c), from, to); + return nearest_point(p, c, Geom::derivative(c), from, to); } /* @@ -110,7 +110,7 @@ inline double nearest_point( Point const& p, Piecewise< D2<SBasis> > const& c ) { - return nearest_point(p, c, c.cuts[0], c.cuts[c.size()]); + return nearest_point(p, c, c.cuts[0], c.cuts[c.size()]); } === modified file 'src/2geom/path.cpp' --- src/2geom/path.cpp 2011-02-02 21:24:36 +0000 +++ src/2geom/path.cpp 2011-09-21 18:30:05 +0000 @@ -205,11 +205,18 @@ { //return a single nearest point for each curve in this path std::vector<double> np; + int count = 0; + std::cout << "Mouse pointer is at " << _point << std::endl; for (const_iterator it = begin() ; it != end_default() ; ++it) //for (std::vector<Path>::const_iterator it = _path.begin(); it != _path.end(), ++it){ { - np.push_back(it->nearestPoint(_point)); + std::cout << "***** Start examining segment nr." << count << " *****" << std::endl; + double dummy = it->nearestPoint(_point); + std::cout << " | point = " << it->pointAt(dummy) << std::endl; + np.push_back(dummy); + count++; } + std::cout << "************** Done with this path*****************" << std::endl; return np; } === modified file 'src/2geom/path.h' --- src/2geom/path.h 2011-06-23 16:38:51 +0000 +++ src/2geom/path.h 2011-09-21 19:42:11 +0000 @@ -681,7 +681,7 @@ inline Coord nearest_point(Point const& p, Path const& c) { - return c.nearestPoint(p); + return c.nearestPoint(p); } } // end namespace Geom === modified file 'src/display/snap-indicator.cpp' --- src/display/snap-indicator.cpp 2011-09-18 17:09:29 +0000 +++ src/display/snap-indicator.cpp 2011-09-19 20:23:59 +0000 @@ -302,7 +302,7 @@ void SnapIndicator::set_new_snapsource(Inkscape::SnapCandidatePoint const &p) { - remove_snapsource(); + //remove_snapsource(); g_assert(_desktop != NULL); === modified file 'src/object-snapper.cpp' --- src/object-snapper.cpp 2011-09-17 12:08:49 +0000 +++ src/object-snapper.cpp 2011-09-21 18:16:30 +0000 @@ -516,12 +516,13 @@ // n curves will return n time values with 0 <= t <= 1 std::vector<double> anp = (*it_pv).nearestPointPerCurve(p_doc); + std::cout << "#nearest points = " << anp.size() << " | p = " << p.getPoint() << std::endl; std::vector<double>::const_iterator np = anp.begin(); unsigned int index = 0; for (; np != anp.end(); np++, index++) { Geom::Curve const *curve = &((*it_pv).at_index(index)); Geom::Point const sp_doc = curve->pointAt(*np); - + _snapmanager->getDesktop()->snapindicator->set_new_snapsource(Inkscape::SnapCandidatePoint(sp_doc*_snapmanager->getDesktop()->doc2dt(), SNAPSOURCE_UNDEFINED)); bool c1 = true; bool c2 = true; if (being_edited) { @@ -547,6 +548,7 @@ Geom::Point const sp_dt = _snapmanager->getDesktop()->doc2dt(sp_doc); if (!being_edited || (c1 && c2)) { Geom::Coord const dist = Geom::distance(sp_doc, p_doc); + std::cout << " dist -> " << dist << std::endl; if (dist < getSnapperTolerance()) { isr.curves.push_back(SnappedCurve(sp_dt, num_path, index, dist, getSnapperTolerance(), getSnapperAlwaysSnap(), false, curve, p.getSourceType(), p.getSourceNum(), it_p->target_type, it_p->target_bbox)); } |