Horizon
|
Represent a set of closed polygons. More...
#include <shape_poly_set.h>
Classes | |
class | ITERATOR_TEMPLATE |
Base class for iterating over all vertices in a given SHAPE_POLY_SET. More... | |
class | SEGMENT_ITERATOR_TEMPLATE |
Base class for iterating over all segments in a given SHAPE_POLY_SET. More... | |
class | TRIANGULATED_POLYGON |
struct | VERTEX_INDEX |
Structure to hold the necessary information in order to index a vertex on a SHAPE_POLY_SET object: the polygon index, the contour index relative to the polygon and the vertex index relative the contour. More... | |
Public Types | |
enum | POLYGON_MODE { PM_FAST = true , PM_STRICTLY_SIMPLE = false } |
Operations on polygons use a aFastMode param if aFastMode is PM_FAST (true) the result can be a weak polygon if aFastMode is PM_STRICTLY_SIMPLE (false) (default) the result is (theoretically) a strictly simple polygon, but calculations can be really significantly time consuming Most of time PM_FAST is preferable. More... | |
enum | CORNER_STRATEGY { ALLOW_ACUTE_CORNERS , CHAMFER_ACUTE_CORNERS , ROUND_ACUTE_CORNERS , CHAMFER_ALL_CORNERS , ROUND_ALL_CORNERS } |
< define how inflate transform build inflated polygon More... | |
typedef std::vector< SHAPE_LINE_CHAIN > | POLYGON |
< represents a single polygon outline with holes. | |
typedef ITERATOR_TEMPLATE< VECTOR2I > | ITERATOR |
typedef ITERATOR_TEMPLATE< const VECTOR2I > | CONST_ITERATOR |
typedef SEGMENT_ITERATOR_TEMPLATE< SEG > | SEGMENT_ITERATOR |
typedef SEGMENT_ITERATOR_TEMPLATE< const SEG > | CONST_SEGMENT_ITERATOR |
Public Member Functions | |
SHAPE_POLY_SET (const BOX2D &aRect) | |
SHAPE_POLY_SET (const SHAPE_LINE_CHAIN &aOutline) | |
Construct a SHAPE_POLY_SET with the first outline given by aOutline. | |
SHAPE_POLY_SET (const SHAPE_POLY_SET &aOther) | |
Copy constructor SHAPE_POLY_SET Performs a deep copy of aOther into this . | |
SHAPE_POLY_SET & | operator= (const SHAPE_POLY_SET &aOther) |
void | CacheTriangulation (bool aPartition=true) |
bool | IsTriangulationUpToDate () const |
MD5_HASH | GetHash () const |
virtual bool | HasIndexableSubshapes () const override |
virtual size_t | GetIndexableSubshapeCount () const override |
virtual void | GetIndexableSubshapes (std::vector< SHAPE * > &aSubshapes) override |
bool | GetRelativeIndices (int aGlobalIdx, VERTEX_INDEX *aRelativeIndices) const |
Convert a global vertex index —i.e., a number that globally identifies a vertex in a concatenated list of all vertices in all contours— and get the index of the vertex relative to the contour relative to the polygon in which it is. | |
bool | GetGlobalIndex (VERTEX_INDEX aRelativeIndices, int &aGlobalIdx) const |
Compute the global index of a vertex from the relative indices of polygon, contour and vertex. | |
SHAPE * | Clone () const override |
Return a dynamically allocated copy of the shape. | |
int | NewOutline () |
Creates a new hole in a given outline. | |
int | NewHole (int aOutline=-1) |
Adds a new outline to the set and returns its index. | |
int | AddOutline (const SHAPE_LINE_CHAIN &aOutline) |
Adds a new hole to the given outline (default: last) and returns its index. | |
int | AddHole (const SHAPE_LINE_CHAIN &aHole, int aOutline=-1) |
Return the area of this poly set. | |
double | Area () |
Count the number of arc shapes present. | |
int | ArcCount () const |
Appends all the arcs in this polyset to aArcBuffer. | |
void | GetArcs (std::vector< SHAPE_ARC > &aArcBuffer) const |
Removes all arc references from all the outlines and holes in the polyset. | |
void | ClearArcs () |
Appends a vertex at the end of the given outline/hole (default: the last outline) | |
int | Append (int x, int y, int aOutline=-1, int aHole=-1, bool aAllowDuplication=false) |
Add a new vertex to the contour indexed by aOutline and aHole (defaults to the outline of the last polygon). | |
void | Append (const SHAPE_POLY_SET &aSet) |
Append a vertex at the end of the given outline/hole (default: the last outline) | |
void | Append (const VECTOR2I &aP, int aOutline=-1, int aHole=-1) |
int | Append (SHAPE_ARC &aArc, int aOutline=-1, int aHole=-1) |
Append a new arc to the contour indexed by aOutline and aHole (defaults to the outline of the last polygon). | |
void | InsertVertex (int aGlobalIndex, const VECTOR2I &aNewVertex) |
Adds a vertex in the globally indexed position aGlobalIndex. | |
const VECTOR2I & | CVertex (int aIndex, int aOutline, int aHole) const |
Return the aGlobalIndex-th vertex in the poly set. | |
const VECTOR2I & | CVertex (int aGlobalIndex) const |
Return the index-th vertex in a given hole outline within a given outline. | |
const VECTOR2I & | CVertex (VERTEX_INDEX aIndex) const |
bool | GetNeighbourIndexes (int aGlobalIndex, int *aPrevious, int *aNext) |
Return the global indexes of the previous and the next corner of the aGlobalIndex-th corner of a contour in the polygon set. | |
bool | IsPolygonSelfIntersecting (int aPolygonIndex) const |
Check whether the aPolygonIndex-th polygon in the set is self intersecting. | |
bool | IsSelfIntersecting () const |
Check whether any of the polygons in the set is self intersecting. | |
unsigned int | TriangulatedPolyCount () const |
Return the number of outlines in the set. | |
int | OutlineCount () const |
Return the number of vertices in a given outline/hole. | |
int | VertexCount (int aOutline=-1, int aHole=-1) const |
Return the number of points in the shape poly set. | |
int | FullPointCount () const |
Returns the number of holes in a given outline. | |
int | HoleCount (int aOutline) const |
Return the reference to aIndex-th outline in the set. | |
SHAPE_LINE_CHAIN & | Outline (int aIndex) |
const SHAPE_LINE_CHAIN & | Outline (int aIndex) const |
SHAPE_POLY_SET | Subset (int aFirstPolygon, int aLastPolygon) |
Return a subset of the polygons in this set, the ones between aFirstPolygon and aLastPolygon. | |
SHAPE_POLY_SET | UnitSet (int aPolygonIndex) |
Return the reference to aHole-th hole in the aIndex-th outline. | |
SHAPE_LINE_CHAIN & | Hole (int aOutline, int aHole) |
Return the aIndex-th subpolygon in the set. | |
POLYGON & | Polygon (int aIndex) |
const POLYGON & | Polygon (int aIndex) const |
const TRIANGULATED_POLYGON * | TriangulatedPolygon (int aIndex) const |
const SHAPE_LINE_CHAIN & | COutline (int aIndex) const |
const SHAPE_LINE_CHAIN & | CHole (int aOutline, int aHole) const |
const POLYGON & | CPolygon (int aIndex) const |
ITERATOR | Iterate (int aFirst, int aLast, bool aIterateHoles=false) |
Return an object to iterate through the points of the polygons between aFirst and aLast . | |
ITERATOR | Iterate (int aOutline) |
ITERATOR | IterateWithHoles (int aOutline) |
ITERATOR | Iterate () |
ITERATOR | IterateWithHoles () |
CONST_ITERATOR | CIterate (int aFirst, int aLast, bool aIterateHoles=false) const |
CONST_ITERATOR | CIterate (int aOutline) const |
CONST_ITERATOR | CIterateWithHoles (int aOutline) const |
CONST_ITERATOR | CIterate () const |
CONST_ITERATOR | CIterateWithHoles () const |
ITERATOR | IterateFromVertexWithHoles (int aGlobalIdx) |
Return an iterator object, for iterating between aFirst and aLast outline, with or without holes (default: without) | |
SEGMENT_ITERATOR | IterateSegments (int aFirst, int aLast, bool aIterateHoles=false) |
Return an iterator object, for iterating between aFirst and aLast outline, with or without holes (default: without) | |
CONST_SEGMENT_ITERATOR | CIterateSegments (int aFirst, int aLast, bool aIterateHoles=false) const |
Return an iterator object, for iterating aPolygonIdx-th polygon edges. | |
SEGMENT_ITERATOR | IterateSegments (int aPolygonIdx) |
Return an iterator object, for iterating aPolygonIdx-th polygon edges. | |
CONST_SEGMENT_ITERATOR | CIterateSegments (int aPolygonIdx) const |
Return an iterator object, for all outlines in the set (no holes). | |
SEGMENT_ITERATOR | IterateSegments () |
Returns an iterator object, for all outlines in the set (no holes) | |
CONST_SEGMENT_ITERATOR | CIterateSegments () const |
Returns an iterator object, for all outlines in the set (with holes) | |
SEGMENT_ITERATOR | IterateSegmentsWithHoles () |
Return an iterator object, for the aOutline-th outline in the set (with holes). | |
SEGMENT_ITERATOR | IterateSegmentsWithHoles (int aOutline) |
Return an iterator object, for the aOutline-th outline in the set (with holes). | |
CONST_SEGMENT_ITERATOR | CIterateSegmentsWithHoles () const |
Return an iterator object, for the aOutline-th outline in the set (with holes). | |
CONST_SEGMENT_ITERATOR | CIterateSegmentsWithHoles (int aOutline) const |
void | BooleanAdd (const SHAPE_POLY_SET &b, POLYGON_MODE aFastMode) |
Perform boolean polyset difference For aFastMode meaning, see function booleanOp. | |
void | BooleanSubtract (const SHAPE_POLY_SET &b, POLYGON_MODE aFastMode) |
Perform boolean polyset intersection For aFastMode meaning, see function booleanOp. | |
void | BooleanIntersection (const SHAPE_POLY_SET &b, POLYGON_MODE aFastMode) |
Perform boolean polyset union between a and b, store the result in it self For aFastMode meaning, see function booleanOp. | |
void | BooleanAdd (const SHAPE_POLY_SET &a, const SHAPE_POLY_SET &b, POLYGON_MODE aFastMode) |
Perform boolean polyset difference between a and b, store the result in it self For aFastMode meaning, see function booleanOp. | |
void | BooleanSubtract (const SHAPE_POLY_SET &a, const SHAPE_POLY_SET &b, POLYGON_MODE aFastMode) |
Perform boolean polyset intersection between a and b, store the result in it self For aFastMode meaning, see function booleanOp. | |
void | BooleanIntersection (const SHAPE_POLY_SET &a, const SHAPE_POLY_SET &b, POLYGON_MODE aFastMode) |
void | Inflate (int aAmount, int aCircleSegCount, CORNER_STRATEGY aCornerStrategy=ROUND_ALL_CORNERS) |
Perform outline inflation/deflation. | |
void | Deflate (int aAmount, int aCircleSegmentsCount, CORNER_STRATEGY aCornerStrategy=ROUND_ALL_CORNERS) |
void | InflateWithLinkedHoles (int aFactor, int aCircleSegmentsCount, POLYGON_MODE aFastMode) |
Perform outline inflation/deflation, using round corners. | |
void | Fracture (POLYGON_MODE aFastMode) |
Convert a single outline slitted ("fractured") polygon into a set ouf outlines with holes. | |
void | Unfracture (POLYGON_MODE aFastMode) |
Return true if the polygon set has any holes. | |
bool | HasHoles () const |
Return true if the polygon set has any holes that share a vertex. | |
bool | HasTouchingHoles () const |
Simplify the polyset (merges overlapping polys, eliminates degeneracy/self-intersections) For aFastMode meaning, see function booleanOp. | |
void | Simplify (POLYGON_MODE aFastMode) |
int | NormalizeAreaOutlines () |
Convert a self-intersecting polygon to one (or more) non self-intersecting polygon(s). | |
const std::string | Format () const override |
bool | Parse (std::stringstream &aStream) override |
void | Move (const VECTOR2I &aVector) override |
void | Mirror (bool aX=true, bool aY=false, const VECTOR2I &aRef={ 0, 0 }) |
Mirror the line points about y or x (or both) | |
void | Rotate (double aAngle, const VECTOR2I &aCenter={ 0, 0 }) override |
Rotate all vertices by a given angle. | |
bool | IsSolid () const override |
const BOX2I | BBox (int aClearance=0) const override |
Compute a bounding box of the shape, with a margin of aClearance a collision. | |
bool | PointOnEdge (const VECTOR2I &aP) const |
Check if point aP lies on an edge or vertex of some of the outlines or holes. | |
bool | Collide (const SHAPE *aShape, int aClearance=0, int *aActual=nullptr, VECTOR2I *aLocation=nullptr) const override |
Check if the boundary of shape (this) lies closer to the shape aShape than aClearance, indicating a collision. | |
bool | Collide (const VECTOR2I &aP, int aClearance=0, int *aActual=nullptr, VECTOR2I *aLocation=nullptr) const override |
Check whether the point aP is either inside or on the edge of the polygon set. | |
bool | Collide (const SEG &aSeg, int aClearance=0, int *aActual=nullptr, VECTOR2I *aLocation=nullptr) const override |
Check whether the segment aSeg collides with the polygon set (or its edge). | |
bool | CollideVertex (const VECTOR2I &aPoint, VERTEX_INDEX &aClosestVertex, int aClearance=0) const |
Check whether aPoint collides with any vertex of any of the contours of the polygon. | |
bool | CollideEdge (const VECTOR2I &aPoint, VERTEX_INDEX &aClosestVertex, int aClearance=0) const |
Check whether aPoint collides with any edge of any of the contours of the polygon. | |
void | BuildBBoxCaches () const |
Construct BBoxCaches for Contains(), below. | |
const BOX2I | BBoxFromCaches () const |
bool | Contains (const VECTOR2I &aP, int aSubpolyIndex=-1, int aAccuracy=0, bool aUseBBoxCaches=false) const |
Return true if a given subpolygon contains the point aP. | |
bool | IsEmpty () const |
void | RemoveVertex (int aGlobalIndex) |
Delete the aGlobalIndex-th vertex. | |
void | RemoveVertex (VERTEX_INDEX aRelativeIndices) |
Delete the vertex indexed by aRelativeIndex (index of polygon, contour and vertex). | |
void | RemoveAllContours () |
void | RemoveContour (int aContourIdx, int aPolygonIdx=-1) |
Delete the aContourIdx-th contour of the aPolygonIdx-th polygon in the set. | |
int | RemoveNullSegments () |
Look for null segments; ie, segments whose ends are exactly the same and deletes them. | |
void | SetVertex (const VERTEX_INDEX &aIndex, const VECTOR2I &aPos) |
Accessor function to set the position of a specific point. | |
void | SetVertex (int aGlobalIndex, const VECTOR2I &aPos) |
Set the vertex based on the global index. | |
int | TotalVertices () const |
Delete aIdx-th polygon from the set. | |
void | DeletePolygon (int aIdx) |
POLYGON | ChamferPolygon (unsigned int aDistance, int aIndex) |
Return a chamfered version of the aIndex-th polygon. | |
POLYGON | FilletPolygon (unsigned int aRadius, int aErrorMax, int aIndex) |
Return a filleted version of the aIndex-th polygon. | |
SHAPE_POLY_SET | Chamfer (int aDistance) |
Return a chamfered version of the polygon set. | |
SHAPE_POLY_SET | Fillet (int aRadius, int aErrorMax) |
Return a filleted version of the polygon set. | |
SEG::ecoord | SquaredDistanceToPolygon (VECTOR2I aPoint, int aIndex, VECTOR2I *aNearest) const |
Compute the minimum distance between the aIndex-th polygon and aPoint. | |
SEG::ecoord | SquaredDistanceToPolygon (const SEG &aSegment, int aIndex, VECTOR2I *aNearest) const |
Compute the minimum distance between the aIndex-th polygon and aSegment with a possible width. | |
SEG::ecoord | SquaredDistance (VECTOR2I aPoint, VECTOR2I *aNearest=nullptr) const |
Compute the minimum distance squared between aPoint and all the polygons in the set. | |
SEG::ecoord | SquaredDistance (const SEG &aSegment, VECTOR2I *aNearest=nullptr) const |
Compute the minimum distance squared between aSegment and all the polygons in the set. | |
bool | IsVertexInHole (int aGlobalIdx) |
Check whether the aGlobalIndex-th vertex belongs to a hole. | |
![]() | |
SHAPE (SHAPE_TYPE aType) | |
Create an empty shape of type aType. | |
bool | IsNull () const |
Return true if the shape is a null shape. | |
virtual bool | Collide (const SHAPE *aShape, int aClearance, VECTOR2I *aMTV) const |
Check if the boundary of shape (this) lies closer to the shape aShape than aClearance, indicating a collision. | |
virtual VECTOR2I | Centre () const |
Compute a center-of-mass of the shape. | |
![]() | |
SHAPE_BASE (SHAPE_TYPE aType) | |
Create an empty shape of type aType. | |
SHAPE_TYPE | Type () const |
Return the type of the shape. | |
Static Public Member Functions | |
static const SHAPE_POLY_SET | BuildPolysetFromOrientedPaths (const std::vector< SHAPE_LINE_CHAIN > &aPaths, bool aReverseOrientation=false, bool aEvenOdd=false) |
Build a SHAPE_POLY_SET from a bunch of outlines in provided in random order. | |
Additional Inherited Members | |
![]() | |
static const int | MIN_PRECISION_IU = 4 |
This is the minimum precision for all the points in a shape. | |
![]() | |
typedef VECTOR2I::extended_type | ecoord |
![]() | |
SHAPE_TYPE | m_type |
< type of our shape | |
Represent a set of closed polygons.
Polygons may be nonconvex, self-intersecting and have holes. Provides boolean operations (using Clipper library as the backend).
Let us define the terms used on this class to clarify methods names and comments:
TODO: add convex partitioning & spatial index
typedef std::vector<SHAPE_LINE_CHAIN> SHAPE_POLY_SET::POLYGON |
< represents a single polygon outline with holes.
The first entry is the outline, the remaining (if any), are the holes N.B. SWIG only supports typedef, so avoid c++ 'using' keyword
< define how inflate transform build inflated polygon
Operations on polygons use a aFastMode param if aFastMode is PM_FAST (true) the result can be a weak polygon if aFastMode is PM_STRICTLY_SIMPLE (false) (default) the result is (theoretically) a strictly simple polygon, but calculations can be really significantly time consuming Most of time PM_FAST is preferable.
PM_STRICTLY_SIMPLE can be used in critical cases (Gerber output for instance)
SHAPE_POLY_SET::SHAPE_POLY_SET | ( | const SHAPE_LINE_CHAIN & | aOutline | ) |
Construct a SHAPE_POLY_SET with the first outline given by aOutline.
aOutline | is a closed outline |
SHAPE_POLY_SET::SHAPE_POLY_SET | ( | const SHAPE_POLY_SET & | aOther | ) |
Copy constructor SHAPE_POLY_SET Performs a deep copy of aOther
into this
.
aOther | is the SHAPE_POLY_SET object that will be copied. |
int SHAPE_POLY_SET::Append | ( | int | x, |
int | y, | ||
int | aOutline = -1 , |
||
int | aHole = -1 , |
||
bool | aAllowDuplication = false |
||
) |
Add a new vertex to the contour indexed by aOutline
and aHole
(defaults to the outline of the last polygon).
x | is the x coordinate of the new vertex. |
y | is the y coordinate of the new vertex. |
aOutline | is the index of the polygon. |
aHole | is the index of the hole (-1 for the main outline), |
aAllowDuplication | is a flag to indicate whether it is allowed to add this corner even if it is duplicated. |
int SHAPE_POLY_SET::Append | ( | SHAPE_ARC & | aArc, |
int | aOutline = -1 , |
||
int | aHole = -1 |
||
) |
Append a new arc to the contour indexed by aOutline
and aHole
(defaults to the outline of the last polygon).
aArc | The arc to be inserted |
aOutline | Index of the polygon |
aHole | Index of the hole (-1 for the main outline) |
|
overridevirtual |
Compute a bounding box of the shape, with a margin of aClearance a collision.
aClearance | how much the bounding box is expanded wrs to the minimum enclosing rectangle for the shape. |
Implements SHAPE.
void SHAPE_POLY_SET::BuildBBoxCaches | ( | ) | const |
Construct BBoxCaches for Contains(), below.
|
static |
Build a SHAPE_POLY_SET from a bunch of outlines in provided in random order.
aPath | set of closed outlines forming the polygon. Positive orientation = outline, negative = hole |
aReverseOrientation | inverts the sign of the orientation of aPaths (so negative = outline) |
aEvenOdd | forces the even-off fill rule (default is non zero) |
SHAPE_POLY_SET SHAPE_POLY_SET::Chamfer | ( | int | aDistance | ) |
Return a chamfered version of the polygon set.
aDistance | is the chamfering distance. |
SHAPE_POLY_SET::POLYGON SHAPE_POLY_SET::ChamferPolygon | ( | unsigned int | aDistance, |
int | aIndex | ||
) |
Return a chamfered version of the aIndex-th polygon.
aDistance | is the chamfering distance. |
aIndex | is the index of the polygon to be chamfered. |
|
overridevirtual |
Return a dynamically allocated copy of the shape.
copy | of the shape Creates a new empty polygon in the set and returns its index |
Reimplemented from SHAPE.
|
overridevirtual |
Check whether the segment aSeg collides with the polygon set (or its edge).
Note that prior to Jul 2020 we considered the edge to not be part of the polygon. However, most other shapes (rects, circles, segments, etc.) include their edges and the difference was causing issues when used for DRC.
(FWIW, SHAPE_LINE_CHAIN was a split personality, with Collide() including its edges but PointInside() not. That has also been corrected.)
aSeg | is the SEG segment whose collision with respect to the poly set will be tested. |
aClearance | is the security distance; if the segment passes closer to the polygon than aClearance distance, then there is a collision. |
aActual | an optional pointer to an int to store the actual distance in the event of a collision. |
Implements SHAPE.
|
overridevirtual |
Check if the boundary of shape (this) lies closer to the shape aShape than aClearance, indicating a collision.
aShape | shape to check collision against |
aClearance | minimum clearance |
aActual | [out] an optional pointer to an int to store the actual distance in the event of a collision. |
aLocation | [out] an option pointer to a point to store a nearby location in the event of a collision. |
Reimplemented from SHAPE.
|
overridevirtual |
Check whether the point aP is either inside or on the edge of the polygon set.
Note that prior to Jul 2020 we considered the edge to not be part of the polygon. However, most other shapes (rects, circles, segments, etc.) include their edges and the difference was causing issues when used for DRC.
(FWIW, SHAPE_LINE_CHAIN was a split personality, with Collide() including its edges but PointInside() not. That has also been corrected.)
aP | is the VECTOR2I point whose collision with respect to the poly set will be tested. |
aClearance | is the security distance; if the point lies closer to the polygon than aClearance distance, then there is a collision. |
aActual | an optional pointer to an int to store the actual distance in the event of a collision. |
Reimplemented from SHAPE.
bool SHAPE_POLY_SET::CollideEdge | ( | const VECTOR2I & | aPoint, |
SHAPE_POLY_SET::VERTEX_INDEX & | aClosestVertex, | ||
int | aClearance = 0 |
||
) | const |
Check whether aPoint collides with any edge of any of the contours of the polygon.
aPoint | is the VECTOR2I point whose collision with respect to the polygon will be tested. |
aClearance | is the security distance; if aPoint lies closer to a vertex than aClearance distance, then there is a collision. |
aClosestVertex | is the index of the closes vertex to aPoint . |
bool SHAPE_POLY_SET::CollideVertex | ( | const VECTOR2I & | aPoint, |
SHAPE_POLY_SET::VERTEX_INDEX & | aClosestVertex, | ||
int | aClearance = 0 |
||
) | const |
Check whether aPoint collides with any vertex of any of the contours of the polygon.
aPoint | is the VECTOR2I point whose collision with respect to the polygon will be tested. |
aClearance | is the security distance; if aPoint lies closer to a vertex than aClearance distance, then there is a collision. |
aClosestVertex | is the index of the closes vertex to aPoint . |
bool SHAPE_POLY_SET::Contains | ( | const VECTOR2I & | aP, |
int | aSubpolyIndex = -1 , |
||
int | aAccuracy = 0 , |
||
bool | aUseBBoxCaches = false |
||
) | const |
Return true if a given subpolygon contains the point aP.
aP | is the point to check |
aSubpolyIndex | is the subpolygon to check, or -1 to check all |
aUseBBoxCaches | gives faster performance when multiple calls are made with no editing in between, but the caller MUST cache the bbox caches before calling (via BuildBBoxCaches(), above) |
SHAPE_POLY_SET SHAPE_POLY_SET::Fillet | ( | int | aRadius, |
int | aErrorMax | ||
) |
Return a filleted version of the polygon set.
aRadius | is the fillet radius. |
aErrorMax | is the maximum allowable deviation of the polygon from the circle |
SHAPE_POLY_SET::POLYGON SHAPE_POLY_SET::FilletPolygon | ( | unsigned int | aRadius, |
int | aErrorMax, | ||
int | aIndex | ||
) |
Return a filleted version of the aIndex-th polygon.
aRadius | is the fillet radius. |
aErrorMax | is the maximum allowable deviation of the polygon from the circle |
aIndex | is the index of the polygon to be filleted |
|
overridevirtual |
Reimplemented from SHAPE.
bool SHAPE_POLY_SET::GetGlobalIndex | ( | SHAPE_POLY_SET::VERTEX_INDEX | aRelativeIndices, |
int & | aGlobalIdx | ||
) | const |
Compute the global index of a vertex from the relative indices of polygon, contour and vertex.
aRelativeIndices | is the set of relative indices. |
aGlobalIdx | [out] is the computed global index. |
aGlobalIdx
reference.
|
overridevirtual |
Reimplemented from SHAPE_BASE.
|
overridevirtual |
Reimplemented from SHAPE_BASE.
bool SHAPE_POLY_SET::GetNeighbourIndexes | ( | int | aGlobalIndex, |
int * | aPrevious, | ||
int * | aNext | ||
) |
Return the global indexes of the previous and the next corner of the aGlobalIndex-th corner of a contour in the polygon set.
They are often aGlobalIndex-1 and aGlobalIndex+1, but not for the first and last corner of the contour.
aGlobalIndex | is index of the corner, globally indexed between all edges in all contours |
aPrevious | is the globalIndex of the previous corner of the same contour. |
aNext | is the globalIndex of the next corner of the same contour. |
bool SHAPE_POLY_SET::GetRelativeIndices | ( | int | aGlobalIdx, |
SHAPE_POLY_SET::VERTEX_INDEX * | aRelativeIndices | ||
) | const |
Convert a global vertex index —i.e., a number that globally identifies a vertex in a concatenated list of all vertices in all contours— and get the index of the vertex relative to the contour relative to the polygon in which it is.
aGlobalIdx | is the global index of the corner whose structured index wants to be found |
aRelativeIndices | is a pointer to the set of relative indices to store. |
|
overridevirtual |
Reimplemented from SHAPE_BASE.
void SHAPE_POLY_SET::Inflate | ( | int | aAmount, |
int | aCircleSegCount, | ||
CORNER_STRATEGY | aCornerStrategy = ROUND_ALL_CORNERS |
||
) |
Perform outline inflation/deflation.
Polygons can have holes, but not linked holes with main outlines, if aFactor < 0. For those use InflateWithLinkedHoles() to avoid odd corners where the link segments meet the outline.
aAmount | is the number of units to offset edges. |
aCircleSegCount | is the number of segments per 360 degrees to use in curve approx |
aCornerStrategy | ALLOW_ACUTE_CORNERS to preserve all angles, CHAMFER_ACUTE_CORNERS to chop angles less than 90°, ROUND_ACUTE_CORNERS to round off angles less than 90°, ROUND_ALL_CORNERS to round regardless of angles |
void SHAPE_POLY_SET::InflateWithLinkedHoles | ( | int | aFactor, |
int | aCircleSegmentsCount, | ||
POLYGON_MODE | aFastMode | ||
) |
Perform outline inflation/deflation, using round corners.
Polygons can have holes and/or linked holes with main outlines. The resulting polygons are also polygons with linked holes to main outlines. For aFastMode meaning, see function booleanOp . Convert a set of polygons with holes to a single outline with "slits"/"fractures" connecting the outer ring to the inner holes For aFastMode meaning, see function booleanOp
void SHAPE_POLY_SET::InsertVertex | ( | int | aGlobalIndex, |
const VECTOR2I & | aNewVertex | ||
) |
Adds a vertex in the globally indexed position aGlobalIndex.
aGlobalIndex | is the global index of the position in which the new vertex will be inserted. |
aNewVertex | is the new inserted vertex. Return the index-th vertex in a given hole outline within a given outline |
bool SHAPE_POLY_SET::IsPolygonSelfIntersecting | ( | int | aPolygonIndex | ) | const |
Check whether the aPolygonIndex-th polygon in the set is self intersecting.
aPolygonIndex | is the index of the polygon that wants to be checked. |
bool SHAPE_POLY_SET::IsSelfIntersecting | ( | ) | const |
Check whether any of the polygons in the set is self intersecting.
|
inlineoverridevirtual |
Implements SHAPE.
bool SHAPE_POLY_SET::IsVertexInHole | ( | int | aGlobalIdx | ) |
Check whether the aGlobalIndex-th vertex belongs to a hole.
aGlobalIdx | is the index of the vertex. |
|
inline |
|
inline |
Return an object to iterate through the points of the polygons between aFirst
and aLast
.
aFirst | is the first polygon whose points will be iterated. |
aLast | is the last polygon whose points will be iterated. |
aIterateHoles | is a flag to indicate whether the points of the holes should be iterated. |
|
inline |
aOutline | is the index of the polygon to be iterated. |
|
inline |
|
inline |
aOutline | the index of the polygon to be iterated. |
void SHAPE_POLY_SET::Mirror | ( | bool | aX = true , |
bool | aY = false , |
||
const VECTOR2I & | aRef = { 0, 0 } |
||
) |
Mirror the line points about y or x (or both)
aX | If true, mirror about the y axis (flip x coordinate) |
aY | If true, mirror about the x axis |
aRef | sets the reference point about which to mirror |
int SHAPE_POLY_SET::NormalizeAreaOutlines | ( | ) |
Convert a self-intersecting polygon to one (or more) non self-intersecting polygon(s).
Removes null segments.
|
overridevirtual |
Reimplemented from SHAPE.
bool SHAPE_POLY_SET::PointOnEdge | ( | const VECTOR2I & | aP | ) | const |
Check if point aP lies on an edge or vertex of some of the outlines or holes.
aP | is the point to check. |
void SHAPE_POLY_SET::RemoveContour | ( | int | aContourIdx, |
int | aPolygonIdx = -1 |
||
) |
Delete the aContourIdx-th contour of the aPolygonIdx-th polygon in the set.
aContourIdx | is the index of the contour in the aPolygonIdx-th polygon to be removed. |
aPolygonIdx | is the index of the polygon in which the to-be-removed contour is. Defaults to the last polygon in the set. |
int SHAPE_POLY_SET::RemoveNullSegments | ( | ) |
Look for null segments; ie, segments whose ends are exactly the same and deletes them.
void SHAPE_POLY_SET::RemoveVertex | ( | int | aGlobalIndex | ) |
Delete the aGlobalIndex-th vertex.
aGlobalIndex | is the global index of the to-be-removed vertex. |
void SHAPE_POLY_SET::RemoveVertex | ( | VERTEX_INDEX | aRelativeIndices | ) |
Delete the vertex indexed by aRelativeIndex (index of polygon, contour and vertex).
aRelativeIndices | is the set of relative indices of the to-be-removed vertex. Remove all outlines & holes (clears) the polygon set. |
|
overridevirtual |
Rotate all vertices by a given angle.
aCenter | is the rotation center. |
aAngle | is the rotation angle in radians. |
Implements SHAPE.
void SHAPE_POLY_SET::SetVertex | ( | const VERTEX_INDEX & | aIndex, |
const VECTOR2I & | aPos | ||
) |
Accessor function to set the position of a specific point.
aIndex | #VERTEX_INDEX of the point to move. |
aPos | destination position of the specified point. |
void SHAPE_POLY_SET::SetVertex | ( | int | aGlobalIndex, |
const VECTOR2I & | aPos | ||
) |
Set the vertex based on the global index.
Throws if the index doesn't exist.
aGlobalIndex | global index of the to-be-moved vertex |
aPos | New position on the vertex Return total number of vertices stored in the set. |
SEG::ecoord SHAPE_POLY_SET::SquaredDistance | ( | const SEG & | aSegment, |
VECTOR2I * | aNearest = nullptr |
||
) | const |
Compute the minimum distance squared between aSegment and all the polygons in the set.
Squared distances are used because they avoid the cost of doing square-roots.
aSegment | is the segment whose distance to the polygon set has to be measured. |
aSegmentWidth | is the width of the segment; defaults to zero. |
aNearest | [out] an optional pointer to be filled in with the point on the polyset which is closest to aSegment. |
SEG::ecoord SHAPE_POLY_SET::SquaredDistance | ( | VECTOR2I | aPoint, |
VECTOR2I * | aNearest = nullptr |
||
) | const |
Compute the minimum distance squared between aPoint and all the polygons in the set.
Squared distances are used because they avoid the cost of doing square-roots.
aPoint | is the point whose distance to the set has to be measured. |
aNearest | [out] an optional pointer to be filled in with the point on the polyset which is closest to aPoint. |
SEG::ecoord SHAPE_POLY_SET::SquaredDistanceToPolygon | ( | const SEG & | aSegment, |
int | aIndex, | ||
VECTOR2I * | aNearest | ||
) | const |
Compute the minimum distance between the aIndex-th polygon and aSegment with a possible width.
aSegment | is the segment whose distance to the aIndex-th polygon has to be measured. |
aIndex | is the index of the polygon whose distance to aPoint has to be measured. |
aNearest | [out] an optional pointer to be filled in with the point on the polyset which is closest to aSegment. |
SEG::ecoord SHAPE_POLY_SET::SquaredDistanceToPolygon | ( | VECTOR2I | aPoint, |
int | aIndex, | ||
VECTOR2I * | aNearest | ||
) | const |
Compute the minimum distance between the aIndex-th polygon and aPoint.
aPoint | is the point whose distance to the aIndex-th polygon has to be measured. |
aIndex | is the index of the polygon whose distance to aPoint has to be measured. |
aNearest | [out] an optional pointer to be filled in with the point on the polyset which is closest to aPoint. |
SHAPE_POLY_SET SHAPE_POLY_SET::Subset | ( | int | aFirstPolygon, |
int | aLastPolygon | ||
) |
Return a subset of the polygons in this set, the ones between aFirstPolygon and aLastPolygon.
aFirstPolygon | is the first polygon to be included in the returned set. |
aLastPolygon | is the last polygon to be excluded of the returned set. |
int SHAPE_POLY_SET::VertexCount | ( | int | aOutline = -1 , |
int | aHole = -1 |
||
) | const |
Return the number of points in the shape poly set.
mainly for reports