Inkscape
Vector Graphics Editor
Loading...
Searching...
No Matches
Geom::Path Class Reference

Sequence of contiguous curves, aka spline. More...

#include <path.h>

Inheritance diagram for Geom::Path:

Classes

class  ClosingSegment
 
class  StitchSegment
 

Public Types

typedef PathInternal::PathData PathData
 
typedef PathInternal::Sequence Sequence
 
typedef PathInternal::BaseIterator< Pathiterator
 
typedef PathInternal::BaseIterator< Path const > const_iterator
 
typedef Sequence::size_type size_type
 
typedef Sequence::difference_type difference_type
 

Public Member Functions

 Path (Point const &p=Point())
 Construct an empty path starting at the specified point.
 
template<typename Iter >
 Path (Iter first, Iter last, bool closed=false, bool stitch=false)
 Construct a path containing a range of curves.
 
 Path (Rect const &r)
 Create a path from a rectangle.
 
 Path (ConvexHull const &)
 Create a path from a convex hull.
 
 Path (Circle const &c)
 Create a path from a circle, using two elliptical arcs.
 
 Path (Ellipse const &e)
 Create a path from an ellipse, using two elliptical arcs.
 
virtual ~Path ()
 
void swap (Path &other) noexcept
 Swap contents with another path.
 
Curve const & operator[] (size_type i) const
 Access a curve by index.
 
Curve const & at (size_type i) const
 Access a curve by index.
 
Curve const & front () const
 Access the first curve in the path.
 
Curve const & initialCurve () const
 Alias for front().
 
Curve const & back () const
 Access the last curve in the path.
 
Curve const & back_open () const
 
Curve const & back_closed () const
 
Curve const & back_default () const
 
Curve const & finalCurve () const
 
const_iterator begin () const
 
const_iterator end () const
 
const_iterator end_default () const
 
const_iterator end_open () const
 
const_iterator end_closed () const
 
iterator begin ()
 
iterator end ()
 
iterator end_default ()
 
iterator end_open ()
 
iterator end_closed ()
 
size_type size_open () const
 Size without the closing segment, even if the path is closed.
 
size_type size_closed () const
 Size with the closing segment, if it makes a difference.
 
size_type size_default () const
 Natural size of the path.
 
size_type size () const
 Natural size of the path.
 
size_type max_size () const
 
bool empty () const
 Check whether path is empty.
 
bool closed () const
 Check whether the path is closed.
 
void close (bool closed=true)
 Set whether the path is closed.
 
void clear ()
 Remove all curves from the path.
 
OptRect boundsFast () const
 Get the approximate bounding box.
 
OptRect boundsExact () const
 Get a tight-fitting bounding box.
 
Piecewise< D2< SBasis > > toPwSb () const
 
bool operator== (Path const &other) const
 Test paths for exact equality.
 
template<typename T >
Pathoperator*= (T const &tr)
 Apply a transform to each curve.
 
Interval timeRange () const
 Get the allowed range of time values.
 
Curve const & curveAt (Coord t, Coord *rest=NULL) const
 Get the curve at the specified time value.
 
LineSegment const & closingSegment () const
 Get the closing segment of the path.
 
Point pointAt (Coord t) const
 Get the point at the specified time value.
 
Coord valueAt (Coord t, Dim2 d) const
 Get one coordinate (X or Y) at the specified time value.
 
Curve const & curveAt (PathTime const &pos) const
 Get the curve at the specified path time.
 
Point pointAt (PathTime const &pos) const
 Get the point at the specified path time.
 
Coord valueAt (PathTime const &pos, Dim2 d) const
 Get one coordinate at the specified path time.
 
Point operator() (Coord t) const
 
PathExtrema extrema (Dim2 d) const
 Find the extrema of the specified coordinate.
 
std::vector< PathTimeroots (Coord v, Dim2 d) const
 Compute intersections with axis-aligned line.
 
std::vector< PathIntersectionintersect (Path const &other, Coord precision=EPSILON) const
 Compute intersections with another path.
 
std::vector< PathIntersectionintersectSelf (Coord precision=EPSILON) const
 Compute intersections of the path with itself.
 
int winding (Point const &p) const
 Determine the winding number at the specified point.
 
std::vector< CoordallNearestTimes (Point const &p, Coord from, Coord to) const
 
std::vector< CoordallNearestTimes (Point const &p) const
 
PathTime nearestTime (Point const &p, Coord *dist=NULL) const
 
std::vector< CoordnearestTimePerCurve (Point const &p) const
 
std::vector< Pointnodes () const
 
void appendPortionTo (Path &p, Coord f, Coord t) const
 
void appendPortionTo (Path &p, PathTime const &from, PathTime const &to, bool cross_start=false) const
 Append a subset of this path to another path.
 
void appendPortionTo (Path &p, PathInterval const &ival) const
 Append a subset of this path to another path.
 
void appendPortionTo (Path &p, PathInterval const &ival, std::optional< Point > const &p_from, std::optional< Point > const &p_to) const
 Append a subset of this path to another path, specifying endpoints.
 
Path portion (Coord f, Coord t) const
 
Path portion (Interval const &i) const
 
Path portion (PathTime const &from, PathTime const &to, bool cross_start=false) const
 Get a subset of the current path with full precision.
 
Path portion (PathInterval const &ival) const
 Get a subset of the current path with full precision.
 
Path reversed () const
 Obtain a reversed version of the current path.
 
void insert (iterator pos, Curve const &curve)
 
template<typename Iter >
void insert (iterator pos, Iter first, Iter last)
 
void erase (iterator pos)
 
void erase (iterator first, iterator last)
 
void erase_last ()
 
void start (Point const &p)
 
Point initialPoint () const
 Get the first point in the path.
 
Point finalPoint () const
 Get the last point in the path.
 
