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

Path and its polyline approximation. More...

#include <Path.h>

Classes

struct  cut_position
 
struct  ForcedSubdivision
 
struct  path_lineto
 Points of the polyline approximation. More...
 

Public Member Functions

 ~Path ()
 
void Reset ()
 Clears all stored path commands and resets flags that are used by command functions while adding path commands.
 
void Copy (Path *who)
 Clear all stored path commands, resets flags and imports path commands from the passed Path object.
 
int ForcePoint ()
 Appends a forced point path command.
 
int Close ()
 Appends a close path command.
 
int MoveTo (Geom::Point const &ip)
 Appends a MoveTo path command.
 
int LineTo (Geom::Point const &ip)
 Appends a LineTo path command.
 
int CubicTo (Geom::Point const &ip, Geom::Point const &iStD, Geom::Point const &iEnD)
 Appends a CubicBezier path command.
 
int ArcTo (Geom::Point const &ip, double iRx, double iRy, double angle, bool iLargeArc, bool iClockwise)
 Appends an ArcTo path command.
 
void Convert (double treshhold)
 Creates a polyline approximation of the path.
 
void ConvertEvenLines (double treshhold)
 Creates a polyline approximation of the path.
 
void ConvertWithBackData (double threshhold, bool relative=false)
 Creates a polyline approximation of the path.
 
void SetBackData (bool nVal)
 Sets the back variable to the value passed in and clears the polyline approximation.
 
void ResetPoints ()
 Clears the polyline approximation.
 
void Fill (Shape *dest, int pathID=-1, bool justAdd=false, bool closeIfNeeded=true, bool invert=false)
 Fills the shape with the polyline approximation stored in this object.
 
void Stroke (Shape *dest, bool doClose, double width, JoinType join, ButtType butt, double miter, bool justAdd=false)
 
void Outline (Path *dest, double width, JoinType join, ButtType butt, double miter)
 
void OutsideOutline (Path *dest, double width, JoinType join, ButtType butt, double miter)
 
void InsideOutline (Path *dest, double width, JoinType join, ButtType butt, double miter)
 
void Simplify (double treshhold)
 Simplify the path.
 
void Coalesce (double tresh)
 Simplify the path with a different approach.
 
void PointAt (int piece, double at, Geom::Point &pos)
 
void PointAndTangentAt (int piece, double at, Geom::Point &pos, Geom::Point &tgt)
 
const Geom::Point PrevPoint (const int i) const
 
void DashPolyline (float head, float tail, float body, int nbD, const float dashs[], bool stPlain, float stOffset)
 
void DashPolylineFromStyle (SPStyle *style, float scale, float min_len)
 
void LoadPath (Geom::Path const &path, Geom::Affine const &tr, bool doTransformation, bool append=false)
 Load a lib2geom Geom::Path in this path object.
 
void LoadPathVector (Geom::PathVector const &pv, Geom::Affine const &tr, bool doTransformation)
 Load a lib2geom Geom::PathVector in this path object.
 
void LoadPathVector (Geom::PathVector const &pv)
 Load a lib2geom Geom::PathVector in this path object.
 
void LoadPathVector (Geom::PathVector const &pv, std::vector< Geom::PathVectorTime > const &cuts)
 Load a lib2geom Geom::PathVector in this path object, plus a list of forced subdivision points.
 
Geom::PathVector MakePathVector () const
 Create a lib2geom Geom::PathVector from this Path object.
 
void Transform (const Geom::Affine &trans)
 Apply a transformation on all path commands.
 
Path ** SubPaths (int &outNb, bool killNoSurf)
 
Path ** SubPathsWithNesting (int &outNb, bool killNoSurf, int nbNest, int *nesting, int *conts)
 
double Surface ()
 
void PolylineBoundingBox (double &l, double &t, double &r, double &b)
 
void FastBBox (double &l, double &t, double &r, double &b)
 
double Length ()
 
void ConvertForcedToMoveTo ()
 
void ConvertForcedToVoid ()
 
cut_positionCurvilignToPosition (int nbCv, double *cvAbs, int &nbCut)
 
cut_position PointToCurvilignPosition (Geom::Point const &pos, unsigned seg=0) const
 
double PositionToLength (int piece, double t)
 
void ConvertPositionsToMoveTo (int nbPos, cut_position *poss)
 
void ConvertPositionsToForced (int nbPos, cut_position *poss)
 
void Affiche ()
 
std::string svg_dump_path () const
 
bool IsLineSegment (int piece)
 

Public Attributes

std::vector< PathDescr * > descr_cmd
 
std::vector< path_linetopts
 

Private Types

enum  { descr_ready = 0 , descr_doing_subpath = 2 , descr_dirty = 16 }
 

Private Member Functions

int AddPoint (Geom::Point const &iPt, bool mvto=false)
 Adds a point to the polyline approximation's list of points.
 
int AddPoint (Geom::Point const &iPt, int ip, double it, bool mvto=false)
 Adds a point to the polyline approximation's list of points.
 
int AddForcedPoint ()
 Adds a forced point to the polyline approximation's list of points.
 
void CloseSubpath ()
 
void InsertMoveTo (Geom::Point const &iPt, int at)
 
void InsertForcePoint (int at)
 
void InsertLineTo (Geom::Point const &iPt, int at)
 
void InsertArcTo (Geom::Point const &ip, double iRx, double iRy, double angle, bool iLargeArc, bool iClockwise, int at)
 
void InsertCubicTo (Geom::Point const &ip, Geom::Point const &iStD, Geom::Point const &iEnD, int at)
 
void DashSubPath (int spL, int spP, std::vector< path_lineto > const &orig_pts, float head, float tail, float body, int nbD, const float dashs[], bool stPlain, float stOffset)
 
void DoArc (Geom::Point const &iS, Geom::Point const &iE, double rx, double ry, double angle, bool large, bool wise, double tresh)
 The function is quite similar to RecCubicTo.
 

Private Attributes

int descr_flags = descr_ready
 
bool back = false
 
std::vector< ForcedSubdivisionforced_subdivisions
 

Friends

class Shape
 

Detailed Description

Path and its polyline approximation.

A Path is exactly analogous to an SVG path element. Like the SVG path element, this class stores path commands. A Path can be approximated by line segments and this approximation is known as a "polyline approximation". Internally, the polyline approximation is stored as a set of points.

Each path command (except the MoveTo), creates a new segment. A path segment can be defined as a function of time over the interval [0, 1]. Each point in the polyline approximation can store the index of the path command that created the path segment that it came from and the time value at which it existed. The midpoint of a line segment would be at

\[ t = 0.5 \]

for example. This information is known as "back data" since it preserves the information about the original segments that existed in the path and can help us recreate them or their portions back. Note that the first point of a subpath stores the index of the moveTo command.

To use this class create a new instance. Call the command functions such as Path::MoveTo, Path::LineTo, Path::CubicTo, etc to append path commands. Then call one of Path::Convert, Path::ConvertEvenLines or Path::ConvertWithBackData to generate the polyline approximation. Then you can do simplification by calling Path::Simplify or fill a Shape by calling Path::Fill on the shape to use features such as Offsetting, Boolean Operations and Tweaking.

Path *path = new Path;
path->MoveTo(Geom::Point(10, 10));
path->LineTo(Geom::Point(100, 10));
path->LineTo(Geom::Point(100, 100));
path->Close();
path->ConvertEvenLines(0.001); // You can use the other variants too
// insteresting stuff here

Definition at line 92 of file Path.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
private
Enumerator
descr_ready 
descr_doing_subpath 
descr_dirty 

Definition at line 97 of file Path.h.

Constructor & Destructor Documentation

◆ ~Path()

Path::~Path ( )

Definition at line 26 of file Path.cpp.

References descr_cmd.

Member Function Documentation

◆ AddForcedPoint()

int Path::AddForcedPoint ( )
private

Adds a forced point to the polyline approximation's list of points.

The point that gets added as a forced point has the same coordinates as the last point that was added (and the same backdata too, if backdata is enabled). If no points exist or the last one isn't a lineto, nothing gets added.

Returns
Index of the point added if it was added, -1 otherwise.

Definition at line 284 of file Path.cpp.

References back, polyline_forced, polyline_lineto, and pts.

Referenced by Convert(), ConvertEvenLines(), and ConvertWithBackData().

◆ AddPoint() [1/2]

int Path::AddPoint ( Geom::Point const &  iPt,
bool  mvto = false 
)
private

Adds a point to the polyline approximation's list of points.

This is used internally by Path::Convert and its variants, so you'd not need to use it by yourself.

If back variable of the instance is set to true, dummy back data will be used with the point. Piece being -1 and time being 0. Since this function doesn't take any back data you'll have to fill in something.

The point doesn't get added if it's a lineto and the point before it has the same coordinates.

Parameters
iPtThe point itself.
mvtoIf true, it's a moveTo otherwise it's a lineto.
Returns
Index of the point added if it was added, -1 otherwise.

Definition at line 254 of file Path.cpp.

References AddPoint(), back, polyline_lineto, polyline_moveto, and pts.

Referenced by AddPoint(), AddPoint(), Convert(), ConvertEvenLines(), ConvertWithBackData(), DashSubPath(), and DoArc().

◆ AddPoint() [2/2]

int Path::AddPoint ( Geom::Point const &  iPt,
int  ip,
double  it,
bool  mvto = false 
)
private

Adds a point to the polyline approximation's list of points.

Let's you specify back data.

This is used internally by Path::Convert and its variants, so you'd not need to use it by yourself.

Parameters
iPtThe point itself.
ipThe index of the path command that created the segment that this point belongs to.
itThe time in that path segment at which this point exists. 0 is beginning and 1 is end.
mvtoIf true, it's a moveTo otherwise it's a lineto.

The point doesn't get added if it's a lineto and the point before it has the same coordinates.

Returns
Index of the point added if it was added, -1 otherwise.

Definition at line 269 of file Path.cpp.

References AddPoint(), back, polyline_lineto, polyline_moveto, and pts.

◆ Affiche()

void Path::Affiche ( )

Definition at line 34 of file Path.cpp.

References descr_cmd.

◆ ArcTo()

int Path::ArcTo ( Geom::Point const &  ip,
double  iRx,
double  iRy,
double  angle,
bool  iLargeArc,
bool  iClockwise 
)

Appends an ArcTo path command.

The parameters are identical to the SVG elliptical arc command.

Parameters
ipThe final point of the arc.
iRxThe radius in the x direction.
iRyThe radius in the y direction.
angleThe angle w.r.t x axis in degrees. TODO: Confirm this
iLargeArcIf true, it's the larger arc, if false, it's the smaller one.
iClockwiseIf true, it's the clockwise arc, if false, it's the anti-clockwise one.
Returns
The index of the path description added.

Definition at line 200 of file Path.cpp.

References descr_cmd, descr_doing_subpath, descr_flags, and MoveTo().

Referenced by ConvertPositionsToMoveTo(), InsertArcTo(), InsideOutline(), Outline(), Shape::ReFormeArcTo(), SubPaths(), and SubPathsWithNesting().

◆ Close()

int Path::Close ( )

Appends a close path command.

Close path command can't be appended if there is no acive subpath.

Returns
Index of the path command in the path commands array if it got appended, -1 otherwise.

Definition at line 109 of file Path.cpp.

References CloseSubpath(), descr_cmd, descr_doing_subpath, and descr_flags.

Referenced by Shape::AddContour(), ConvertPositionsToMoveTo(), Shape::ConvertToForme(), InsideOutline(), LoadPath(), LoadPathVector(), Outline(), SubPaths(), and SubPathsWithNesting().

◆ CloseSubpath()

void Path::CloseSubpath ( )
private

◆ Coalesce()

void Path::Coalesce ( double  tresh)

Simplify the path with a different approach.

This function is also supposed to do simplification but by merging (coalescing) existing path descriptions instead of doing any fitting. But I seriously doubt whether this is useful at all or works at all. More experimentation needed. TODO

Parameters
thresholdThe threshold for simplification.

Definition at line 1310 of file PathSimplify.cpp.

References PathDescr::associated, CloseSubpath(), ConvertEvenLines(), Copy(), descr_arcto, descr_close, descr_cmd, descr_cubicto, descr_doing_subpath, descr_flags, descr_forced, descr_lineto, descr_moveto, PathDescrMoveTo::p, and SetBackData().

◆ Convert()

void Path::Convert ( double  treshhold)

Creates a polyline approximation of the path.

Doesn't keep any back data. Line segments are not split into smaller line segments.

Threshold has no strict definition. It means different things for each path segment.

Parameters
threshholdThe error threshold used to approximate curves by line segments. The smaller this is, the more line segments there will be.

Definition at line 145 of file PathConversion.cpp.

References AddForcedPoint(), AddPoint(), PathDescrArcTo::angle, PathDescrArcTo::clockwise, CloseSubpath(), descr_arcto, descr_close, descr_cmd, descr_cubicto, descr_doing_subpath, descr_flags, descr_forced, descr_lineto, descr_moveto, DoArc(), PathDescrCubicTo::end, PathDescrArcTo::large, PathDescrMoveTo::p, PathDescrLineTo::p, PathDescrCubicTo::p, PathDescrArcTo::p, pts, ResetPoints(), PathDescrArcTo::rx, PathDescrArcTo::ry, SetBackData(), and PathDescrCubicTo::start.

