48 for (
const auto & it : *
this) {
49 n += it.size_default();
59 for (
auto & i : *
this) {
67 for (
const auto & i : *
this) {
71 std::reverse(ret.
begin(), ret.
end());
110 if (
empty())
return bound;
122 if (
empty())
return bound;
133 for (std::size_t i = 0; i <
size(); ++i) {
134 (*this)[i].snapEnds(precision);
141class PathIntersectionSweepSet {
144 boost::intrusive::list_member_hook<> _hook;
149 PathRecord(
Path const &p, std::size_t i,
unsigned w)
156 typedef std::vector<PathRecord>::iterator ItemIterator;
158 PathIntersectionSweepSet(std::vector<PVIntersection> &
result,
159 PathVector
const &a, PathVector
const &b,
Coord precision)
163 _records.reserve(a.size() + b.size());
164 for (std::size_t i = 0; i < a.size(); ++i) {
165 _records.emplace_back(a[i], i, 0);
167 for (std::size_t i = 0; i < b.size(); ++i) {
168 _records.emplace_back(b[i], i, 1);
172 std::vector<PathRecord> &
items() {
return _records; }
174 Interval itemBounds(ItemIterator ii) {
175 OptRect r = ii->path->boundsFast();
180 void addActiveItem(ItemIterator ii) {
181 unsigned w = ii->which;
182 unsigned ow = (ii->which + 1) % 2;
185 if (!ii->path->boundsFast().intersects(i.path->boundsFast()))
continue;
186 std::vector<PathIntersection> px = ii->path->intersect(*i.path, _precision);
187 for (
auto & k : px) {
188 PathVectorTime tw(ii->index, k.first), tow(i.index, k.second);
198 void removeActiveItem(ItemIterator ii) {
199 ActivePathList &apl =
_active[ii->which];
200 apl.erase(apl.iterator_to(*ii));
204 typedef boost::intrusive::list
206 , boost::intrusive::member_hook
208 , boost::intrusive::list_member_hook<>
213 std::vector<PVIntersection> &
_result;
214 std::vector<PathRecord> _records;
221 std::vector<PVIntersection>
result;
223 PathIntersectionSweepSet pisset(
result, *
this, other, precision);
235 for (
const auto & i : *
this) {
236 if (!i.boundsFast().contains(p))
continue;
237 wind += i.winding(p);
244 std::optional<PathVectorTime> retval;
249 PathTime pos = (*this)[i].nearestTime(p, &d);
264 std::vector<PathVectorTime> retval;
269 PathTime pos = (*this)[i].nearestTime(p, &d);
287 std::vector<Point>
result;
289 size_type path_size = (*this)[i].size_closed();
290 for (
size_type j = 0; j < path_size; ++j) {
291 result.push_back((*
this)[i][j].initialPoint());
301 ret.
t = modf(t, &rest);
Path - a sequence of contiguous curves.
3x3 affine transformation matrix.
Abstract continuous curve on a plane defined on [0,1].
virtual Coord valueAt(Coord t, Dim2 d) const
Evaluate one of the coordinates at the specified time value.
virtual Point pointAt(Coord t) const
Evaluate the curve at a specified time value.
void unionWith(CRect const &b)
Enlarge the rectangle to contain the argument.
Axis-aligned rectangle that can be empty.
virtual void feed(Curve const &c, bool moveto_initial=true)
std::vector< PathVectorTime > allNearestTimes(Point const &p, Coord *dist=NULL) const
PathVectorTime _factorTime(Coord t) const
size_type size() const
Get the number of paths in the vector.
Coord valueAt(Coord t, Dim2 d) const
std::vector< Point > nodes() const
void push_back(Path const &path)
Append a path at the end.
Sequence::const_iterator const_iterator
OptRect boundsExact() const
int winding(Point const &p) const
Determine the winding number at the specified point.
Point pointAt(Coord t) const
Sequence::size_type size_type
void snapEnds(Coord precision=EPSILON)
OptRect boundsFast() const
Curve const & curveAt(Coord t, Coord *rest=NULL) const
Path & at(size_type index)
bool empty() const
Check whether the vector contains any paths.
PathVector reversed(bool reverse_paths=true) const
Get a new vector with reversed direction of paths.
std::optional< PathVectorTime > nearestTime(Point const &p, Coord *dist=NULL) const
void reverse(bool reverse_paths=true)
Reverse the direction of paths in the vector.
size_type curveCount() const
Get the total number of curves in the vector.
std::vector< PVIntersection > intersect(PathVector const &other, Coord precision=EPSILON) const
Path & pathAt(Coord t, Coord *rest=NULL)
Sequence of contiguous curves, aka spline.
OptRect boundsExact() const
Get a tight-fitting bounding box.
OptRect boundsFast() const
Get the approximate bounding box.
Curve const & at(size_type i) const
Access a curve by index.
Two-dimensional point that doubles as a vector.
Serialize paths to SVG path data strings.
std::string str() const
Retrieve the generated path data string.
Generic sweepline algorithm.
void process()
Process entry and exit events.
std::vector< ItemIterator > _active
std::vector< Geom::PathVector > _result
Dim2
2D axis enumeration (X or Y).
constexpr Coord infinity()
Get a value representing infinity.
double Coord
Floating point type used to store coordinates.
Various utility functions.
std::ostream & operator<<(std::ostream &os, const Bezier &b)
PathVector - a sequence of subpaths.
Generalized time value in the path.
size_type curve_index
Index of the curve in the path.
Coord t
Time value in the curve.
Generalized time value in the path vector.
size_type path_index
Index of the path in the vector.
Path sink which writes an SVG-compatible command string.
Class for implementing sweepline algorithms.