Inkscape
Vector Graphics Editor
|
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_position * | CurvilignToPosition (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_lineto > | pts |
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< ForcedSubdivision > | forced_subdivisions |
Friends | |
class | Shape |
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
|
private |
|
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.
Definition at line 284 of file Path.cpp.
References back, polyline_forced, polyline_lineto, and pts.
Referenced by Convert(), ConvertEvenLines(), and ConvertWithBackData().
|
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.
iPt | The point itself. |
mvto | If true, it's a moveTo otherwise it's a lineto. |
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().
|
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.
iPt | The point itself. |
ip | The index of the path command that created the segment that this point belongs to. |
it | The time in that path segment at which this point exists. 0 is beginning and 1 is end. |
mvto | If 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.
Definition at line 269 of file Path.cpp.
References AddPoint(), back, polyline_lineto, polyline_moveto, and pts.
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.
ip | The final point of the arc. |
iRx | The radius in the x direction. |
iRy | The radius in the y direction. |
angle | The angle w.r.t x axis in degrees. TODO: Confirm this |
iLargeArc | If true, it's the larger arc, if false, it's the smaller one. |
iClockwise | If true, it's the clockwise arc, if false, it's the anti-clockwise one. |
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().
int Path::Close | ( | ) |
Appends a close path command.
Close path command can't be appended if there is no acive subpath.
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().
|
private |
Definition at line 75 of file Path.cpp.
References descr_doing_subpath, and descr_flags.
Referenced by Close(), Coalesce(), Convert(), ConvertEvenLines(), ConvertWithBackData(), InsideOutline(), MoveTo(), Outline(), and OutsideOutline().
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
threshold | The 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().
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.
threshhold | The 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().
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.
threshhold | The 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().
void Path::ConvertForcedToMoveTo | ( | ) |
Definition at line 672 of file PathCutting.cpp.
References descr_arcto, descr_close, descr_cmd, descr_cubicto, descr_forced, descr_lineto, descr_moveto, PathDescrMoveTo::p, PathDescrLineTo::p, PathDescrCubicTo::p, PathDescrArcTo::p, PathDescrForced::p, and PathDescrClose::p.
void Path::ConvertForcedToVoid | ( | ) |
Definition at line 661 of file PathCutting.cpp.
References descr_cmd, and descr_forced.
void Path::ConvertPositionsToForced | ( | int | nbPos, |
cut_position * | poss | ||
) |
Definition at line 955 of file PathCutting.cpp.
References PathDescrArcTo::angle, PathDescrArcTo::clockwise, CmpPosition(), delta, descr_arcto, descr_close, descr_cmd, descr_cubicto, descr_doing_subpath, descr_flags, descr_forced, descr_lineto, descr_moveto, PathDescrCubicTo::end, InsertArcTo(), InsertCubicTo(), InsertForcePoint(), InsertLineTo(), PathDescrArcTo::large, len, PathDescrMoveTo::p, PathDescrLineTo::p, PathDescrCubicTo::p, PathDescrArcTo::p, PathDescrForced::p, Path::cut_position::piece, PointAt(), PrevPoint(), PathDescrArcTo::rx, PathDescrArcTo::ry, PathDescrCubicTo::start, and Path::cut_position::t.
Referenced by ConvertPositionsToMoveTo().
void Path::ConvertPositionsToMoveTo | ( | int | nbPos, |
cut_position * | poss | ||
) |
Definition at line 1154 of file PathCutting.cpp.
References PathDescrArcTo::angle, ArcTo(), PathDescrArcTo::clockwise, Close(), ConvertPositionsToForced(), Copy(), CubicTo(), descr_arcto, descr_close, descr_cmd, descr_cubicto, descr_forced, descr_lineto, descr_moveto, PathDescrCubicTo::end, PathDescrArcTo::large, LineTo(), Geom::LInfty(), MoveTo(), PathDescrMoveTo::p, PathDescrLineTo::p, PathDescrCubicTo::p, PathDescrArcTo::p, PrevPoint(), PathDescrArcTo::rx, PathDescrArcTo::ry, and PathDescrCubicTo::start.
Referenced by Inkscape::ObjectSet::_pathBoolOp().
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.
threshhold | The 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. |
relative | Whether 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().
void Path::Copy | ( | Path * | who | ) |
Clear all stored path commands, resets flags and imports path commands from the passed Path object.
who | Path 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().
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.
ip | The final point of the bezier curve or p3. |
iStD | 3 * (p1 - p0). Weird way to store it but that's how it is. |
iEnD | 3 * (p3 - p2). Weird way to store it but that's how it is. |
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().
Path::cut_position * Path::CurvilignToPosition | ( | int | nbCv, |
double * | cvAbs, | ||
int & | nbCut | ||
) |
Definition at line 791 of file PathCutting.cpp.
References back, CmpCurv(), Geom::L2(), len, Path::cut_position::piece, polyline_moveto, pts, and Path::cut_position::t.
Referenced by sp_textpath_to_text().
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().
void Path::DashPolylineFromStyle | ( | SPStyle * | style, |
float | scale, | ||
float | min_len | ||
) |
Definition at line 58 of file PathCutting.cpp.
References DashPolyline(), scale, SPStyle::stroke_dasharray, and SPStyle::stroke_dashoffset.
|
private |
Definition at line 93 of file PathCutting.cpp.
References AddPoint(), back, and Geom::L2().
Referenced by DashPolyline().
|
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().
void Path::FastBBox | ( | double & | l, |
double & | t, | ||
double & | r, | ||
double & | b | ||
) |
Definition at line 427 of file Path.cpp.
References descr_arcto, descr_cmd, descr_cubicto, descr_lineto, descr_moveto, PathDescrCubicTo::end, PathDescrMoveTo::p, PathDescrLineTo::p, PathDescrCubicTo::p, PathDescrArcTo::p, PathDescrCubicTo::start, Geom::X, and Geom::Y.
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).
dest | The shape to fill. |
pathID | A 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. |
justAdd | If 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. |
closeIfNeeded | If set to true, the graph will be closed always. Otherwise, it won't be closed. |
invert | If 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. |
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().
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.
Definition at line 80 of file Path.cpp.
References descr_cmd, descr_doing_subpath, and descr_flags.
Referenced by Shape::AddContour(), and InsertForcePoint().
|
private |
Definition at line 212 of file Path.cpp.
References ArcTo(), and descr_cmd.
Referenced by ConvertPositionsToForced().
|
private |
Definition at line 186 of file Path.cpp.
References CubicTo(), and descr_cmd.
Referenced by ConvertPositionsToForced().
|
private |
Definition at line 95 of file Path.cpp.
References descr_cmd, and ForcePoint().
Referenced by ConvertPositionsToForced().
|
private |
Definition at line 161 of file Path.cpp.
References descr_cmd, and LineTo().
Referenced by ConvertPositionsToForced().
|
private |
Definition at line 197 of file PathOutline.cpp.
References PathDescrArcTo::angle, ArcTo(), PathDescrArcTo::clockwise, Close(), CloseSubpath(), CubicTo(), descr_arcto, descr_close, descr_cmd, descr_cubicto, descr_doing_subpath, descr_flags, descr_forced, descr_lineto, descr_moveto, PathDescrCubicTo::end, PathDescrArcTo::large, LineTo(), MoveTo(), PrevPoint(), Reset(), PathDescrArcTo::rx, PathDescrArcTo::ry, SetBackData(), PathDescrCubicTo::start, and width.
bool Path::IsLineSegment | ( | int | piece | ) |
Definition at line 590 of file Path.cpp.
References descr_cmd, descr_lineto, and PathDescr::getType().
double Path::Length | ( | ) |
Definition at line 431 of file PathCutting.cpp.
References Geom::L2(), len, polyline_moveto, and pts.
Referenced by sp_textpath_to_text().
int Path::LineTo | ( | Geom::Point const & | ip | ) |
Appends a LineTo path command.
ip | The point to draw a line to. |
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().
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.
path | The Geom::Path object to load. |
tr | A transformation matrix. |
doTransformation | If set to true, the transformation matrix tr is applied on the path before it's loaded in this path object. |
append | If 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().
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.
pv | A reference to the Geom::PathVector object to load. |
Definition at line 376 of file PathCutting.cpp.
References LoadPathVector().
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.
pv | The Geom::PathVector object to load. |
tr | A transformation to apply on each path. |
doTransformation | If 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().
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.
pv | A reference to the Geom::PathVector object to load. |
cuts | A 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().
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.
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().
int Path::MoveTo | ( | Geom::Point const & | ip | ) |
Appends a MoveTo path command.
ip | The point to move to. |
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().
Definition at line 26 of file PathOutline.cpp.
References PathDescrArcTo::angle, ArcTo(), butt_pointy, butt_round, butt_square, Geom::Point::ccw(), PathDescrArcTo::clockwise, Close(), CloseSubpath(), CubicTo(), descr_arcto, descr_close, descr_cmd, descr_cubicto, descr_doing_subpath, descr_flags, descr_forced, descr_lineto, descr_moveto, PathDescrCubicTo::end, PathDescrArcTo::large, LineTo(), MoveTo(), PrevPoint(), Reset(), PathDescrArcTo::rx, PathDescrArcTo::ry, SetBackData(), PathDescrCubicTo::start, and width.
Referenced by Inkscape::UI::Tools::TextTool::_updateCursor().
Definition at line 176 of file PathOutline.cpp.
References CloseSubpath(), descr_cmd, descr_doing_subpath, descr_flags, Reset(), SetBackData(), and width.
Referenced by SPOffset::set_shape().
void Path::PointAndTangentAt | ( | int | piece, |
double | at, | ||
Geom::Point & | pos, | ||
Geom::Point & | tgt | ||
) |
Definition at line 368 of file Path.cpp.
References descr_arcto, descr_close, descr_cmd, descr_cubicto, descr_forced, descr_lineto, descr_moveto, PathDescr::getType(), len, PathDescrMoveTo::p, PointAndTangentAt(), and PrevPoint().
Referenced by PointAndTangentAt(), and sp_textpath_to_text().
void Path::PointAt | ( | int | piece, |
double | at, | ||
Geom::Point & | pos | ||
) |
piece | Index of a one of our commands. |
at | Distance along the segment that corresponds to ‘piece’ (0 <= at <= 1) |
pos | Filled 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().
Path::cut_position Path::PointToCurvilignPosition | ( | Geom::Point const & | pos, |
unsigned | seg = 0 |
||
) | const |
Definition at line 855 of file PathCutting.cpp.
References Geom::Point::cw(), Path::cut_position::piece, polyline_moveto, pts, result, square(), Geom::X, and Geom::Y.
Referenced by get_nearest_position_on_Path().
void Path::PolylineBoundingBox | ( | double & | l, |
double & | t, | ||
double & | r, | ||
double & | b | ||
) |
double Path::PositionToLength | ( | int | piece, |
double | t | ||
) |
Definition at line 941 of file PathCutting.cpp.
References Geom::L2(), polyline_moveto, and pts.
const Geom::Point Path::PrevPoint | ( | const int | i | ) | const |
Definition at line 420 of file PathConversion.cpp.
References descr_arcto, descr_close, descr_cmd, descr_cubicto, descr_forced, descr_lineto, descr_moveto, PathDescrMoveTo::p, PathDescrLineTo::p, PathDescrCubicTo::p, PathDescrArcTo::p, and PrevPoint().
Referenced by ConvertPositionsToForced(), ConvertPositionsToMoveTo(), InsideOutline(), Outline(), PointAndTangentAt(), PointAt(), PrevPoint(), Shape::ReFormeArcTo(), Shape::ReFormeCubicTo(), and svg_dump_path().
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().
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().
void Path::SetBackData | ( | bool | nVal | ) |
Sets the back variable to the value passed in and clears the polyline approximation.
nVal | True 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().
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
threshold | The 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().
void Path::Stroke | ( | Shape * | dest, |
bool | doClose, | ||
double | width, | ||
JoinType | join, | ||
ButtType | butt, | ||
double | miter, | ||
bool | justAdd = false |
||
) |
Definition at line 45 of file PathStroke.cpp.
References Shape::AddEdge(), butt_round, end, LEFT, Geom::LInfty(), Shape::MakeBackData(), polyline_forced, polyline_lineto, pts, Shape::Reset(), RIGHT, and width.
Path ** Path::SubPaths | ( | int & | outNb, |
bool | killNoSurf | ||
) |
Definition at line 479 of file PathCutting.cpp.
References PathDescrArcTo::angle, ArcTo(), PathDescrArcTo::clockwise, Close(), Convert(), CubicTo(), descr_arcto, descr_close, descr_cmd, descr_cubicto, descr_lineto, descr_moveto, PathDescrCubicTo::end, PathDescrArcTo::large, LineTo(), MoveTo(), PathDescrMoveTo::p, PathDescrLineTo::p, PathDescrCubicTo::p, PathDescrArcTo::p, PathDescrArcTo::rx, PathDescrArcTo::ry, SetBackData(), PathDescrCubicTo::start, and Surface().
Referenced by Inkscape::ObjectSet::_pathBoolOp(), and SPOffset::set_shape().
Path ** Path::SubPathsWithNesting | ( | int & | outNb, |
bool | killNoSurf, | ||
int | nbNest, | ||
int * | nesting, | ||
int * | conts | ||
) |
Definition at line 557 of file PathCutting.cpp.
References PathDescrArcTo::angle, ArcTo(), PathDescrArcTo::clockwise, Close(), Convert(), CubicTo(), descr_arcto, descr_close, descr_cmd, descr_cubicto, descr_lineto, descr_moveto, PathDescrCubicTo::end, PathDescrArcTo::large, LineTo(), MoveTo(), PathDescrMoveTo::p, PathDescrLineTo::p, PathDescrCubicTo::p, PathDescrArcTo::p, PathDescrArcTo::rx, PathDescrArcTo::ry, SetBackData(), PathDescrCubicTo::start, and Surface().
Referenced by Inkscape::ObjectSet::_pathBoolOp(), and pathvector_cut().
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().
std::string Path::svg_dump_path | ( | ) | const |
Definition at line 577 of file Path.cpp.
References descr_cmd, PrevPoint(), and Inkscape::SVGOStringStream::str().
Referenced by Inkscape::ObjectSet::_pathBoolOp(), Inkscape::UI::Tools::do_trace(), refresh_offset_source(), sp_selected_path_create_offset_object(), sp_selected_path_do_offset(), and Inkscape::UI::Tools::sp_tweak_dilate_recursive().
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.
trans | The 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().
|
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().
std::vector<PathDescr*> Path::descr_cmd |
A vector of owned pointers to path commands.
Definition at line 108 of file Path.h.
Referenced by Inkscape::ObjectSet::_pathBoolOp(), Affiche(), ArcTo(), Close(), Coalesce(), Convert(), ConvertEvenLines(), ConvertForcedToMoveTo(), ConvertForcedToVoid(), ConvertPositionsToForced(), ConvertPositionsToMoveTo(), Shape::ConvertToFormeNested(), ConvertWithBackData(), Copy(), CubicTo(), FastBBox(), ForcePoint(), InsertArcTo(), InsertCubicTo(), InsertForcePoint(), InsertLineTo(), InsertMoveTo(), InsideOutline(), IsLineSegment(), LineTo(), LoadPathVector(), MakePathVector(), MoveTo(), Outline(), OutsideOutline(), PointAndTangentAt(), PointAt(), PrevPoint(), Inkscape::Text::Layout::queryCursorShape(), Shape::ReFormeArcTo(), Shape::ReFormeCubicTo(), Reset(), sp_selected_path_create_offset_object(), sp_selected_path_do_offset(), Inkscape::UI::Tools::sp_tweak_dilate_recursive(), SubPaths(), SubPathsWithNesting(), svg_dump_path(), and ~Path().
|
private |
Definition at line 105 of file Path.h.
Referenced by ArcTo(), Close(), CloseSubpath(), Coalesce(), Convert(), ConvertEvenLines(), ConvertPositionsToForced(), ConvertWithBackData(), CubicTo(), ForcePoint(), InsideOutline(), LineTo(), MoveTo(), Outline(), OutsideOutline(), and Reset().
|
private |
Definition at line 140 of file Path.h.
Referenced by ConvertWithBackData(), Copy(), LoadPathVector(), and Reset().
std::vector<path_lineto> Path::pts |
A vector storing the polyline approximation points.
Definition at line 128 of file Path.h.
Referenced by AddForcedPoint(), AddPoint(), AddPoint(), Convert(), ConvertEvenLines(), ConvertWithBackData(), CurvilignToPosition(), DashPolyline(), Fill(), Inkscape::Text::Layout::fitToPathAlign(), is_line(), Length(), PointToCurvilignPosition(), PolylineBoundingBox(), PositionToLength(), ResetPoints(), Simplify(), Stroke(), and Surface().