Referenced by extract_shape(), SPOffset::set_shape(), sp_offset_top_point(), SubPaths(), and SubPathsWithNesting().

◆ ConvertEvenLines()

void Path::ConvertEvenLines ( double  treshhold)

Creates a polyline approximation of the path.

Line segments are split into further smaller line segments such that each of those line segments is no bigger than threshold.

Breaking up into further smaller line segments is useful for path simplification as you can then fit cubic Bezier patches on those small line segments.

Threshold has no strict definition. It means different things for each path segment.

Parameters
threshholdThe error threshold used to approximate the path. The smaller this is, the more line segments there will be and the better the polyline approximation would be.

Definition at line 270 of file PathConversion.cpp.

References AddForcedPoint(), AddPoint(), PathDescrArcTo::angle, PathDescrArcTo::clockwise, CloseSubpath(), descr_arcto, descr_close, descr_cmd, descr_cubicto, descr_doing_subpath, descr_flags, descr_forced, descr_lineto, descr_moveto, DoArc(), PathDescrCubicTo::end, Geom::L2(), PathDescrArcTo::large, Geom::LInfty(), PathDescrMoveTo::p, PathDescrLineTo::p, PathDescrCubicTo::p, PathDescrArcTo::p, pts, ResetPoints(), PathDescrArcTo::rx, PathDescrArcTo::ry, SetBackData(), and PathDescrCubicTo::start.

Referenced by Coalesce(), Inkscape::UI::Tools::do_trace(), SPOffset::set_shape(), sp_selected_path_do_offset(), and Inkscape::UI::Tools::sp_tweak_dilate_recursive().

◆ ConvertForcedToMoveTo()

◆ ConvertForcedToVoid()

void Path::ConvertForcedToVoid ( )

Definition at line 661 of file PathCutting.cpp.

References descr_cmd, and descr_forced.

◆ ConvertPositionsToForced()

◆ ConvertPositionsToMoveTo()

◆ ConvertWithBackData()

void Path::ConvertWithBackData ( double  threshhold,
bool  relative = false 
)

Creates a polyline approximation of the path.

Line segments are not split into smaller line segments. Stores back data for later recomposition.

Threshold has no strict definition. It means different things for each path segment.

Parameters
threshholdThe error threshold used to approximate the path. The smaller this is, the more line segments there will be and the better the polyline approximation would be.
relativeWhether to interpret threshold relatively, rather than absolutely.

Definition at line 26 of file PathConversion.cpp.

References AddForcedPoint(), AddPoint(), CloseSubpath(), descr_arcto, descr_close, descr_cmd, descr_cubicto, descr_doing_subpath, descr_flags, descr_forced, descr_lineto, descr_moveto, DoArc(), forced_subdivisions, pts, ResetPoints(), and SetBackData().

Referenced by Inkscape::UI::Tools::TextTool::_updateCursor(), Inkscape::UI::Tools::do_trace(), refresh_textpath_source(), and SPOffset::set_shape().

◆ Copy()

void Path::Copy ( Path who)

Clear all stored path commands, resets flags and imports path commands from the passed Path object.

Parameters
whoPath object whose path commands to copy.

Definition at line 57 of file Path.cpp.

References descr_cmd, forced_subdivisions, and ResetPoints().

Referenced by Inkscape::ObjectSet::_pathBoolOp(), Coalesce(), and ConvertPositionsToMoveTo().

◆ CubicTo()

int Path::CubicTo ( Geom::Point const &  ip,
Geom::Point const &  iStD,
Geom::Point const &  iEnD 
)

Appends a CubicBezier path command.

In order to understand the parameters let p0, p1, p2, p3 denote the four points of a cubic Bezier curve. p0 is the start point. p3 is the end point. p1 and p2 are the two control points.

Parameters
ipThe final point of the bezier curve or p3.
iStD3 * (p1 - p0). Weird way to store it but that's how it is.
iEnD3 * (p3 - p2). Weird way to store it but that's how it is.
Returns
The index of the path description added.

Definition at line 175 of file Path.cpp.

References descr_cmd, descr_doing_subpath, descr_flags, and MoveTo().

Referenced by ConvertPositionsToMoveTo(), InsertCubicTo(), InsideOutline(), Outline(), Shape::ReFormeCubicTo(), SubPaths(), and SubPathsWithNesting().

◆ CurvilignToPosition()

Path::cut_position * Path::CurvilignToPosition ( int  nbCv,
double *  cvAbs,
int &  nbCut 
)