Point initialUnitTangent () const
 Get the unit tangent vector at the start of the path, or the zero vector if undefined.
 
Point finalUnitTangent () const
 Get the unit tangent vector at the end of the path, or the zero vector if undefined.
 
void setInitial (Point const &p)
 
void setFinal (Point const &p)
 
void append (Curve *curve)
 Add a new curve to the end of the path.
 
void append (Curve const &curve)
 
void append (D2< SBasis > const &curve)
 
void append (Path const &other)
 
void replace (iterator replaced, Curve const &curve)
 
void replace (iterator first, iterator last, Curve const &curve)
 
void replace (iterator replaced, Path const &path)
 
void replace (iterator first, iterator last, Path const &path)
 
template<typename Iter >
void replace (iterator replaced, Iter first, Iter last)
 
template<typename Iter >
void replace (iterator first_replaced, iterator last_replaced, Iter first, Iter last)
 
template<typename CurveType , typename... Args>
void appendNew (Args &&... args)
 Append a new curve to the path.
 
void snapEnds (Coord precision=EPSILON)
 Reduce the closing segment to a point if it's shorter than precision.
 
void stitchTo (Point const &p)
 Append a stitching segment ending at the specified point.
 
Path withoutDegenerateCurves () const
 Return a copy of the path without degenerate curves, except possibly for a degenerate closing segment.
 
void checkContinuity () const
 Verify the continuity invariant.
 
void setStitching (bool x)
 Enable or disable the throwing of exceptions when stitching discontinuities.
 

Private Member Functions

bool _includesClosingSegment () const
 
void _unshare ()
 
PathTime _factorTime (Coord t) const
 
void stitch (Sequence::iterator first_replaced, Sequence::iterator last_replaced, Sequence &sequence)
 
void do_update (Sequence::iterator first, Sequence::iterator last, Sequence &source)
 
void do_append (Curve *curve)
 

Static Private Member Functions

static Sequence::iterator seq_iter (iterator const &iter)
 
static Sequence::const_iterator seq_iter (const_iterator const &iter)
 

Private Attributes

std::shared_ptr< PathData_data
 
ClosingSegment_closing_seg
 
bool _closed
 
bool _exception_on_stitch
 

Friends

template<typename T >
Path operator* (Path const &path, T const &tr)
 

Related Symbols

(Note that these are not member symbols.)

void swap (Path &a, Path &b) noexcept
 Swap contents of two paths.
 

Detailed Description

Sequence of contiguous curves, aka spline.

Path represents a sequence of contiguous curves, also known as a spline. It corresponds to a "subpath" in SVG terminology. It can represent both open and closed subpaths. The final point of each curve is exactly equal to the initial point of the next curve.

The path always contains a linear closing segment that connects the final point of the last "real" curve to the initial point of the first curve. This way the curves form a closed loop even for open paths. If the closing segment has nonzero length and the path is closed, it is considered a normal part of the path data. There are three distinct sets of end iterators one can use to iterate over the segments:

  • Iterating between begin() and end() will iterate over segments which are part of the path.
  • Iterating between begin() and end_closed() will always iterate over a closed loop of segments.
  • Iterating between begin() and end_open() will always skip the final linear closing segment.

If the final point of the last "real" segment coincides exactly with the initial point of the first segment, the closing segment will be absent from both [begin(), end_open()) and [begin(), end_closed()).

Normally, an exception will be thrown when you try to insert a curve that makes the path non-continuous. If you are working with unsanitized curve data, you can call setStitching(true), which will insert line segments to make the path continuous.

Internally, Path uses copy-on-write data. This is done for two reasons: first, copying a Curve requires calling a virtual function, so it's a little more expensive that normal copying; and second, it reduces the memory cost of copying the path. Therefore you can return Path and PathVector from functions without worrying about temporary copies.

Note that this class cannot represent arbitrary shapes, which may contain holes. To do that, use PathVector, which is more generic.

It's not very convenient to create a Path directly. To construct paths more easily, use PathBuilder.

Definition at line 351 of file path.h.

Member Typedef Documentation

◆ const_iterator

Definition at line 358 of file path.h.

◆ difference_type

typedef Sequence::difference_type Geom::Path::difference_type

Definition at line 360 of file path.h.

◆ iterator

Definition at line 357 of file path.h.

◆ PathData

Definition at line 355 of file path.h.

◆ Sequence

Definition at line 356 of file path.h.

◆ size_type

typedef Sequence::size_type Geom::Path::size_type

Definition at line 359 of file path.h.

Constructor & Destructor Documentation

◆ Path() [1/6]

Geom::Path::Path ( Point const &  p = Point())
inlineexplicit

Construct an empty path starting at the specified point.

Definition at line 381 of file path.h.

References _closing_seg, and _data.

◆ Path() [2/6]

template<typename Iter >
Geom::Path::Path ( Iter  first,
Iter  last,
bool  closed = false,
bool  stitch = false 
)
inline

Construct a path containing a range of curves.

Definition at line 392 of file path.h.

References _closing_seg, and _data.

◆ Path() [3/6]

Path::Path ( Rect const &  r)
explicit

Create a path from a rectangle.

Definition at line 257 of file path.cpp.

References _closing_seg, _data, and Geom::GenericRect< C >::corner().

◆ Path() [4/6]

◆ Path() [5/6]

Path::Path ( Circle const &  c)
explicit

Create a path from a circle, using two elliptical arcs.

Definition at line 294 of file path.cpp.

References _closing_seg, _data, and c.

◆ Path() [6/6]

Path::Path ( Ellipse const &  e)
explicit

Create a path from an ellipse, using two elliptical arcs.

Definition at line 308 of file path.cpp.

References _closing_seg, _data, Geom::Ellipse::pointAt(), Geom::Ellipse::rays(), and Geom::Ellipse::rotationAngle().

◆ ~Path()

virtual Geom::Path::~Path ( )
inlinevirtual

Definition at line 418 of file path.h.

Member Function Documentation

◆ _factorTime()

PathTime Path::_factorTime ( Coord  t) const
private

Definition at line 1105 of file path.cpp.

References Geom::PathTime::curve_index, size_default(), and Geom::PathTime::t.

Referenced by curveAt(), pointAt(), and valueAt().

◆ _includesClosingSegment()

bool Geom::Path::_includesClosingSegment ( ) const
inlineprivate

Definition at line 840 of file path.h.

References _closed, _closing_seg, and Geom::BezierCurveN< degree >::isDegenerate().

Referenced by back_default(), reversed(), and size_default().

◆ _unshare()

void Geom::Path::_unshare ( )
inlineprivate

◆ allNearestTimes() [1/2]

std::vector< Coord > Geom::Path::allNearestTimes ( Point const &  p) const
inline

Definition at line 613 of file path.h.

References allNearestTimes(), and size_default().

◆ allNearestTimes() [2/2]

std::vector< double > Path::allNearestTimes ( Point const &  p,
Coord  from,
Coord  to 
) const

Definition at line 638 of file path.cpp.

References allNearestTimes(), boundsFast(), closed(), Geom::distanceSq(), pointAt(), size(), and swap.

Referenced by allNearestTimes(), and allNearestTimes().

◆ append() [1/4]

void Geom::Path::append ( Curve curve)
inline

Add a new curve to the end of the path.

This inserts the new curve right before the closing segment. The path takes ownership of the passed pointer, which should not be freed.

Definition at line 750 of file path.h.

References _unshare(), do_append(), and stitchTo().

Referenced by Inkscape::UI::Tools::PenTool::_redoLastPoint(), SPCurve::append(), Geom::PathIteratorSink< OutputIterator >::append(), SPCurve::append_continuous(), appendPortionTo(), appendPortionTo(), Geom::PlanarGraph< EdgeLabel >::deviatesLeft(), Inkscape::LivePathEffect::LPETaperStroke::doBeforeEffect(), Inkscape::LivePathEffect::LPEAttachPath::doEffect(), Inkscape::LivePathEffect::LPEFillBetweenMany::doEffect(), Inkscape::LivePathEffect::LPEFillBetweenStrokes::doEffect(), Inkscape::LivePathEffect::LPEKnot::doEffect_path(), Inkscape::LivePathEffect::LPECopyRotate::doEffect_path(), Inkscape::LivePathEffect::LPEEmbroderyStitch::doEffect_path(), Inkscape::LivePathEffect::LPEFilletChamfer::doEffect_path(), Inkscape::LivePathEffect::LPEPowerStroke::doEffect_path(), Inkscape::LivePathEffect::LPEPts2Ellipse::gen_axes_paths(), Inkscape::LivePathEffect::LPEPts2Ellipse::gen_perspective_axes_paths(), Inkscape::half_outline(), Geom::Interpolate::CentripetalCatmullRomInterpolator::interpolateToPath(), Inkscape::LivePathEffect::FilletChamferKnotHolderEntity::knot_get(), Inkscape::outline_join(), pathv_to_cubicbezier(), pathv_to_linear(), pathv_to_linear_and_cubic_beziers(), Inkscape::Extension::Internal::PrintEmf::pathv_to_simple_polygon(), plot(), Inkscape::LivePathEffect::return_at_first_cusp(), SPGenericEllipse::set_shape(), Inkscape::LivePathEffect::LPERoughHatches::smoothSnake(), Inkscape::LivePathEffect::sp_bspline_do_effect(), Inkscape::LivePathEffect::LPECopyRotate::split(), TEST_F(), and Inkscape::LivePathEffect::LPEPts2Ellipse::unit_arc_path().

◆ append() [2/4]

void Geom::Path::append ( Curve const &  curve)
inline

Definition at line 756 of file path.h.

References _unshare(), do_append(), and stitchTo().

◆ append() [3/4]

void Geom::Path::append ( D2< SBasis > const &  curve)
inline

Definition at line 761 of file path.h.

References _unshare(), do_append(), stitchTo(), Geom::X, and Geom::Y.

◆ append() [4/4]

void Geom::Path::append ( Path const &  other)
inline

Definition at line 766 of file path.h.

References begin(), end(), end_open(), and replace().

◆ appendNew()

template<typename CurveType , typename... Args>
void Geom::Path::appendNew ( Args &&...  args)
inline

Append a new curve to the path.

This family of methods will automatically use the current final point of the path as the first argument of the new curve's constructor. To call this method, you'll need to write e.g.:

path.template appendNew<CubicBezier>(control1, control2, end_point);

It is important to note that the coordinates passed to appendNew should be finite! If one of the coordinates is infinite, 2geom will throw a ContinuityError exception.

Definition at line 804 of file path.h.

References _unshare(), do_append(), and finalPoint().

