diff options
| author | Maximilian Albert <maximilian.albert@gmail.com> | 2008-09-08 22:20:36 +0000 |
|---|---|---|
| committer | cilix42 <cilix42@users.sourceforge.net> | 2008-09-08 22:20:36 +0000 |
| commit | b7b17f36b9e3d2814dcf0f4db1fb329976c2e85a (patch) | |
| tree | 7d9c97f8bd561cd70afd0fe44e507a6e4f91dfd3 /src/2geom/pathvector.cpp | |
| parent | add missing #include for gtk version check (diff) | |
| download | inkscape-b7b17f36b9e3d2814dcf0f4db1fb329976c2e85a.tar.gz inkscape-b7b17f36b9e3d2814dcf0f4db1fb329976c2e85a.zip | |
2geom update (rev. 1578); fixes node editing of some degenerate paths
(bzr r6784)
Diffstat (limited to 'src/2geom/pathvector.cpp')
| -rw-r--r-- | src/2geom/pathvector.cpp | 32 |
1 files changed, 28 insertions, 4 deletions
diff --git a/src/2geom/pathvector.cpp b/src/2geom/pathvector.cpp index 6d4e24c9f..39a00d8dc 100644 --- a/src/2geom/pathvector.cpp +++ b/src/2geom/pathvector.cpp @@ -90,19 +90,19 @@ Rect bounds_exact( PathVector const& pv ) /* Note: undefined for empty pathvectors or pathvectors with empty paths. * */ -PathVectorPosition nearestPoint(PathVector const & path_in, Point const& _point, double *distance_squared) +boost::optional<PathVectorPosition> nearestPoint(PathVector const & path_in, Point const& _point, double *distance_squared) { - PathVectorPosition retval; + boost::optional<PathVectorPosition> retval; double mindsq = infinity(); unsigned int i = 0; for (Geom::PathVector::const_iterator pit = path_in.begin(); pit != path_in.end(); ++pit) { double dsq; double t = pit->nearestPoint(_point, &dsq); + //std::cout << t << "," << dsq << std::endl; if (dsq < mindsq) { mindsq = dsq; - retval.path_nr = i; - retval.t = t; + retval = PathVectorPosition(i, t); } ++i; @@ -114,6 +114,30 @@ PathVectorPosition nearestPoint(PathVector const & path_in, Point const& _point, return retval; } +std::vector<PathVectorPosition> allNearestPoints(PathVector const & path_in, Point const& _point, double *distance_squared) +{ + std::vector<PathVectorPosition> retval; + + double mindsq = infinity(); + unsigned int i = 0; + for (Geom::PathVector::const_iterator pit = path_in.begin(); pit != path_in.end(); ++pit) { + double dsq; + double t = pit->nearestPoint(_point, &dsq); + if (dsq < mindsq) { + mindsq = dsq; + retval.push_back(PathVectorPosition(i, t)); + } + + ++i; + } + + if (distance_squared) { + *distance_squared = mindsq; + } + return retval; + +} + } // namespace Geom #endif // SEEN_GEOM_PATHVECTOR_CPP |
