![]() |
KiCad PCB EDA Suite
|
#include <shape_simple.h>
Public Member Functions | |
SHAPE_SIMPLE () | |
Constructor Creates an empty polygon. More... | |
SHAPE_SIMPLE (const SHAPE_LINE_CHAIN &aPoly) | |
SHAPE_SIMPLE (const SHAPE_SIMPLE &aOther) | |
SHAPE * | Clone () const override |
Return a dynamically allocated copy of the shape. More... | |
void | Clear () |
Function Clear() Removes all points from the polygon. More... | |
const BOX2I | BBox (int aClearance=0) const override |
Compute a bounding box of the shape, with a margin of aClearance a collision. More... | |
int | PointCount () const |
Function PointCount() More... | |
const VECTOR2I & | CPoint (int aIndex) const |
Function Point() More... | |
const VECTOR2D | CDPoint (int aIndex) const |
Function CDPoint() More... | |
const SHAPE_LINE_CHAIN & | Vertices () const |
Function Vertices() More... | |
void | Append (int aX, int aY) |
Function Append() More... | |
void | Append (const VECTOR2I &aP) |
Function Append() More... | |
bool | Collide (const SEG &aSeg, int aClearance=0, int *aActual=nullptr, VECTOR2I *aLocation=nullptr) const override |
Check if the boundary of shape (this) lies closer to the point aP than aClearance, indicating a collision. More... | |
void | Rotate (double aAngle, const VECTOR2I &aCenter={ 0, 0 }) override |
void | Move (const VECTOR2I &aVector) override |
bool | IsSolid () const override |
virtual const VECTOR2I | GetPoint (int aIndex) const override |
virtual const SEG | GetSegment (int aIndex) const override |
virtual size_t | GetPointCount () const override |
virtual size_t | GetSegmentCount () const override |
bool | IsClosed () const override |
virtual bool | Collide (const VECTOR2I &aP, int aClearance=0, int *aActual=nullptr, VECTOR2I *aLocation=nullptr) const override |
Check if point aP lies closer to us than aClearance. More... | |
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. More... | |
virtual bool | Collide (const SHAPE *aShape, int aClearance=0, int *aActual=nullptr, VECTOR2I *aLocation=nullptr) const |
SEG::ecoord | SquaredDistance (const VECTOR2I &aP, bool aOutlineOnly=false) const |
bool | PointInside (const VECTOR2I &aPt, int aAccuracy=0, bool aUseBBoxCache=false) const |
Check if point aP lies inside a polygon (any type) defined by the line chain. More... | |
bool | PointOnEdge (const VECTOR2I &aP, int aAccuracy=0) const |
Check if point aP lies on an edge or vertex of the line chain. More... | |
int | EdgeContainingPoint (const VECTOR2I &aP, int aAccuracy=0) const |
Check if point aP lies on an edge or vertex of the line chain. More... | |
bool | IsNull () const |
Return true if the shape is a null shape. More... | |
virtual VECTOR2I | Centre () const |
Compute a center-of-mass of the shape. More... | |
virtual bool | Parse (std::stringstream &aStream) |
virtual const std::string | Format () const |
FACET * | NewFacet () |
SGNODE * | CalcShape (SGNODE *aParent, SGNODE *aColor, WRL1_ORDER aVertexOrder, float aCreaseLimit=0.74317, bool isVRML2=false) |
SHAPE_TYPE | Type () const |
Return the type of the shape. More... | |
virtual bool | HasIndexableSubshapes () const |
virtual size_t | GetIndexableSubshapeCount () const |
virtual void | GetIndexableSubshapes (std::vector< SHAPE * > &aSubshapes) |
Static Public Attributes | |
static const int | MIN_PRECISION_IU = 4 |
This is the minimum precision for all the points in a shape. More... | |
Protected Types | |
typedef VECTOR2I::extended_type | ecoord |
Protected Attributes | |
SHAPE_TYPE | m_type |
< type of our shape More... | |
Private Attributes | |
SHAPE_LINE_CHAIN | m_points |
Represents a simple polygon consisting of a zero-thickness closed chain of connected line segments.
Internally the vertices are held in a SHAPE_LINE_CHAIN, please note that there is a "virtual" line segment between the last and first vertex.
Definition at line 43 of file shape_simple.h.
|
protectedinherited |
|
inline |
Constructor Creates an empty polygon.
Definition at line 50 of file shape_simple.h.
References m_points, and SHAPE_LINE_CHAIN::SetClosed().
Referenced by Clone().
|
inline |
Definition at line 56 of file shape_simple.h.
References m_points, and SHAPE_LINE_CHAIN::SetClosed().
|
inline |
Definition at line 63 of file shape_simple.h.
|
inline |
Function Append()
Appends a new point at the end of the polygon.
aX | is X coordinate of the new point |
aY | is Y coordinate of the new point |
Definition at line 145 of file shape_simple.h.
Referenced by PNS_KICAD_IFACE_BASE::syncPad(), and PNS_KICAD_IFACE_BASE::syncZone().
|
inline |
Function Append()
Appends a new point at the end of the polygon.
aP | the new point |
Definition at line 157 of file shape_simple.h.
References SHAPE_LINE_CHAIN::Append(), and m_points.
|
inlineoverridevirtual |
Compute a bounding box of the shape, with a margin of aClearance a collision.
aClearance | how much the bounding box is expanded wrs to the minimum enclosing rectangle for the shape. |
Implements SHAPE.
Definition at line 82 of file shape_simple.h.
References SHAPE_LINE_CHAIN::BBox(), and m_points.
Referenced by PNS::ConvexHull(), and PNS::OPTIMIZER::customBreakouts().
|
inherited |
Definition at line 713 of file wrlfacet.cpp.
References IFSG_NODE::AddChildNode(), IFSG_INDEX::AddIndex(), IFSG_NODE::AddRefNode(), colors, SHAPE::facets, IFSG_NODE::GetRawPtr(), S3D::GetSGNodeParent(), IFSG_FACESET::NewNode(), IFSG_SHAPE::NewNode(), NULL, IFSG_COLORS::SetColorList(), IFSG_COORDS::SetCoordsList(), IFSG_NORMALS::SetNormalList(), SGPOINT::x, SGPOINT::y, and SGPOINT::z.
Referenced by WRL1FACESET::TranslateToSG(), X3DIFACESET::TranslateToSG(), and WRL2FACESET::TranslateToSG().
|
inline |
Function CDPoint()
Returns a given point as a vector with elements of type double.
aIndex | index of the point |
Definition at line 120 of file shape_simple.h.
References CPoint(), VECTOR2< T >::x, and VECTOR2< T >::y.
Referenced by ROUTER_PREVIEW_ITEM::drawShape().
|
inlinevirtualinherited |
Compute a center-of-mass of the shape.
Definition at line 216 of file shape.h.
References SHAPE::BBox(), and BOX2< Vec >::Centre().
Referenced by Collide().
|
inline |
Function Clear() Removes all points from the polygon.
Definition at line 76 of file shape_simple.h.
References SHAPE_LINE_CHAIN::Clear(), and m_points.
|
inlineoverridevirtual |
Return a dynamically allocated copy of the shape.
copy | of the shape |
Reimplemented from SHAPE.
Definition at line 67 of file shape_simple.h.
References SHAPE_SIMPLE().
|
inlineoverridevirtual |
Check if the boundary of shape (this) lies closer to the point aP than aClearance, indicating a collision.
aActual | [out] an optional pointer to an int to store the actual distance in the event of a collision. |
aLocation | [out] an option pointer to a point to store a nearby location in the event of a collision. |
Reimplemented from SHAPE_LINE_CHAIN_BASE.
Definition at line 163 of file shape_simple.h.
References SHAPE_LINE_CHAIN_BASE::Collide(), and m_points.
|
virtualinherited |
Check if the boundary of shape (this) lies closer to the shape aShape than aClearance, indicating a collision.
aShape | shape to check collision against |
aClearance | minimum clearance |
aMTV | 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. |
Reimplemented in SHAPE_RECT, SHAPE_SEGMENT, and SHAPE_COMPOUND.
Definition at line 881 of file shape_collisions.cpp.
References collideShapes().
|
virtualinherited |
Reimplemented in SHAPE_POLY_SET, SHAPE_RECT, SHAPE_SEGMENT, and SHAPE_COMPOUND.
Definition at line 887 of file shape_collisions.cpp.
References collideShapes().
|
overridevirtualinherited |
Check if point aP lies closer to us than aClearance.
aP | the point to check for collisions with |
aClearance | minimum distance that does not qualify as a collision. |
aActual | an optional pointer to an int to store the actual distance in the event of a collision. |
Reimplemented from SHAPE.
Definition at line 88 of file shape_line_chain.cpp.
References VECTOR2< T >::ECOORD_MAX, SHAPE_LINE_CHAIN_BASE::GetSegment(), SHAPE_LINE_CHAIN_BASE::GetSegmentCount(), SHAPE_LINE_CHAIN_BASE::IsClosed(), SEG::NearestPoint(), SHAPE_LINE_CHAIN_BASE::PointInside(), and SEG::Square().
Referenced by PNS::MEANDERED_LINE::CheckSelfIntersections(), Collide(), Collide(), and PCB_SELECTION_TOOL::hitTestDistance().
|
inline |
Function Point()
Returns a const reference to a given point in the polygon. Negative indices count from the end of the point list, e.g. -1 means "last point", -2 means "second to last point" and so on.
aIndex | index of the point |
Definition at line 107 of file shape_simple.h.
References SHAPE_LINE_CHAIN::CPoint(), and m_points.
Referenced by CDPoint().
|
inherited |
Check if point aP lies on an edge or vertex of the line chain.
aP | point to check |
Definition at line 857 of file shape_line_chain.cpp.
References SEG::A, SEG::B, SEG::Distance(), SHAPE_LINE_CHAIN_BASE::GetPoint(), SHAPE_LINE_CHAIN_BASE::GetPointCount(), SHAPE_LINE_CHAIN_BASE::GetSegment(), SHAPE_LINE_CHAIN_BASE::GetSegmentCount(), VECTOR2< T >::x, and VECTOR2< T >::y.
Referenced by SHAPE_LINE_CHAIN_BASE::PointOnEdge().
|
virtualinherited |
Reimplemented in SHAPE_POLY_SET, SHAPE_LINE_CHAIN, SHAPE_RECT, SHAPE_SEGMENT, and SHAPE_COMPOUND.
Definition at line 35 of file shape.cpp.
Referenced by SHAPE_FILE_IO::Write().
|
inlinevirtualinherited |
Reimplemented in SHAPE_POLY_SET, and SHAPE_COMPOUND.
|
inlinevirtualinherited |
Reimplemented in SHAPE_POLY_SET, and SHAPE_COMPOUND.
Definition at line 106 of file shape.h.
Referenced by SHAPE_COMPOUND::AddShape(), and ROUTER_PREVIEW_ITEM::ViewDraw().
|
inlineoverridevirtual |
Implements SHAPE_LINE_CHAIN_BASE.
Definition at line 184 of file shape_simple.h.
References SHAPE_LINE_CHAIN::CPoint(), and m_points.
|
inlineoverridevirtual |
Implements SHAPE_LINE_CHAIN_BASE.
Definition at line 186 of file shape_simple.h.
References m_points, and SHAPE_LINE_CHAIN::PointCount().
|
inlineoverridevirtual |
Implements SHAPE_LINE_CHAIN_BASE.
Definition at line 185 of file shape_simple.h.
References SHAPE_LINE_CHAIN::CSegment(), and m_points.
Referenced by PCB_GRID_HELPER::computeAnchors(), and KIGFX::PCB_PAINTER::draw().
|
inlineoverridevirtual |
Implements SHAPE_LINE_CHAIN_BASE.
Definition at line 187 of file shape_simple.h.
References m_points, and SHAPE_LINE_CHAIN::SegmentCount().
Referenced by PCB_GRID_HELPER::computeAnchors(), and KIGFX::PCB_PAINTER::draw().
|
inlinevirtualinherited |
Reimplemented in SHAPE_POLY_SET, and SHAPE_COMPOUND.
Definition at line 99 of file shape.h.
Referenced by SHAPE_COMPOUND::AddShape(), and ROUTER_PREVIEW_ITEM::ViewDraw().
|
inlineoverridevirtual |
Implements SHAPE_LINE_CHAIN_BASE.
Definition at line 189 of file shape_simple.h.
|
inlineinherited |
Return true if the shape is a null shape.
true | if null :-) |
Definition at line 150 of file shape.h.
References SHAPE_BASE::m_type, and SH_NULL.
|
inlineoverridevirtual |
|
inlineoverridevirtual |
Implements SHAPE.
Definition at line 174 of file shape_simple.h.
References m_points, and SHAPE_LINE_CHAIN::Move().
|
inherited |
Definition at line 705 of file wrlfacet.cpp.
References SHAPE::facets.
Referenced by WRL1FACESET::TranslateToSG(), X3DIFACESET::TranslateToSG(), and WRL2FACESET::TranslateToSG().
|
virtualinherited |
Reimplemented in SHAPE_POLY_SET, and SHAPE_LINE_CHAIN.
|
inline |
Function PointCount()
Returns the number of points (vertices) in this polygon
Definition at line 93 of file shape_simple.h.
References m_points, and SHAPE_LINE_CHAIN::PointCount().
Referenced by ROUTER_PREVIEW_ITEM::drawShape().
|
inherited |
Check if point aP lies inside a polygon (any type) defined by the line chain.
For closed shapes only.
aPt | point to check |
aUseBBoxCache | gives better peformance if the bounding box caches have been generated. |
To check for interior points, we draw a line in the positive x direction from the point. If it intersects an even number of segments, the point is outside the line chain (it had to first enter and then exit). Otherwise, it is inside the chain.
Note: slope might be denormal here in the case of a horizontal line but we require our y to move from above to below the point (or vice versa)
Note: we open-code CPoint() here so that we don't end up calculating the size of the vector number-of-points times. This has a non-trivial impact on zone fill times.
Definition at line 798 of file shape_line_chain.cpp.
References SHAPE_LINE_CHAIN_BASE::GetPoint(), SHAPE_LINE_CHAIN_BASE::GetPointCount(), SHAPE_LINE_CHAIN_BASE::IsClosed(), SHAPE_LINE_CHAIN_BASE::PointOnEdge(), rescale(), VECTOR2< T >::x, and VECTOR2< T >::y.
Referenced by Collide(), SHAPE_LINE_CHAIN_BASE::Collide(), POLY_GRID_PARTITION::containsPoint(), SHAPE_POLY_SET::containsSingle(), LIB_POLYLINE::HitTest(), ZONE::HitTestCutout(), MARKER_BASE::HitTestMarker(), SHAPE_LINE_CHAIN_BASE::SquaredDistance(), PNS::LINE::Walkaround(), and walkaround2().
|
inherited |
Check if point aP lies on an edge or vertex of the line chain.
aP | point to check |
Definition at line 852 of file shape_line_chain.cpp.
References SHAPE_LINE_CHAIN_BASE::EdgeContainingPoint().
Referenced by LIB_POLYLINE::HitTest(), FABMASTER::loadZones(), SHAPE_LINE_CHAIN_BASE::PointInside(), PNS::LINE::Walkaround(), and walkaround2().
|
inlineoverridevirtual |
aCenter | is the rotation center. |
aAngle | rotation angle in radians. |
Implements SHAPE.
Definition at line 169 of file shape_simple.h.
|
inherited |
Definition at line 352 of file shape_line_chain.cpp.
References VECTOR2< T >::ECOORD_MAX, SHAPE_LINE_CHAIN_BASE::GetSegment(), SHAPE_LINE_CHAIN_BASE::GetSegmentCount(), SHAPE_LINE_CHAIN_BASE::IsClosed(), SHAPE_LINE_CHAIN_BASE::PointInside(), and SEG::SquaredDistance().
Referenced by SHAPE_LINE_CHAIN::Distance().
|
inlineinherited |
Return the type of the shape.
the | type |
Definition at line 94 of file shape.h.
References SHAPE_BASE::m_type.
Referenced by PNS::DP_GATEWAYS::BuildFromPrimitivePair(), PNS::buildHullForPrimitiveShape(), Collide(), SHAPE_POLY_SET::Collide(), collideShapes(), collideSingleShapes(), PNS::OPTIMIZER::computeBreakouts(), ROUTER_PREVIEW_ITEM::drawShape(), PNS::SOLID::HoleHull(), PNS::SOLID::Hull(), and SHAPE_FILE_IO::Write().
|
inline |
Function Vertices()
Returns the list of vertices defining this simple polygon.
Definition at line 133 of file shape_simple.h.
References m_points.
Referenced by PNS::ConvexHull(), PNS::OPTIMIZER::customBreakouts(), and KIGFX::PCB_PAINTER::draw().
|
private |
Definition at line 196 of file shape_simple.h.
Referenced by Append(), BBox(), Clear(), Collide(), CPoint(), GetPoint(), GetPointCount(), GetSegment(), GetSegmentCount(), Move(), PointCount(), SHAPE_SIMPLE(), and Vertices().
|
protectedinherited |
< type of our shape
Definition at line 110 of file shape.h.
Referenced by SHAPE::IsNull(), and SHAPE_BASE::Type().
|
staticinherited |
This is the minimum precision for all the points in a shape.
Definition at line 122 of file shape.h.
Referenced by BOOST_AUTO_TEST_CASE(), DIRECTION_45::BuildInitialTrace(), CompareLength(), EDIT_TOOL::FilletTracks(), and CIRCLE::Intersect().