◆ DashPolyline()

void Path::DashPolyline ( float  head,
float  tail,
float  body,
int  nbD,
const float  dashs[],
bool  stPlain,
float  stOffset 
)

Definition at line 32 of file PathCutting.cpp.

References DashSubPath(), polyline_moveto, and pts.

Referenced by DashPolylineFromStyle().

◆ DashPolylineFromStyle()

void Path::DashPolylineFromStyle ( SPStyle style,
float  scale,
float  min_len 
)

◆ DashSubPath()

void Path::DashSubPath ( int  spL,
int  spP,
std::vector< path_lineto > const &  orig_pts,
float  head,
float  tail,
float  body,
int  nbD,
const float  dashs[],
bool  stPlain,
float  stOffset 
)
private

Definition at line 93 of file PathCutting.cpp.

References AddPoint(), back, and Geom::L2().

Referenced by DashPolyline().

◆ DoArc()

void Path::DoArc ( Geom::Point const &  iS,
Geom::Point const &  iE,
double  rx,
double  ry,
double  angle,
bool  large,
bool  wise,
double  tresh 
)
private

The function is quite similar to RecCubicTo.

Some of the maths, specially that in ArcAnglesAndCenter is too cryptic and I have not spent enough time deriving it yet either. The important thing is how the Arc is split into line segments and that I can explain. Given the threshold and the two radii, a maximum angle is calculated. This angle is a measure of how big a sub-arc you can substitute with a line segment without breaking the threshold. Then you divide the whole arc into sectors such that each one's angle is under or equal to maximum angle.

In this image, the red dashed arc is the actual arc that was to be approximated. The blue arcs are sectors, each one having an angle equal to or smaller than maximum angle (which is 20 degrees) in this example. The final polyline approximation is shown by the pink dotted line segments.

TODO: Understand the maths in ArcAnglesAndCenter and how the maximum angle is calculated.

Definition at line 564 of file PathConversion.cpp.

References AddPoint(), and ArcAnglesAndCenter().

Referenced by Convert(), ConvertEvenLines(), and ConvertWithBackData().

◆ FastBBox()

void Path::FastBBox ( double &  l,
double &  t,
double &  r,
double &  b 
)

◆ Fill()

void Path::Fill ( Shape dest,
int  pathID = -1,
bool  justAdd = false,
bool  closeIfNeeded = true,
bool  invert = false 
)

Fills the shape with the polyline approximation stored in this object.

For each line segment in the polyline approximation, an edge is created in the shape.

One important point to highlight is the closeIfNeeded argument. For each subpath (where a sub path is a moveTo followed by one or more lineTo points) you can either have the start and end points being identical or very close (a closed contour) or have them apart (an open contour). If you set closeIfNeeded to true, it'll automatically add a closing segment if needed and close an open contour by itself. If your contour is already closed, it makes sure that the first and last point are the same ones in the graph (instead of being two indentical points). If closeIfNeeded is false, it just doesn't care at all. Even if your contour is closed, the first and last point will be separate (even though they would be duplicates).

Parameters
destThe shape to fill.
pathIDA unique number for this path. The shape will associate this number with each edge that comes from this path. Later on, when you use Shape::ConvertToForme you'll pass an array of Path objects (named orig) and the shape will use that pathID to do orig[pathID] and get the original path information.
justAddIf set to true, this will function will just fill stuff in without resetting any existing stuff in Shape. If set to false, it'll make sure to reset the shape and already make room for the maximum number of possible points and edges.
closeIfNeededIf set to true, the graph will be closed always. Otherwise, it won't be closed.
invertIf set to true, the graph is drawn exactly in the manner opposite to the actual polyline approximation that this object stores, if false, it's stored indentical to how it's in the polyline approximation.
Todo:
"the graph is drawn exactly in the manner opposite"? Does this mean the edges of the directed graph are reversed?

Definition at line 833 of file PathConversion.cpp.

References Shape::AddEdge(), Shape::AddPoint(), back, Shape::ConnectEnd(), Shape::ConnectStart(), Shape::DisconnectEnd(), Shape::DisconnectStart(), Shape::ebData, invert(), Geom::LInfty(), Shape::MakeBackData(), Shape::numberOfPoints(), polyline_moveto, pts, and Shape::Reset().

Referenced by Inkscape::UI::Tools::TextTool::_updateCursor(), Inkscape::UI::Tools::do_trace(), extract_shape(), make_shape(), SPOffset::set_shape(), and sp_offset_top_point().

◆ ForcePoint()

int Path::ForcePoint ( )

Appends a forced point path command.

Forced points are places in the path which are preferred to be kept in the simplification algorithm. The simplification algorithm will try to retain those points. This can be beneficial in situations such as self-intersections where we would want the intersection point to remain unchanged after any simplification is done.

TODO: Confirm this with some testing.

A forced point command can't be appended if there is no active subpath that we are drawing on. If you imagine calling these command functions as giving instructions to a pen, a forced point command requires that the pen is already touching the canvas. The pen is not on the canvas when you instantiate the Path object and it also leaves it when you call Path::Close. The term "active subpath" simply means that the pen is already touching the canvas.

Returns
Index of the path command in the path commands array if it got appended, -1 otherwise.

Definition at line 80 of file Path.cpp.

References descr_cmd, descr_doing_subpath, and descr_flags.

Referenced by Shape::AddContour(), and InsertForcePoint().

◆ InsertArcTo()

void Path::InsertArcTo ( Geom::Point const &  ip,
double  iRx,
double  iRy,
double  angle,
bool  iLargeArc,
bool  iClockwise,
int  at 
)
private

Definition at line 212 of file Path.cpp.

References ArcTo(), and descr_cmd.

Referenced by ConvertPositionsToForced().

◆ InsertCubicTo()

void Path::InsertCubicTo ( Geom::Point const &  ip,
Geom::Point const &  iStD,
Geom::Point const &  iEnD,
int  at 
)
private

Definition at line 186 of file Path.cpp.

References CubicTo(), and descr_cmd.

Referenced by ConvertPositionsToForced().

◆ InsertForcePoint()

void Path::InsertForcePoint ( int  at)
private

Definition at line 95 of file Path.cpp.

References descr_cmd, and ForcePoint().

Referenced by ConvertPositionsToForced().

◆ InsertLineTo()

void Path::InsertLineTo ( Geom::Point const &  iPt,
int  at 
)
private

Definition at line 161 of file Path.cpp.

References descr_cmd, and LineTo().

Referenced by ConvertPositionsToForced().

◆ InsertMoveTo()

void Path::InsertMoveTo ( Geom::Point const &  iPt,
int  at 
)
private

Definition at line 137 of file Path.cpp.

References descr_cmd, and MoveTo().

◆ InsideOutline()

◆ IsLineSegment()

bool Path::IsLineSegment ( int  piece)

Definition at line 590 of file Path.cpp.

References descr_cmd, descr_lineto, and PathDescr::getType().

◆ Length()

double Path::Length ( )
Returns
Length of the lines in the pts vector.

Definition at line 431 of file PathCutting.cpp.

References Geom::L2(), len, polyline_moveto, and pts.

Referenced by sp_textpath_to_text().

◆ LineTo()

int Path::LineTo ( Geom::Point const &  ip)

Appends a LineTo path command.

Parameters
ipThe point to draw a line to.
Returns
The index of the path description added.

Definition at line 151 of file Path.cpp.

References descr_cmd, descr_doing_subpath, descr_flags, and MoveTo().

Referenced by Shape::AddContour(), ConvertPositionsToMoveTo(), Shape::ConvertToForme(), InsertLineTo(), InsideOutline(), Outline(), Shape::ReFormeLineTo(), SubPaths(), and SubPathsWithNesting().

◆ LoadPath()

void Path::LoadPath ( Geom::Path const &  path,
Geom::Affine const &  tr,
bool  doTransformation,
bool  append = false 
)

Load a lib2geom Geom::Path in this path object.

append is false by default: it means that the path should be resetted.

The Geom::Path object is read and path commands making it up are appended in the Path object.

Parameters
pathThe Geom::Path object to load.
trA transformation matrix.
doTransformationIf set to true, the transformation matrix tr is applied on the path before it's loaded in this path object.
appendIf set to true, any existing path commands in this object are retained. If set to false, any existing path commands will be cleared.

If it is true, the path is not resetted and Geom::Path will be appended as a new path

Definition at line 351 of file PathCutting.cpp.

References append(), Close(), Geom::Path::closed(), Geom::Path::empty(), Geom::Path::initialPoint(), MoveTo(), Reset(), and SetBackData().

Referenced by LoadPathVector().

◆ LoadPathVector() [1/3]

void Path::LoadPathVector ( Geom::PathVector const &  pv)

Load a lib2geom Geom::PathVector in this path object.

Any existing path commands in this object are cleared.

Parameters
pvA reference to the Geom::PathVector object to load.

Definition at line 376 of file PathCutting.cpp.

References LoadPathVector().

◆ LoadPathVector() [2/3]

void Path::LoadPathVector ( Geom::PathVector const &  pv,
Geom::Affine const &  tr,
bool  doTransformation 
)

Load a lib2geom Geom::PathVector in this path object.

(supports transformation)

Any existing path commands in this object are cleared.

Parameters
pvThe Geom::PathVector object to load.
trA transformation to apply on each path.
doTransformationIf set to true, the transformation in tr is applied.

Definition at line 417 of file PathCutting.cpp.

References LoadPath(), Reset(), and SetBackData().

Referenced by Inkscape::UI::Tools::PencilTool::_sketchInterpolate(), Inkscape::UI::Tools::TextTool::_updateCursor(), Inkscape::UI::Tools::do_trace(), extract_shape(), LoadPathVector(), make_path(), refresh_textpath_source(), sp_offset_top_point(), and Transform().

◆ LoadPathVector() [3/3]

void Path::LoadPathVector ( Geom::PathVector const &  pv,
std::vector< Geom::PathVectorTime > const &  cuts 
)

Load a lib2geom Geom::PathVector in this path object, plus a list of forced subdivision points.

Any existing path commands in this object are cleared.

Parameters
pvA reference to the Geom::PathVector object to load.
cutsA list of times where ConvertWithBackData() should insert forced subdivisions, sorted ascending.

Definition at line 381 of file PathCutting.cpp.

References Close(), descr_cmd, forced_subdivisions, MoveTo(), Reset(), SetBackData(), and Geom::PathVector::size().

◆ MakePathVector()

Geom::PathVector Path::MakePathVector ( ) const

Create a lib2geom Geom::PathVector from this Path object.

Make a Geom::PathVector version of the path description.

Looks like the time this was written Geom::PathBuilder didn't exist or maybe the author wasn't aware of it.

Returns
The Geom::PathVector created.
A PathVector copy of the path description

Definition at line 274 of file PathCutting.cpp.

References Geom::Path::appendNew(), Geom::PathVector::back(), c, Geom::Path::close(), data, descr_arcto, descr_close, descr_cmd, descr_cubicto, descr_lineto, descr_moveto, Geom::PathVector::push_back(), and Geom::Path::start().

Referenced by Inkscape::UI::Tools::PencilTool::_sketchInterpolate(), Inkscape::UI::Tools::TextTool::_updateCursor(), flattened(), and Transform().

◆ MoveTo()

int Path::MoveTo ( Geom::Point const &  ip)

Appends a MoveTo path command.

Parameters
ipThe point to move to.
Returns
The index of the path description added.

Definition at line 125 of file Path.cpp.

References CloseSubpath(), descr_cmd, descr_doing_subpath, and descr_flags.

Referenced by Shape::AddContour(), ArcTo(), ConvertPositionsToMoveTo(), Shape::ConvertToForme(), CubicTo(), InsertMoveTo(), InsideOutline(), LineTo(), LoadPath(), LoadPathVector(), Outline(), SubPaths(), and SubPathsWithNesting().

◆ Outline()

◆ OutsideOutline()

void Path::OutsideOutline ( Path dest,
double  width,
JoinType  join,
ButtType  butt,
double  miter 
)

◆ PointAndTangentAt()

void Path::PointAndTangentAt ( int  piece,
double  at,
Geom::Point pos,
Geom::Point tgt 
)

◆ PointAt()

void Path::PointAt ( int  piece,
double  at,
Geom::Point pos 
)
Parameters
pieceIndex of a one of our commands.
atDistance along the segment that corresponds to ‘piece’ (0 <= at <= 1)
posFilled in with the point at ‘at’ on ‘piece’.

Definition at line 328 of file Path.cpp.

References descr_arcto, descr_close, descr_cmd, descr_cubicto, descr_forced, descr_lineto, descr_moveto, PathDescr::getType(), len, PointAt(), and PrevPoint().

Referenced by ConvertPositionsToForced(), get_point_on_Path(), and PointAt().

◆ PointToCurvilignPosition()

Path::cut_position Path::PointToCurvilignPosition ( Geom::Point const &  pos,
unsigned  seg = 0 
) const

◆ PolylineBoundingBox()

void Path::PolylineBoundingBox ( double &  l,
double &  t,
double &  r,
double &  b 
)

Definition at line 301 of file Path.cpp.

References pts, Geom::X, and Geom::Y.

Referenced by SPOffset::set_shape().

◆ PositionToLength()

double Path::PositionToLength ( int  piece,
double  t 
)

Definition at line 941 of file PathCutting.cpp.

References Geom::L2(), polyline_moveto, and pts.

◆ PrevPoint()

◆ Reset()

void Path::Reset ( )

Clears all stored path commands and resets flags that are used by command functions while adding path commands.

Definition at line 45 of file Path.cpp.

References descr_cmd, descr_flags, and forced_subdivisions.

Referenced by Shape::ConvertToForme(), Shape::ConvertToForme(), Shape::ConvertToFormeNested(), InsideOutline(), LoadPath(), LoadPathVector(), LoadPathVector(), Outline(), OutsideOutline(), Simplify(), sp_selected_path_do_offset(), and Inkscape::UI::Tools::sp_tweak_dilate_recursive().

◆ ResetPoints()

void Path::ResetPoints ( )

Clears the polyline approximation.

Definition at line 248 of file Path.cpp.

References pts.

Referenced by Convert(), ConvertEvenLines(), ConvertWithBackData(), Copy(), and SetBackData().

◆ SetBackData()

void Path::SetBackData ( bool  nVal)

Sets the back variable to the value passed in and clears the polyline approximation.

Parameters
nValTrue if we are going to have backdata and false otherwise.

Definition at line 232 of file Path.cpp.

References back, and ResetPoints().

Referenced by Coalesce(), Convert(), ConvertEvenLines(), ConvertWithBackData(), InsideOutline(), LoadPath(), LoadPathVector(), LoadPathVector(), Outline(), OutsideOutline(), SPOffset::set_shape(), sp_selected_path_create_offset_object(), sp_selected_path_do_offset(), Inkscape::UI::Tools::sp_tweak_dilate_recursive(), SubPaths(), and SubPathsWithNesting().

◆ Simplify()

void Path::Simplify ( double  treshhold)

Simplify the path.

Fit the least possible number of cubic Bezier patches on the polyline approximation while respecting the threshold (keeping the error small). The function clears existing path commands and the resulting cubic Bezier patches will be pushed as path commands in the instance.

The algorithm to fit cubic Bezier curves on the polyline approximation's points.

http://www.cs.mtu.edu/~shene/COURSES/cs3621/NOTES/INT-APP/CURVE-APP-global.html

Parameters
thresholdThe threshold for simplification. A measure of how much error is okay. The smaller this number is, the more conservative the fitting algorithm will be.

Definition at line 50 of file PathSimplify.cpp.

References polyline_forced, polyline_lineto, pts, and Reset().

Referenced by Inkscape::UI::Tools::PencilTool::_sketchInterpolate(), Inkscape::UI::Tools::do_trace(), SPOffset::set_shape(), sp_selected_path_do_offset(), and Inkscape::UI::Tools::sp_tweak_dilate_recursive().

◆ Stroke()

void Path::Stroke ( Shape dest,
bool  doClose,
double  width,
JoinType  join,
ButtType  butt,
double  miter,
bool  justAdd = false 
)

◆ SubPaths()

◆ SubPathsWithNesting()

◆ Surface()

double Path::Surface ( )

Definition at line 453 of file PathCutting.cpp.

References Geom::cross(), polyline_moveto, and pts.

Referenced by SPOffset::set_shape(), SubPaths(), and SubPathsWithNesting().

◆ svg_dump_path()

◆ Transform()

void Path::Transform ( const Geom::Affine trans)

Apply a transformation on all path commands.

Apply a transform in-place.

Done by calling the transform method on each path command.

Parameters
transThe transformation to apply.

Note: Converts to Geom::PathVector, applies the transform, and converts back.

Definition at line 422 of file Path.cpp.

References LoadPathVector(), and MakePathVector().

Referenced by Inkscape::ObjectSet::_pathBoolOp().

Friends And Related Symbol Documentation

◆ Shape

friend class Shape
friend

Definition at line 94 of file Path.h.

Member Data Documentation

◆ back

bool Path::back = false
private

If true, indicates that the polyline approximation is going to have backdata. No need to set this manually though. When Path::Convert or any of its variants is called, it's set automatically.

Definition at line 131 of file Path.h.

Referenced by AddForcedPoint(), AddPoint(), AddPoint(), CurvilignToPosition(), DashSubPath(), Fill(), Tracer::optimize(), and SetBackData().

◆ descr_cmd

◆ descr_flags

◆ forced_subdivisions

std::vector<ForcedSubdivision> Path::forced_subdivisions
private

Definition at line 140 of file Path.h.

Referenced by ConvertWithBackData(), Copy(), LoadPathVector(), and Reset().

◆ pts


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