KiCad PCB EDA Suite
|
#include <shape_rect.h>
Public Member Functions | |
SHAPE_RECT () | |
Create an empty (0-sized) rectangle. | |
SHAPE_RECT (const BOX2I &aBox) | |
Create a rectangle defined by a BOX2. | |
SHAPE_RECT (int aX0, int aY0, int aW, int aH) | |
Create a rectangle defined by top-left corner (aX0, aY0), width aW and height aH. | |
SHAPE_RECT (const VECTOR2I &aP0, int aW, int aH) | |
Create a rectangle defined by top-left corner aP0, width aW and height aH. | |
SHAPE_RECT (const VECTOR2I &aP0, const VECTOR2I &aP1) | |
Create by two corners. | |
SHAPE_RECT (const SHAPE_RECT &aOther) | |
SHAPE * | Clone () const override |
Return a dynamically allocated copy of the shape. | |
const BOX2I | BBox (int aClearance=0) const override |
Compute a bounding box of the shape, with a margin of aClearance a collision. | |
SHAPE_RECT | GetInflated (int aOffset) const |
Return a rectangle that is larger by aOffset in all directions, but still centered on the original rectangle. | |
int | Diagonal () const |
Return length of the diagonal of the rectangle. | |
int | MajorDimension () const |
int | MinorDimension () const |
bool | Collide (const SHAPE *aShape, int aClearance, VECTOR2I *aMTV) const override |
Check if the boundary of shape (this) lies closer to the shape aShape than aClearance, indicating a collision. | |
bool | Collide (const SHAPE *aShape, int aClearance=0, int *aActual=nullptr, VECTOR2I *aLocation=nullptr) const override |
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. | |
const VECTOR2I & | GetPosition () const |
const VECTOR2I | GetSize () const |
int | GetWidth () const |
int | GetHeight () const |
void | Move (const VECTOR2I &aVector) override |
void | Rotate (const EDA_ANGLE &aAngle, const VECTOR2I &aCenter={ 0, 0 }) override |
This function has limited utility for SHAPE_RECT as non-cartesian rotations will distort the rectangle. | |
bool | IsSolid () const override |
const SHAPE_LINE_CHAIN | Outline () const |
virtual const std::string | Format (bool aCplusPlus=true) const override |
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 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. | |
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. | |
virtual SEG::ecoord | SquaredDistance (const VECTOR2I &aP, bool aOutlineOnly=false) const |
virtual bool | PointInside (const VECTOR2I &aPt, int aAccuracy=0, bool aUseBBoxCache=false) const |
Check if point aP lies inside a closed shape. | |
virtual bool | Parse (std::stringstream &aStream) |
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. | |
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. | |
Protected Types | |
typedef VECTOR2I::extended_type | ecoord |
Protected Attributes | |
SHAPE_TYPE | m_type |
< type of our shape | |
Private Attributes | |
VECTOR2I | m_p0 |
Top-left corner. | |
int | m_w |
Width. | |
int | m_h |
Height. | |
std::list< FACET * > | facets |
Definition at line 37 of file shape_rect.h.
|
protectedinherited |
|
inline |
Create an empty (0-sized) rectangle.
Definition at line 43 of file shape_rect.h.
Referenced by Clone().
|
inline |
Create a rectangle defined by a BOX2.
Definition at line 52 of file shape_rect.h.
|
inline |
Create a rectangle defined by top-left corner (aX0, aY0), width aW and height aH.
Definition at line 62 of file shape_rect.h.
|
inline |
Create a rectangle defined by top-left corner aP0, width aW and height aH.
Definition at line 72 of file shape_rect.h.
Create by two corners.
Definition at line 82 of file shape_rect.h.
|
inline |
Definition at line 89 of file shape_rect.h.
|
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 102 of file shape_rect.h.
References m_h, m_p0, m_w, VECTOR2< T >::x, and VECTOR2< T >::y.
Referenced by ROUNDRECT::BBox(), Collide(), and Collide().
|
inherited |
Definition at line 703 of file wrlfacet.cpp.
References IFSG_NODE::AddChildNode(), IFSG_INDEX::AddIndex(), IFSG_NODE::AddRefNode(), SHAPE::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().
|
inlinevirtualinherited |
Compute a center-of-mass of the shape.
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().
|
inlineoverridevirtual |
Return a dynamically allocated copy of the shape.
copy | of the shape |
Reimplemented from SHAPE.
Definition at line 96 of file shape_rect.h.
References SHAPE_RECT().
|
overridevirtual |
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. |
Implements SHAPE.
Definition at line 30 of file shape_rect.cpp.
References SEG::A, SEG::B, BBox(), BOX2< Vec >::Contains(), VECTOR2< int32_t >::ECOORD_MAX, m_h, m_p0, m_w, SEG::NearestPoint(), SEG::Square(), SEG::SquaredDistance(), VECTOR2< T >::x, and VECTOR2< T >::y.
|
inlineoverridevirtual |
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 | [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. |
Reimplemented from SHAPE.
Definition at line 142 of file shape_rect.h.
References SHAPE::Collide().
Referenced by Collide(), EE_SELECTION_TOOL::GuessSelectionCandidates(), and SCH_JUNCTION::HitTest().
|
inlinevirtualinherited |
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 181 of file shape.h.
References SHAPE::Collide().
Referenced by BOOST_AUTO_TEST_CASE(), DRC_RTREE::CheckColliding(), FOOTPRINT::CheckShortingPads(), SHAPE_COMPOUND::Collide(), Collide(), SHAPE_SEGMENT::Collide(), SHAPE_ARC::Collide(), SHAPE_POLY_SET::Collide(), SHAPE::Collide(), CN_ZONE_LAYER::Collide(), collide(), PNS::ITEM::collideSimple(), PNS::SHOVE::onCollidingVia(), PNS::SHOVE::onReverseCollidingVia(), PNS::HIT_VISITOR::operator()(), 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::testSingleLayerItemAgainstItem().
|
inline |
Return length of the diagonal of the rectangle.
Definition at line 127 of file shape_rect.h.
References VECTOR2< T >::EuclideanNorm(), m_h, and m_w.
|
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.
aP | is the point to test |
Reimplemented in SHAPE_COMPOUND, and SHAPE_LINE_CHAIN.
Definition at line 108 of file shape.cpp.
References SHAPE::SquaredDistance().
|
overridevirtual |
Reimplemented from SHAPE.
Definition at line 105 of file shape_rect.cpp.
References m_h, m_p0, m_w, VECTOR2< T >::x, and VECTOR2< T >::y.
|
inherited |
Return the actual minimum distance between two shapes.
distance | in 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 SHAPE_POLY_SET::COutline(), SHAPE_BASE::GetIndexableSubshapeCount(), SHAPE_BASE::GetIndexableSubshapes(), SHAPE_POLY_SET::OutlineCount(), and SHAPE_BASE::Type().
|
inline |
Definition at line 184 of file shape_rect.h.
References m_h.
Referenced by KIGFX::PCB_PAINTER::draw(), ROUNDRECT::GetHeight(), KIGEOM::GetPoint(), OUTSET_ROUTINE::ProcessItem(), and ROUNDRECT::TransformToPolygon().
|
inlinevirtualinherited |
Reimplemented in SHAPE_COMPOUND, and SHAPE_POLY_SET.
Definition at line 113 of file shape.h.
Referenced by SHAPE::GetClearance().
|
inlinevirtualinherited |
Reimplemented in SHAPE_COMPOUND, and SHAPE_POLY_SET.
Definition at line 115 of file shape.h.
Referenced by SHAPE_COMPOUND::AddShape(), SHAPE::GetClearance(), and ROUTER_PREVIEW_ITEM::ViewDraw().
|
inline |
Return a rectangle that is larger by aOffset in all directions, but still centered on the original rectangle.
Definition at line 113 of file shape_rect.h.
References m_h, m_p0, and m_w.
Referenced by ROUNDRECT::GetInflated(), and ROUNDRECT::OutsetFrom().
|
inline |
Definition at line 160 of file shape_rect.h.
References m_p0.
Referenced by CreepageGraph::Addshape(), PNS::BuildHullForPrimitiveShape(), Collide(), BOARD_ADAPTER::createPadWithMargin(), KIGFX::PCB_PAINTER::draw(), ROUTER_PREVIEW_ITEM::drawShape(), KIGEOM::GetPoint(), ROUNDRECT::GetPosition(), GetRectRoundedToGridOutwards(), OUTSET_ROUTINE::ProcessItem(), PNS::OPTIMIZER::rectBreakouts(), and ROUNDRECT::TransformToPolygon().
|
inline |
Definition at line 168 of file shape_rect.h.
Referenced by CreepageGraph::Addshape(), PNS::BuildHullForPrimitiveShape(), Collide(), BOARD_ADAPTER::createPadWithMargin(), KIGFX::PCB_PAINTER::draw(), ROUTER_PREVIEW_ITEM::drawShape(), GetRectRoundedToGridOutwards(), and PNS::OPTIMIZER::rectBreakouts().
|
inline |
Definition at line 176 of file shape_rect.h.
References m_w.
Referenced by KIGFX::PCB_PAINTER::draw(), KIGEOM::GetPoint(), ROUNDRECT::GetWidth(), OUTSET_ROUTINE::ProcessItem(), and ROUNDRECT::TransformToPolygon().
|
inlinevirtualinherited |
Reimplemented in SHAPE_COMPOUND, and SHAPE_POLY_SET.
Definition at line 108 of file shape.h.
Referenced by ROUTER_PREVIEW_ITEM::ViewDraw().
|
inlineinherited |
Return true if the shape is a null shape.
true | if null :-) |
Definition at line 166 of file shape.h.
References SHAPE_BASE::m_type, and SH_NULL.
|
inlineoverridevirtual |
Implements SHAPE.
Definition at line 207 of file shape_rect.h.
|
inline |
Definition at line 132 of file shape_rect.h.
Referenced by ROUNDRECT::ROUNDRECT().
|
inline |
Definition at line 137 of file shape_rect.h.
|
inlineoverridevirtual |
|
inherited |
Definition at line 695 of file wrlfacet.cpp.
References SHAPE::facets.
Referenced by WRL2FACESET::TranslateToSG(), X3DIFACESET::TranslateToSG(), and WRL1FACESET::TranslateToSG().
|
inline |
Definition at line 212 of file shape_rect.h.
References SHAPE_LINE_CHAIN::Append(), m_h, m_p0, m_w, SHAPE_LINE_CHAIN::SetClosed(), VECTOR2< T >::x, and VECTOR2< T >::y.
Referenced by Collide(), PAD::MergePrimitivesAsPolygon(), and PCB_IO_EASYEDAPRO_PARSER::ParseBoard().
|
virtualinherited |
Reimplemented in SHAPE_LINE_CHAIN, and SHAPE_POLY_SET.
|
virtualinherited |
Check if point aP lies inside a closed shape.
Always returns false if this shape is not closed.
aPt | point to check |
aUseBBoxCache | gives better performance if the bounding box caches have been generated. |
Reimplemented in SHAPE_LINE_CHAIN_BASE, and SHAPE_POLY_SET.
Definition at line 126 of file shape.cpp.
References SHAPE_POLY_SET::COutline(), ERROR_INSIDE, SHAPE_POLY_SET::OutlineCount(), SHAPE_LINE_CHAIN_BASE::PointInside(), and SHAPE::TransformToPolygon().
|
inlineoverridevirtual |
This function has limited utility for SHAPE_RECT as non-cartesian rotations will distort the rectangle.
If you might need to handle non-90° rotations then the SHAPE_RECT should first be converted to a SHAPE_SIMPLE which can then be free-rotated.
Implements SHAPE.
Definition at line 199 of file shape_rect.h.
|
virtualinherited |
Reimplemented in SHAPE_LINE_CHAIN_BASE, and SHAPE_POLY_SET.
Definition at line 114 of file shape.cpp.
References SHAPE_POLY_SET::COutline(), VECTOR2< int32_t >::ECOORD_MAX, ERROR_INSIDE, SHAPE_POLY_SET::OutlineCount(), SHAPE_LINE_CHAIN_BASE::SquaredDistance(), and SHAPE::TransformToPolygon().
Referenced by SHAPE::Distance().
|
overridevirtual |
Fills a SHAPE_POLY_SET with a polygon representation of this shape.
aBuffer | [out] will be filled with the polygonal representation of this shape. |
aError | controls the maximum allowed deviation when converting rounded shapes to segments |
aErrorLoc | controls where the error is placed when approximating rounded shapes |
Implements SHAPE.
Definition at line 123 of file shape_rect.cpp.
References SHAPE_LINE_CHAIN::Append(), m_h, m_p0, m_w, SHAPE_POLY_SET::NewOutline(), SHAPE_POLY_SET::Outline(), SHAPE_LINE_CHAIN::SetClosed(), VECTOR2< T >::x, and VECTOR2< T >::y.
|
inlineinherited |
Return the type of the shape.
the | type |
Definition at line 98 of file shape.h.
References SHAPE_BASE::m_type.
Referenced by CreepageGraph::Addshape(), 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(), EDA_SHAPE::EDA_SHAPE(), SHAPE::GetClearance(), PNS::HOLE::Hull(), PNS::SOLID::Hull(), DRC_RTREE::QueryColliding(), PNS::HOLE::Radius(), ROUTER_PREVIEW_ITEM::ROUTER_PREVIEW_ITEM(), PNS::HOLE::SetCenter(), PNS::HOLE::SetRadius(), STROKE_PARAMS::Stroke(), and SHAPE_FILE_IO::Write().
|
inlineinherited |
Definition at line 103 of file shape.h.
References SHAPE_BASE::m_type, and SHAPE_TYPE_asString().
Referenced by Collide().
|
privateinherited |
Definition at line 143 of file wrlfacet.h.
Referenced by SHAPE::CalcShape(), and SHAPE::NewFacet().
|
private |
Height.
Definition at line 232 of file shape_rect.h.
Referenced by BBox(), Collide(), Diagonal(), Format(), GetHeight(), GetInflated(), GetSize(), MajorDimension(), MinorDimension(), Outline(), and TransformToPolygon().
|
private |
Top-left corner.
Definition at line 230 of file shape_rect.h.
Referenced by BBox(), Collide(), Format(), GetInflated(), GetPosition(), Move(), Outline(), and TransformToPolygon().
|
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().
|
private |
Width.
Definition at line 231 of file shape_rect.h.
Referenced by BBox(), Collide(), Diagonal(), Format(), GetInflated(), GetSize(), GetWidth(), MajorDimension(), MinorDimension(), Outline(), and TransformToPolygon().
|
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().