From 6a9762c7603a32c7ec5cc0aaed8048d84daee6e8 Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Thu, 30 Apr 2015 11:17:07 +0200 Subject: Update 2Geom to r2347 (bzr r14059.2.3) --- src/2geom/pathvector.h | 53 +++++++++++++++++++++++++------------------------- 1 file changed, 26 insertions(+), 27 deletions(-) (limited to 'src/2geom/pathvector.h') diff --git a/src/2geom/pathvector.h b/src/2geom/pathvector.h index 9140e3872..375c4f0a0 100644 --- a/src/2geom/pathvector.h +++ b/src/2geom/pathvector.h @@ -43,7 +43,7 @@ namespace Geom { -/** @brief Position (generalized time value) in the path vector. +/** @brief Generalized time value in the path vector. * * This class exists because mapping the range of multiple curves onto the same interval * as the curve index, we lose some precision. For instance, a path with 16 curves will @@ -52,41 +52,41 @@ namespace Geom { * pointAt(), nearestTime() and so on. * * @ingroup Paths */ -struct PathVectorPosition - : public PathPosition - , boost::totally_ordered +struct PathVectorTime + : public PathTime + , boost::totally_ordered { size_type path_index; ///< Index of the path in the vector - PathVectorPosition() : PathPosition(0, 0), path_index(0) {} - PathVectorPosition(size_type _i, size_type _c, Coord _t) - : PathPosition(_c, _t), path_index(_i) {} - PathVectorPosition(size_type _i, PathPosition const &pos) - : PathPosition(pos), path_index(_i) {} + PathVectorTime() : PathTime(0, 0), path_index(0) {} + PathVectorTime(size_type _i, size_type _c, Coord _t) + : PathTime(_c, _t), path_index(_i) {} + PathVectorTime(size_type _i, PathTime const &pos) + : PathTime(pos), path_index(_i) {} - bool operator<(PathVectorPosition const &other) const { + bool operator<(PathVectorTime const &other) const { if (path_index < other.path_index) return true; if (path_index == other.path_index) { - return static_cast(*this) < static_cast(other); + return static_cast(*this) < static_cast(other); } return false; } - bool operator==(PathVectorPosition const &other) const { + bool operator==(PathVectorTime const &other) const { return path_index == other.path_index - && static_cast(*this) == static_cast(other); + && static_cast(*this) == static_cast(other); } - PathPosition const &asPathPosition() const { - return *static_cast(this); + PathTime const &asPathTime() const { + return *static_cast(this); } }; -typedef Intersection PathVectorIntersection; +typedef Intersection PathVectorIntersection; typedef PathVectorIntersection PVIntersection; ///< Alias to save typing template <> struct ShapeTraits { - typedef PathVectorPosition TimeType; + typedef PathVectorTime TimeType; //typedef PathVectorInterval IntervalType; typedef PathVector AffineClosureType; typedef PathVectorIntersection IntersectionType; @@ -118,7 +118,7 @@ class PathVector { typedef std::vector Sequence; public: - typedef PathVectorPosition Position; + typedef PathVectorTime Position; typedef Sequence::iterator iterator; typedef Sequence::const_iterator const_iterator; typedef Sequence::size_type size_type; @@ -224,19 +224,19 @@ public: Coord valueAt(Coord t, Dim2 d) const; Point pointAt(Coord t) const; - Path &pathAt(Position const &pos) { + Path &pathAt(PathVectorTime const &pos) { return const_cast(static_cast(this)->pathAt(pos)); } - Path const &pathAt(Position const &pos) const { + Path const &pathAt(PathVectorTime const &pos) const { return at(pos.path_index); } - Curve const &curveAt(Position const &pos) const { + Curve const &curveAt(PathVectorTime const &pos) const { return at(pos.path_index).at(pos.curve_index); } - Point pointAt(Position const &pos) const { + Point pointAt(PathVectorTime const &pos) const { return at(pos.path_index).at(pos.curve_index).pointAt(pos.t); } - Coord valueAt(Position const &pos, Dim2 d) const { + Coord valueAt(PathVectorTime const &pos, Dim2 d) const { return at(pos.path_index).at(pos.curve_index).valueAt(pos.t, d); } @@ -265,12 +265,11 @@ public: * This is simply the sum of winding numbers for constituent paths. */ int winding(Point const &p) const; - Coord nearestTime(Point const &p) const; - boost::optional nearestPosition(Point const &p, Coord *dist = NULL) const; - std::vector allNearestPositions(Point const &p, Coord *dist = NULL) const; + boost::optional nearestTime(Point const &p, Coord *dist = NULL) const; + std::vector allNearestTimes(Point const &p, Coord *dist = NULL) const; private: - Position _getPosition(Coord t) const; + PathVectorTime _factorTime(Coord t) const; Sequence _data; }; -- cgit v1.2.3