KiCad PCB EDA Suite
|
#include <shape_segment.h>
Public Member Functions | |
SHAPE_SEGMENT () | |
SHAPE_SEGMENT (const VECTOR2I &aA, const VECTOR2I &aB, int aWidth=0) | |
SHAPE_SEGMENT (const SEG &aSeg, int aWidth=0) | |
~SHAPE_SEGMENT () | |
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. | |
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 segment aSeg than aClearance, indicating a collision. | |
bool | Collide (const VECTOR2I &aP, 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. | |
void | SetSeg (const SEG &aSeg) |
const SEG & | GetSeg () const |
VECTOR2I | GetStart () const override |
VECTOR2I | GetEnd () const override |
void | SetWidth (int aWidth) override |
int | GetWidth () const override |
int | GetTotalLength () const |
Get the total length of the segment, from tip to tip. | |
VECTOR2I | GetCenter () const |
EDA_ANGLE | GetAngle () const |
bool | IsSolid () const override |
void | Rotate (const EDA_ANGLE &aAngle, const VECTOR2I &aCenter={ 0, 0 }) override |
void | Move (const VECTOR2I &aVector) override |
bool | Is45Degree (EDA_ANGLE aTollerance=EDA_ANGLE(1.0, DEGREES_T)) 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 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 |
bool | NearestPoints (const SHAPE *aOther, VECTOR2I &aPtThis, VECTOR2I &aPtOther) const |
Return the two points that mark the closest distance between this shape and aOther. | |
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 Member Functions | |
static SHAPE_SEGMENT | BySizeAndCenter (const VECTOR2I &aSize, const VECTOR2I &aCenter, const EDA_ANGLE &aRotation) |
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 | |
SEG | m_seg |
int | m_width |
std::list< FACET * > | facets |
Definition at line 37 of file shape_segment.h.
|
protectedinherited |
|
inline |
Definition at line 40 of file shape_segment.h.
References m_width, SH_SEGMENT, and SHAPE::SHAPE().
Referenced by BySizeAndCenter(), and Clone().
Definition at line 45 of file shape_segment.h.
References m_seg, m_width, SH_SEGMENT, and SHAPE::SHAPE().
|
inline |
Definition at line 51 of file shape_segment.h.
References m_seg, m_width, SH_SEGMENT, and SHAPE::SHAPE().
|
inline |
Definition at line 59 of file shape_segment.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 66 of file shape_segment.h.
References BOX2< Vec >::Inflate(), m_seg, and m_width.
|
static |
Definition at line 33 of file shape_segment.cpp.
References RotatePoint(), SHAPE_SEGMENT(), VECTOR2< T >::x, and VECTOR2< T >::y.
Referenced by PCB_GRID_HELPER::computeAnchors().
|
inherited |
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 WRL1FACESET::TranslateToSG(), WRL2FACESET::TranslateToSG(), and X3DIFACESET::TranslateToSG().
|
inlinevirtualinherited |
Compute a center-of-mass of the shape.
Definition at line 232 of file shape.h.
References BBox(), and BOX2< Vec >::Centre().
Referenced by PCB_CONTROL::ApplyDesignBlockLayout(), PNS::TOPOLOGY::AssembleDiffPair(), Collide(), and pickSegment().
|
inlineoverridevirtual |
Return a dynamically allocated copy of the shape.
copy | of the shape |
Reimplemented from SHAPE.
Definition at line 61 of file shape_segment.h.
References m_seg, m_width, SHAPE::SHAPE(), and SHAPE_SEGMENT().
Referenced by PNS_KICAD_IFACE_BASE::syncPad().
|
inlineoverridevirtual |
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. |
Implements SHAPE.
Definition at line 82 of file shape_segment.h.
References SEG::A, SEG::B, Collide(), m_seg, m_width, and SEG::Square().
|
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 71 of file shape_segment.h.
References SHAPE::Collide(), and SHAPE::SHAPE().
Referenced by Collide(), Collide(), PAD::HitTest(), and PAD::HitTest().
|
inlineoverridevirtual |
Reimplemented from SHAPE.
Definition at line 76 of file shape_segment.h.
References SHAPE::Collide(), and SHAPE::SHAPE().
|
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.
Definition at line 105 of file shape_segment.h.
References m_seg, m_width, and SEG::Square().
|
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 109 of file shape.cpp.
References SquaredDistance().
|
overridevirtual |
Reimplemented from SHAPE.
Definition at line 57 of file shape_segment.cpp.
References SHAPE::Format(), m_seg, and m_width.
|
inline |
Definition at line 161 of file shape_segment.h.
References m_seg.
Referenced by KIGEOM::GetOvalKeyPoints().
|
inline |
Definition at line 156 of file shape_segment.h.
References m_seg.
Referenced by KIGEOM::GetOvalKeyPoints().
|
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 55 of file shape.cpp.
References SHAPE_POLY_SET::COutline(), SHAPE_BASE::GetIndexableSubshapeCount(), SHAPE_BASE::GetIndexableSubshapes(), SHAPE_POLY_SET::OutlineCount(), SH_POLY_SET, SHAPE(), and SHAPE_BASE::Type().
|
inlineoverridevirtual |
|
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(), and SHAPE::GetClearance().
|
inline |
Definition at line 130 of file shape_segment.h.
References m_seg.
Referenced by STEP_PCB_MODEL::AddBarrel(), STEP_PCB_MODEL::AddHole(), CREEPAGE_GRAPH::Addshape(), BOARD_ADAPTER::addShape(), PNS::ApproximateSegmentAsRect(), Collide(), Collide(), Collide(), Collide(), Collide(), SHAPE_POLY_SET::Collide(), KIGEOM::ConvertToChain(), BOARD_ADAPTER::createPadWithMargin(), KIGFX::PCB_PAINTER::draw(), KIGFX::PCB_PAINTER::draw(), KIGFX::SCH_PAINTER::draw(), ROUTER_PREVIEW_ITEM::drawShape(), NearestPoints(), NearestPoints(), NearestPoints(), NearestPoints(), NearestPoints(), BRDITEMS_PLOTTER::PlotDimension(), KIGFX::PCB_PAINTER::renderNetNameForSegment(), PNS::SegmentHull(), STROKE_PARAMS::Stroke(), and PCB_DIMENSION_BASE::TransformShapeToPolygon().
|
inlineoverridevirtual |
|
inline |
Get the total length of the segment, from tip to tip.
Definition at line 151 of file shape_segment.h.
References m_seg, and m_width.
Referenced by KIGEOM::GetOvalKeyPoints().
|
inlineoverridevirtual |
Reimplemented from SHAPE.
Definition at line 143 of file shape_segment.h.
References m_width.
Referenced by STEP_PCB_MODEL::AddBarrel(), STEP_PCB_MODEL::AddHole(), CREEPAGE_GRAPH::Addshape(), PNS::ApproximateSegmentAsRect(), Collide(), Collide(), Collide(), Collide(), Collide(), SHAPE_POLY_SET::Collide(), KIGEOM::ConvertToChain(), BOARD_ADAPTER::createPadWithMargin(), KIGFX::PCB_PAINTER::draw(), ROUTER_PREVIEW_ITEM::drawShape(), KIGEOM::GetOvalKeyPoints(), NearestPoints(), NearestPoints(), NearestPoints(), NearestPoints(), KIGFX::PCB_PAINTER::renderNetNameForSegment(), and PNS::SegmentHull().
|
inlinevirtualinherited |
Reimplemented in SHAPE_COMPOUND, and SHAPE_POLY_SET.
Definition at line 125 of file shape_segment.cpp.
References EDA_ANGLE::AsDegrees(), m_seg, and EDA_ANGLE::Normalize180().
|
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 166 of file shape_segment.h.
|
inlineoverridevirtual |
|
inherited |
Return the two points that mark the closest distance between this shape and aOther.
Public interface for finding nearest points between two shapes.
If the shapes are overlapping, the points will be the same.
aOther | the other shape to compare with |
aPtThis | [out] the point on this shape closest to aOther |
aPtOther | [out] the point on aOther closest to this shape |
aA | first shape |
aB | second shape |
aPtA | [out] nearest point on first shape |
aPtB | [out] nearest point on second shape |
Definition at line 911 of file shape_nearest_points.cpp.
References nearestPoints(), and SHAPE().
Referenced by BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), and BOOST_AUTO_TEST_CASE().
|
inherited |
Definition at line 695 of file wrlfacet.cpp.
References facets.
Referenced by WRL1FACESET::TranslateToSG(), WRL2FACESET::TranslateToSG(), and X3DIFACESET::TranslateToSG().
|
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 127 of file shape.cpp.
References SHAPE_POLY_SET::COutline(), ERROR_INSIDE, SHAPE_POLY_SET::OutlineCount(), SHAPE_LINE_CHAIN_BASE::PointInside(), and TransformToPolygon().
|
inlineoverridevirtual |
aCenter | is the rotation center. |
aAngle | rotation angle. |
Implements SHAPE.
Definition at line 171 of file shape_segment.h.
|
inline |
Definition at line 125 of file shape_segment.h.
References m_seg.
|
inlineoverridevirtual |
|
virtualinherited |
Reimplemented in SHAPE_LINE_CHAIN_BASE, and SHAPE_POLY_SET.
Definition at line 115 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 TransformToPolygon().
Referenced by 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 141 of file shape_segment.cpp.
References m_seg, m_width, and TransformOvalToPolygon().
Referenced by EXPORTER_STEP::buildGraphic3DShape(), FABMASTER::createBoardItems(), and BOARD_ADAPTER::createLayers().
|
inlineinherited |
Return the type of the shape.
the | type |
Definition at line 98 of file shape.h.
References m_type.
Referenced by CREEPAGE_GRAPH::Addshape(), PNS::DP_GATEWAYS::BuildFromPrimitivePair(), PNS::BuildHullForPrimitiveShape(), PNS_LOG_VIEWER_FRAME::buildListTree(), Collide(), SHAPE_POLY_SET::Collide(), collideShapes(), collideSingleShapes(), PNS::OPTIMIZER::computeBreakouts(), ROUTER_PREVIEW_ITEM::drawShape(), PNS_LOG_VIEWER_FRAME::drawSimpleShape(), EDA_SHAPE::EDA_SHAPE(), SHAPE::GetClearance(), nearestPoints(), nearestPointsSingleShapes(), DRC_RTREE::QueryColliding(), STROKE_PARAMS::Stroke(), and SHAPE_FILE_IO::Write().
|
inlineinherited |
|
privateinherited |
Definition at line 143 of file wrlfacet.h.
Referenced by CalcShape(), and NewFacet().
|
private |
Definition at line 191 of file shape_segment.h.
Referenced by BBox(), Clone(), Collide(), Collide(), Format(), GetAngle(), GetCenter(), GetEnd(), GetSeg(), GetStart(), GetTotalLength(), Is45Degree(), Move(), SetSeg(), SHAPE_SEGMENT(), SHAPE_SEGMENT(), 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 TypeName().
|
private |
Definition at line 192 of file shape_segment.h.
Referenced by BBox(), Clone(), Collide(), Collide(), Format(), GetTotalLength(), GetWidth(), SetWidth(), SHAPE_SEGMENT(), SHAPE_SEGMENT(), SHAPE_SEGMENT(), 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 DIRECTION_45::BuildInitialTrace(), CompareLength(), CIRCLE::Contains(), EDIT_TOOL::FilletTracks(), CIRCLE::IntersectLine(), and LINE_FILLET_ROUTINE::ProcessLinePair().