Referenced by Inkscape::UI::Tools::PencilTool::_sketchInterpolate(), Inkscape::ObjectSnapper::_snapPathsConstrained(), Inkscape::LivePathEffect::LPECopyRotate::addCanvasIndicators(), Inkscape::LivePathEffect::LPEMirrorSymmetry::addCanvasIndicators(), Inkscape::LivePathEffect::LPESlice::addCanvasIndicators(), Inkscape::LivePathEffect::LPETransform2Pts::addCanvasIndicators(), Inkscape::LivePathEffect::LPEFilletChamfer::addChamferSteps(), Inkscape::LivePathEffect::LPERoughen::addNodesAndJitter(), SPCurve::append(), Inkscape::Text::Layout::baseline(), Inkscape::UI::Tools::MeasureTool::createAngleDisplayCurve(), Inkscape::LivePathEffect::LPEMeasureSegments::createLine(), Spiro::ConverterPath::curveto(), SPCurve::curveto(), Inkscape::LivePathEffect::LPEVonKoch::doBeforeEffect(), Inkscape::LivePathEffect::LPEMeasureSegments::doBeforeEffect(), Inkscape::LivePathEffect::LPETaperStroke::doBeforeEffect(), Inkscape::LivePathEffect::LPEAttachPath::doEffect(), Inkscape::LivePathEffect::LPEFillBetweenMany::doEffect(), Inkscape::LivePathEffect::LPEFillBetweenStrokes::doEffect(), Inkscape::LivePathEffect::LPEConstructGrid::doEffect_path(), Inkscape::LivePathEffect::LPECopyRotate::doEffect_path(), Inkscape::LivePathEffect::LPEFilletChamfer::doEffect_path(), Inkscape::LivePathEffect::LPELineSegment::doEffect_path(), Inkscape::LivePathEffect::LPEMirrorSymmetry::doEffect_path(), Inkscape::LivePathEffect::LPEPowerStroke::doEffect_path(), Inkscape::LivePathEffect::LPEExtrude::doEffect_pwd2(), Inkscape::LivePathEffect::LPETransform2Pts::doEffect_pwd2(), Inkscape::LivePathEffect::LPEShowHandles::drawHandleLine(), Inkscape::LivePathEffect::LPESimplify::drawHandleLine(), Inkscape::UI::Tools::fit_item(), Inkscape::LivePathEffect::LPEPts2Ellipse::gen_iso_frame_paths(), Inkscape::LivePathEffect::LPEPts2Ellipse::gen_perspective_frame_paths(), Geom::Interpolate::Linear::interpolateToPath(), Geom::Interpolate::CubicBezierFit::interpolateToPath(), Geom::Interpolate::CubicBezierJohan::interpolateToPath(), Geom::Interpolate::CubicBezierSmooth::interpolateToPath(), interpolateToPath(), interpolateToPath2(), Spiro::ConverterPath::lineto(), SPCurve::lineto(), Path::MakePathVector(), ordered_fit(), pathv_to_cubicbezier(), Spiro::ConverterPath::quadto(), SPCurve::quadto(), Inkscape::Extension::Internal::PrintMetafile::rect_cutter(), Inkscape::LivePathEffect::LPEBendPath::resetDefaults(), Inkscape::LivePathEffect::LPECurveStitch::resetDefaults(), Inkscape::LivePathEffect::LPEEnvelope::resetDefaults(), Inkscape::LivePathEffect::LPEVonKoch::resetDefaults(), Inkscape::UI::Tools::MeasureTool::setLine(), Inkscape::UI::Tools::MeasureTool::showCanvasItems(), Inkscape::LivePathEffect::LPERoughHatches::smoothSnake(), Inkscape::LivePathEffect::sp_bspline_do_effect(), Inkscape::LivePathEffect::LPESlice::splititem(), TEST_F(), Inkscape::LivePathEffect::LPEPts2Ellipse::unit_arc_path(), and Tracer::worker_helper().

◆ appendPortionTo() [1/4]

void Path::appendPortionTo ( Path p,
Coord  f,
Coord  t 
) const

Definition at line 777 of file path.cpp.

References append(), begin(), end(), Geom::inc(), insert(), and size().

Referenced by appendPortionTo(), appendPortionTo(), portion(), portion(), portion(), and TEST_F().

◆ appendPortionTo() [2/4]

void Geom::Path::appendPortionTo ( Path p,
PathInterval const &  ival 
) const
inline

Append a subset of this path to another path.

This version allows you to explicitly pass a PathInterval.

Definition at line 635 of file path.h.

References appendPortionTo().

◆ appendPortionTo() [3/4]

void Path::appendPortionTo ( Path p,
PathInterval const &  ival,
std::optional< Point > const &  p_from,
std::optional< Point > const &  p_to 
) const

Append a subset of this path to another path, specifying endpoints.

This method is for use in situations where endpoints of the portion segments have to be set exactly, for instance when computing Boolean operations.

Definition at line 815 of file path.cpp.

References append(), c, Geom::PathInterval::crossesStart(), Geom::PathTime::curve_index, Geom::PathInterval::from(), Geom::PathInterval::isDegenerate(), Geom::PathInterval::pathSize(), pointAt(), Geom::Curve::portion(), Geom::PathInterval::reverse(), Geom::reverse(), Geom::Curve::setFinal(), Geom::Curve::setInitial(), size_closed(), stitchTo(), Geom::PathTime::t, and Geom::PathInterval::to().

◆ appendPortionTo() [4/4]

void Geom::Path::appendPortionTo ( Path p,
PathTime const &  from,
PathTime const &  to,
bool  cross_start = false 
) const
inline

Append a subset of this path to another path.

An extra stitching segment will be inserted if the start point of the portion and the final point of the target path do not match exactly. The closing segment of the target path will be modified.

Definition at line 628 of file path.h.

References appendPortionTo(), and size_closed().

◆ at()

◆ back()

Curve const & Geom::Path::back ( ) const
inline

◆ back_closed()

◆ back_default()

Curve const & Geom::Path::back_default ( ) const
inline

◆ back_open()

Curve const & Geom::Path::back_open ( ) const
inline

◆ begin() [1/2]

iterator Geom::Path::begin ( )
inline

Definition at line 469 of file path.h.

◆ begin() [2/2]

◆ boundsExact()

OptRect Path::boundsExact ( ) const

Get a tight-fitting bounding box.

This will return the smallest possible axis-aligned rectangle containing all the curves in the path.

Definition at line 372 of file path.cpp.

References begin(), bounds, Geom::Curve::boundsExact(), empty(), end(), front(), and Geom::GenericRect< C >::unionWith().

Referenced by Geom::PathVector::boundsExact(), and wrap_path().

◆ boundsFast()

OptRect Path::boundsFast ( ) const

