KiCad PCB EDA Suite
|
An abstract shape on 2D plane. More...
#include <shape.h>
Public Member Functions | |
SHAPE (SHAPE_TYPE aType) | |
Create an empty shape of type aType. More... | |
virtual | ~SHAPE () |
virtual SHAPE * | Clone () const |
Return a dynamically allocated copy of the shape. More... | |
int | GetClearance (const SHAPE *aOther) const |
Return the actual minimum distance between two shapes. More... | |
bool | IsNull () const |
Return true if the shape is a null shape. More... | |
virtual bool | Collide (const VECTOR2I &aP, int aClearance=0, int *aActual=nullptr, VECTOR2I *aLocation=nullptr) const |
Check if the boundary of shape (this) lies closer to the point aP than aClearance, indicating a collision. 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 |
virtual bool | Collide (const SEG &aSeg, int aClearance=0, int *aActual=nullptr, VECTOR2I *aLocation=nullptr) const =0 |
Check if the boundary of shape (this) lies closer to the segment aSeg than aClearance, indicating a collision. More... | |
virtual const BOX2I | BBox (int aClearance=0) const =0 |
Compute a bounding box of the shape, with a margin of aClearance a collision. More... | |
virtual VECTOR2I | Centre () const |
Compute a center-of-mass of the shape. More... | |
virtual void | Rotate (const EDA_ANGLE &aAngle, const VECTOR2I &aCenter={ 0, 0 })=0 |
virtual void | Move (const VECTOR2I &aVector)=0 |
virtual bool | IsSolid () const =0 |
virtual bool | Parse (std::stringstream &aStream) |
virtual const std::string | Format (bool aCplusPlus=true) const |
~SHAPE () | |
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... | |
wxString | TypeName () const |
virtual bool | HasIndexableSubshapes () const |
virtual size_t | GetIndexableSubshapeCount () const |
virtual void | GetIndexableSubshapes (std::vector< const SHAPE * > &aSubshapes) const |
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 | |
std::list< FACET * > | facets |
|
protected |
|
inline |
SHAPE::~SHAPE | ( | ) |
|
pure virtual |
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. |
Implemented in SHAPE_ARC, SHAPE_CIRCLE, SHAPE_COMPOUND, SHAPE_LINE_CHAIN, SHAPE_NULL, SHAPE_POLY_SET::TRIANGULATED_POLYGON::TRI, SHAPE_POLY_SET, SHAPE_RECT, SHAPE_SEGMENT, and SHAPE_SIMPLE.
Referenced by boundingBox(), PNS::DP_GATEWAYS::BuildFromPrimitivePair(), Centre(), PNS::ARC::ChangedArea(), PNS::VIA::ChangedArea(), DRC_RTREE::CheckColliding(), CN_ZONE_LAYER::Collide(), SHAPE_INDEX< T >::Query(), SHAPE_INDEX_LIST< T, >::Query(), SHAPE_INDEX_LIST< T, >::query_iterator::query_iterator(), SHAPE_INDEX_LIST< T, >::SHAPE_ENTRY::SHAPE_ENTRY(), and ROUTER_PREVIEW_ITEM::ViewBBox().
SGNODE * SHAPE::CalcShape | ( | SGNODE * | aParent, |
SGNODE * | aColor, | ||
WRL1_ORDER | aVertexOrder, | ||
float | aCreaseLimit = 0.74317 , |
||
bool | isVRML2 = false |
||
) |
Definition at line 703 of file wrlfacet.cpp.
References IFSG_NODE::AddChildNode(), IFSG_INDEX::AddIndex(), IFSG_NODE::AddRefNode(), facets, IFSG_NODE::GetRawPtr(), S3D::GetSGNodeParent(), IFSG_FACESET::NewNode(), IFSG_SHAPE::NewNode(), IFSG_COLORS::SetColorList(), IFSG_COORDS::SetCoordsList(), IFSG_NORMALS::SetNormalList(), SGPOINT::x, SGPOINT::y, and SGPOINT::z.
Referenced by WRL2FACESET::TranslateToSG(), X3DIFACESET::TranslateToSG(), and WRL1FACESET::TranslateToSG().
|
inlinevirtual |
Compute a center-of-mass of the shape.
Definition at line 230 of file shape.h.
References BBox(), and BOX2< Vec >::Centre().
Referenced by Collide().
|
inlinevirtual |
Return a dynamically allocated copy of the shape.
copy | of the shape |
Reimplemented in SHAPE_ARC, SHAPE_CIRCLE, SHAPE_COMPOUND, SHAPE_LINE_CHAIN, SHAPE_NULL, SHAPE_POLY_SET, SHAPE_RECT, SHAPE_SEGMENT, and SHAPE_SIMPLE.
Definition at line 146 of file shape.h.
Referenced by PNS_TEST_DEBUG_DECORATOR::AddItem(), PNS_TEST_DEBUG_DECORATOR::AddShape(), PNS::HOLE::Clone(), PNS::SOLID::operator=(), ROUTER_PREVIEW_ITEM::ROUTER_PREVIEW_ITEM(), PNS::SOLID::SOLID(), and ROUTER_PREVIEW_ITEM::Update().
|
pure virtual |
Check if the boundary of shape (this) lies closer to the segment aSeg than aClearance, indicating a collision.
aActual | [out] an optional pointer to an int to be updated with the actual distance int the event of a collision. |
aLocation | [out] an option pointer to a point to store a nearby location in the event of a collision. |
Implemented in SHAPE_LINE_CHAIN_BASE, SHAPE_ARC, SHAPE_CIRCLE, SHAPE_COMPOUND, SHAPE_LINE_CHAIN, SHAPE_NULL, SHAPE_POLY_SET, SHAPE_RECT, SHAPE_SEGMENT, and SHAPE_SIMPLE.
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_COMPOUND, SHAPE_RECT, and SHAPE_SEGMENT.
Definition at line 1124 of file shape_collisions.cpp.
References collideShapes().
|
virtual |
Reimplemented in SHAPE_ARC, SHAPE_COMPOUND, SHAPE_POLY_SET, SHAPE_RECT, and SHAPE_SEGMENT.
Definition at line 1130 of file shape_collisions.cpp.
References collideShapes().
|
inlinevirtual |
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 in SHAPE_LINE_CHAIN_BASE, SHAPE_ARC, SHAPE_LINE_CHAIN, SHAPE_POLY_SET, and SHAPE_SEGMENT.
Definition at line 179 of file shape.h.
References Collide().
Referenced by BOOST_AUTO_TEST_CASE(), DRC_RTREE::CheckColliding(), FOOTPRINT::CheckShortingPads(), SHAPE_COMPOUND::Collide(), SHAPE_RECT::Collide(), SHAPE_SEGMENT::Collide(), SHAPE_ARC::Collide(), SHAPE_POLY_SET::Collide(), Collide(), CN_ZONE_LAYER::Collide(), collide(), PNS::ITEM::collideSimple(), PNS::SHOVE::onCollidingVia(), PNS::HIT_VISITOR::operator()(), RN_NET::OptimizeRNEdges(), PNS::VIA::PushoutForce(), DRC_RTREE::QueryColliding(), PNS::OPTIMIZER::smartPadsSingle(), DRC_TEST_PROVIDER_EDGE_CLEARANCE::testAgainstEdge(), DRC_TEST_PROVIDER_PHYSICAL_CLEARANCE::testItemAgainstItem(), DRC_TEST_PROVIDER_COPPER_CLEARANCE::testPadAgainstItem(), and DRC_TEST_PROVIDER_COPPER_CLEARANCE::testTrackAgainstItem().
|
virtual |
Reimplemented in SHAPE_CIRCLE, SHAPE_COMPOUND, SHAPE_LINE_CHAIN, SHAPE_POLY_SET, SHAPE_RECT, and SHAPE_SEGMENT.
Definition at line 41 of file shape.cpp.
References SHAPE_BASE::m_type.
Referenced by SHAPE_CIRCLE::Format(), SHAPE_SEGMENT::Format(), and SHAPE_FILE_IO::Write().
int SHAPE::GetClearance | ( | const SHAPE * | aOther | ) | const |
Return the actual minimum distance between two shapes.
distance | in IU |
Definition at line 49 of file shape.cpp.
References SHAPE_BASE::GetIndexableSubshapeCount(), and SHAPE_BASE::GetIndexableSubshapes().
|
inlinevirtualinherited |
Reimplemented in SHAPE_COMPOUND, and SHAPE_POLY_SET.
Definition at line 111 of file shape.h.
Referenced by GetClearance().
|
inlinevirtualinherited |
Reimplemented in SHAPE_COMPOUND, and SHAPE_POLY_SET.
Definition at line 113 of file shape.h.
Referenced by SHAPE_COMPOUND::AddShape(), GetClearance(), and ROUTER_PREVIEW_ITEM::ViewDraw().
|
inlinevirtualinherited |
Reimplemented in SHAPE_COMPOUND, and SHAPE_POLY_SET.
Definition at line 106 of file shape.h.
Referenced by SHAPE_COMPOUND::AddShape(), and ROUTER_PREVIEW_ITEM::ViewDraw().
|
inline |
Return true if the shape is a null shape.
true | if null :-) |
Definition at line 164 of file shape.h.
References SHAPE_BASE::m_type, and SH_NULL.
|
pure virtual |
Implemented in SHAPE_ARC, SHAPE_CIRCLE, SHAPE_COMPOUND, SHAPE_LINE_CHAIN, SHAPE_NULL, SHAPE_POLY_SET::TRIANGULATED_POLYGON::TRI, SHAPE_POLY_SET, SHAPE_RECT, SHAPE_SEGMENT, and SHAPE_SIMPLE.
|
pure virtual |
Implemented in SHAPE_ARC, SHAPE_CIRCLE, SHAPE_COMPOUND, SHAPE_LINE_CHAIN, SHAPE_NULL, SHAPE_POLY_SET::TRIANGULATED_POLYGON::TRI, SHAPE_POLY_SET, SHAPE_RECT, SHAPE_SEGMENT, and SHAPE_SIMPLE.
Referenced by PNS::HOLE::Move(), and PNS::SOLID::SetPos().
FACET * SHAPE::NewFacet | ( | ) |
Definition at line 695 of file wrlfacet.cpp.
References facets.
Referenced by WRL2FACESET::TranslateToSG(), X3DIFACESET::TranslateToSG(), and WRL1FACESET::TranslateToSG().
|
virtual |
Reimplemented in SHAPE_LINE_CHAIN, and SHAPE_POLY_SET.
|
pure virtual |
aCenter | is the rotation center. |
aAngle | rotation angle. |
Implemented in SHAPE_ARC, SHAPE_CIRCLE, SHAPE_COMPOUND, SHAPE_LINE_CHAIN, SHAPE_NULL, SHAPE_POLY_SET::TRIANGULATED_POLYGON::TRI, SHAPE_POLY_SET, SHAPE_RECT, SHAPE_SEGMENT, and SHAPE_SIMPLE.
|
inlineinherited |
Return the type of the shape.
the | type |
Definition at line 96 of file shape.h.
References SHAPE_BASE::m_type.
Referenced by PNS::DP_GATEWAYS::BuildFromPrimitivePair(), PNS::BuildHullForPrimitiveShape(), PNS_LOG_VIEWER_FRAME::buildListTree(), SHAPE_POLY_SET::Collide(), Collide(), collideShapes(), collideSingleShapes(), PNS::OPTIMIZER::computeBreakouts(), ROUTER_PREVIEW_ITEM::drawShape(), PNS_LOG_VIEWER_FRAME::drawSimpleShape(), PNS::HOLE::Hull(), PNS::SOLID::Hull(), PNS::HOLE::Radius(), PNS::HOLE::SetCenter(), PNS::HOLE::SetRadius(), STROKE_PARAMS::Stroke(), and SHAPE_FILE_IO::Write().
|
inlineinherited |
Definition at line 101 of file shape.h.
References SHAPE_BASE::m_type, and SHAPE_TYPE_asString().
Referenced by Collide().
|
private |
Definition at line 143 of file wrlfacet.h.
Referenced by CalcShape(), and NewFacet().
|
protectedinherited |
< type of our shape
Definition at line 117 of file shape.h.
Referenced by Format(), IsNull(), SHAPE_BASE::Type(), and SHAPE_BASE::TypeName().
|
static |
This is the minimum precision for all the points in a shape.
Definition at line 129 of file shape.h.
Referenced by BOOST_AUTO_TEST_CASE(), DIRECTION_45::BuildInitialTrace(), CompareLength(), CIRCLE::Contains(), EDIT_TOOL::FilletTracks(), and CIRCLE::IntersectLine().