KiCad PCB EDA Suite
Loading...
Searching...
No Matches
SHAPE_POLY_SET Class Reference

Represent a set of closed polygons. More...

#include <shape_poly_set.h>

Inheritance diagram for SHAPE_POLY_SET:
SHAPE SHAPE_BASE KIFONT::OUTLINE_GLYPH

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...
 
typedef std::vector< SHAPE_LINE_CHAINPOLYGON
 represents a single polygon outline with holes.
 
typedef ITERATOR_TEMPLATE< VECTOR2IITERATOR
 
typedef ITERATOR_TEMPLATE< const VECTOR2ICONST_ITERATOR
 
typedef SEGMENT_ITERATOR_TEMPLATE< SEGSEGMENT_ITERATOR
 
typedef SEGMENT_ITERATOR_TEMPLATE< const SEGCONST_SEGMENT_ITERATOR
 

Public Member Functions

 SHAPE_POLY_SET ()
 
 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 POLYGON &aPolygon)
 Construct a SHAPE_POLY_SET with the first polygon given by aPolygon.
 
 SHAPE_POLY_SET (const SHAPE_POLY_SET &aOther)
 Copy constructor SHAPE_POLY_SET Performs a deep copy of aOther into this.
 
 ~SHAPE_POLY_SET ()
 
SHAPE_POLY_SEToperator= (const SHAPE_POLY_SET &aOther)
 
virtual void CacheTriangulation (bool aPartition=true, bool aSimplify=false)
 Build a polygon triangulation, needed to draw a polygon on OpenGL and in some other calculations.
 
bool IsTriangulationUpToDate () const
 
HASH_128 GetHash () const
 
virtual bool HasIndexableSubshapes () const override
 
virtual size_t GetIndexableSubshapeCount () const override
 
virtual void GetIndexableSubshapes (std::vector< const SHAPE * > &aSubshapes) const 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.
 
SHAPEClone () const override
 Return a dynamically allocated copy of the shape.
 
SHAPE_POLY_SET CloneDropTriangulation () const
 
int NewOutline ()
 Creates a new empty polygon in the set and returns its index.
 
int NewHole (int aOutline=-1)
 Creates a new hole in a given outline.
 
int AddOutline (const SHAPE_LINE_CHAIN &aOutline)
 Adds a new outline to the set and returns its index.
 
int AddHole (const SHAPE_LINE_CHAIN &aHole, int aOutline=-1)
 Adds a new hole to the given outline (default: last) and returns its index.
 
int AddPolygon (const POLYGON &apolygon)
 Adds a polygon to the set.
 
double Area ()
 Return the area of this poly set.
 
int ArcCount () const
 Count the number of arc shapes present.
 
void GetArcs (std::vector< SHAPE_ARC > &aArcBuffer) const
 Appends all the arcs in this polyset to aArcBuffer.
 
void ClearArcs ()
 Removes all arc references from all the outlines and holes in the polyset.
 
int Append (int x, int y, int aOutline=-1, int aHole=-1, bool aAllowDuplication=false)
 Appends a vertex at the end of the given outline/hole (default: the last outline)
 
void Append (const SHAPE_POLY_SET &aSet)
 Merge polygons from two sets.
 
void Append (const VECTOR2I &aP, int aOutline=-1, int aHole=-1)
 Append a vertex at the end of the given outline/hole (default: the last outline)
 
int Append (const SHAPE_ARC &aArc, int aOutline=-1, int aHole=-1, double aAccuracy=SHAPE_ARC::DefaultAccuracyForPCB())
 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 VECTOR2ICVertex (int aIndex, int aOutline, int aHole) const
 Return the index-th vertex in a given hole outline within a given outline.
 
const VECTOR2ICVertex (int aGlobalIndex) const
 Return the aGlobalIndex-th vertex in the poly set.
 
const VECTOR2ICVertex (VERTEX_INDEX aIndex) const
 Return the index-th vertex in a given hole outline within a given outline.
 
bool GetNeighbourIndexes (int aGlobalIndex, int *aPrevious, int *aNext) const
 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 triangulated polygons.
 
int OutlineCount () const
 Return the number of outlines in the set.
 
int VertexCount (int aOutline=-1, int aHole=-1) const
 Return the number of vertices in a given outline/hole.
 
int FullPointCount () const
 Return the number of points in the shape poly set.
 
int HoleCount (int aOutline) const
 Returns the number of holes in a given outline.
 
SHAPE_LINE_CHAINOutline (int aIndex)
 Return the reference to aIndex-th outline in the set.
 
const SHAPE_LINE_CHAINOutline (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)
 
SHAPE_LINE_CHAINHole (int aOutline, int aHole)
 Return the reference to aHole-th hole in the aIndex-th outline.
 
POLYGONPolygon (int aIndex)
 Return the aIndex-th subpolygon in the set.
 
const POLYGONPolygon (int aIndex) const
 
const TRIANGULATED_POLYGONTriangulatedPolygon (int aIndex) const
 
const SHAPE_LINE_CHAINCOutline (int aIndex) const
 
const SHAPE_LINE_CHAINCHole (int aOutline, int aHole) const
 
const POLYGONCPolygon (int aIndex) const
 
const std::vector< POLYGON > & CPolygons () 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)
 
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 between aFirst and aLast outline, with or without holes (default: without)
 
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 iterating aPolygonIdx-th polygon edges.
 
SEGMENT_ITERATOR IterateSegments ()
 Return 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 (no holes)
 
SEGMENT_ITERATOR IterateSegmentsWithHoles ()
 Returns an iterator object, for all outlines 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
 Return an iterator object, for the aOutline-th outline in the set (with holes).
 
void BooleanAdd (const SHAPE_POLY_SET &b, POLYGON_MODE aFastMode)
 Perform boolean polyset union For aFastMode meaning, see function booleanOp.
 
void BooleanSubtract (const SHAPE_POLY_SET &b, POLYGON_MODE aFastMode)
 Perform boolean polyset difference For aFastMode meaning, see function booleanOp.
 
void BooleanIntersection (const SHAPE_POLY_SET &b, POLYGON_MODE aFastMode)
 Perform boolean polyset intersection For aFastMode meaning, see function booleanOp.
 
void BooleanXor (const SHAPE_POLY_SET &b, POLYGON_MODE aFastMode)
 Perform boolean polyset exclusive or For aFastMode meaning, see function booleanOp.
 
void BooleanAdd (const SHAPE_POLY_SET &a, 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 BooleanSubtract (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 BooleanIntersection (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 BooleanXor (const SHAPE_POLY_SET &a, const SHAPE_POLY_SET &b, POLYGON_MODE aFastMode)
 Perform boolean polyset exclusive or between a and b, store the result in it self For aFastMode meaning, see function booleanOp.
 
void RebuildHolesFromContours ()
 Extract all contours from this polygon set, then recreate polygons with holes.
 
void Inflate (int aAmount, CORNER_STRATEGY aCornerStrategy, int aMaxError, bool aSimplify=false)
 Perform outline inflation/deflation.
 
void Deflate (int aAmount, CORNER_STRATEGY aCornerStrategy, int aMaxError)
 
void OffsetLineChain (const SHAPE_LINE_CHAIN &aLine, int aAmount, CORNER_STRATEGY aCornerStrategy, int aMaxError, bool aSimplify)
 Perform offsetting of a line chain.
 
void InflateWithLinkedHoles (int aFactor, CORNER_STRATEGY aCornerStrategy, int aMaxError, POLYGON_MODE aFastMode)
 Perform outline inflation/deflation, using round corners.
 
void Fracture (POLYGON_MODE aFastMode)
 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 Unfracture (POLYGON_MODE aFastMode)
 Convert a single outline slitted ("fractured") polygon into a set ouf outlines with holes.
 
bool HasHoles () const
 Return true if the polygon set has any holes.
 
bool HasTouchingHoles () const
 Return true if the polygon set has any holes that share a vertex.
 
void Simplify (POLYGON_MODE aFastMode)
 Simplify the polyset (merges overlapping polys, eliminates degeneracy/self-intersections) For aFastMode meaning, see function booleanOp.
 
void SimplifyOutlines (int aMaxError=0)
 Simplifies the lines in the polyset.
 
int NormalizeAreaOutlines ()
 Convert a self-intersecting polygon to one (or more) non self-intersecting polygon(s).
 
const std::string Format (bool aCplusPlus=true) const override
 
bool Parse (std::stringstream &aStream) override
 
void Move (const VECTOR2I &aVector) override
 
void Mirror (const VECTOR2I &aRef, FLIP_DIRECTION aFlipDirection)
 Mirror the line points about y or x (or both)
 
void Rotate (const EDA_ANGLE &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, int aAccuracy=0) 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=nullptr, 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=nullptr, int aClearance=0) const
 Check whether aPoint collides with any edge of any of the contours of the polygon.
 
bool PointInside (const VECTOR2I &aPt, int aAccuracy=0, bool aUseBBoxCache=false) const override
 Check if point aP lies inside a closed shape.
 
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
 Return true if the set is empty (no polygons at all)
 
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 ()
 Remove all outlines & holes (clears) the polygon set.
 
void RemoveContour (int aContourIdx, int aPolygonIdx=-1)
 Delete the aContourIdx-th contour of the aPolygonIdx-th polygon in the set.
 
void RemoveOutline (int aOutlineIdx)
 Delete the aOutlineIdx-th outline of the set including its contours and holes.
 
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
 Return total number of vertices stored in the set.
 
void DeletePolygon (int aIdx)
 Delete aIdx-th polygon from the set.
 
void DeletePolygonAndTriangulationData (int aIdx, bool aUpdateHash=true)
 Delete aIdx-th polygon and its triangulation data from the set.
 
void UpdateTriangulationDataHash ()
 
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 (const VECTOR2I &aPoint, bool aOutlineOnly, VECTOR2I *aNearest) const
 Compute the minimum distance squared between aPoint and all the polygons in the set.
 
SEG::ecoord SquaredDistance (const VECTOR2I &aPoint, bool aOutlineOnly=false) const override
 
SEG::ecoord SquaredDistanceToSeg (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.
 
void TransformToPolygon (SHAPE_POLY_SET &aBuffer, int aError, ERROR_LOC aErrorLoc) const override
 Fills a SHAPE_POLY_SET with a polygon representation of this shape.
 
int GetClearance (const SHAPE *aOther) const
 Return the actual minimum distance between two shapes.
 
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.
 
virtual int Distance (const VECTOR2I &aP) const
 Returns the minimum distance from a given point to this shape.
 
FACETNewFacet ()
 
SGNODECalcShape (SGNODE *aParent, SGNODE *aColor, WRL1_ORDER aVertexOrder, float aCreaseLimit=0.74317, bool isVRML2=false)
 
SHAPE_TYPE Type () const
 Return the type of the shape.
 
wxString TypeName () const
 

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.
 

Static Public Attributes

static const int MIN_PRECISION_IU = 4
 This is the minimum precision for all the points in a shape.
 

Protected Types

typedef VECTOR2I::extended_type ecoord
 

Protected Member Functions

void cacheTriangulation (bool aPartition, bool aSimplify, std::vector< std::unique_ptr< TRIANGULATED_POLYGON > > *aHintData)
 

Protected Attributes

std::vector< POLYGONm_polys
 
std::vector< std::unique_ptr< TRIANGULATED_POLYGON > > m_triangulatedPolys
 
std::atomic< bool > m_triangulationValid = false
 
std::mutex m_triangulationMutex
 
SHAPE_TYPE m_type
 < type of our shape
 

Private Types

enum  DROP_TRIANGULATION_FLAG { SINGLETON }
 
enum  CORNER_MODE { CHAMFERED , FILLETED }
 Operation ChamferPolygon and FilletPolygon are computed under the private chamferFillet method; this enum is defined to make the necessary distinction when calling this method from the public ChamferPolygon and FilletPolygon methods. More...
 

Private Member Functions

 SHAPE_POLY_SET (const SHAPE_POLY_SET &aOther, DROP_TRIANGULATION_FLAG)
 
void fractureSingle (POLYGON &paths)
 
void unfractureSingle (POLYGON &path)
 
void importTree (ClipperLib::PolyTree *tree, const std::vector< CLIPPER_Z_VALUE > &aZValueBuffer, const std::vector< SHAPE_ARC > &aArcBuffe)
 
void importTree (Clipper2Lib::PolyTree64 &tree, const std::vector< CLIPPER_Z_VALUE > &aZValueBuffer, const std::vector< SHAPE_ARC > &aArcBuffe)
 
void importPaths (Clipper2Lib::Paths64 &paths, const std::vector< CLIPPER_Z_VALUE > &aZValueBuffer, const std::vector< SHAPE_ARC > &aArcBuffe)
 
void importPolyPath (const std::unique_ptr< Clipper2Lib::PolyPath64 > &aPolyPath, const std::vector< CLIPPER_Z_VALUE > &aZValueBuffer, const std::vector< SHAPE_ARC > &aArcBuffer)
 
void inflate1 (int aAmount, int aCircleSegCount, CORNER_STRATEGY aCornerStrategy)
 
void inflate2 (int aAmount, int aCircleSegCount, CORNER_STRATEGY aCornerStrategy, bool aSimplify=false)
 
void inflateLine2 (const SHAPE_LINE_CHAIN &aLine, int aAmount, int aCircleSegCount, CORNER_STRATEGY aCornerStrategy, bool aSimplify=false)
 
void booleanOp (ClipperLib::ClipType aType, const SHAPE_POLY_SET &aOtherShape, POLYGON_MODE aFastMode)
 This is the engine to execute all polygon boolean transforms (AND, OR, ... and polygon simplification (merging overlapping polygons).
 
void booleanOp (ClipperLib::ClipType aType, const SHAPE_POLY_SET &aShape, const SHAPE_POLY_SET &aOtherShape, POLYGON_MODE aFastMode)
 
void booleanOp (Clipper2Lib::ClipType aType, const SHAPE_POLY_SET &aOtherShape)
 
void booleanOp (Clipper2Lib::ClipType aType, const SHAPE_POLY_SET &aShape, const SHAPE_POLY_SET &aOtherShape)
 
bool containsSingle (const VECTOR2I &aP, int aSubpolyIndex, int aAccuracy, bool aUseBBoxCaches=false) const
 Check whether the point aP is inside the aSubpolyIndex-th polygon of the polyset.
 
POLYGON chamferFilletPolygon (CORNER_MODE aMode, unsigned int aDistance, int aIndex, int aErrorMax)
 Return the chamfered or filleted version of the aIndex-th polygon in the set, depending on the aMode selected.
 
bool hasTouchingHoles (const POLYGON &aPoly) const
 Return true if the polygon set has any holes that touch share a vertex.
 
HASH_128 checksum () const
 

Private Attributes

HASH_128 m_hash
 
bool m_hashValid = false
 
std::list< FACET * > facets
 

Detailed Description

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:

  • Polygon: each polygon in the set.
  • Outline: first polyline in each polygon; represents its outer contour.
  • Hole: second and following polylines in the polygon.
  • Contour: each polyline of each polygon in the set, whether or not it is an outline or a hole.
  • Vertex (or corner): each one of the points that define a contour.

TODO: add convex partitioning & spatial index

Definition at line 68 of file shape_poly_set.h.

Member Typedef Documentation

◆ CONST_ITERATOR

◆ CONST_SEGMENT_ITERATOR

◆ ecoord

typedef VECTOR2I::extended_type SHAPE::ecoord
protectedinherited

Definition at line 284 of file shape.h.

◆ ITERATOR

◆ 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

Definition at line 74 of file shape_poly_set.h.

◆ SEGMENT_ITERATOR

Member Enumeration Documentation

◆ CORNER_MODE

Operation ChamferPolygon and FilletPolygon are computed under the private chamferFillet method; this enum is defined to make the necessary distinction when calling this method from the public ChamferPolygon and FilletPolygon methods.

Enumerator
CHAMFERED 
FILLETED 

Definition at line 1554 of file shape_poly_set.h.

◆ DROP_TRIANGULATION_FLAG

Enumerator
SINGLETON 

Definition at line 1484 of file shape_poly_set.h.

◆ POLYGON_MODE

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)

Enumerator
PM_FAST 
PM_STRICTLY_SIMPLE 

Definition at line 997 of file shape_poly_set.h.

Constructor & Destructor Documentation

◆ SHAPE_POLY_SET() [1/6]

SHAPE_POLY_SET::SHAPE_POLY_SET ( )

Definition at line 75 of file shape_poly_set.cpp.

Referenced by Clone(), and CloneDropTriangulation().

◆ SHAPE_POLY_SET() [2/6]

◆ SHAPE_POLY_SET() [3/6]

SHAPE_POLY_SET::SHAPE_POLY_SET ( const SHAPE_LINE_CHAIN aOutline)

Construct a SHAPE_POLY_SET with the first outline given by aOutline.

Parameters
aOutlineis a closed outline

Definition at line 93 of file shape_poly_set.cpp.

References AddOutline().

◆ SHAPE_POLY_SET() [4/6]

SHAPE_POLY_SET::SHAPE_POLY_SET ( const POLYGON aPolygon)

Construct a SHAPE_POLY_SET with the first polygon given by aPolygon.

Parameters
aPolygonis a polygon

Definition at line 100 of file shape_poly_set.cpp.

References AddPolygon().

◆ SHAPE_POLY_SET() [5/6]

SHAPE_POLY_SET::SHAPE_POLY_SET ( const SHAPE_POLY_SET aOther)

Copy constructor SHAPE_POLY_SET Performs a deep copy of aOther into this.

Parameters
aOtheris the SHAPE_POLY_SET object that will be copied.

Definition at line 107 of file shape_poly_set.cpp.

References HASH_128::Clear(), GetHash(), IsTriangulationUpToDate(), m_hash, m_hashValid, m_triangulatedPolys, m_triangulationValid, TriangulatedPolyCount(), and TriangulatedPolygon().

◆ ~SHAPE_POLY_SET()

SHAPE_POLY_SET::~SHAPE_POLY_SET ( )

Definition at line 146 of file shape_poly_set.cpp.

◆ SHAPE_POLY_SET() [6/6]

SHAPE_POLY_SET::SHAPE_POLY_SET ( const SHAPE_POLY_SET aOther,
DROP_TRIANGULATION_FLAG   
)
private

Member Function Documentation

◆ AddHole()

◆ AddOutline()

int SHAPE_POLY_SET::AddOutline ( const SHAPE_LINE_CHAIN aOutline)

Adds a new outline to the set and returns its index.

Definition at line 547 of file shape_poly_set.cpp.

References SHAPE_LINE_CHAIN::IsClosed(), and m_polys.

Referenced by ZONE_FILLER::addHatchFillTypeOnZone(), ZONE::AddPolygon(), BOOST_AUTO_TEST_CASE(), buildBoardBoundingBoxPoly(), KI_TEST::BuildHollowSquare(), KI_TEST::BuildPolyset(), KI_TEST::CommonTestData::CommonTestData(), ConvertImageToPolygons(), ConvertPolygonToBlocks(), ALTIUM_PCB::ConvertShapeBasedRegions6ToBoardItemOnLayer(), ALTIUM_PCB::ConvertShapeBasedRegions6ToFootprintItemOnLayer(), CADSTAR_ARCHIVE_PARSER::SHAPE::ConvertToPolySet(), MULTICHANNEL_TOOL::copyRuleAreaContents(), FOOTPRINT::CoverageRatio(), BOARD_ADAPTER::createPadWithMargin(), doConvertOutlineToPolygon(), KIGFX::GERBVIEW_PAINTER::draw(), EDA_SHAPE::EDA_SHAPE(), ZONE_FILLER::Fill(), ZONE_FILLER::fillCopperZone(), GEOM_TEST::FilletPolySet(), FOOTPRINT::GetBoundingHull(), PNS::HOLE::Hull(), PNS::SOLID::Hull(), FEATURES_MANAGER::InitFeatureList(), IteratorFixture::IteratorFixture(), KIGFX::knockoutText(), DSN::SPECCTRA_DB::makeIMAGE(), CONVERT_TOOL::makePolysFromChainedSegs(), PAD::MergePrimitivesAsPolygon(), NormalizeAreaOutlines(), PCB_IO_EAGLE::packagePolygon(), PCB_IO_EASYEDAPRO_PARSER::ParseBoard(), PCB_IO_EASYEDAPRO_PARSER::ParseFootprint(), ALTIUM_PCB::ParseRegions6Data(), PCB_IO_KICAD_SEXPR_PARSER::parseRenderCache(), partitionPolyIntoRegularCellGrid(), ZONE_CREATE_HELPER::performZoneCutout(), PlotStandardLayer(), RebuildHolesFromContours(), SHAPE_POLY_SET(), TestConcaveSquareFillet(), TestSquareFillet(), SHAPE_LINE_CHAIN::TransformToPolygon(), and SHAPE_SIMPLE::TransformToPolygon().

◆ AddPolygon()

int SHAPE_POLY_SET::AddPolygon ( const POLYGON apolygon)

Adds a polygon to the set.

Definition at line 580 of file shape_poly_set.cpp.

References m_polys.

Referenced by SHAPE_POLY_SET(), and kiapi::common::UnpackPolySet().

◆ Append() [1/4]

int SHAPE_POLY_SET::Append ( const SHAPE_ARC aArc,
int  aOutline = -1,
int  aHole = -1,
double  aAccuracy = SHAPE_ARC::DefaultAccuracyForPCB() 
)

Append a new arc to the contour indexed by aOutline and aHole (defaults to the outline of the last polygon).

Parameters
aArcThe arc to be inserted
aOutlineIndex of the polygon
aHoleIndex of the hole (-1 for the main outline)
aAccuracyAccuracy of the arc representation in IU
Returns
the number of points in the arc (including the interpolated points from the arc)

Definition at line 294 of file shape_poly_set.cpp.

References m_polys.

◆ Append() [2/4]

void SHAPE_POLY_SET::Append ( const SHAPE_POLY_SET aSet)

Merge polygons from two sets.

Definition at line 2531 of file shape_poly_set.cpp.

References m_polys.

◆ Append() [3/4]

void SHAPE_POLY_SET::Append ( const VECTOR2I aP,
int  aOutline = -1,
int  aHole = -1 
)

Append a vertex at the end of the given outline/hole (default: the last outline)

Definition at line 2537 of file shape_poly_set.cpp.

References Append(), VECTOR2< T >::x, and VECTOR2< T >::y.

◆ Append() [4/4]

int SHAPE_POLY_SET::Append ( int  x,
int  y,
int  aOutline = -1,
int  aHole = -1,
bool  aAllowDuplication = false 
)

Appends a vertex at the end of the given outline/hole (default: the last outline)

Add a new vertex to the contour indexed by aOutline and aHole (defaults to the outline of the last polygon).

Parameters
xis the x coordinate of the new vertex.
yis the y coordinate of the new vertex.
aOutlineis the index of the polygon.
aHoleis the index of the hole (-1 for the main outline),
aAllowDuplicationis a flag to indicate whether it is allowed to add this corner even if it is duplicated.
Returns
the number of corners of the selected contour after the addition.

Definition at line 271 of file shape_poly_set.cpp.

References m_polys.

Referenced by AR_AUTOPLACER::addFpBody(), addHoleToPolygon(), ZONE_FILLER::addKnockout(), AR_AUTOPLACER::addPad(), PAD::AddPrimitivePoly(), PCB_IO_IPC2581::addShape(), Append(), ZONE::AppendCorner(), BOARD::BOARD(), BOOST_AUTO_TEST_CASE(), BuildBoardPolygonOutlines(), PCB_TEXT::buildBoundingHull(), ZONE_FILLER::buildCopperItemClearances(), BuildFootprintPolygonOutlines(), TEARDROP_MANAGER::computeAnchorPoints(), AM_PRIMITIVE::ConvertBasicShapeToPolygon(), ALTIUM_PCB::ConvertFills6ToFootprintItemOnLayer(), GERBER_DRAW_ITEM::ConvertSegmentToPolygon(), D_CODE::ConvertShapeToPolygon(), CornerListToPolygon(), BITMAPCONV_INFO::createOutputData(), BOARD_ADAPTER::createPadWithMargin(), STEP_PCB_MODEL::CreatePCB(), CONVERT_TOOL::CreatePolys(), TEARDROP_MANAGER::createTeardrop(), KIGFX::PCB_PAINTER::draw(), KIGFX::GERBVIEW_PAINTER::drawPolygon(), GERBER_FILE_IMAGE::Execute_DCODE_Command(), GERBER_FILE_IMAGE::Execute_G_Command(), fillArcPOLY(), PCB_BASE_FRAME::FocusOnItems(), FOOTPRINT::GetBoundingHull(), getRectangleAlongCentreLine(), EDA_SHAPE::hitTest(), InsertVertex(), KIGFX::knockoutText(), FABMASTER::loadFootprints(), PCB_IO_EAGLE::loadPolygon(), FABMASTER::loadShapePolySet(), SCH_IO_EAGLE::loadSymbolPolyLine(), PCB_IO_KICAD_LEGACY::loadZONE_CONTAINER(), DSN::SPECCTRA_DB::makeIMAGE(), CONVERT_TOOL::makePolysFromClosedGraphics(), PCB_IO_EASYEDAPRO_PARSER::ParseBoard(), PCB_IO_EASYEDA_PARSER::ParseToBoardItemContainer(), DXF_PLOTTER::PlotPoly(), BRDITEMS_PLOTTER::PlotShape(), PlotStandardLayer(), POLYGON_BOOLEAN_ROUTINE::ProcessShape(), RENDER_3D_OPENGL::reload(), EDA_SHAPE::rotate(), KIGFX::PREVIEW::POLYGON_ITEM::SetPoints(), EDA_SHAPE::SetPolyPoints(), SHAPE_POLY_SET(), DS_DATA_ITEM_POLYGONS::SyncDrawItems(), TransformArcToPolygon(), TransformCircleToPolygon(), TransformOvalToPolygon(), TransformRingToPolygon(), TransformRoundChamferedRectToPolygon(), EDA_SHAPE::TransformShapeToPolygon(), ZONE::TransformShapeToPolygon(), PCB_TEXTBOX::TransformShapeToPolygon(), PAD::TransformShapeToPolygon(), ZONE::TransformSmoothedOutlineToPolygon(), ZONE::TransformSolidAreasShapesToPolygon(), PCB_TEXT::TransformTextToPolySet(), PCB_TEXTBOX::TransformTextToPolySet(), TransformToPolygon(), TransformTrapezoidToPolygon(), PCB_DIM_ALIGNED::updateGeometry(), PCB_DIM_ORTHOGONAL::updateGeometry(), PCB_DIM_RADIAL::updateGeometry(), and PCB_DIM_LEADER::updateGeometry().

◆ ArcCount()

int SHAPE_POLY_SET::ArcCount ( ) const

Count the number of arc shapes present.

Definition at line 604 of file shape_poly_set.cpp.

References ArcCount(), and m_polys.

Referenced by ArcCount(), and booleanOp().

◆ Area()

◆ BBox()

◆ BBoxFromCaches()

◆ BooleanAdd() [1/2]

void SHAPE_POLY_SET::BooleanAdd ( const SHAPE_POLY_SET a,
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.

Definition at line 997 of file shape_poly_set.cpp.

References booleanOp().

◆ BooleanAdd() [2/2]

◆ BooleanIntersection() [1/2]

void SHAPE_POLY_SET::BooleanIntersection ( 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.

Definition at line 1011 of file shape_poly_set.cpp.

References booleanOp().

◆ BooleanIntersection() [2/2]

◆ booleanOp() [1/4]

void SHAPE_POLY_SET::booleanOp ( Clipper2Lib::ClipType  aType,
const SHAPE_POLY_SET aOtherShape 
)
private

Definition at line 859 of file shape_poly_set.cpp.

References booleanOp().

◆ booleanOp() [2/4]

void SHAPE_POLY_SET::booleanOp ( Clipper2Lib::ClipType  aType,
const SHAPE_POLY_SET aShape,
const SHAPE_POLY_SET aOtherShape 
)
private

◆ booleanOp() [3/4]

void SHAPE_POLY_SET::booleanOp ( ClipperLib::ClipType  aType,
const SHAPE_POLY_SET aOtherShape,
POLYGON_MODE  aFastMode 
)
private

This is the engine to execute all polygon boolean transforms (AND, OR, ... and polygon simplification (merging overlapping polygons).

Parameters
aTypeis the transform type ( see ClipperLib::ClipType )
aOtherShapeis the SHAPE_LINE_CHAIN to combine with me.
aFastModeis an option to choose if the result can be a weak polygon or a strictly simple polygon. if aFastMode is PM_FAST the result can be a weak polygon if aFastMode is PM_STRICTLY_SIMPLE (default) the result is (theoretically) a strictly simple polygon, but calculations can be really significantly time consuming

Definition at line 747 of file shape_poly_set.cpp.

References booleanOp().

Referenced by BooleanAdd(), BooleanIntersection(), booleanOp(), BooleanSubtract(), BooleanXor(), and Simplify().

◆ booleanOp() [4/4]

void SHAPE_POLY_SET::booleanOp ( ClipperLib::ClipType  aType,
const SHAPE_POLY_SET aShape,
const SHAPE_POLY_SET aOtherShape,
POLYGON_MODE  aFastMode 
)
private

◆ BooleanSubtract() [1/2]

void SHAPE_POLY_SET::BooleanSubtract ( 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.

Definition at line 1004 of file shape_poly_set.cpp.

References booleanOp().

◆ BooleanSubtract() [2/2]

◆ BooleanXor() [1/2]

void SHAPE_POLY_SET::BooleanXor ( const SHAPE_POLY_SET a,
const SHAPE_POLY_SET b,
POLYGON_MODE  aFastMode 
)

Perform boolean polyset exclusive or between a and b, store the result in it self For aFastMode meaning, see function booleanOp.

Definition at line 1018 of file shape_poly_set.cpp.

References booleanOp().

◆ BooleanXor() [2/2]

void SHAPE_POLY_SET::BooleanXor ( const SHAPE_POLY_SET b,
POLYGON_MODE  aFastMode 
)

Perform boolean polyset exclusive or For aFastMode meaning, see function booleanOp.

Definition at line 991 of file shape_poly_set.cpp.

References booleanOp().

Referenced by playground_main_func().

◆ BuildBBoxCaches()

void SHAPE_POLY_SET::BuildBBoxCaches ( ) const

Construct BBoxCaches for Contains(), below.

Note
These caches must be built before a group of calls to Contains(). They are not kept up-to-date by editing actions.

Definition at line 2616 of file shape_poly_set.cpp.

References CHole(), COutline(), SHAPE_LINE_CHAIN::GenerateBBoxCache(), HoleCount(), and OutlineCount().

Referenced by ZONE_FILLER::fillCopperZone(), and DRC_TEST_PROVIDER_COPPER_CLEARANCE::testZonesToZones().

◆ BuildPolysetFromOrientedPaths()

const SHAPE_POLY_SET SHAPE_POLY_SET::BuildPolysetFromOrientedPaths ( const std::vector< SHAPE_LINE_CHAIN > &  aPaths,
bool  aReverseOrientation = false,
bool  aEvenOdd = false 
)
static

Build a SHAPE_POLY_SET from a bunch of outlines in provided in random order.

Parameters
aPathset of closed outlines forming the polygon. Positive orientation = outline, negative = hole
aReverseOrientationinverts the sign of the orientation of aPaths (so negative = outline)
aEvenOddforces the even-off fill rule (default is non zero)
Returns
the constructed poly set

Definition at line 3502 of file shape_poly_set.cpp.

References SHAPE_LINE_CHAIN::Append(), Hole(), NewHole(), NewOutline(), Outline(), and path.

Referenced by convertPolygon().

◆ cacheTriangulation()

◆ CacheTriangulation()

virtual void SHAPE_POLY_SET::CacheTriangulation ( bool  aPartition = true,
bool  aSimplify = false 
)
inlinevirtual

Build a polygon triangulation, needed to draw a polygon on OpenGL and in some other calculations.

Parameters
aPartition= true to created a trinagulation in a partition on a grid false to create a more basic triangulation of the polygons Note in partition calculations the grid size is hard coded to 1e7. This is a good value for Pcbnew: 1cm, in internal units. But not good for Gerbview (1e7 = 10cm), however using a partition is not useful.
aSimplify= force the algorithm to simplify the POLY_SET before triangulating

Reimplemented in KIFONT::OUTLINE_GLYPH.

Definition at line 550 of file shape_poly_set.h.

References cacheTriangulation().

Referenced by FOOTPRINT::BuildCourtyardCaches(), KIFONT::OUTLINE_GLYPH::CacheTriangulation(), ZONE::CacheTriangulation(), Collide(), MULTICHANNEL_TOOL::copyRuleAreaContents(), KIGFX::PCB_PAINTER::draw(), KIGFX::GERBVIEW_PAINTER::draw(), Mirror(), Rotate(), and PNS_KICAD_IFACE_BASE::syncZone().

◆ CalcShape()

◆ Centre()

virtual VECTOR2I SHAPE::Centre ( ) const
inlinevirtualinherited

Compute a center-of-mass of the shape.

Returns
the center-of-mass point

Definition at line 232 of file shape.h.

References SHAPE::BBox(), and BOX2< Vec >::Centre().

Referenced by PNS::TOPOLOGY::AssembleDiffPair(), Collide(), SCH_EASYEDA_PARSER::ParseSchematic(), and pickSegment().

◆ Chamfer()

SHAPE_POLY_SET SHAPE_POLY_SET::Chamfer ( int  aDistance)

Return a chamfered version of the polygon set.

Parameters
aDistanceis the chamfering distance.
Returns
A set containing the chamfered version of this set.

Definition at line 2918 of file shape_poly_set.cpp.

References ChamferPolygon(), and m_polys.

Referenced by ZONE_FILLER::addHatchFillTypeOnZone().

◆ chamferFilletPolygon()

SHAPE_POLY_SET::POLYGON SHAPE_POLY_SET::chamferFilletPolygon ( CORNER_MODE  aMode,
unsigned int  aDistance,
int  aIndex,
int  aErrorMax 
)
private

Return the chamfered or filleted version of the aIndex-th polygon in the set, depending on the aMode selected.

Parameters
aModerepresent which action will be taken: CORNER_MODE::CHAMFERED will return a chamfered version of the polygon, CORNER_MODE::FILLETED will return a filleted version of the polygon.
aDistanceis the chamfering distance if aMode = CHAMFERED; if aMode = FILLETED, is the filleting radius.
aIndexis the index of the polygon that will be chamfered/filleted.
aErrorMaxis the maximum allowable deviation of the polygon from the circle if aMode = FILLETED. If aMode = CHAMFERED, it is unused.
Returns
the chamfered/filleted version of the polygon.

Definition at line 2940 of file shape_poly_set.cpp.

References std::abs(), SHAPE_LINE_CHAIN::Append(), CHAMFERED, SHAPE_LINE_CHAIN::CPoint(), distance(), GetArcToSegmentCount(), KiROUND(), Polygon(), RADIANS_T, RemoveNullSegments(), SHAPE_LINE_CHAIN::SetClosed(), and VECTOR2< T >::x.

Referenced by ChamferPolygon(), and FilletPolygon().

◆ ChamferPolygon()

SHAPE_POLY_SET::POLYGON SHAPE_POLY_SET::ChamferPolygon ( unsigned int  aDistance,
int  aIndex 
)

Return a chamfered version of the aIndex-th polygon.

Parameters
aDistanceis the chamfering distance.
aIndexis the index of the polygon to be chamfered.
Returns
A polygon containing the chamfered version of the aIndex-th polygon.

Definition at line 2765 of file shape_poly_set.cpp.

References CHAMFERED, and chamferFilletPolygon().

Referenced by Chamfer().

◆ checksum()

◆ CHole()

◆ CIterate() [1/3]

CONST_ITERATOR SHAPE_POLY_SET::CIterate ( ) const
inline

Definition at line 879 of file shape_poly_set.h.

References CIterate(), and OutlineCount().

Referenced by CIterate(), and CIterateWithHoles().

◆ CIterate() [2/3]

◆ CIterate() [3/3]

CONST_ITERATOR SHAPE_POLY_SET::CIterate ( int  aOutline) const
inline

Definition at line 869 of file shape_poly_set.h.

References CIterate().

◆ CIterateSegments() [1/3]

CONST_SEGMENT_ITERATOR SHAPE_POLY_SET::CIterateSegments ( ) const
inline

Returns an iterator object, for all outlines in the set (no holes)

Definition at line 960 of file shape_poly_set.h.

References CIterateSegments(), and OutlineCount().

Referenced by CIterateSegments(), and CIterateSegmentsWithHoles().

◆ CIterateSegments() [2/3]

◆ CIterateSegments() [3/3]

CONST_SEGMENT_ITERATOR SHAPE_POLY_SET::CIterateSegments ( int  aPolygonIdx) const
inline

Return an iterator object, for iterating aPolygonIdx-th polygon edges.

Definition at line 948 of file shape_poly_set.h.

References CIterateSegments().

◆ CIterateSegmentsWithHoles() [1/2]

CONST_SEGMENT_ITERATOR SHAPE_POLY_SET::CIterateSegmentsWithHoles ( ) const
inline

Return an iterator object, for the aOutline-th outline in the set (with holes).

Definition at line 978 of file shape_poly_set.h.

References CIterateSegments(), and OutlineCount().

Referenced by CreepageGraph::Addshape(), CollideEdge(), IsPolygonSelfIntersecting(), and SquaredDistanceToPolygon().

◆ CIterateSegmentsWithHoles() [2/2]

CONST_SEGMENT_ITERATOR SHAPE_POLY_SET::CIterateSegmentsWithHoles ( int  aOutline) const
inline

Return an iterator object, for the aOutline-th outline in the set (with holes).

Definition at line 984 of file shape_poly_set.h.

References CIterateSegments().

◆ CIterateWithHoles() [1/2]

CONST_ITERATOR SHAPE_POLY_SET::CIterateWithHoles ( ) const
inline

Definition at line 884 of file shape_poly_set.h.

References CIterate(), and OutlineCount().

Referenced by CollideVertex().

◆ CIterateWithHoles() [2/2]

CONST_ITERATOR SHAPE_POLY_SET::CIterateWithHoles ( int  aOutline) const
inline

◆ ClearArcs()

◆ Clone()

SHAPE * SHAPE_POLY_SET::Clone ( ) const
overridevirtual

Return a dynamically allocated copy of the shape.

Return values
copyof the shape

Reimplemented from SHAPE.

Definition at line 151 of file shape_poly_set.cpp.

References SHAPE_POLY_SET().

◆ CloneDropTriangulation()

◆ Collide() [1/4]

bool SHAPE_POLY_SET::Collide ( const SEG aSeg,
int  aClearance = 0,
int *  aActual = nullptr,
VECTOR2I aLocation = nullptr 
) const
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.)

Parameters
aSegis the SEG segment whose collision with respect to the poly set will be tested.
aClearanceis the security distance; if the segment passes closer to the polygon than aClearance distance, then there is a collision.
aActualan optional pointer to an int to store the actual distance in the event of a collision.
Returns
true if the segment aSeg collides with the polygon, false in any other case.

Implements SHAPE.

Definition at line 2284 of file shape_poly_set.cpp.

References SEG::Square(), and SquaredDistanceToSeg().

◆ Collide() [2/4]

bool SHAPE::Collide ( const SHAPE aShape,
int  aClearance,
VECTOR2I aMTV 
) const
virtualinherited

Check if the boundary of shape (this) lies closer to the shape aShape than aClearance, indicating a collision.

Parameters
aShapeshape to check collision against
aClearanceminimum clearance
aMTV[out] minimum translation vector
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.
Returns
true, if there is a collision.

Reimplemented in SHAPE_COMPOUND, SHAPE_RECT, and SHAPE_SEGMENT.

Definition at line 1172 of file shape_collisions.cpp.

References collideShapes().

◆ Collide() [3/4]

bool SHAPE_POLY_SET::Collide ( const SHAPE aShape,
int  aClearance = 0,
int *  aActual = nullptr,
VECTOR2I aLocation = nullptr 
) const
overridevirtual

Check if the boundary of shape (this) lies closer to the shape aShape than aClearance, indicating a collision.

Parameters
aShapeshape to check collision against
aClearanceminimum 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.
Returns
true if there is a collision.

Reimplemented from SHAPE.

Definition at line 2329 of file shape_poly_set.cpp.

References CacheTriangulation(), Collide(), SHAPE::Collide(), SHAPE_CIRCLE::GetCenter(), SHAPE_CIRCLE::GetRadius(), SHAPE_SEGMENT::GetSeg(), SHAPE_SEGMENT::GetWidth(), m_triangulatedPolys, SH_CIRCLE, SH_SEGMENT, and SHAPE_BASE::Type().

Referenced by Collide(), collideSingleShapes(), collidesWithArea(), collidesWithCourtyard(), PAD::doCheckPad(), DRAWING_TOOL::DrawVia(), ZONE_FILLER::Fill(), ZONE::GetInteractingZones(), EDA_SHAPE::hitTest(), DS_DRAW_ITEM_POLYPOLYGONS::HitTest(), FOOTPRINT::HitTestAccurate(), PCB_SELECTION_TOOL::hitTestDistance(), ZONE_FILLER::knockoutThermalReliefs(), DRC_TEST_PROVIDER_ANNULAR_WIDTH::Run(), DRC_INTERACTIVE_COURTYARD_CLEARANCE::testCourtyardClearances(), DRC_TEST_PROVIDER_COURTYARD_CLEARANCE::testCourtyardClearances(), and DRC_TEST_PROVIDER_PHYSICAL_CLEARANCE::testItemAgainstZones().

◆ Collide() [4/4]

bool SHAPE_POLY_SET::Collide ( const VECTOR2I aP,
int  aClearance = 0,
int *  aActual = nullptr,
VECTOR2I aLocation = nullptr 
) const
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.)

Parameters
aPis the VECTOR2I point whose collision with respect to the poly set will be tested.
aClearanceis the security distance; if the point lies closer to the polygon than aClearance distance, then there is a collision.
aActualan optional pointer to an int to store the actual distance in the event of a collision.
Returns
true if the point aP collides with the polygon; false in any other case.

Reimplemented from SHAPE.

Definition at line 2305 of file shape_poly_set.cpp.

References IsEmpty(), SEG::Square(), SquaredDistance(), and VertexCount().

◆ CollideEdge()

bool SHAPE_POLY_SET::CollideEdge ( const VECTOR2I aPoint,
SHAPE_POLY_SET::VERTEX_INDEX aClosestVertex = nullptr,
int  aClearance = 0 
) const

Check whether aPoint collides with any edge of any of the contours of the polygon.

Parameters
aPointis the VECTOR2I point whose collision with respect to the polygon will be tested.
aClearanceis the security distance; if aPoint lies closer to a vertex than aClearance distance, then there is a collision.
aClosestVertexis the index of the closes vertex to aPoint.
Returns
bool - true if there is a collision, false in any other case.

Definition at line 2583 of file shape_poly_set.cpp.

References CIterateSegmentsWithHoles(), SEG::Square(), and SEG::SquaredDistance().

Referenced by EDA_SHAPE::hitTest(), ZONE::HitTestForEdge(), and SCH_EDIT_FRAME::RecalculateConnections().

◆ CollideVertex()

bool SHAPE_POLY_SET::CollideVertex ( const VECTOR2I aPoint,
SHAPE_POLY_SET::VERTEX_INDEX aClosestVertex = nullptr,
int  aClearance = 0 
) const

Check whether aPoint collides with any vertex of any of the contours of the polygon.

Parameters
aPointis the VECTOR2I point whose collision with respect to the polygon will be tested.
aClearanceis the security distance; if aPoint lies closer to a vertex than aClearance distance, then there is a collision.
aClosestVertexis the index of the closes vertex to aPoint.
Returns
bool - true if there is a collision, false in any other case.

Definition at line 2543 of file shape_poly_set.cpp.

References CIterateWithHoles(), delta, and SEG::Square().

Referenced by ZONE::HitTestForCorner().

◆ Contains()

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.

Parameters
aPis the point to check
aSubpolyIndexis the subpolygon to check, or -1 to check all
aUseBBoxCachesgives 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)
Returns
true if the polygon contains the point

Definition at line 2628 of file shape_poly_set.cpp.

References containsSingle(), m_polys, and OutlineCount().

Referenced by CollectKnockedOutSegments(), ZONE_FILLER::fillCopperZone(), CADSTAR_PCB_ARCHIVE_LOADER::getKiCadPad(), GERBER_DRAW_ITEM::HitTest(), ZONE::HitTestFilledArea(), PATH_CONNECTION::isValid(), segPolyIntersection(), and BOARD::TestZoneIntersection().

◆ containsSingle()

bool SHAPE_POLY_SET::containsSingle ( const VECTOR2I aP,
int  aSubpolyIndex,
int  aAccuracy,
bool  aUseBBoxCaches = false 
) const
private

Check whether the point aP is inside the aSubpolyIndex-th polygon of the polyset.

If the points lies on an edge, the polygon is considered to contain it.

Parameters
aPis the VECTOR2I point whose position with respect to the inside of the aSubpolyIndex-th polygon will be tested.
aSubpolyIndexis an integer specifying which polygon in the set has to be checked.
aAccuracyaccuracy in internal units
aUseBBoxCachesgives 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)
Returns
true if aP is inside aSubpolyIndex-th polygon; false in any other case.

Definition at line 2684 of file shape_poly_set.cpp.

References CHole(), HoleCount(), m_polys, SHAPE_LINE_CHAIN_BASE::PointInside(), and PointInside().

Referenced by Contains(), and SquaredDistanceToPolygon().

◆ COutline()

const SHAPE_LINE_CHAIN & SHAPE_POLY_SET::COutline ( int  aIndex) const
inline

Definition at line 775 of file shape_poly_set.h.

References m_polys.

Referenced by PAD::AddPrimitivePoly(), FEATURES_MANAGER::AddShape(), TRIANGLE_DISPLAY_LIST::AddToMiddleContourns(), PNS_LOG_VIEWER_OVERLAY::AnnotatedPolyset(), BuildBBoxCaches(), BuildConvexHull(), PAD::buildEffectiveShape(), convertPolygon(), ConvertPolygonToBlocks(), MULTICHANNEL_TOOL::copyRuleAreaContents(), GENCAD_EXPORTER::CreatePadsShapesSection(), CONVERT_TOOL::CreatePolys(), KIGFX::PCB_PAINTER::Draw(), KIGFX::PCB_PAINTER::draw(), KIGFX::GERBVIEW_PAINTER::draw(), KIGFX::GERBVIEW_PAINTER::drawApertureMacro(), KIGFX::CAIRO_GAL_BASE::DrawPolygon(), KIGFX::OPENGL_GAL::DrawPolygon(), KIGFX::GERBVIEW_PAINTER::drawPolygon(), KIGFX::PREVIEW::POLYGON_ITEM::drawPreviewShape(), EDA_SHAPE::DupPolyPointsList(), EXPORTER_PCB_VRML::ExportVrmlBoard(), EXPORTER_PCB_VRML::ExportVrmlPolygonSet(), FOOTPRINT::GetBoundingHull(), SHAPE::GetClearance(), FOOTPRINT::GetEffectiveShape(), EDA_SHAPE::GetLength(), CADSTAR_PCB_ARCHIVE_LOADER::getZoneFromCadstarShape(), API_HANDLER_PCB::handleGetPadShapeAsPolygon(), DS_DRAW_ITEM_POLYPOLYGONS::HitTest(), EDA_SHAPE::hitTest(), CONNECTIVITY_DATA::IsConnectedOnLayer(), FABMASTER::loadGraphics(), FABMASTER::loadPolygon(), PCB_IO_EAGLE::loadPolygon(), EDA_SHAPE::makeEffectiveShapes(), SCH_RULE_AREA::MakeEffectiveShapes(), DSN::SPECCTRA_DB::makePADSTACK(), SHAPE_LINE_CHAIN::OffsetLine(), PCB_IO_EASYEDA_PARSER::ParseToBoardItemContainer(), PlotLayerOutlines(), DXF_PLOTTER::PlotPoly(), BRDITEMS_PLOTTER::PlotShape(), SHAPE::PointInside(), PointInside(), DRC_TEST_PROVIDER_ANNULAR_WIDTH::Run(), SHAPE::SquaredDistance(), DXF_PLOTTER::ThickSegment(), HYPERLYNX_EXPORTER::writeBoardInfo(), HYPERLYNX_EXPORTER::writeNetObjects(), and GBR_TO_PCB_EXPORTER::writePcbPolygon().

◆ CPolygon()

◆ CPolygons()

◆ CVertex() [1/3]

const VECTOR2I & SHAPE_POLY_SET::CVertex ( int  aGlobalIndex) const

◆ CVertex() [2/3]

◆ CVertex() [3/3]

const VECTOR2I & SHAPE_POLY_SET::CVertex ( SHAPE_POLY_SET::VERTEX_INDEX  index) const

Return the index-th vertex in a given hole outline within a given outline.

Definition at line 429 of file shape_poly_set.cpp.

References CVertex(), SHAPE_POLY_SET::VERTEX_INDEX::m_contour, SHAPE_POLY_SET::VERTEX_INDEX::m_polygon, and SHAPE_POLY_SET::VERTEX_INDEX::m_vertex.

◆ Deflate()

◆ DeletePolygon()

void SHAPE_POLY_SET::DeletePolygon ( int  aIdx)

Delete aIdx-th polygon from the set.

Definition at line 2493 of file shape_poly_set.cpp.

References m_polys.

Referenced by ZONE_FILLER::addHatchFillTypeOnZone(), BOOST_AUTO_TEST_CASE(), cacheTriangulation(), ZONE_FILLER::fillCopperZone(), and PlotStandardLayer().

◆ DeletePolygonAndTriangulationData()

void SHAPE_POLY_SET::DeletePolygonAndTriangulationData ( int  aIdx,
bool  aUpdateHash = true 
)

Delete aIdx-th polygon and its triangulation data from the set.

If called with aUpdateHash false, caller must call UpdateTriangulationDataHash().

Definition at line 2499 of file shape_poly_set.cpp.

References checksum(), m_hash, m_hashValid, m_polys, m_triangulatedPolys, and m_triangulationValid.

◆ Distance()

int SHAPE::Distance ( const VECTOR2I aP) const
virtualinherited

Returns the minimum distance from a given point to this shape.

Always returns zero if the point is inside a closed shape and aOutlineOnly is false.

Parameters
aPis the point to test
Returns
the distance from the shape to aP

Reimplemented in SHAPE_COMPOUND, and SHAPE_LINE_CHAIN.

Definition at line 108 of file shape.cpp.

References SHAPE::SquaredDistance().

◆ Fillet()

SHAPE_POLY_SET SHAPE_POLY_SET::Fillet ( int  aRadius,
int  aErrorMax 
)

Return a filleted version of the polygon set.

Parameters
aRadiusis the fillet radius.
aErrorMaxis the maximum allowable deviation of the polygon from the circle
Returns
A set containing the filleted version of this set.

Definition at line 2929 of file shape_poly_set.cpp.

References FilletPolygon(), and m_polys.

Referenced by ZONE_FILLER::addHatchFillTypeOnZone().

◆ FilletPolygon()

SHAPE_POLY_SET::POLYGON SHAPE_POLY_SET::FilletPolygon ( unsigned int  aRadius,
int  aErrorMax,
int  aIndex 
)

Return a filleted version of the aIndex-th polygon.

Parameters
aRadiusis the fillet radius.
aErrorMaxis the maximum allowable deviation of the polygon from the circle
aIndexis the index of the polygon to be filleted
Returns
A polygon containing the filleted version of the aIndex-th polygon.

Definition at line 2771 of file shape_poly_set.cpp.

References chamferFilletPolygon(), and FILLETED.

Referenced by Fillet(), and GEOM_TEST::FilletPolySet().

◆ Format()

const std::string SHAPE_POLY_SET::Format ( bool  aCplusPlus = true) const
overridevirtual

Reimplemented from SHAPE.

Definition at line 2144 of file shape_poly_set.cpp.

References m_polys.

◆ Fracture()

void SHAPE_POLY_SET::Fracture ( POLYGON_MODE  aFastMode)

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.

Definition at line 1889 of file shape_poly_set.cpp.

References fractureSingle(), m_polys, and Simplify().

Referenced by addHoleToPolygon(), PCB_IO_IPC2581::addKnockoutText(), PAD::addPadPrimitivesToPolygon(), PAD::AddPrimitivePoly(), FEATURES_MANAGER::AddShape(), cacheTriangulation(), convertPolygon(), BITMAPCONV_INFO::createOutputData(), KIGFX::PCB_PAINTER::draw(), CADSTAR_PCB_ARCHIVE_LOADER::drawCadstarShape(), CALLBACK_GAL::DrawGlyph(), AR_AUTOPLACER::drawPlacementRoutingMatrix(), EXPORTER_PCB_VRML::ExportStandardLayers(), EXPORTER_PCB_VRML::ExportVrmlSolderMask(), ZONE_FILLER::fillCopperZone(), AR_AUTOPLACER::fillMatrix(), ZONE_FILLER::fillNonCopperZone(), APERTURE_MACRO::GetApertureMacroShape(), InflateWithLinkedHoles(), FEATURES_MANAGER::InitFeatureList(), KIGFX::knockoutText(), CADSTAR_PCB_ARCHIVE_LOADER::loadCoppers(), FABMASTER::loadFootprints(), FABMASTER::loadGraphics(), FABMASTER::loadPolygon(), PCB_IO_EASYEDAPRO_PARSER::ParseBoard(), ALTIUM_PCB::ParseRegions6Data(), PCB_IO_EASYEDA_PARSER::ParseToBoardItemContainer(), DXF_PLOTTER::PlotPoly(), BRDITEMS_PLOTTER::PlotShape(), PlotSolderMaskLayer(), BRDITEMS_PLOTTER::PlotText(), RENDER_3D_RAYTRACE_BASE::Reload(), DRC_TEST_PROVIDER_DISALLOW::Run(), EDA_SHAPE::SetPolyShape(), TransformRingToPolygon(), PAD::TransformShapeToPolygon(), and ZONE::TransformSmoothedOutlineToPolygon().

◆ fractureSingle()

void SHAPE_POLY_SET::fractureSingle ( POLYGON paths)
private

◆ FullPointCount()

int SHAPE_POLY_SET::FullPointCount ( ) const

◆ GetArcs()

void SHAPE_POLY_SET::GetArcs ( std::vector< SHAPE_ARC > &  aArcBuffer) const

Appends all the arcs in this polyset to aArcBuffer.

Definition at line 618 of file shape_poly_set.cpp.

References m_polys.

Referenced by BOOST_AUTO_TEST_CASE().

◆ GetClearance()

int SHAPE::GetClearance ( const SHAPE aOther) const
inherited

Return the actual minimum distance between two shapes.

Return values
distancein IU

POLY_SETs contain a bunch of polygons that are triangulated. But there are way more triangles than necessary for collision detection. Triangles check three vertices each but for the outline, we only need one. These are also fractured, so we don't need to worry about holes

Definition at line 54 of file shape.cpp.

References COutline(), SHAPE_BASE::GetIndexableSubshapeCount(), SHAPE_BASE::GetIndexableSubshapes(), OutlineCount(), and SHAPE_BASE::Type().

◆ GetGlobalIndex()

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.

Parameters
aRelativeIndicesis the set of relative indices.
aGlobalIdx[out] is the computed global index.
Returns
true if the relative indices are correct; false otherwise. The computed global index is returned in the aGlobalIdx reference.

Definition at line 203 of file shape_poly_set.cpp.

References SHAPE_POLY_SET::VERTEX_INDEX::m_contour, SHAPE_POLY_SET::VERTEX_INDEX::m_polygon, m_polys, SHAPE_POLY_SET::VERTEX_INDEX::m_vertex, and Polygon().

Referenced by GetNeighbourIndexes(), and ZONE::GetSelectedCorner().

◆ GetHash()

◆ GetIndexableSubshapeCount()

size_t SHAPE_POLY_SET::GetIndexableSubshapeCount ( ) const
overridevirtual

Reimplemented from SHAPE_BASE.

Definition at line 3424 of file shape_poly_set.cpp.

References m_triangulatedPolys.

Referenced by GetIndexableSubshapes().

◆ GetIndexableSubshapes()

void SHAPE_POLY_SET::GetIndexableSubshapes ( std::vector< const SHAPE * > &  aSubshapes) const
overridevirtual

Reimplemented from SHAPE_BASE.

Definition at line 3435 of file shape_poly_set.cpp.

References GetIndexableSubshapeCount(), and m_triangulatedPolys.

◆ GetNeighbourIndexes()

bool SHAPE_POLY_SET::GetNeighbourIndexes ( int  aGlobalIndex,
int *  aPrevious,
int *  aNext 
) const

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.

Parameters
aGlobalIndexis index of the corner, globally indexed between all edges in all contours
aPreviousis the globalIndex of the previous corner of the same contour.
aNextis the globalIndex of the next corner of the same contour.
Returns
true if OK, false if aGlobalIndex is out of range

Definition at line 435 of file shape_poly_set.cpp.

References GetGlobalIndex(), GetRelativeIndices(), SHAPE_POLY_SET::VERTEX_INDEX::m_contour, SHAPE_POLY_SET::VERTEX_INDEX::m_polygon, m_polys, SHAPE_POLY_SET::VERTEX_INDEX::m_vertex, and next().

Referenced by BOOST_AUTO_TEST_CASE(), PCB_POINT_EDITOR::chamferCorner(), and ZONE::MoveEdge().

◆ GetRelativeIndices()

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.

Parameters
aGlobalIdxis the global index of the corner whose structured index wants to be found
aRelativeIndicesis a pointer to the set of relative indices to store.
Returns
true if the global index is correct and the information in aRelativeIndices is valid; false otherwise.

Definition at line 163 of file shape_poly_set.cpp.

References CPolygon(), SHAPE_POLY_SET::VERTEX_INDEX::m_contour, SHAPE_POLY_SET::VERTEX_INDEX::m_polygon, SHAPE_POLY_SET::VERTEX_INDEX::m_vertex, OutlineCount(), and SHAPE_LINE_CHAIN::PointCount().

Referenced by CVertex(), ZONE::GetCornerPosition(), GetNeighbourIndexes(), InsertVertex(), IsVertexInHole(), IterateFromVertexWithHoles(), RemoveVertex(), ZONE::SetCornerPosition(), ZONE::SetSelectedCorner(), and SetVertex().

◆ HasHoles()

bool SHAPE_POLY_SET::HasHoles ( ) const

Return true if the polygon set has any holes.

Definition at line 2065 of file shape_poly_set.cpp.

References m_polys.

Referenced by PAD::AddPrimitivePoly(), cacheTriangulation(), CALLBACK_GAL::DrawGlyph(), and SHAPE_LINE_CHAIN::OffsetLine().

◆ HasIndexableSubshapes()

bool SHAPE_POLY_SET::HasIndexableSubshapes ( ) const
overridevirtual

Reimplemented from SHAPE_BASE.

Definition at line 3418 of file shape_poly_set.cpp.

References IsTriangulationUpToDate().

◆ HasTouchingHoles()

bool SHAPE_POLY_SET::HasTouchingHoles ( ) const

Return true if the polygon set has any holes that share a vertex.

Definition at line 3385 of file shape_poly_set.cpp.

References CPolygon(), hasTouchingHoles(), and OutlineCount().

◆ hasTouchingHoles()

bool SHAPE_POLY_SET::hasTouchingHoles ( const POLYGON aPoly) const
private

Return true if the polygon set has any holes that touch share a vertex.

Definition at line 3397 of file shape_poly_set.cpp.

Referenced by HasTouchingHoles().

◆ Hole()

◆ HoleCount()

◆ importPaths()

void SHAPE_POLY_SET::importPaths ( Clipper2Lib::Paths64 &  paths,
const std::vector< CLIPPER_Z_VALUE > &  aZValueBuffer,
const std::vector< SHAPE_ARC > &  aArcBuffe 
)
private

Definition at line 1402 of file shape_poly_set.cpp.

References m_polys, and path.

◆ importPolyPath()

void SHAPE_POLY_SET::importPolyPath ( const std::unique_ptr< Clipper2Lib::PolyPath64 > &  aPolyPath,
const std::vector< CLIPPER_Z_VALUE > &  aZValueBuffer,
const std::vector< SHAPE_ARC > &  aArcBuffer 
)
private

Definition at line 1368 of file shape_poly_set.cpp.

References importPolyPath(), and m_polys.

Referenced by importPolyPath(), and importTree().

◆ importTree() [1/2]

void SHAPE_POLY_SET::importTree ( Clipper2Lib::PolyTree64 &  tree,
const std::vector< CLIPPER_Z_VALUE > &  aZValueBuffer,
const std::vector< SHAPE_ARC > &  aArcBuffe 
)
private

Definition at line 1391 of file shape_poly_set.cpp.

References importPolyPath(), and m_polys.

◆ importTree() [2/2]

void SHAPE_POLY_SET::importTree ( ClipperLib::PolyTree *  tree,
const std::vector< CLIPPER_Z_VALUE > &  aZValueBuffer,
const std::vector< SHAPE_ARC > &  aArcBuffe 
)
private

Definition at line 1344 of file shape_poly_set.cpp.

References m_polys.

Referenced by booleanOp(), inflate1(), inflate2(), and inflateLine2().

◆ Inflate()

void SHAPE_POLY_SET::Inflate ( int  aAmount,
CORNER_STRATEGY  aCornerStrategy,
int  aMaxError,
bool  aSimplify = false 
)

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.

Parameters
aAmountis the number of units to offset edges.
aCornerStrategyALLOW_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
aMaxErroris the allowable deviation when rounding corners with an approximated polygon

Definition at line 1326 of file shape_poly_set.cpp.

References std::abs(), FULL_CIRCLE, GetArcToSegmentCount(), and inflate2().

Referenced by BOARD_ADAPTER::addShape(), ZONE_FILLER::buildCopperItemClearances(), FOOTPRINT::BuildCourtyardCaches(), ZONE::BuildSmoothedPoly(), CADSTAR_PCB_ARCHIVE_LOADER::calculateZonePriorities(), BOARD_ADAPTER::createPadWithMargin(), CONVERT_TOOL::CreatePolys(), Deflate(), KIGFX::PCB_PAINTER::draw(), ZONE_FILLER::fillCopperZone(), ZONE_FILLER::fillNonCopperZone(), CADSTAR_PCB_ARCHIVE_LOADER::getPolySetFromCadstarShape(), InflateWithLinkedHoles(), PATH_CONNECTION::isValid(), CADSTAR_PCB_ARCHIVE_LOADER::loadCoppers(), PCB_IO_EAGLE::loadPolygon(), PCB_IO_EAGLE::packagePolygon(), PCB_IO_EASYEDAPRO_PARSER::ParseBoard(), ALTIUM_PCB::ParsePolygons6Data(), BRDITEMS_PLOTTER::PlotShape(), DRC_TEST_PROVIDER_TEXT_DIMS::Run(), DIALOG_GLOBAL_EDIT_TEARDROPS::TransferDataFromWindow(), EDA_SHAPE::TransformShapeToPolygon(), PAD::TransformShapeToPolygon(), ZONE::TransformSmoothedOutlineToPolygon(), PCB_TEXT::TransformTextToPolySet(), and PCB_TEXTBOX::TransformTextToPolySet().

◆ inflate1()

void SHAPE_POLY_SET::inflate1 ( int  aAmount,
int  aCircleSegCount,
CORNER_STRATEGY  aCornerStrategy 
)
private

Definition at line 1034 of file shape_poly_set.cpp.

References std::abs(), importTree(), m_polys, and SEG_CNT_MAX.

◆ inflate2()

void SHAPE_POLY_SET::inflate2 ( int  aAmount,
int  aCircleSegCount,
CORNER_STRATEGY  aCornerStrategy,
bool  aSimplify = false 
)
private

Definition at line 1125 of file shape_poly_set.cpp.

References std::abs(), importTree(), m_polys, and SEG_CNT_MAX.

Referenced by Inflate().

◆ inflateLine2()

void SHAPE_POLY_SET::inflateLine2 ( const SHAPE_LINE_CHAIN aLine,
int  aAmount,
int  aCircleSegCount,
CORNER_STRATEGY  aCornerStrategy,
bool  aSimplify = false 
)
private

◆ InflateWithLinkedHoles()

void SHAPE_POLY_SET::InflateWithLinkedHoles ( int  aFactor,
CORNER_STRATEGY  aCornerStrategy,
int  aMaxError,
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 .

Definition at line 1025 of file shape_poly_set.cpp.

References Fracture(), Inflate(), and Unfracture().

Referenced by FEATURES_MANAGER::AddPadShape(), PCB_IO_IPC2581::addShape(), PCB_IO_KICAD_LEGACY::loadZONE_CONTAINER(), PlotStandardLayer(), and ZONE::TransformShapeToPolygon().

◆ InsertVertex()

void SHAPE_POLY_SET::InsertVertex ( int  aGlobalIndex,
const VECTOR2I aNewVertex 
)

Adds a vertex in the globally indexed position aGlobalIndex.

Parameters
aGlobalIndexis the global index of the position in which the new vertex will be inserted.
aNewVertexis the new inserted vertex.

Definition at line 317 of file shape_poly_set.cpp.

References Append(), GetRelativeIndices(), SHAPE_POLY_SET::VERTEX_INDEX::m_contour, SHAPE_POLY_SET::VERTEX_INDEX::m_polygon, m_polys, SHAPE_POLY_SET::VERTEX_INDEX::m_vertex, and TotalVertices().

Referenced by PCB_POINT_EDITOR::addCorner(), and PCB_POINT_EDITOR::chamferCorner().

◆ IsEmpty()

◆ IsNull()

bool SHAPE::IsNull ( ) const
inlineinherited

Return true if the shape is a null shape.

Return values
trueif null :-)

Definition at line 166 of file shape.h.

References SHAPE_BASE::m_type, and SH_NULL.

◆ IsPolygonSelfIntersecting()

bool SHAPE_POLY_SET::IsPolygonSelfIntersecting ( int  aPolygonIndex) const

Check whether the aPolygonIndex-th polygon in the set is self intersecting.

Parameters
aPolygonIndexis the index of the polygon that wants to be checked.
Returns
true if the aPolygonIndex-th polygon is self intersecting, false otherwise.

Definition at line 485 of file shape_poly_set.cpp.

References SEG::A, std::abs(), SEG::B, CIterateSegmentsWithHoles(), SEG::Collide(), FullPointCount(), SEG::Index(), VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by IsSelfIntersecting().

◆ IsSelfIntersecting()

bool SHAPE_POLY_SET::IsSelfIntersecting ( ) const

Check whether any of the polygons in the set is self intersecting.

Returns
true if any of the polygons is self intersecting, false otherwise.

Definition at line 535 of file shape_poly_set.cpp.

References IsPolygonSelfIntersecting(), and m_polys.

Referenced by cacheTriangulation().

◆ IsSolid()

bool SHAPE_POLY_SET::IsSolid ( ) const
inlineoverridevirtual

Implements SHAPE.

Definition at line 1158 of file shape_poly_set.h.

◆ IsTriangulationUpToDate()

◆ IsVertexInHole()

bool SHAPE_POLY_SET::IsVertexInHole ( int  aGlobalIdx)

Check whether the aGlobalIndex-th vertex belongs to a hole.

Parameters
aGlobalIdxis the index of the vertex.
Returns
true if the globally indexed aGlobalIdx-th vertex belongs to a hole.

Definition at line 2905 of file shape_poly_set.cpp.

References GetRelativeIndices(), and SHAPE_POLY_SET::VERTEX_INDEX::m_contour.

◆ Iterate() [1/3]

ITERATOR SHAPE_POLY_SET::Iterate ( )
inline
Returns
an iterator object to visit all points in all outlines of the set, without visiting the points in the holes.

Definition at line 840 of file shape_poly_set.h.

References Iterate(), and OutlineCount().

Referenced by Iterate(), and IterateWithHoles().

◆ Iterate() [2/3]

ITERATOR SHAPE_POLY_SET::Iterate ( int  aFirst,
int  aLast,
bool  aIterateHoles = false 
)
inline

Return an object to iterate through the points of the polygons between aFirst and aLast.

Parameters
aFirstis the first polygon whose points will be iterated.
aLastis the last polygon whose points will be iterated.
aIterateHolesis a flag to indicate whether the points of the holes should be iterated.
Returns
ITERATOR - the iterator object.

Definition at line 802 of file shape_poly_set.h.

References SHAPE_POLY_SET::ITERATOR_TEMPLATE< T >::m_currentContour, SHAPE_POLY_SET::ITERATOR_TEMPLATE< T >::m_currentPolygon, SHAPE_POLY_SET::ITERATOR_TEMPLATE< T >::m_currentVertex, SHAPE_POLY_SET::ITERATOR_TEMPLATE< T >::m_iterateHoles, SHAPE_POLY_SET::ITERATOR_TEMPLATE< T >::m_lastPolygon, SHAPE_POLY_SET::ITERATOR_TEMPLATE< T >::m_poly, and OutlineCount().

Referenced by PCB_POINT_EDITOR::addCorner(), PCB_POINT_EDITOR::chamferCorner(), and ZONE::Iterate().

◆ Iterate() [3/3]

ITERATOR SHAPE_POLY_SET::Iterate ( int  aOutline)
inline
Parameters
aOutlineis the index of the polygon to be iterated.
Returns
an iterator object to visit all points in the main outline of the aOutline-th polygon, without visiting the points in the holes.

Definition at line 821 of file shape_poly_set.h.

References Iterate().

◆ IterateFromVertexWithHoles()

◆ IterateSegments() [1/3]

SEGMENT_ITERATOR SHAPE_POLY_SET::IterateSegments ( )
inline

Return an iterator object, for all outlines in the set (no holes).

Definition at line 954 of file shape_poly_set.h.

References IterateSegments(), and OutlineCount().

Referenced by IterateSegments(), and IterateSegmentsWithHoles().

◆ IterateSegments() [2/3]

◆ IterateSegments() [3/3]

SEGMENT_ITERATOR SHAPE_POLY_SET::IterateSegments ( int  aPolygonIdx)
inline

Return an iterator object, for iterating aPolygonIdx-th polygon edges.

Definition at line 942 of file shape_poly_set.h.

References IterateSegments().

◆ IterateSegmentsWithHoles() [1/2]

SEGMENT_ITERATOR SHAPE_POLY_SET::IterateSegmentsWithHoles ( )
inline

Returns an iterator object, for all outlines in the set (with holes)

Definition at line 966 of file shape_poly_set.h.

References IterateSegments(), and OutlineCount().

Referenced by GENCAD_EXPORTER::CreateBoardSection(), doConvertOutlineToPolygon(), ZONE::HatchBorder(), BOARD::TestZoneIntersection(), and DRC_TEST_PROVIDER_COPPER_CLEARANCE::testZonesToZones().

◆ IterateSegmentsWithHoles() [2/2]

SEGMENT_ITERATOR SHAPE_POLY_SET::IterateSegmentsWithHoles ( int  aOutline)
inline

Return an iterator object, for the aOutline-th outline in the set (with holes).

Definition at line 972 of file shape_poly_set.h.

References IterateSegments().

◆ IterateWithHoles() [1/2]

ITERATOR SHAPE_POLY_SET::IterateWithHoles ( )
inline
Returns
an iterator object to visit all points in all outlines of the set, visiting also the points in the holes.

Definition at line 849 of file shape_poly_set.h.

References Iterate(), and OutlineCount().

Referenced by IterateFromVertexWithHoles(), and RemoveNullSegments().

◆ IterateWithHoles() [2/2]

ITERATOR SHAPE_POLY_SET::IterateWithHoles ( int  aOutline)
inline
Parameters
aOutlinethe index of the polygon to be iterated.
Returns
an iterator object to visit all points in the main outline of the aOutline-th polygon, visiting also the points in the holes.

Definition at line 831 of file shape_poly_set.h.

References Iterate().

Referenced by findVertex(), ZONE::HatchBorder(), ZONE::IterateWithHoles(), and BOARD::TestZoneIntersection().

◆ Mirror()

void SHAPE_POLY_SET::Mirror ( const VECTOR2I aRef,
FLIP_DIRECTION  aFlipDirection 
)

Mirror the line points about y or x (or both)

Parameters
aRefsets the reference point about which to mirror
aFlipDirectionis the direction to mirror the points.

Definition at line 2724 of file shape_poly_set.cpp.

References CacheTriangulation(), m_polys, m_triangulationValid, and path.

Referenced by GERBER_DRAW_ITEM::ConvertSegmentToPolygon(), EDA_SHAPE::flip(), FOOTPRINT::Flip(), FABMASTER::loadFootprints(), PCB_SHAPE::Mirror(), and ZONE::Mirror().

◆ Move()

◆ NewFacet()

FACET * SHAPE::NewFacet ( )
inherited

◆ NewHole()

int SHAPE_POLY_SET::NewHole ( int  aOutline = -1)

Creates a new hole in a given outline.

Definition at line 254 of file shape_poly_set.cpp.

References m_polys, and SHAPE_LINE_CHAIN::SetClosed().

Referenced by BuildPolysetFromOrientedPaths(), ZONE::NewHole(), and TransformRingToPolygon().

◆ NewOutline()

int SHAPE_POLY_SET::NewOutline ( )

Creates a new empty polygon in the set and returns its index.

Definition at line 242 of file shape_poly_set.cpp.

References m_polys, and SHAPE_LINE_CHAIN::SetClosed().

Referenced by AR_AUTOPLACER::addFpBody(), addHoleToPolygon(), ZONE_FILLER::addKnockout(), AR_AUTOPLACER::addPad(), SCH_SHAPE::AddPoint(), PCB_IO_IPC2581::addShape(), ZONE::AppendCorner(), EDA_SHAPE::beginEdit(), BOARD::BOARD(), BOOST_AUTO_TEST_CASE(), BuildBoardPolygonOutlines(), PCB_TEXT::buildBoundingHull(), BuildFootprintPolygonOutlines(), BuildPolysetFromOrientedPaths(), KI_TEST::CommonTestData::CommonTestData(), TEARDROP_MANAGER::computeAnchorPoints(), AM_PRIMITIVE::ConvertBasicShapeToPolygon(), ALTIUM_PCB::ConvertFills6ToFootprintItemOnLayer(), GERBER_DRAW_ITEM::ConvertSegmentToPolygon(), D_CODE::ConvertShapeToPolygon(), CornerListToPolygon(), BITMAPCONV_INFO::createOutputData(), BOARD_ADAPTER::createPadWithMargin(), TEARDROP_MANAGER::createTeardrop(), KIGFX::PCB_PAINTER::draw(), KIGFX::GERBVIEW_PAINTER::drawPolygon(), GERBER_FILE_IMAGE::Execute_DCODE_Command(), fillArcPOLY(), PCB_BASE_FRAME::FocusOnItems(), FOOTPRINT::GetBoundingHull(), getRectangleAlongCentreLine(), EDA_SHAPE::hitTest(), TEST_EE_ITEM_FIXTURE::Instantiate(), KIGFX::knockoutText(), FABMASTER::loadFootprints(), PCB_IO_EAGLE::loadPolygon(), FABMASTER::loadShapePolySet(), FABMASTER::loadZone(), PCB_IO_KICAD_LEGACY::loadZONE_CONTAINER(), RULE_AREA_CREATE_HELPER::OnComplete(), PCB_IO_KICAD_SEXPR_PARSER::parseTextBoxContent(), PCB_IO_KICAD_SEXPR_PARSER::parseZONE(), DXF_PLOTTER::PlotPoly(), BRDITEMS_PLOTTER::PlotShape(), PlotStandardLayer(), POLYGON_BOOLEAN_ROUTINE::ProcessShape(), RENDER_3D_OPENGL::reload(), EDA_SHAPE::rotate(), KIGFX::PREVIEW::POLYGON_ITEM::SetPoints(), EDA_SHAPE::SetPolyPoints(), SHAPE_POLY_SET(), DS_DATA_ITEM_POLYGONS::SyncDrawItems(), TransformArcToPolygon(), TransformCircleToPolygon(), TransformOvalToPolygon(), EDA_SHAPE::TransformShapeToPolygon(), PCB_TEXTBOX::TransformShapeToPolygon(), PCB_TEXT::TransformTextToPolySet(), PCB_TEXTBOX::TransformTextToPolySet(), ROUNDRECT::TransformToPolygon(), SHAPE_RECT::TransformToPolygon(), PCB_DIM_ALIGNED::updateGeometry(), PCB_DIM_ORTHOGONAL::updateGeometry(), PCB_DIM_RADIAL::updateGeometry(), and PCB_DIM_LEADER::updateGeometry().

◆ NormalizeAreaOutlines()

int SHAPE_POLY_SET::NormalizeAreaOutlines ( )

Convert a self-intersecting polygon to one (or more) non self-intersecting polygon(s).

Removes null segments.

Returns
the polygon count (always >= 1, because there is at least one polygon) There are new polygons only if the polygon count is > 1.

Definition at line 2109 of file shape_poly_set.cpp.

References AddOutline(), BooleanSubtract(), OutlineCount(), PM_FAST, PM_STRICTLY_SIMPLE, Polygon(), RemoveNullSegments(), and Simplify().

Referenced by BITMAPCONV_INFO::createOutputData().

◆ OffsetLineChain()

void SHAPE_POLY_SET::OffsetLineChain ( const SHAPE_LINE_CHAIN aLine,
int  aAmount,
CORNER_STRATEGY  aCornerStrategy,
int  aMaxError,
bool  aSimplify 
)

Perform offsetting of a line chain.

Replaces this polygon set with the result.

Parameters
aLineis the line to perform offsetting on.
aAmountis the number of units to offset the line chain.
aCornerStrategyALLOW_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
aMaxErroris the allowable deviation when rounding corners with an approximated polygon
aSimplifyset to simplify the output polygon.

Definition at line 1335 of file shape_poly_set.cpp.

References std::abs(), FULL_CIRCLE, GetArcToSegmentCount(), and inflateLine2().

Referenced by PCB_TUNING_PATTERN::getOutline(), and SHAPE_LINE_CHAIN::OffsetLine().

◆ operator=()

SHAPE_POLY_SET & SHAPE_POLY_SET::operator= ( const SHAPE_POLY_SET aOther)

◆ Outline() [1/2]

SHAPE_LINE_CHAIN & SHAPE_POLY_SET::Outline ( int  aIndex)
inline

Return the reference to aIndex-th outline in the set.

Definition at line 727 of file shape_poly_set.h.

References m_polys.

Referenced by EE_POINT_EDITOR::addCorner(), ZONE_FILLER::addHatchFillTypeOnZone(), PCB_IO_IPC2581::addOutlineNode(), PCB_IO_IPC2581::addPackage(), SCH_SHAPE::AddPoint(), Area(), EDA_SHAPE::beginEdit(), BOOST_AUTO_TEST_CASE(), BuildBoardPolygonOutlines(), FOOTPRINT::BuildCourtyardCaches(), BuildFootprintPolygonOutlines(), BuildPolysetFromOrientedPaths(), ZONE::BuildSmoothedPoly(), ZONE_FILLER::buildThermalSpokes(), cacheTriangulation(), EDA_SHAPE::calcEdit(), FOOTPRINT::CheckNetTies(), KI_TEST::CheckShapePolySet(), collide(), collidesWithArea(), TEARDROP_MANAGER::computeAnchorPoints(), ZONE_FILLER::connect_nearby_polys(), EDA_SHAPE::continueEdit(), ALTIUM_PCB::ConvertFills6ToFootprintItemOnLayer(), ConvertPolygonToBlocks(), FOOTPRINT::CoverageRatio(), BITMAPCONV_INFO::createOutputData(), PLACEFILE_GERBER_WRITER::CreatePlaceFile(), doConvertOutlineToPolygon(), KIGFX::DS_PAINTER::draw(), KIGFX::PCB_PAINTER::draw(), CALLBACK_GAL::DrawGlyph(), DRAWING_TOOL::DrawVia(), EDA_SHAPE::endEdit(), GBR_TO_PCB_EXPORTER::export_flashed_copper_item(), GBR_TO_PCB_EXPORTER::export_non_copper_item(), DSN::SPECCTRA_DB::fillBOUNDARY(), AR_AUTOPLACER::fillMatrix(), POLYGON_BOOLEAN_ROUTINE::Finalize(), TEARDROP_MANAGER::findAnchorPointsOnTrack(), CADSTAR_SCH_ARCHIVE_LOADER::fixUpLibraryPins(), GERBER_PLOTTER::FlashPadChamferRoundRect(), DXF_PLOTTER::FlashPadCustom(), HPGL_PLOTTER::FlashPadCustom(), PSLIKE_PLOTTER::FlashPadCustom(), GERBER_PLOTTER::FlashPadCustom(), DXF_PLOTTER::FlashPadRoundRect(), GERBER_PLOTTER::FlashPadRoundRect(), HPGL_PLOTTER::FlashPadRoundRect(), PSLIKE_PLOTTER::FlashPadRoundRect(), PCB_IO_KICAD_SEXPR::format(), formatPoly(), APERTURE_MACRO::GetApertureMacroShape(), BOARD::GetBoardPolygonOutlines(), PCB_SHAPE::GetCorners(), DIALOG_BOARD_STATISTICS::getDataFromPCB(), PCB_SHAPE::GetFocusPosition(), SCH_SHAPE::GetItemDescription(), PCB_TUNING_PATTERN::getOutline(), CADSTAR_PCB_ARCHIVE_LOADER::getPolySetFromCadstarShape(), CADSTAR_SCH_ARCHIVE_LOADER::getScaledLibPart(), EDA_SHAPE::hitTest(), PNS::HOLE::Hull(), PNS::SOLID::Hull(), TEST_EE_ITEM_FIXTURE::Instantiate(), EDA_SHAPE::IsClosed(), GEOM_TEST::IsPolySetValid(), EDA_SHAPE::IsPolyShapeValid(), FABMASTER::loadFootprints(), FABMASTER::loadZone(), DSN::SPECCTRA_DB::makeIMAGE(), DSN::SPECCTRA_DB::makePADSTACK(), PCB_SHAPE::Normalize(), RULE_AREA_CREATE_HELPER::OnComplete(), ALTIUM_PCB::ParsePolygons6Data(), SCH_IO_KICAD_SEXPR_PARSER::ParseSchematic(), SCH_IO_KICAD_SEXPR_PARSER::parseSchRuleArea(), PCB_IO_KICAD_SEXPR_PARSER::parseTextBoxContent(), PCB_IO_KICAD_SEXPR_PARSER::parseZONE(), ZONE_CREATE_HELPER::performZoneCutout(), playground_main_func(), SCH_RULE_AREA::Plot(), SCH_SHAPE::Plot(), PlotDrawingSheet(), BRDITEMS_PLOTTER::PlotShape(), BRDITEMS_PLOTTER::PlotText(), BRDITEMS_PLOTTER::PlotZone(), polygonArea(), SCH_SHAPE::Print(), SCH_SHAPE::PrintBackground(), GERBER_DRAW_ITEM::PrintGerberPoly(), DS_DRAW_ITEM_POLYPOLYGONS::PrintWsItem(), DRC_RTREE::QueryColliding(), RENDER_3D_OPENGL::reload(), EE_POINT_EDITOR::removeCorner(), EE_POINT_EDITOR::removeCornerCondition(), DRC_TEST_PROVIDER_ANNULAR_WIDTH::Run(), DRC_TEST_PROVIDER_EDGE_CLEARANCE::Run(), DRC_TEST_PROVIDER_SLIVER_CHECKER::Run(), SCH_IO_KICAD_LEGACY_LIB_CACHE::savePolyLine(), EDA_SHAPE::scale(), SHAPE_POLY_SET(), ZONE_FILLER::subtractHigherPriorityZones(), PNS_KICAD_IFACE_BASE::syncTextItem(), DRC_INTERACTIVE_COURTYARD_CLEARANCE::testCourtyardClearances(), DRC_TEST_PROVIDER_ZONE_CONNECTIONS::testZoneLayer(), DRC_TEST_PROVIDER_PHYSICAL_CLEARANCE::testZoneLayer(), DIALOG_GLOBAL_EDIT_TEARDROPS::TransferDataFromWindow(), TransformArcToPolygon(), EDA_SHAPE::TransformShapeToPolygon(), PCB_TEXTBOX::TransformShapeToPolygon(), ROUNDRECT::TransformToPolygon(), SHAPE_RECT::TransformToPolygon(), VERTEX_CONNECTOR::VERTEX_CONNECTOR(), and GBR_TO_PCB_EXPORTER::writePcbZoneItem().

◆ Outline() [2/2]

const SHAPE_LINE_CHAIN & SHAPE_POLY_SET::Outline ( int  aIndex) const
inline

Definition at line 732 of file shape_poly_set.h.

References m_polys.

◆ OutlineCount()

int SHAPE_POLY_SET::OutlineCount ( ) const
inline

Return the number of outlines in the set.

Definition at line 705 of file shape_poly_set.h.

References m_polys.

Referenced by FEATURES_MANAGER::AddContour(), PCB_IO_IPC2581::addContourNode(), PCB_POINT_EDITOR::addCorner(), ZONE_FILLER::addHatchFillTypeOnZone(), PCB_IO_IPC2581::addKnockoutText(), PCB_IO_IPC2581::addOutlineNode(), EDA_DATA::AddPackage(), PCB_IO_IPC2581::addPackage(), PAD::addPadPrimitivesToPolygon(), FEATURES_MANAGER::AddPadShape(), ZONE::AddPolygon(), PAD::AddPrimitivePoly(), FEATURES_MANAGER::AddShape(), PCB_IO_IPC2581::addShape(), TRIANGLE_DISPLAY_LIST::AddToMiddleContourns(), PNS_LOG_VIEWER_OVERLAY::AnnotatedPolyset(), ZONE::AppendCorner(), Area(), booleanOp(), BOOST_AUTO_TEST_CASE(), BOOST_FIXTURE_TEST_CASE(), BuildBBoxCaches(), BuildBoardPolygonOutlines(), BuildConvexHull(), FOOTPRINT::BuildCourtyardCaches(), BuildFootprintPolygonOutlines(), ZONE::BuildSmoothedPoly(), ZONE_FILLER::buildThermalSpokes(), cacheTriangulation(), PCB_POINT_EDITOR::chamferCorner(), FOOTPRINT::CheckNetTies(), KI_TEST::CheckShapePolySet(), CIterate(), CIterateSegments(), CIterateSegmentsWithHoles(), CIterateWithHoles(), collide(), collidesWithArea(), ZONE_FILLER::connect_nearby_polys(), Contains(), convertPolygon(), ConvertPolygonToBlocks(), RENDER_3D_OPENGL::createBoard(), BITMAPCONV_INFO::createOutputData(), GENCAD_EXPORTER::CreatePadsShapesSection(), STEP_PCB_MODEL::CreatePCB(), PLACEFILE_GERBER_WRITER::CreatePlaceFile(), CONVERT_TOOL::CreatePolys(), PAD::doCheckPad(), doConvertOutlineToPolygon(), KIGFX::DS_PAINTER::draw(), KIGFX::PCB_PAINTER::draw(), KIGFX::GERBVIEW_PAINTER::draw(), KIGFX::GERBVIEW_PAINTER::drawApertureMacro(), D_CODE::DrawFlashedPolygon(), D_CODE::DrawFlashedShape(), KIGFX::GERBVIEW_PAINTER::drawFlashedShape(), CALLBACK_GAL::DrawGlyph(), AR_AUTOPLACER::drawPlacementRoutingMatrix(), KIGFX::CAIRO_GAL_BASE::DrawPolygon(), KIGFX::OPENGL_GAL::DrawPolygon(), KIGFX::GERBVIEW_PAINTER::drawPolygon(), KIGFX::PREVIEW::POLYGON_ITEM::drawPreviewShape(), KIGFX::OPENGL_GAL::drawTriangulatedPolyset(), DRAWING_TOOL::DrawVia(), EDA_SHAPE::DupPolyPointsList(), GERBER_FILE_IMAGE::Execute_DCODE_Command(), GBR_TO_PCB_EXPORTER::export_copper_item(), EXPORTER_PCB_VRML::ExportVrmlBoard(), EXPORTER_PCB_VRML::ExportVrmlPolygonSet(), fillArcPOLY(), DSN::SPECCTRA_DB::fillBOUNDARY(), ZONE_FILLER::fillCopperZone(), GEOM_TEST::FilletPolySet(), POLYGON_BOOLEAN_ROUTINE::Finalize(), DXF_PLOTTER::FlashPadCustom(), HPGL_PLOTTER::FlashPadCustom(), PSLIKE_PLOTTER::FlashPadCustom(), GERBER_PLOTTER::FlashPadCustom(), FullPointCount(), RENDER_3D_OPENGL::generateHoles(), RENDER_3D_OPENGL::generateLayerList(), PCB_IO_IPC2581::generateLayerSetNet(), RENDER_3D_OPENGL::generateViasAndPads(), APERTURE_MACRO::GetApertureMacroShape(), BOARD::GetBoardPolygonOutlines(), GERBER_DRAW_ITEM::GetBoundingBox(), FOOTPRINT::GetBoundingHull(), SHAPE::GetClearance(), PCB_SHAPE::GetCorners(), DIALOG_BOARD_STATISTICS::getDataFromPCB(), FOOTPRINT::GetEffectiveShape(), PCB_TUNING_PATTERN::getOutline(), EDA_SHAPE::GetPointCount(), CADSTAR_PCB_ARCHIVE_LOADER::getPolySetFromCadstarShape(), GetRelativeIndices(), D_CODE::GetShapeDim(), HasTouchingHoles(), EDA_SHAPE::hitTest(), DS_DRAW_ITEM_POLYPOLYGONS::HitTest(), ZONE::HitTestCutout(), FEATURES_MANAGER::InitFeatureList(), isCopperOutside(), GEOM_TEST::IsPolySetValid(), EDA_SHAPE::IsPolyShapeValid(), Iterate(), IterateSegments(), IterateSegmentsWithHoles(), IterateWithHoles(), FABMASTER::loadFootprints(), FABMASTER::loadGraphics(), FABMASTER::loadPolygon(), PCB_IO_EAGLE::loadPolygon(), EDA_SHAPE::makeEffectiveShapes(), SCH_RULE_AREA::MakeEffectiveShapes(), PCB_SHAPE::Normalize(), NormalizeAreaOutlines(), SHAPE_LINE_CHAIN::OffsetLine(), SHAPE_POLY_SET::ITERATOR_TEMPLATE< T >::operator bool(), kiapi::common::PackPolySet(), PCB_IO_EASYEDAPRO_PARSER::ParseBoard(), PCB_IO_EASYEDAPRO_PARSER::ParseFootprint(), ALTIUM_PCB::ParsePolygons6Data(), PCB_IO_KICAD_SEXPR_PARSER::parseRenderCache(), PCB_IO_EASYEDA_PARSER::ParseToBoardItemContainer(), ZONE_CREATE_HELPER::performZoneCutout(), playground_main_func(), PlotDrawingSheet(), PlotLayerOutlines(), DXF_PLOTTER::PlotPoly(), BRDITEMS_PLOTTER::PlotShape(), PlotStandardLayer(), BRDITEMS_PLOTTER::PlotText(), BRDITEMS_PLOTTER::PlotZone(), SHAPE::PointInside(), PointInside(), polygonArea(), GERBER_DRAW_ITEM::Print(), DS_DRAW_ITEM_POLYPOLYGONS::PrintWsItem(), POLYGON_SUBTRACT_ROUTINE::ProcessSubsequentPolygon(), POLYGON_INTERSECT_ROUTINE::ProcessSubsequentPolygon(), DRC_RTREE::QueryColliding(), RENDER_3D_RAYTRACE_BASE::Reload(), ZONE::RemoveCutout(), DRC_TEST_PROVIDER_ANNULAR_WIDTH::Run(), DRC_TEST_PROVIDER_SLIVER_CHECKER::Run(), DRC_TEST_PROVIDER_TEXT_DIMS::Run(), EDA_SHAPE::scale(), EDA_SHAPE::SetPolyShape(), SHAPE::SquaredDistance(), Subset(), PNS_KICAD_IFACE_BASE::syncTextItem(), TestConcaveSquareFillet(), DRC_INTERACTIVE_COURTYARD_CLEARANCE::testCourtyardClearances(), DRC_TEST_PROVIDER_COURTYARD_CLEARANCE::testCourtyardClearances(), TestSquareFillet(), DRC_TEST_PROVIDER_PHYSICAL_CLEARANCE::testZoneLayer(), EDA_SHAPE::TransformShapeToPolygon(), VERTEX_CONNECTOR::VERTEX_CONNECTOR(), HYPERLYNX_EXPORTER::writeBoardInfo(), HYPERLYNX_EXPORTER::writeNetObjects(), GBR_TO_PCB_EXPORTER::writePcbPolygon(), and GBR_TO_PCB_EXPORTER::writePcbZoneItem().

◆ Parse()

bool SHAPE_POLY_SET::Parse ( std::stringstream &  aStream)
overridevirtual

◆ PointInside()

bool SHAPE_POLY_SET::PointInside ( const VECTOR2I aPt,
int  aAccuracy = 0,
bool  aUseBBoxCache = false 
) const
overridevirtual

Check if point aP lies inside a closed shape.

Always returns false if this shape is not closed.

Parameters
aPtpoint to check
aUseBBoxCachegives better performance if the bounding box caches have been generated.
Returns
true if the point is inside the shape (edge is not treated as being inside).

Reimplemented from SHAPE.

Definition at line 3553 of file shape_poly_set.cpp.

References COutline(), OutlineCount(), and SHAPE_LINE_CHAIN_BASE::PointInside().

Referenced by containsSingle().

◆ PointOnEdge()

bool SHAPE_POLY_SET::PointOnEdge ( const VECTOR2I aP,
int  aAccuracy = 0 
) const

Check if point aP lies on an edge or vertex of some of the outlines or holes.

Parameters
aPis the point to check.
Returns
true if the point lies on the edge of any polygon.

Definition at line 2267 of file shape_poly_set.cpp.

References m_polys.

Referenced by PATH_CONNECTION::isValid().

◆ Polygon() [1/2]

◆ Polygon() [2/2]

const POLYGON & SHAPE_POLY_SET::Polygon ( int  aIndex) const
inline

Definition at line 765 of file shape_poly_set.h.

References m_polys.

◆ RebuildHolesFromContours()

void SHAPE_POLY_SET::RebuildHolesFromContours ( )

Extract all contours from this polygon set, then recreate polygons with holes.

Essentially XOR'ing, but faster. Self-intersecting polygons are not supported.

Definition at line 641 of file shape_poly_set.cpp.

References AddHole(), AddOutline(), SHAPE_LINE_CHAIN::CPoint(), m_polys, path, SHAPE_LINE_CHAIN_BASE::PointInside(), and process.

Referenced by PCB_IO_EASYEDAPRO_PARSER::ParseBoard(), PCB_IO_EASYEDAPRO_PARSER::ParseFootprint(), and PCB_IO_EASYEDA_PARSER::ParseToBoardItemContainer().

◆ RemoveAllContours()

◆ RemoveContour()

void SHAPE_POLY_SET::RemoveContour ( int  aContourIdx,
int  aPolygonIdx = -1 
)

Delete the aContourIdx-th contour of the aPolygonIdx-th polygon in the set.

Parameters
aContourIdxis the index of the contour in the aPolygonIdx-th polygon to be removed.
aPolygonIdxis the index of the polygon in which the to-be-removed contour is. Defaults to the last polygon in the set.

Definition at line 2418 of file shape_poly_set.cpp.

References m_polys.

Referenced by PCB_POINT_EDITOR::removeCorner().

◆ RemoveNullSegments()

int SHAPE_POLY_SET::RemoveNullSegments ( )

Look for null segments; ie, segments whose ends are exactly the same and deletes them.

Returns
the number of deleted segments.

Definition at line 2434 of file shape_poly_set.cpp.

References SHAPE_POLY_SET::ITERATOR_TEMPLATE< T >::GetIndex(), SHAPE_POLY_SET::ITERATOR_TEMPLATE< T >::IsEndContour(), IterateWithHoles(), and RemoveVertex().

Referenced by BOOST_AUTO_TEST_CASE(), chamferFilletPolygon(), and NormalizeAreaOutlines().

◆ RemoveOutline()

void SHAPE_POLY_SET::RemoveOutline ( int  aOutlineIdx)

Delete the aOutlineIdx-th outline of the set including its contours and holes.

Parameters
aOutlineIdxis the index of the outline to be removed.

Definition at line 2428 of file shape_poly_set.cpp.

References m_polys.

◆ RemoveVertex() [1/2]

void SHAPE_POLY_SET::RemoveVertex ( int  aGlobalIndex)

Delete the aGlobalIndex-th vertex.

Parameters
aGlobalIndexis the global index of the to-be-removed vertex.

Definition at line 2649 of file shape_poly_set.cpp.

References GetRelativeIndices(), and RemoveVertex().

Referenced by PCB_POINT_EDITOR::chamferCorner(), PCB_POINT_EDITOR::removeCorner(), RemoveNullSegments(), and RemoveVertex().

◆ RemoveVertex() [2/2]

void SHAPE_POLY_SET::RemoveVertex ( VERTEX_INDEX  aRelativeIndices)

Delete the vertex indexed by aRelativeIndex (index of polygon, contour and vertex).

Parameters
aRelativeIndicesis the set of relative indices of the to-be-removed vertex.

Definition at line 2661 of file shape_poly_set.cpp.

References SHAPE_POLY_SET::VERTEX_INDEX::m_contour, SHAPE_POLY_SET::VERTEX_INDEX::m_polygon, m_polys, and SHAPE_POLY_SET::VERTEX_INDEX::m_vertex.

◆ Rotate()

◆ SetVertex() [1/2]

void SHAPE_POLY_SET::SetVertex ( const VERTEX_INDEX aIndex,
const VECTOR2I aPos 
)

Accessor function to set the position of a specific point.

Parameters
aIndex#VERTEX_INDEX of the point to move.
aPosdestination position of the specified point.

Definition at line 2678 of file shape_poly_set.cpp.

References SHAPE_POLY_SET::VERTEX_INDEX::m_contour, SHAPE_POLY_SET::VERTEX_INDEX::m_polygon, m_polys, and SHAPE_POLY_SET::VERTEX_INDEX::m_vertex.

Referenced by ZONE::MoveEdge(), ZONE::SetCornerPosition(), SetVertex(), and POLYGON_POINT_EDIT_BEHAVIOR::UpdateOutlineFromPoints().

◆ SetVertex() [2/2]

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.

Parameters
aGlobalIndexglobal index of the to-be-moved vertex
aPosNew position on the vertex

Definition at line 2667 of file shape_poly_set.cpp.

References GetRelativeIndices(), and SetVertex().

◆ Simplify()

◆ SimplifyOutlines()

void SHAPE_POLY_SET::SimplifyOutlines ( int  aMaxError = 0)

Simplifies the lines in the polyset.

This checks intermediate points to see if they are collinear with their neighbors, and removes them if they are.

Parameters
aMaxErroris the maximum error to allow when simplifying the lines.

Definition at line 2097 of file shape_poly_set.cpp.

References m_polys, and path.

Referenced by EXPORTER_STEP::buildBoard3DShapes(), EXPORTER_STEP::buildZones3DShape(), and cacheTriangulation().

◆ SquaredDistance() [1/2]

SEG::ecoord SHAPE_POLY_SET::SquaredDistance ( const VECTOR2I aPoint,
bool  aOutlineOnly,
VECTOR2I aNearest 
) 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.

Parameters
aPointis 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.
Returns
The minimum distance squared between aPoint and all the polygons in the set. If the point is contained in any of the polygons, the distance is zero.

Definition at line 2851 of file shape_poly_set.cpp.

References VECTOR2< int32_t >::ECOORD_MAX, m_polys, and SquaredDistanceToPolygon().

Referenced by Collide(), and SquaredDistance().

◆ SquaredDistance() [2/2]

SEG::ecoord SHAPE_POLY_SET::SquaredDistance ( const VECTOR2I aP,
bool  aOutlineOnly = false 
) const
inlineoverridevirtual
See also
SHAPE::Distance

Reimplemented from SHAPE.

Definition at line 1437 of file shape_poly_set.h.

References SquaredDistance().

◆ SquaredDistanceToPolygon() [1/2]

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.

Parameters
aSegmentis the segment whose distance to the aIndex-th polygon has to be measured.
aIndexis 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.
Returns
The minimum distance between aSegment and all the segments of the aIndex-th polygon. If the point is contained in the polygon, the distance is zero.

Definition at line 2814 of file shape_poly_set.cpp.

References SEG::A, SEG::B, CIterateSegmentsWithHoles(), containsSingle(), and VECTOR2< T >::SquaredDistance().

◆ SquaredDistanceToPolygon() [2/2]

SEG::ecoord SHAPE_POLY_SET::SquaredDistanceToPolygon ( VECTOR2I  aPoint,
int  aIndex,
VECTOR2I aNearest 
) const

Compute the minimum distance between the aIndex-th polygon and aPoint.

Parameters
aPointis the point whose distance to the aIndex-th polygon has to be measured.
aIndexis 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.
Returns
The minimum distance between aPoint and all the segments of the aIndex-th polygon. If the point is contained in the polygon, the distance is zero.

Definition at line 2778 of file shape_poly_set.cpp.

References CIterateSegmentsWithHoles(), and containsSingle().

Referenced by SquaredDistance(), and SquaredDistanceToSeg().

◆ SquaredDistanceToSeg()

SEG::ecoord SHAPE_POLY_SET::SquaredDistanceToSeg ( 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.

Parameters
aSegmentis the segment whose distance to the polygon set has to be measured.
aSegmentWidthis 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.
Returns
The minimum distance squared between aSegment and all the polygons in the set. If the point is contained in the polygon, the distance is zero.

Definition at line 2880 of file shape_poly_set.cpp.

References VECTOR2< int32_t >::ECOORD_MAX, m_polys, and SquaredDistanceToPolygon().

Referenced by BOOST_AUTO_TEST_CASE(), Collide(), and DRC_TEST_PROVIDER_ANNULAR_WIDTH::Run().

◆ Subset()

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.

Parameters
aFirstPolygonis the first polygon to be included in the returned set.
aLastPolygonis the last polygon to be excluded of the returned set.
Returns
a set containing the polygons between aFirstPolygon (included) and aLastPolygon (excluded).

Definition at line 385 of file shape_poly_set.cpp.

References m_polys, OutlineCount(), and Polygon().

Referenced by UnitSet().

◆ TotalVertices()

◆ TransformToPolygon()

void SHAPE_POLY_SET::TransformToPolygon ( SHAPE_POLY_SET aBuffer,
int  aError,
ERROR_LOC  aErrorLoc 
) const
inlineoverridevirtual

Fills a SHAPE_POLY_SET with a polygon representation of this shape.

Parameters
aBuffer[out] will be filled with the polygonal representation of this shape.
aErrorcontrols the maximum allowed deviation when converting rounded shapes to segments
aErrorLoccontrols where the error is placed when approximating rounded shapes

Implements SHAPE.

Definition at line 1473 of file shape_poly_set.h.

References Append().

Referenced by EXPORTER_STEP::buildFootprint3DShapes(), EXPORTER_STEP::buildTrack3DShape(), and DRC_TEST_PROVIDER_ANNULAR_WIDTH::Run().

◆ TriangulatedPolyCount()

unsigned int SHAPE_POLY_SET::TriangulatedPolyCount ( ) const
inline

◆ TriangulatedPolygon()

◆ Type()

◆ TypeName()

wxString SHAPE_BASE::TypeName ( ) const
inlineinherited

Definition at line 103 of file shape.h.

References SHAPE_BASE::m_type, and SHAPE_TYPE_asString().

Referenced by Collide().

◆ Unfracture()

void SHAPE_POLY_SET::Unfracture ( POLYGON_MODE  aFastMode)

Convert a single outline slitted ("fractured") polygon into a set ouf outlines with holes.

Definition at line 2080 of file shape_poly_set.cpp.

References m_polys, path, Simplify(), and unfractureSingle().

Referenced by EXPORTER_STEP::buildZones3DShape(), and InflateWithLinkedHoles().

◆ unfractureSingle()

◆ UnitSet()

SHAPE_POLY_SET SHAPE_POLY_SET::UnitSet ( int  aPolygonIndex)
inline

Definition at line 748 of file shape_poly_set.h.

References Subset().

◆ UpdateTriangulationDataHash()

void SHAPE_POLY_SET::UpdateTriangulationDataHash ( )

Definition at line 2524 of file shape_poly_set.cpp.

References checksum(), m_hash, and m_hashValid.

◆ VertexCount()

int SHAPE_POLY_SET::VertexCount ( int  aOutline = -1,
int  aHole = -1 
) const

Member Data Documentation

◆ facets

std::list< FACET* > SHAPE::facets
privateinherited

Definition at line 143 of file wrlfacet.h.

Referenced by SHAPE::CalcShape(), and SHAPE::NewFacet().

◆ m_hash

◆ m_hashValid

bool SHAPE_POLY_SET::m_hashValid = false
private

◆ m_polys

◆ m_triangulatedPolys

◆ m_triangulationMutex

std::mutex SHAPE_POLY_SET::m_triangulationMutex
protected

Definition at line 1586 of file shape_poly_set.h.

Referenced by cacheTriangulation().

◆ m_triangulationValid

std::atomic<bool> SHAPE_POLY_SET::m_triangulationValid = false
protected

◆ m_type

SHAPE_TYPE SHAPE_BASE::m_type
protectedinherited

< type of our shape

Definition at line 119 of file shape.h.

Referenced by SHAPE::Format(), SHAPE::IsNull(), SHAPE_BASE::Type(), and SHAPE_BASE::TypeName().

◆ MIN_PRECISION_IU

const int SHAPE::MIN_PRECISION_IU = 4
staticinherited

This is the minimum precision for all the points in a shape.

Definition at line 131 of file shape.h.

Referenced by BOOST_AUTO_TEST_CASE(), DIRECTION_45::BuildInitialTrace(), CompareLength(), CIRCLE::Contains(), EDIT_TOOL::FilletTracks(), CIRCLE::IntersectLine(), and LINE_FILLET_ROUTINE::ProcessLinePair().


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