Get the approximate bounding box.

The rectangle returned by this method will contain all the curves, but it's not guaranteed to be the smallest possible one

Definition at line 348 of file path.cpp.

References _data, begin(), bounds, Geom::Curve::boundsFast(), empty(), end(), front(), and Geom::GenericRect< C >::unionWith().

Referenced by allNearestTimes(), Geom::bounds(), Geom::PathVector::boundsFast(), Inkscape::find_interior_point(), Inkscape::UI::Tools::fit_item(), Inkscape::UI::Tools::NodeTool::select_area(), and wrap_path().

◆ checkContinuity()

void Path::checkContinuity ( ) const

Verify the continuity invariant.

If the path is not contiguous, this will throw a CountinuityError.

Definition at line 1090 of file path.cpp.

References _data.

Referenced by do_update(), and TEST_F().

◆ clear()

◆ close()

void Path::close ( bool  closed = true)

Set whether the path is closed.

When closing a path where the last segment can be represented as a closing segment, the last segment will be removed. When opening a path, the closing segment will be erased. This means that closing and then opening a path will not always give back the original path.

Definition at line 322 of file path.cpp.

References _closed, _closing_seg, _data, c, initialPoint(), and Geom::BezierCurve::setInitial().

Referenced by Geom::PlanarGraph< EdgeLabel >::_reglueTeardrop(), SPCurve::backspace(), SPCurve::closepath(), Geom::PathIteratorSink< OutputIterator >::closePath(), SPCurve::closepath_current(), Spiro::ConverterPath::curveto(), Geom::PlanarGraph< EdgeLabel >::deviatesLeft(), Inkscape::LivePathEffect::LPETaperStroke::doBeforeEffect(), Inkscape::LivePathEffect::LPEFillBetweenMany::doEffect(), Inkscape::LivePathEffect::LPEFillBetweenStrokes::doEffect(), Inkscape::LivePathEffect::LPECopyRotate::doEffect_path(), Inkscape::LivePathEffect::LPEFilletChamfer::doEffect_path(), Inkscape::LivePathEffect::LPEMirrorSymmetry::doEffect_path(), Inkscape::LivePathEffect::LPEPowerStroke::doEffect_path(), Inkscape::UI::Tools::fit_item(), Inkscape::LivePathEffect::LPEPts2Ellipse::gen_iso_frame_paths(), Inkscape::LivePathEffect::LPEPts2Ellipse::gen_perspective_frame_paths(), Inkscape::half_outline(), Spiro::ConverterPath::lineto(), Path::MakePathVector(), pathv_to_cubicbezier(), pathv_to_linear(), pathv_to_linear_and_cubic_beziers(), Inkscape::Extension::Internal::PrintEmf::pathv_to_simple_polygon(), portion(), portion(), portion(), Spiro::ConverterPath::quadto(), Inkscape::Extension::Internal::PrintMetafile::rect_cutter(), Inkscape::LivePathEffect::LPESlice::splititem(), TEST_F(), TEST_F(), Inkscape::LivePathEffect::LPEPts2Ellipse::unit_arc_path(), and wrap_path().

◆ closed()

◆ closingSegment()

LineSegment const & Geom::Path::closingSegment ( ) const
inline

Get the closing segment of the path.

Definition at line 561 of file path.h.

References _closing_seg.

◆ curveAt() [1/2]

Curve const & Path::curveAt ( Coord  t,
Coord rest = NULL 
) const

Get the curve at the specified time value.

Parameters
tTime value
restOptional storage for the corresponding time value in the curve

Definition at line 440 of file path.cpp.

References _factorTime(), at(), Geom::PathTime::curve_index, and Geom::PathTime::t.

Referenced by Inkscape::LivePathEffect::LPEPowerStroke::doEffect_path(), and Geom::find_direction_of_travel().

◆ curveAt() [2/2]

Curve const & Path::curveAt ( PathTime const &  pos) const

Get the curve at the specified path time.

Definition at line 459 of file path.cpp.

References at(), and Geom::PathTime::curve_index.

◆ do_append()

◆ do_update()

void Path::do_update ( Sequence::iterator  first,
Sequence::iterator  last,
Sequence source 
)
private

◆ empty()

bool Geom::Path::empty ( ) const
inline

Check whether path is empty.

The path is empty if it contains only the closing segment, which according to the continuity invariant must be degenerate. Note that unlike standard containers, two empty paths are not necessarily identical, because the degenerate closing segment may be at a different point, affecting the operation of methods such as appendNew().

Definition at line 500 of file path.h.

References _data.

Referenced by Inkscape::UI::Tools::PencilTool::addPowerStrokePencil(), back_open(), SPCurve::backspace(), boundsExact(), boundsFast(), count_path_curves(), count_path_degenerations(), count_path_nodes(), Inkscape::LivePathEffect::LPECopyRotate::doEffect_path(), extrema(), feed_path_to_cairo(), feed_path_to_cairo(), SPCurve::first_segment(), SPCurve::last_segment(), Path::LoadPath(), Geom::parting_point(), Geom::path_direction(), Geom::path_mono_splits(), SPCurve::penultimate_point(), reversed(), SPCurve::second_point(), Inkscape::LivePathEffect::LPECopyRotate::split(), stitchTo(), Inkscape::LivePathEffect::stretch_along(), and wrap_path().

◆ end() [1/2]

iterator Geom::Path::end ( )
inline

Definition at line 470 of file path.h.

References end_default().

◆ end() [2/2]

◆ end_closed() [1/2]

iterator Geom::Path::end_closed ( )
inline

Definition at line 473 of file path.h.

References size_closed().

◆ end_closed() [2/2]

const_iterator Geom::Path::end_closed ( ) const
inline

Definition at line 468 of file path.h.

References size_closed().

Referenced by winding().

◆ end_default() [1/2]

