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

#include <shape_compound.h>

Inheritance diagram for SHAPE_COMPOUND:
SHAPE SHAPE_BASE

Public Member Functions

 SHAPE_COMPOUND ()
 
 SHAPE_COMPOUND (const std::vector< SHAPE * > &aShapes)
 
 SHAPE_COMPOUND (const SHAPE_COMPOUND &aOther)
 
 ~SHAPE_COMPOUND ()
 
SHAPE_COMPOUNDClone () const override
 Return a dynamically allocated copy of the shape.
 
const std::string Format (bool aCplusPlus=true) 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 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
 
const std::vector< SHAPE * > & Shapes () const
 
const BOX2I BBox (int aClearance=0) const override
 Compute a bounding box of the shape, with a margin of aClearance a collision.
 
int Distance (const SEG &aSeg) const
 
void Move (const VECTOR2I &aVector) override
 
void AddShape (SHAPE *aShape)
 
void AddShape (std::shared_ptr< SHAPE > aShape)
 
bool Empty () const
 
int Size () const
 
void Rotate (const EDA_ANGLE &aAngle, const VECTOR2I &aCenter={ 0, 0 }) override
 
bool IsSolid () const override
 
SHAPEUniqueSubshape () const
 
virtual bool HasIndexableSubshapes () const override
 
virtual size_t GetIndexableSubshapeCount () const override
 
virtual void GetIndexableSubshapes (std::vector< const SHAPE * > &aSubshapes) 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.
 
virtual int Distance (const VECTOR2I &aP) const
 Returns the minimum distance from a given point to 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 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 VECTOR2I GetStart () const
 
virtual VECTOR2I GetEnd () const
 
virtual int GetWidth () const
 
virtual void SetWidth (int aWidth)
 
virtual bool Parse (std::stringstream &aStream)
 
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 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

BOX2I m_cachedBBox
 
bool m_dirty
 
std::vector< SHAPE * > m_shapes
 
std::list< FACET * > facets
 

Detailed Description

Definition at line 38 of file shape_compound.h.

Member Typedef Documentation

◆ ecoord

typedef VECTOR2I::extended_type SHAPE::ecoord
protectedinherited

Definition at line 301 of file shape.h.

Constructor & Destructor Documentation

◆ SHAPE_COMPOUND() [1/3]

SHAPE_COMPOUND::SHAPE_COMPOUND ( )
inline

Definition at line 41 of file shape_compound.h.

References m_dirty, SH_COMPOUND, and SHAPE::SHAPE().

Referenced by AddShape(), AddShape(), Clone(), and SHAPE_COMPOUND().

◆ SHAPE_COMPOUND() [2/3]

SHAPE_COMPOUND::SHAPE_COMPOUND ( const std::vector< SHAPE * > & aShapes)

Definition at line 42 of file shape_compound.cpp.

References m_dirty, m_shapes, SH_COMPOUND, and SHAPE::SHAPE().

◆ SHAPE_COMPOUND() [3/3]

SHAPE_COMPOUND::SHAPE_COMPOUND ( const SHAPE_COMPOUND & aOther)

Definition at line 51 of file shape_compound.cpp.

References m_dirty, m_shapes, SH_COMPOUND, SHAPE::SHAPE(), SHAPE_COMPOUND(), and Shapes().

◆ ~SHAPE_COMPOUND()

SHAPE_COMPOUND::~SHAPE_COMPOUND ( )

Definition at line 63 of file shape_compound.cpp.

References m_shapes.

Member Function Documentation

◆ AddShape() [1/2]

void SHAPE_COMPOUND::AddShape ( SHAPE * aShape)
inline

◆ AddShape() [2/2]

void SHAPE_COMPOUND::AddShape ( std::shared_ptr< SHAPE > aShape)
inline

Definition at line 104 of file shape_compound.h.

References m_dirty, m_shapes, SHAPE::SHAPE(), and SHAPE_COMPOUND().

◆ BBox()

const BOX2I SHAPE_COMPOUND::BBox ( int aClearance = 0) const
overridevirtual

Compute a bounding box of the shape, with a margin of aClearance a collision.

Parameters
aClearancehow much the bounding box is expanded wrs to the minimum enclosing rectangle for the shape.
Returns
the bounding box.

Implements SHAPE.

Definition at line 76 of file shape_compound.cpp.

References m_shapes, and BOX2< Vec >::Merge().

Referenced by PAD::BuildEffectiveShapes(), and PAD::GetBoundingBox().

◆ 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 BBox(), and BOX2< Vec >::Centre().

Referenced by PCB_CONTROL::ApplyDesignBlockLayout(), PNS::TOPOLOGY::AssembleDiffPair(), Collide(), and pickSegment().

◆ Clone()

SHAPE_COMPOUND * SHAPE_COMPOUND::Clone ( ) const
overridevirtual

Return a dynamically allocated copy of the shape.

Return values
copyof the shape

Reimplemented from SHAPE.

Definition at line 70 of file shape_compound.cpp.

References SHAPE_COMPOUND().

◆ Collide() [1/4]

virtual bool SHAPE::Collide ( const VECTOR2I & aP,
int aClearance = 0,
int * aActual = nullptr,
VECTOR2I * aLocation = nullptr ) const
inlinevirtualinherited

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

Parameters
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_ARC, SHAPE_LINE_CHAIN, SHAPE_LINE_CHAIN_BASE, SHAPE_POLY_SET, and SHAPE_SEGMENT.

Definition at line 181 of file shape.h.

References Collide().

Referenced by BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), DRC_RTREE::CheckColliding(), FOOTPRINT::CheckShortingPads(), CN_ZONE_LAYER::Collide(), Collide(), SHAPE_ARC::Collide(), SHAPE_COMPOUND::Collide(), SHAPE_COMPOUND::Collide(), SHAPE_POLY_SET::Collide(), SHAPE_RECT::Collide(), SHAPE_RECT::Collide(), SHAPE_SEGMENT::Collide(), SHAPE_SEGMENT::Collide(), collide(), PNS::ITEM::collideSimple(), MULTICHANNEL_TOOL::copyRuleAreaContents(), PCB_SELECTION_TOOL::hitTestDistance(), PNS::SHOVE::onCollidingVia(), PNS::SHOVE::onReverseCollidingVia(), CN_VISITOR::operator()(), PNS::HIT_VISITOR::operator()(), PNS::VIA::PushoutForce(), DRC_RTREE::QueryColliding(), DRC_RTREE::QueryColliding(), DRC_TEST_PROVIDER_SILK_CLEARANCE::Run(), KIGEOM::ShapeHitTest(), PNS::OPTIMIZER::smartPadsSingle(), DRC_TEST_PROVIDER_EDGE_CLEARANCE::testAgainstEdge(), DRC_TEST_PROVIDER_PHYSICAL_CLEARANCE::testItemAgainstItem(), DRC_TEST_PROVIDER_COPPER_CLEARANCE::testPadAgainstItem(), DRC_TEST_PROVIDER_COPPER_CLEARANCE::testSingleLayerItemAgainstItem(), DRC_TEST_PROVIDER_COPPER_CLEARANCE::testTrackClearances(), and DIALOG_TRACK_VIA_PROPERTIES::TransferDataFromWindow().

◆ Collide() [2/4]

bool SHAPE_COMPOUND::Collide ( const SEG & aSeg,
int aClearance = 0,
int * aActual = nullptr,
VECTOR2I * aLocation = nullptr ) const
overridevirtual

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

Parameters
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.
Returns
true, if there is a collision.

Implements SHAPE.

Definition at line 117 of file shape_compound.cpp.

References SEG::A, actual, m_shapes, and SHAPE::SHAPE().

◆ Collide() [3/4]

bool SHAPE_COMPOUND::Collide ( const SHAPE * aShape,
int aClearance,
VECTOR2I * aMTV ) const
inlineoverridevirtual

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 from SHAPE.

Definition at line 59 of file shape_compound.h.

References SHAPE::Collide(), and SHAPE::SHAPE().

◆ Collide() [4/4]

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

Reimplemented from SHAPE.

Definition at line 64 of file shape_compound.h.

References SHAPE::Collide(), and SHAPE::SHAPE().

◆ Distance() [1/2]

int SHAPE_COMPOUND::Distance ( const SEG & aSeg) const

Definition at line 98 of file shape_compound.cpp.

◆ Distance() [2/2]

int SHAPE::Distance ( const VECTOR2I & aP) const
virtual

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 from SHAPE.

Definition at line 244 of file shape.cpp.

◆ Empty()

bool SHAPE_COMPOUND::Empty ( ) const
inline

Definition at line 123 of file shape_compound.h.

References m_shapes.

◆ Format()

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

Reimplemented from SHAPE.

Definition at line 30 of file shape_compound.cpp.

References m_shapes.

◆ 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 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().

◆ GetEnd()

virtual VECTOR2I SHAPE::GetEnd ( ) const
inlinevirtualinherited

Reimplemented in SHAPE_ARC, and SHAPE_SEGMENT.

Definition at line 287 of file shape.h.

◆ GetIndexableSubshapeCount()

virtual size_t SHAPE_COMPOUND::GetIndexableSubshapeCount ( ) const
inlineoverridevirtual

Reimplemented from SHAPE_BASE.

Definition at line 147 of file shape_compound.h.

References m_shapes.

◆ GetIndexableSubshapes()

virtual void SHAPE_COMPOUND::GetIndexableSubshapes ( std::vector< const SHAPE * > & aSubshapes) const
inlineoverridevirtual

Reimplemented from SHAPE_BASE.

Definition at line 152 of file shape_compound.h.

References m_shapes.

◆ GetStart()

virtual VECTOR2I SHAPE::GetStart ( ) const
inlinevirtualinherited

Reimplemented in SHAPE_ARC, and SHAPE_SEGMENT.

Definition at line 286 of file shape.h.

Referenced by CADSTAR_PCB_ARCHIVE_LOADER::loadCoppers().

◆ GetWidth()

virtual int SHAPE::GetWidth ( ) const
inlinevirtualinherited

Reimplemented in SHAPE_ARC, SHAPE_RECT, and SHAPE_SEGMENT.

Definition at line 289 of file shape.h.

Referenced by SHAPE_LINE_CHAIN::SHAPE_LINE_CHAIN().

◆ HasIndexableSubshapes()

virtual bool SHAPE_COMPOUND::HasIndexableSubshapes ( ) const
inlineoverridevirtual

Reimplemented from SHAPE_BASE.

Definition at line 142 of file shape_compound.h.

◆ 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.

◆ IsSolid()

bool SHAPE_COMPOUND::IsSolid ( ) const
overridevirtual

Implements SHAPE.

Definition at line 111 of file shape_compound.cpp.

◆ Move()

void SHAPE_COMPOUND::Move ( const VECTOR2I & aVector)
overridevirtual

Implements SHAPE.

Definition at line 91 of file shape_compound.cpp.

References m_shapes, and BOX2< Vec >::Move().

◆ NearestPoints()

bool SHAPE::NearestPoints ( const SHAPE * aOther,
VECTOR2I & aPtThis,
VECTOR2I & aPtOther ) const
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.

Parameters
aOtherthe 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
Returns
true if the points were found
Parameters
aAfirst shape
aBsecond shape
aPtA[out] nearest point on first shape
aPtB[out] nearest point on second shape
Returns
true if nearest points were found, false otherwise

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().

◆ NewFacet()

FACET * SHAPE::NewFacet ( )
inherited

◆ Parse()

bool SHAPE::Parse ( std::stringstream & aStream)
virtualinherited

Reimplemented in SHAPE_LINE_CHAIN, and SHAPE_POLY_SET.

Definition at line 40 of file shape.cpp.

◆ PointInside()

bool SHAPE::PointInside ( const VECTOR2I & aPt,
int aAccuracy = 0,
bool aUseBBoxCache = false ) const
virtualinherited

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 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().

◆ Rotate()

void SHAPE_COMPOUND::Rotate ( const EDA_ANGLE & aAngle,
const VECTOR2I & aCenter = { 0, 0 } )
overridevirtual
Parameters
aCenteris the rotation center.
aAnglerotation angle.

Implements SHAPE.

Definition at line 105 of file shape_compound.cpp.

◆ SetWidth()

virtual void SHAPE::SetWidth ( int aWidth)
inlinevirtualinherited

Reimplemented in SHAPE_ARC, SHAPE_LINE_CHAIN, and SHAPE_SEGMENT.

Definition at line 290 of file shape.h.

◆ Shapes()

const std::vector< SHAPE * > & SHAPE_COMPOUND::Shapes ( ) const
inline

Definition at line 70 of file shape_compound.h.

References m_shapes.

Referenced by collideShapes(), PNS::HOLE::Hull(), PNS::SOLID::Hull(), nearestPoints(), and SHAPE_COMPOUND().

◆ Size()

int SHAPE_COMPOUND::Size ( ) const
inline

Definition at line 128 of file shape_compound.h.

References m_shapes.

◆ SquaredDistance()

SEG::ecoord SHAPE::SquaredDistance ( const VECTOR2I & aP,
bool aOutlineOnly = false ) const
virtualinherited

◆ TransformToPolygon()

void SHAPE_COMPOUND::TransformToPolygon ( SHAPE_POLY_SET & aBuffer,
int aError,
ERROR_LOC aErrorLoc ) const
overridevirtual

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 166 of file shape_compound.cpp.

References m_shapes, and SHAPE::SHAPE().

◆ Type()

◆ TypeName()

wxString SHAPE_BASE::TypeName ( ) const
inlineinherited

Definition at line 103 of file shape.h.

References m_type, and SHAPE_TYPE_asString().

Referenced by Collide(), Collide(), Collide(), Collide(), Collide(), Collide(), Collide(), and Collide().

◆ UniqueSubshape()

SHAPE * SHAPE_COMPOUND::UniqueSubshape ( ) const
inline

Definition at line 137 of file shape_compound.h.

References m_shapes, and SHAPE::SHAPE().

Member Data Documentation

◆ facets

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

Definition at line 143 of file wrlfacet.h.

Referenced by CalcShape(), and NewFacet().

◆ m_cachedBBox

BOX2I SHAPE_COMPOUND::m_cachedBBox
private

Definition at line 163 of file shape_compound.h.

◆ m_dirty

bool SHAPE_COMPOUND::m_dirty
private

Definition at line 164 of file shape_compound.h.

Referenced by AddShape(), AddShape(), SHAPE_COMPOUND(), SHAPE_COMPOUND(), and SHAPE_COMPOUND().

◆ m_shapes

◆ 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 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 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: