karbon
VSegment Class Reference
#include <vsegment.h>
Detailed Description
A class representing lines and beziers.We waste some KoPoints, if we would use only lines, but this makes it easy to convert the segment types into each other. Make sure yourself, that you pass values to functions within proper ranges.
Definition at line 42 of file vsegment.h.
Public Types | |
enum | VCtrlPointFixing { none = 0, first = 1, second = 2 } |
enum | VState { normal, deleted } |
Public Member Functions | |
VSegment (unsigned short deg=3) | |
VSegment (const VSegment &segment) | |
~VSegment () | |
unsigned short | degree () const |
void | setDegree (unsigned short deg) |
bool | isBegin () const |
bool | isLine () const |
bool | isCurve () const |
VState | state () const |
void | setState (VState state) |
const KoPoint & | point (int i) const |
const KoPoint & | p (int i) const |
const KoPoint & | knot () const |
void | setPoint (int i, const KoPoint &p) |
void | setP (int i, const KoPoint &p) |
void | setKnot (const KoPoint &p) |
bool | pointIsSelected (int i) const |
bool | knotIsSelected () const |
void | selectPoint (int i, bool select=true) |
void | selectKnot (bool select=true) |
uint | nodeNear (const KoPoint &p, double isNearRange=VGlobal::isNearRange) const |
VSegment * | prev () const |
VSegment * | next () const |
bool | isFlat (double flatness=VGlobal::flatnessTolerance) const |
KoPoint | pointAt (double t) const |
void | pointDerivativesAt (double t, KoPoint *p=0L, KoPoint *d1=0L, KoPoint *d2=0L) const |
KoPoint | tangentAt (double t) const |
void | pointTangentNormalAt (double t, KoPoint *p=0L, KoPoint *tn=0L, KoPoint *n=0L) const |
double | length (double t=1.0) const |
double | chordLength () const |
double | polyLength () const |
double | lengthParam (double len) const |
double | nearestPointParam (const KoPoint &p) const |
bool | isSmooth (const VSegment &next) const |
bool | isSmooth () const |
VSegment * | revert () const |
VSegment * | splitAt (double t) |
bool | intersects (const VSegment &segment) const |
double | pointIsLeft (const KoPoint &p) const |
KoRect | boundingBox () const |
void | draw (VPainter *painter) const |
void | load (const QDomElement &element) |
VSegment * | clone () const |
Static Public Member Functions | |
static double | height (const KoPoint &a, const KoPoint &p, const KoPoint &b) |
static bool | linesIntersect (const KoPoint &a0, const KoPoint &a1, const KoPoint &b0, const KoPoint &b1) |
Friends | |
class | VSubpath |
class | VSubpathIterator |
Member Enumeration Documentation
|
Tells which control point is "fixed" i.e. located at the corresponding knot and invisible. This flag makes no sense for line segments. Definition at line 53 of file vsegment.h. |
Member Function Documentation
|
Calculates the bounding box.
Definition at line 724 of file vsegment.cc. |
|
Calculates the chord length (the distance from the previous knot to the current knot).
Definition at line 361 of file vsegment.cc. |
|
Returns a pointer to a copy of this segment.
Definition at line 1108 of file vsegment.cc. |
|
Returns the segment's degree, which is identical to the number of nodes. For cubic beziers it is "three" and "one" for lines. Definition at line 77 of file vsegment.h. |
|
Calculates height of point p above line AB.
Definition at line 922 of file vsegment.cc. |
|
Returns true, if this segment intersects the other segment.
Definition at line 978 of file vsegment.cc. |
|
Tests for the segment type ("begin", "line" or "curve").
Definition at line 91 of file vsegment.h. |
|
Returns true if the segment is flat. That means it's height is smaller than flatness. Definition at line 139 of file vsegment.cc. |
|
Calculates wether the tangent at the knot is exactly parallel to the tangent at p0 of the next segment. Returns false if the current segment is a "begin". Definition at line 700 of file vsegment.cc. |
|
Returns the knot. This is a convenience function using point(). Definition at line 135 of file vsegment.h. |
|
Returns true if the knot is selected. This is a convenience function. Definition at line 181 of file vsegment.h. |
|
Calculates the arclength from p0 to the point parametrized by 0 <= t <= 1. For beziers this function is a bit expensive. Definition at line 291 of file vsegment.cc. |
|
Calculates the parameter of a point located at arclength len. This is the exact inverse operation of length( t ). Definition at line 396 of file vsegment.cc. |
|
Calculates whether lines A0A1 and B0B1 intersect.
Definition at line 949 of file vsegment.cc. |
|
Calculates the parameter of the nearest point on this segment to the point p. This function is pretty expensive. Definition at line 437 of file vsegment.cc. |
|
Returns a pointer to the next not deleted segment, if stored in a VSubpath.
Definition at line 1050 of file vsegment.cc. |
|
Returns index of the node at point p. Returns 0 if no segment point matches point p. Definition at line 994 of file vsegment.cc. |
|
This is a convenience function. It returns the point with index 0 <= i <= degree() while p( 0 ) is the knot of the previous segment. Definition at line 125 of file vsegment.h. |
|
Returns the segment's point with index 0 <= i < degree().
Definition at line 115 of file vsegment.h. |
|
Calculates the point on this segment at parameter 0 <= t <= 1. This is a convenience wrapper for pointDerivativesAt(). Definition at line 165 of file vsegment.cc. |
|
Calculates the point and the derivatives of first and second order for 0 <= t <= 1.
Definition at line 175 of file vsegment.cc. |
|
Returns a number > 0 if the point p is left, 0 if it's on and a number < 0 if it's right of the infinite line through the previous segment's knot and the current knot.
Definition at line 355 of file vsegment.h. |
|
Returns true if the point with index 0 <= i < degree() is selected.
Definition at line 173 of file vsegment.h. |
|
Calculates the point, the tangent vector and the normal vector for 0 <= t <= 1. The tangent vector and the normal vector are normalized (length=1). Definition at line 258 of file vsegment.cc. |
|
Calculates the length of the control polygon.
Definition at line 373 of file vsegment.cc. |
|
Returns a pointer to the previous not deleted segment, if stored in a VSubpath.
Definition at line 1037 of file vsegment.cc. |
|
Creates a reverted version of this segment. For example: if this segment is a line from A to B, the result is a line from B to A. Definition at line 1011 of file vsegment.cc. |
|
Selects/deselects the knot of this segment.
Definition at line 197 of file vsegment.h. |
|
Selects the point with index 0 <= i < degree().
Definition at line 189 of file vsegment.h. |
|
Sets the segment's degree and thus resizes the array of node data. The node data is copied from the old knot "backwards". Definition at line 72 of file vsegment.cc. |
|
Sets the knot. This is a convenience function. Definition at line 164 of file vsegment.h. |
|
This is a convenience function. It sets the point with index 0 <= i <= degree() to "p" while setP( 0 ) sets the knot of the previous segment. Definition at line 153 of file vsegment.h. |
|
Sets the segment's point with index 0 <= i < degree() to "p".
Definition at line 143 of file vsegment.h. |
|
Sets the segment state.
Definition at line 106 of file vsegment.h. |
|
Splits the segment at parameter 0 <= t <= 1. Returns a pointer to the first segment and modifies the current one to be the second segment. Definition at line 857 of file vsegment.cc. |
|
Returns the segment state.
Definition at line 98 of file vsegment.h. |
|
Calculates the normalized tangent vector (length=1) at the point parameterized by 0 <= t <= 1. This is a convenience wrapper for pointTangentNormalAt(). Use the latter function directly if you need to calculate the point and normal vector or tangent vector at once. Definition at line 248 of file vsegment.cc. |
The documentation for this class was generated from the following files: