Horizon
|
Class SHAPE_LINE_CHAIN. More...
#include <shape_line_chain.h>
Classes | |
struct | compareOriginDistance |
struct | INTERSECTION |
Struct INTERSECTION. More... | |
Public Types | |
typedef std::vector< INTERSECTION > | INTERSECTIONS |
Public Member Functions | |
SHAPE_LINE_CHAIN () | |
Constructor Initializes an empty line chain. | |
SHAPE_LINE_CHAIN (const SHAPE_LINE_CHAIN &aShape) | |
Copy Constructor. | |
SHAPE_LINE_CHAIN (const VECTOR2I &aA, const VECTOR2I &aB) | |
Constructor Initializes a 2-point line chain (a single segment) | |
SHAPE_LINE_CHAIN (const VECTOR2I &aA, const VECTOR2I &aB, const VECTOR2I &aC) | |
SHAPE_LINE_CHAIN (const VECTOR2I &aA, const VECTOR2I &aB, const VECTOR2I &aC, const VECTOR2I &aD) | |
SHAPE_LINE_CHAIN (const VECTOR2I *aV, int aCount) | |
SHAPE * | Clone () const override |
Function Clone() More... | |
void | Clear () |
Function Clear() Removes all points from the line chain. | |
void | SetClosed (bool aClosed) |
Function SetClosed() More... | |
bool | IsClosed () const |
Function IsClosed() More... | |
int | SegmentCount () const |
Function SegmentCount() More... | |
int | PointCount () const |
Function PointCount() More... | |
SEG | Segment (int aIndex) |
Function Segment() More... | |
const SEG | CSegment (int aIndex) const |
Function CSegment() More... | |
VECTOR2I & | Point (int aIndex) |
Function Point() More... | |
const VECTOR2I & | CPoint (int aIndex) const |
Function CPoint() More... | |
VECTOR2I & | LastPoint () |
Returns the last point in the line chain. | |
const VECTOR2I & | CLastPoint () const |
Returns the last point in the line chain. | |
const BOX2I | BBox (int aClearance=0) const override |
Function BBox() More... | |
bool | Collide (const VECTOR2I &aP, int aClearance=0) const override |
Function Collide() More... | |
bool | Collide (const SEG &aSeg, int aClearance=0) const override |
Function Collide() More... | |
int | Distance (const VECTOR2I &aP, bool aOutlineOnly=false) const |
Function Distance() More... | |
const SHAPE_LINE_CHAIN | Reverse () const |
Function Reverse() More... | |
int | Length () const |
Function Length() More... | |
void | Append (int aX, int aY, bool aAllowDuplication=false) |
Function Append() More... | |
void | Append (const VECTOR2I &aP, bool aAllowDuplication=false) |
Function Append() More... | |
void | Append (const SHAPE_LINE_CHAIN &aOtherLine) |
Function Append() More... | |
void | Insert (int aVertex, const VECTOR2I &aP) |
void | Replace (int aStartIndex, int aEndIndex, const VECTOR2I &aP) |
Function Replace() More... | |
void | Replace (int aStartIndex, int aEndIndex, const SHAPE_LINE_CHAIN &aLine) |
Function Replace() More... | |
void | Remove (int aStartIndex, int aEndIndex) |
Function Remove() More... | |
void | Remove (int aIndex) |
Function Remove() removes the aIndex-th point from the line chain. More... | |
int | Split (const VECTOR2I &aP) |
Function Split() More... | |
int | Find (const VECTOR2I &aP) const |
Function Find() More... | |
int | FindSegment (const VECTOR2I &aP) const |
Function FindSegment() More... | |
const SHAPE_LINE_CHAIN | Slice (int aStartIndex, int aEndIndex=-1) const |
Function Slice() More... | |
bool | Intersects (const SHAPE_LINE_CHAIN &aChain) const |
int | Intersect (const SEG &aSeg, INTERSECTIONS &aIp) const |
Function Intersect() More... | |
int | Intersect (const SHAPE_LINE_CHAIN &aChain, INTERSECTIONS &aIp) const |
Function Intersect() More... | |
int | PathLength (const VECTOR2I &aP) const |
Function PathLength() More... | |
bool | PointInside (const VECTOR2I &aP) const |
Function PointInside() More... | |
bool | PointOnEdge (const VECTOR2I &aP) const |
Function PointOnEdge() More... | |
bool | CheckClearance (const VECTOR2I &aP, const int aDist) const |
Function CheckClearance() More... | |
const OPT< INTERSECTION > | SelfIntersecting () const |
Function SelfIntersecting() More... | |
SHAPE_LINE_CHAIN & | Simplify () |
Function Simplify() More... | |
const VECTOR2I | NearestPoint (const VECTOR2I &aP) const |
Function NearestPoint() More... | |
const VECTOR2I | NearestPoint (const SEG &aSeg, int &dist) const |
Function NearestPoint() More... | |
const std::string | Format () const override |
bool | Parse (std::stringstream &aStream) override |
bool | operator!= (const SHAPE_LINE_CHAIN &aRhs) const |
bool | CompareGeometry (const SHAPE_LINE_CHAIN &aOther) const |
void | Move (const VECTOR2I &aVector) override |
void | Rotate (double aAngle, const VECTOR2I &aCenter) |
Function Rotate rotates all vertices by a given angle. More... | |
bool | IsSolid () const override |
const VECTOR2I | PointAlong (int aPathLength) const |
double | Area () const |
![]() | |
SHAPE (SHAPE_TYPE aType) | |
Constructor. More... | |
SHAPE_TYPE | Type () const |
Function Type() More... | |
virtual bool | Collide (const SHAPE *aShape, int aClearance, VECTOR2I &aMTV) const |
Function Collide() More... | |
virtual bool | Collide (const SHAPE *aShape, int aClearance=0) const |
virtual VECTOR2I | Centre () const |
Function Centre() More... | |
Additional Inherited Members | |
![]() | |
typedef VECTOR2I::extended_type | ecoord |
![]() | |
SHAPE_TYPE | m_type |
| |
Class SHAPE_LINE_CHAIN.
Represents a polyline (an zero-thickness chain of connected line segments). I purposedly didn't name it "polyline" to avoid confusion with the existing CPolyLine class in pcbnew.
SHAPE_LINE_CHAIN class shall not be used for polygons!
|
inline |
Function Append()
Appends another line chain at the end.
aOtherLine | the line chain to be appended. |
|
inline |
Function Append()
Appends a new point at the end of the line chain.
aP | the new point |
aAllowDuplication | = true to append the new point even it is the same as the last entered point false (default) to skip it if it is the same as the last entered point |
|
inline |
Function Append()
Appends a new point at the end of the line chain.
aX | is X coordinate of the new point |
aY | is Y coordinate of the new point |
aAllowDuplication | = true to append the new point even it is the same as the last entered point false (default) to skip it if it is the same as the last entered point |
|
inlineoverridevirtual |
bool SHAPE_LINE_CHAIN::CheckClearance | ( | const VECTOR2I & | aP, |
const int | aDist | ||
) | const |
Function CheckClearance()
Checks if point aP is closer to (or on) an edge or vertex of the line chain.
aP | point to check |
aDist | distance in internal units |
|
overridevirtual |
|
overridevirtual |
|
overridevirtual |
|
inline |
Function CPoint()
Returns a const reference to a given point in the line chain.
aIndex | index of the point |
|
inline |
Function CSegment()
Returns a constant copy of the aIndex-th segment in the line chain.
aIndex | index of the segment in the line chain. Negative values are counted from the end (i.e. -1 means the last segment in the line chain) |
int SHAPE_LINE_CHAIN::Distance | ( | const VECTOR2I & | aP, |
bool | aOutlineOnly = false |
||
) | const |
Function Distance()
Computes the minimum distance between the line chain and a point aP.
aP | the point |
int SHAPE_LINE_CHAIN::Find | ( | const VECTOR2I & | aP | ) | const |
Function Find()
Searches for point aP.
aP | the point to be looked for |
int SHAPE_LINE_CHAIN::FindSegment | ( | const VECTOR2I & | aP | ) | const |
Function FindSegment()
Searches for segment containing point aP.
aP | the point to be looked for |
|
overridevirtual |
Reimplemented from SHAPE.
int SHAPE_LINE_CHAIN::Intersect | ( | const SEG & | aSeg, |
INTERSECTIONS & | aIp | ||
) | const |
Function Intersect()
Finds all intersection points between our line chain and the segment aSeg.
aSeg | the segment chain to find intersections with |
aIp | reference to a vector to store found intersections. Intersection points are sorted with increasing distances from point aSeg.a. |
int SHAPE_LINE_CHAIN::Intersect | ( | const SHAPE_LINE_CHAIN & | aChain, |
INTERSECTIONS & | aIp | ||
) | const |
Function Intersect()
Finds all intersection points between our line chain and the line chain aChain.
aChain | the line chain to find intersections with |
aIp | reference to a vector to store found intersections. Intersection points are sorted with increasing path lengths from the starting point of aChain. |
|
inline |
Function IsClosed()
int SHAPE_LINE_CHAIN::Length | ( | ) | const |
Function Length()
Returns length of the line chain in Euclidean metric.
Function NearestPoint()
Finds a point on the line chain that is closest to the line defined by the points of segment aSeg, also returns the distance.
aSeg | Segment defining the line. |
dist | reference receiving the distance to the nearest point. |
Function NearestPoint()
Finds a point on the line chain that is closest to point aP.
|
overridevirtual |
Reimplemented from SHAPE.
int SHAPE_LINE_CHAIN::PathLength | ( | const VECTOR2I & | aP | ) | const |
Function PathLength()
Computes the walk path length from the beginning of the line chain and the point aP belonging to our line.
|
inline |
Function Point()
Returns a reference to a given point in the line chain.
aIndex | index of the point |
|
inline |
Function PointCount()
Returns the number of points (vertices) in this line chain
bool SHAPE_LINE_CHAIN::PointInside | ( | const VECTOR2I & | aP | ) | const |
Function PointInside()
Checks if point aP lies inside a polygon (any type) defined by the line chain. For closed shapes only.
aP | point to check |
To check for interior points, we draw a line in the positive x direction from the point. If it intersects an even number of segments, the point is outside the line chain (it had to first enter and then exit). Otherwise, it is inside the chain.
Note: slope might be denormal here in the case of a horizontal line but we require our y to move from above to below the point (or vice versa)
bool SHAPE_LINE_CHAIN::PointOnEdge | ( | const VECTOR2I & | aP | ) | const |
Function PointOnEdge()
Checks if point aP lies on an edge or vertex of the line chain.
aP | point to check |
|
inline |
Function Remove() removes the aIndex-th point from the line chain.
aIndex | is the index of the point to be removed. |
void SHAPE_LINE_CHAIN::Remove | ( | int | aStartIndex, |
int | aEndIndex | ||
) |
Function Remove()
Removes the range of points [start_index, end_index] from the line chain.
aStartIndex | start of the point range to be replaced (inclusive) |
aEndIndex | end of the point range to be replaced (inclusive) |
void SHAPE_LINE_CHAIN::Replace | ( | int | aStartIndex, |
int | aEndIndex, | ||
const SHAPE_LINE_CHAIN & | aLine | ||
) |
Function Replace()
Replaces points with indices in range [start_index, end_index] with the points from line chain aLine.
aStartIndex | start of the point range to be replaced (inclusive) |
aEndIndex | end of the point range to be replaced (inclusive) |
aLine | replacement line chain. |
void SHAPE_LINE_CHAIN::Replace | ( | int | aStartIndex, |
int | aEndIndex, | ||
const VECTOR2I & | aP | ||
) |
Function Replace()
Replaces points with indices in range [start_index, end_index] with a single point aP.
aStartIndex | start of the point range to be replaced (inclusive) |
aEndIndex | end of the point range to be replaced (inclusive) |
aP | replacement point |
const SHAPE_LINE_CHAIN SHAPE_LINE_CHAIN::Reverse | ( | ) | const |
Function Reverse()
Reverses point order in the line chain.
void SHAPE_LINE_CHAIN::Rotate | ( | double | aAngle, |
const VECTOR2I & | aCenter | ||
) |
Function Rotate rotates all vertices by a given angle.
aCenter | is the rotation center |
aAngle | rotation angle in radians |
|
inline |
|
inline |
const OPT< SHAPE_LINE_CHAIN::INTERSECTION > SHAPE_LINE_CHAIN::SelfIntersecting | ( | ) | const |
Function SelfIntersecting()
Checks if the line chain is self-intersecting.
|
inline |
Function SetClosed()
Marks the line chain as closed (i.e. with a segment connecting the last point with the first point).
aClosed | whether the line chain is to be closed or not. |
SHAPE_LINE_CHAIN & SHAPE_LINE_CHAIN::Simplify | ( | ) |
Function Simplify()
Simplifies the line chain by removing colinear adjacent segments and duplicate vertices.
const SHAPE_LINE_CHAIN SHAPE_LINE_CHAIN::Slice | ( | int | aStartIndex, |
int | aEndIndex = -1 |
||
) | const |
Function Slice()
Returns a subset of this line chain containing the [start_index, end_index] range of points.
aStartIndex | start of the point range to be returned (inclusive) |
aEndIndex | end of the point range to be returned (inclusive) |
int SHAPE_LINE_CHAIN::Split | ( | const VECTOR2I & | aP | ) |
Function Split()
Inserts the point aP belonging to one of the our segments, splitting the adjacent segment in two.
aP | the point to be inserted |