iterator Geom::Path::end_default ( )
inline

Definition at line 471 of file path.h.

References size_default().

◆ end_default() [2/2]

const_iterator Geom::Path::end_default ( ) const
inline

Definition at line 466 of file path.h.

References size_default().

Referenced by count_path_degenerations(), end(), end(), nearestTimePerCurve(), and toPwSb().

◆ end_open() [1/2]

iterator Geom::Path::end_open ( )
inline

Definition at line 472 of file path.h.

References size_open().

◆ end_open() [2/2]

◆ erase() [1/2]

void Path::erase ( iterator  first,
iterator  last 
)

Definition at line 922 of file path.cpp.

References _unshare(), do_update(), and seq_iter().

◆ erase() [2/2]

void Path::erase ( iterator  pos)

Definition at line 913 of file path.cpp.

References _unshare(), do_update(), and seq_iter().

Referenced by erase_last(), and Inkscape::half_outline().

◆ erase_last()

void Geom::Path::erase_last ( )
inline

◆ extrema()

PathExtrema Path::extrema ( Dim2  d) const

Find the extrema of the specified coordinate.

Returns a PathExtrema struct describing "witness" points on the path where the specified coordinate attains its minimum and maximum values.

A closure to update the current minimum and maximum values.

Definition at line 88 of file path-extrema.cpp.

References _data, Geom::derivative(), empty(), Geom::find_direction_of_travel(), initialPoint(), Geom::PathExtrema::min_point, origin, Geom::other_dimension(), root, and Geom::Bezier::roots().

◆ finalCurve()

Curve const & Geom::Path::finalCurve ( ) const
inline

Definition at line 462 of file path.h.

References back_default().

Referenced by Inkscape::LivePathEffect::LPETransform2Pts::doOnApply().

◆ finalPoint()

◆ finalUnitTangent()

Point Geom::Path::finalUnitTangent ( ) const
inline

Get the unit tangent vector at the end of the path, or the zero vector if undefined.

Definition at line 724 of file path.h.

References begin(), and end().

Referenced by Geom::PlanarGraph< EdgeLabel >::_mergeShorterLonger(), and Geom::find_direction_of_travel().

◆ front()

Curve const & Geom::Path::front ( ) const
inline

◆ initialCurve()

Curve const & Geom::Path::initialCurve ( ) const
inline

Alias for front().

Definition at line 445 of file path.h.

References _data.

◆ initialPoint()

◆ initialUnitTangent()

Point Geom::Path::initialUnitTangent ( ) const
inline

Get the unit tangent vector at the start of the path, or the zero vector if undefined.

Definition at line 713 of file path.h.

Referenced by Geom::PlanarGraph< EdgeLabel >::_mergeShorterLonger(), Geom::PlanarGraph< EdgeLabel >::deviatesLeft(), and Geom::find_direction_of_travel().

◆ insert() [1/2]

void Path::insert ( iterator  pos,
Curve const &  curve 
)

Definition at line 904 of file path.cpp.

References _unshare(), do_update(), and seq_iter().

Referenced by appendPortionTo().

◆ insert() [2/2]

template<typename Iter >
void Geom::Path::insert ( iterator  pos,
Iter  first,
Iter  last 
)
inline

Definition at line 686 of file path.h.

References _unshare(), do_update(), and seq_iter().

◆ intersect()

std::vector< PathIntersection > Path::intersect ( Path const &  other,
Coord  precision = EPSILON 
) const

Compute intersections with another path.

Definition at line 575 of file path.cpp.

References Geom::Sweeper< SweepSet >::process(), result, and size().

◆ intersectSelf()

std::vector< PathIntersection > Path::intersectSelf ( Coord  precision = EPSILON) const

Compute intersections of the path with itself.

Definition at line 153 of file self-intersect.cpp.

References Geom::Sweeper< SweepSet >::process(), and result.

◆ max_size()

size_type Geom::Path::max_size ( ) const
inline

Definition at line 492 of file path.h.

References _data.

◆ nearestTime()

◆ nearestTimePerCurve()

std::vector< Coord > Path::nearestTimePerCurve ( Point const &  p) const

Definition at line 723 of file path.cpp.

References begin(), and end_default().

◆ nodes()

std::vector< Point > Path::nodes ( ) const

Definition at line 767 of file path.cpp.

References _data, result, and size_closed().

◆ operator()()

Point Geom::Path::operator() ( Coord  t) const
inline

Definition at line 582 of file path.h.

References pointAt().

◆ operator*=()

template<typename T >
Path & Geom::Path::operator*= ( T const &  tr)
inline

Apply a transform to each curve.

Definition at line 534 of file path.h.

References _data, and _unshare().

◆ operator==()

bool Path::operator== ( Path const &  other) const

Test paths for exact equality.

Definition at line 417 of file path.cpp.

References _closed, and _data.

◆ operator[]()

Curve const & Geom::Path::operator[] ( size_type  i) const
inline

Access a curve by index.

Definition at line 436 of file path.h.

References _data.

◆ pointAt() [1/2]

Point Path::pointAt ( Coord  t) const

Get the point at the specified time value.

Note that this method has reduced precision with respect to calling pointAt() directly on the curve. If you want high precision results, use the version that takes a PathTime parameter.

Allowed time values range from zero to the number of curves; you can retrieve the allowed range of values with timeRange().

Definition at line 449 of file path.cpp.

References _factorTime(), and pointAt().

Referenced by Inkscape::LivePathEffect::LPEFilletChamfer::addChamferSteps(), Inkscape::LivePathEffect::LPERoughen::addNodesAndJitter(), allNearestTimes(), appendPortionTo(), Inkscape::do_offset(), Inkscape::LivePathEffect::LPEPowerStroke::doEffect_path(), Inkscape::LivePathEffect::LPEVonKoch::doEffect_path(), edges(), Inkscape::find_interior_point(), Geom::mono_pair(), operator()(), Geom::parting_point(), pointAt(), Inkscape::LivePathEffect::LPEOffset::sp_get_offset(), and Inkscape::LivePathEffect::LPECopyRotate::split().

◆ pointAt() [2/2]

Point Path::pointAt ( PathTime const &  pos) const

Get the point at the specified path time.

Definition at line 463 of file path.cpp.

References at(), Geom::PathTime::curve_index, Geom::Curve::pointAt(), and Geom::PathTime::t.

◆ portion() [1/4]

◆ portion() [2/4]

Path Geom::Path::portion ( Interval const &  i) const
inline

Definition at line 652 of file path.h.

References Geom::GenericInterval< C >::max(), Geom::GenericInterval< C >::min(), and portion().

Referenced by portion().

◆ portion() [3/4]

Path Geom::Path::portion ( PathInterval const &  ival) const
inline

Get a subset of the current path with full precision.

This version allows you to explicitly pass a PathInterval.

Definition at line 669 of file path.h.

References appendPortionTo(), and close().

◆ portion() [4/4]

Path Geom::Path::portion ( PathTime const &  from,
PathTime const &  to,
bool  cross_start = false 
) const
inline

Get a subset of the current path with full precision.

When from is larger (later in the path) than to, the returned portion will be reversed. If cross_start is true, the portion will be reversed and will cross the initial point of the path. Therefore, when from is larger than to and cross_start is true, the returned portion will not be reversed, but will "wrap around" the end of the path.

Definition at line 660 of file path.h.

References appendPortionTo(), and close().

◆ replace() [1/6]

void Path::replace ( iterator  first,
iterator  last,
Curve const &  curve 
)

Definition at line 948 of file path.cpp.

References _unshare(), do_update(), and seq_iter().

◆ replace() [2/6]

void Path::replace ( iterator  first,
iterator  last,
Path const &  path 
)

Definition at line 964 of file path.cpp.

References begin(), end(), and replace().

◆ replace() [3/6]

template<typename Iter >
void Geom::Path::replace ( iterator  first_replaced,
iterator  last_replaced,
Iter  first,
Iter  last 
)
inline

Definition at line 781 of file path.h.

References _unshare(), do_update(), and seq_iter().

◆ replace() [4/6]

void Path::replace ( iterator  replaced,
Curve const &  curve 
)

Definition at line 943 of file path.cpp.

References replace().

Referenced by append(), SPCurve::last_point_additive_move(), replace(), replace(), replace(), and replace().

◆ replace() [5/6]

template<typename Iter >
void Geom::Path::replace ( iterator  replaced,
Iter  first,
Iter  last 
)
inline

Definition at line 776 of file path.h.

References replace().

◆ replace() [6/6]

void Path::replace ( iterator  replaced,
Path const &  path 
)

Definition at line 959 of file path.cpp.

References begin(), end(), and replace().

◆ reversed()

Path Path::reversed ( ) const

Obtain a reversed version of the current path.

The final point of the current path will become the initial point of the reversed path, unless it is closed and has a non-degenerate closing segment. In that case, the new initial point will be the final point of the last "real" segment.

Definition at line 866 of file path.cpp.

References _closed, _closing_seg, _data, _includesClosingSegment(), empty(), finalPoint(), front(), initialPoint(), and Geom::Path::ClosingSegment::reverse().

Referenced by Geom::PlanarGraph< EdgeLabel >::_getPathImpl(), Geom::PlanarGraph< EdgeLabel >::_reglueTeardrop(), Geom::PlanarGraph< EdgeLabel >::deviatesLeft(), Inkscape::LivePathEffect::LPEFillBetweenMany::doEffect(), Inkscape::LivePathEffect::LPEFillBetweenStrokes::doEffect(), Inkscape::outline(), Inkscape::LivePathEffect::LPERoughHatches::smoothSnake(), TEST(), and wrap_path().

◆ roots()

std::vector< PathTime > Path::roots ( Coord  v,
Dim2  d 
) const

Compute intersections with axis-aligned line.

Definition at line 472 of file path.cpp.

References size().

Referenced by TEST_F(), TEST_F(), and wrap_path().

◆ seq_iter() [1/2]

static Sequence::const_iterator Geom::Path::seq_iter ( const_iterator const &  iter)
inlinestaticprivate

◆ seq_iter() [2/2]

static Sequence::iterator Geom::Path::seq_iter ( iterator const &  iter)
inlinestaticprivate

◆ setFinal()

◆ setInitial()

◆ setStitching()

◆ size()

◆ size_closed()

size_type Geom::Path::size_closed ( ) const
inline

Size with the closing segment, if it makes a difference.

If the closing segment is degenerate, i.e. its initial and final points are exactly equal, then it is not included in this size.

Definition at line 481 of file path.h.

References _closing_seg, _data, and Geom::BezierCurveN< degree >::isDegenerate().

Referenced by appendPortionTo(), appendPortionTo(), end_closed(), end_closed(), nodes(), and size_default().

◆ size_default()

◆ size_open()

size_type Geom::Path::size_open ( ) const
inline

◆ snapEnds()

void Path::snapEnds ( Coord  precision = EPSILON)

Reduce the closing segment to a point if it's shorter than precision.

Do this by moving the final point.

Definition at line 969 of file path.cpp.

References _closed, _closing_seg, _data, _unshare(), Geom::are_near(), Geom::BezierCurve::finalPoint(), Geom::BezierCurve::length(), setFinal(), and Geom::BezierCurve::setInitial().

Referenced by Inkscape::LivePathEffect::LPEFillBetweenMany::doEffect(), and Inkscape::LivePathEffect::LPEFillBetweenStrokes::doEffect().

◆ start()

void Path::start ( Point const &  p)

Definition at line 426 of file path.cpp.

References _closing_seg, _data, clear(), Geom::BezierCurve::setFinal(), and Geom::BezierCurve::setInitial().

Referenced by Geom::PlanarGraph< EdgeLabel >::_mergeShorterLonger(), Inkscape::ObjectSnapper::_snapPathsConstrained(), Inkscape::LivePathEffect::LPECopyRotate::addCanvasIndicators(), Inkscape::LivePathEffect::LPEMirrorSymmetry::addCanvasIndicators(), Inkscape::LivePathEffect::LPESlice::addCanvasIndicators(), Inkscape::LivePathEffect::LPETransform2Pts::addCanvasIndicators(), Inkscape::Text::Layout::baseline(), Inkscape::UI::Tools::MeasureTool::createAngleDisplayCurve(), Inkscape::LivePathEffect::LPEMeasureSegments::createLine(), Inkscape::LivePathEffect::LPEFilletChamfer::doEffect_path(), Inkscape::LivePathEffect::LPETransform2Pts::doEffect_pwd2(), Inkscape::LivePathEffect::LPEShowHandles::drawHandleLine(), Inkscape::LivePathEffect::LPESimplify::drawHandleLine(), Inkscape::UI::Tools::fit_item(), Inkscape::half_outline(), Geom::Interpolate::Linear::interpolateToPath(), Geom::Interpolate::CubicBezierFit::interpolateToPath(), Geom::Interpolate::CubicBezierJohan::interpolateToPath(), Geom::Interpolate::CubicBezierSmooth::interpolateToPath(), interpolateToPath(), interpolateToPath2(), Path::MakePathVector(), Spiro::ConverterPath::moveto(), Geom::PathIteratorSink< OutputIterator >::moveTo(), pathv_to_cubicbezier(), pathv_to_linear(), pathv_to_linear_and_cubic_beziers(), Inkscape::Extension::Internal::PrintEmf::pathv_to_simple_polygon(), Inkscape::Extension::Internal::PrintMetafile::rect_cutter(), Inkscape::LivePathEffect::LPEBendPath::resetDefaults(), Inkscape::LivePathEffect::LPECurveStitch::resetDefaults(), Inkscape::LivePathEffect::LPEEnvelope::resetDefaults(), Inkscape::UI::Tools::MeasureTool::setLine(), Inkscape::UI::Tools::MeasureTool::showCanvasItems(), TEST_F(), and wrap_path().

◆ stitch()

void Geom::Path::stitch ( Sequence::iterator  first_replaced,
Sequence::iterator  last_replaced,
Sequence sequence 
)
private

◆ stitchTo()

void Path::stitchTo ( Point const &  p)

Append a stitching segment ending at the specified point.

Definition at line 932 of file path.cpp.

References _closing_seg, _exception_on_stitch, _unshare(), do_append(), empty(), and Geom::BezierCurve::initialPoint().

Referenced by append(), append(), append(), and appendPortionTo().

◆ swap()

void Geom::Path::swap ( Path other)
inlinenoexcept

Swap contents with another path.

Todo:
Add noexcept specifiers for C++11

Definition at line 424 of file path.h.

References _closed, _closing_seg, _data, _exception_on_stitch, and swap.

◆ timeRange()

Interval Path::timeRange ( ) const

Get the allowed range of time values.

Returns
Values for which pointAt() and valueAt() yield valid results.

Definition at line 434 of file path.cpp.

References size_default().

Referenced by Geom::parting_point().

◆ toPwSb()

◆ valueAt() [1/2]

Coord Path::valueAt ( Coord  t,
Dim2  d 
) const

Get one coordinate (X or Y) at the specified time value.

Definition at line 454 of file path.cpp.

References _factorTime(), and valueAt().

Referenced by Geom::path_mono_splits(), TEST_F(), and valueAt().

◆ valueAt() [2/2]

Coord Path::valueAt ( PathTime const &  pos,
Dim2  d 
) const

Get one coordinate at the specified path time.

Definition at line 467 of file path.cpp.

References at(), Geom::PathTime::curve_index, Geom::PathTime::t, and Geom::Curve::valueAt().

◆ winding()

int Path::winding ( Point const &  p) const

Determine the winding number at the specified point.

The winding number is the number of full turns made by a ray that connects the passed point and the path's value (i.e. the result of the pointAt() method) as the time increases from 0 to the maximum valid value. Positive numbers indicate turns in the direction of increasing angles.

Winding numbers are often used as the definition of what is considered "inside" the shape. Typically points with either nonzero winding or odd winding are considered to be inside the path.

Definition at line 595 of file path.cpp.

References begin(), bounds, end_closed(), Geom::GenericRect< C >::height(), Geom::GenericRect< C >::left(), Geom::GenericRect< C >::right(), Geom::X, and Geom::Y.

Referenced by Inkscape::find_interior_point(), Inkscape::UI::ControlPointSelection::selectArea(), TEST_F(), and Geom::winding().

◆ withoutDegenerateCurves()

Path Path::withoutDegenerateCurves ( ) const

Return a copy of the path without degenerate curves, except possibly for a degenerate closing segment.

Definition at line 979 of file path.cpp.

References _closed, begin(), end_open(), result, and size().

Friends And Related Symbol Documentation

◆ operator*

template<typename T >
Path operator* ( Path const &  path,
T const &  tr 
)
friend

Definition at line 544 of file path.h.

◆ swap

void swap ( Path a,
Path b 
)
friend

Swap contents of two paths.

Definition at line 433 of file path.h.

Referenced by allNearestTimes(), and swap().

Member Data Documentation

◆ _closed

◆ _closing_seg

◆ _data

◆ _exception_on_stitch

bool Geom::Path::_exception_on_stitch
private

Definition at line 863 of file path.h.

Referenced by do_update(), setStitching(), stitchTo(), and swap().


The documentation for this class was generated from the following files: