KiCad PCB EDA Suite
Loading...
Searching...
No Matches
SHAPE Class Referenceabstract

An abstract shape on 2D plane. More...

#include <shape.h>

Inheritance diagram for SHAPE:
SHAPE_BASE SHAPE_ARC SHAPE_CIRCLE SHAPE_COMPOUND SHAPE_LINE_CHAIN_BASE SHAPE_NULL SHAPE_POLY_SET SHAPE_RECT SHAPE_SEGMENT

Public Member Functions

 SHAPE (SHAPE_TYPE aType)
 Create an empty shape of type aType. More...
 
virtual ~SHAPE ()
 
virtual SHAPEClone () 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 ()
 
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. 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
 

Detailed Description

An abstract shape on 2D plane.

Definition at line 123 of file shape.h.

Member Typedef Documentation

◆ ecoord

Definition at line 250 of file shape.h.

Constructor & Destructor Documentation

◆ SHAPE()

SHAPE::SHAPE ( SHAPE_TYPE  aType)
inline

Create an empty shape of type aType.

Definition at line 134 of file shape.h.

◆ ~SHAPE() [1/2]

SHAPE::~SHAPE ( )
inlinevirtual

Definition at line 138 of file shape.h.

◆ ~SHAPE() [2/2]

SHAPE::~SHAPE ( )

Member Function Documentation

◆ BBox()

virtual const BOX2I SHAPE::BBox ( int  aClearance = 0) const
pure virtual

◆ CalcShape()

◆ Centre()

virtual VECTOR2I SHAPE::Centre ( ) const
inlinevirtual

Compute a center-of-mass of the shape.

Returns
the center-of-mass point

Definition at line 230 of file shape.h.

References BBox(), and BOX2< Vec >::Centre().

Referenced by Collide().

◆ Clone()

virtual SHAPE * SHAPE::Clone ( ) const
inlinevirtual

◆ Collide() [1/4]

virtual bool SHAPE::Collide ( const SEG aSeg,
int  aClearance = 0,
int *  aActual = nullptr,
VECTOR2I aLocation = nullptr 
) const
pure virtual

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.

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.

◆ Collide() [2/4]

bool SHAPE::Collide ( const SHAPE aShape,
int  aClearance,
VECTOR2I aMTV 
) const
virtual

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
aMTVminimum 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 in SHAPE_COMPOUND, SHAPE_RECT, and SHAPE_SEGMENT.

Definition at line 1124 of file shape_collisions.cpp.

References collideShapes().

◆ Collide() [3/4]

bool SHAPE::Collide ( const SHAPE aShape,
int  aClearance = 0,
int *  aActual = nullptr,
VECTOR2I aLocation = nullptr 
) const
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().

◆ Collide() [4/4]

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

◆ Format()

const std::string SHAPE::Format ( bool  aCplusPlus = true) const
virtual

◆ GetClearance()

int SHAPE::GetClearance ( const SHAPE aOther) const

Return the actual minimum distance between two shapes.

Return values
distancein IU

Definition at line 49 of file shape.cpp.

References SHAPE_BASE::GetIndexableSubshapeCount(), and SHAPE_BASE::GetIndexableSubshapes().

◆ GetIndexableSubshapeCount()

virtual size_t SHAPE_BASE::GetIndexableSubshapeCount ( ) const
inlinevirtualinherited

Reimplemented in SHAPE_COMPOUND, and SHAPE_POLY_SET.

Definition at line 111 of file shape.h.

Referenced by GetClearance().

◆ GetIndexableSubshapes()

virtual void SHAPE_BASE::GetIndexableSubshapes ( std::vector< const SHAPE * > &  aSubshapes) const
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().

◆ HasIndexableSubshapes()

virtual bool SHAPE_BASE::HasIndexableSubshapes ( ) const
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().

◆ IsNull()

bool SHAPE::IsNull ( ) const
inline

Return true if the shape is a null shape.

Return values
trueif null :-)

Definition at line 164 of file shape.h.

References SHAPE_BASE::m_type, and SH_NULL.

◆ IsSolid()

◆ Move()

◆ NewFacet()

FACET * SHAPE::NewFacet ( )

◆ Parse()

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

Reimplemented in SHAPE_LINE_CHAIN, and SHAPE_POLY_SET.

Definition at line 34 of file shape.cpp.

◆ Rotate()

virtual void SHAPE::Rotate ( const EDA_ANGLE aAngle,
const VECTOR2I aCenter = { 0, 0 } 
)
pure virtual
Parameters
aCenteris the rotation center.
aAnglerotation 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.

◆ Type()

◆ TypeName()

wxString SHAPE_BASE::TypeName ( ) const
inlineinherited

Definition at line 101 of file shape.h.

References SHAPE_BASE::m_type, and SHAPE_TYPE_asString().

Referenced by Collide().

Member Data Documentation

◆ facets

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

Definition at line 143 of file wrlfacet.h.

Referenced by CalcShape(), and NewFacet().

◆ m_type

SHAPE_TYPE SHAPE_BASE::m_type
protectedinherited

< type of our shape

Definition at line 117 of file shape.h.

Referenced by Format(), IsNull(), SHAPE_BASE::Type(), and SHAPE_BASE::TypeName().

◆ MIN_PRECISION_IU

const int SHAPE::MIN_PRECISION_IU = 4
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().


The documentation for this class was generated from the following files: