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

#include <shape_circle.h>

Inheritance diagram for SHAPE_CIRCLE:
SHAPE SHAPE_BASE

Public Member Functions

 SHAPE_CIRCLE ()
 
 SHAPE_CIRCLE (const VECTOR2I &aCenter, int aRadius)
 
 SHAPE_CIRCLE (const CIRCLE &aCircle)
 
 SHAPE_CIRCLE (const SHAPE_CIRCLE &aOther)
 
 ~SHAPE_CIRCLE ()
 
SHAPEClone () const override
 Return a dynamically allocated copy of the shape.
 
SHAPE_CIRCLEoperator= (const SHAPE_CIRCLE &)=default
 
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 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.
 
void SetRadius (int aRadius)
 
void SetCenter (const VECTOR2I &aCenter)
 
int GetRadius () const
 
const VECTOR2I GetCenter () const
 
const CIRCLE GetCircle () const
 
void Move (const VECTOR2I &aVector) override
 
void Rotate (const EDA_ANGLE &aAngle, const VECTOR2I &aCenter={ 0, 0 }) override
 
bool IsSolid () const override
 
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 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.
 
virtual bool Collide (const SHAPE *aShape, int aClearance=0, int *aActual=nullptr, VECTOR2I *aLocation=nullptr) const
 
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)
 
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
 
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

CIRCLE m_circle
 
std::list< FACET * > facets
 

Detailed Description

Definition at line 37 of file shape_circle.h.

Member Typedef Documentation

◆ ecoord

typedef VECTOR2I::extended_type SHAPE::ecoord
protectedinherited

Definition at line 284 of file shape.h.

Constructor & Destructor Documentation

◆ SHAPE_CIRCLE() [1/4]

SHAPE_CIRCLE::SHAPE_CIRCLE ( )
inline

Definition at line 40 of file shape_circle.h.

Referenced by Clone().

◆ SHAPE_CIRCLE() [2/4]

SHAPE_CIRCLE::SHAPE_CIRCLE ( const VECTOR2I aCenter,
int  aRadius 
)
inline

Definition at line 45 of file shape_circle.h.

◆ SHAPE_CIRCLE() [3/4]

SHAPE_CIRCLE::SHAPE_CIRCLE ( const CIRCLE aCircle)
inline

Definition at line 50 of file shape_circle.h.

◆ SHAPE_CIRCLE() [4/4]

SHAPE_CIRCLE::SHAPE_CIRCLE ( const SHAPE_CIRCLE aOther)
inline

Definition at line 55 of file shape_circle.h.

◆ ~SHAPE_CIRCLE()

SHAPE_CIRCLE::~SHAPE_CIRCLE ( )
inline

Definition at line 60 of file shape_circle.h.

Member Function Documentation

◆ BBox()

const BOX2I SHAPE_CIRCLE::BBox ( int  aClearance = 0) const
inlineoverridevirtual

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 70 of file shape_circle.h.

References CIRCLE::Center, m_circle, and CIRCLE::Radius.

Referenced by CONNECTIVITY_DATA::TestTrackEndpointDangling().

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

Referenced by PNS::TOPOLOGY::AssembleDiffPair(), Collide(), SCH_EASYEDA_PARSER::ParseSchematic(), and pickSegment().

◆ Clone()

SHAPE * SHAPE_CIRCLE::Clone ( ) const
inlineoverridevirtual

Return a dynamically allocated copy of the shape.

Return values
copyof the shape

Reimplemented from SHAPE.

Definition at line 63 of file shape_circle.h.

References SHAPE_CIRCLE().

◆ Collide() [1/4]

bool SHAPE_CIRCLE::Collide ( const SEG aSeg,
int  aClearance = 0,
int *  aActual = nullptr,
VECTOR2I aLocation = nullptr 
) const
inlineoverridevirtual

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 77 of file shape_circle.h.

References CIRCLE::Center, m_circle, SEG::NearestPoint(), CIRCLE::Radius, and SEG::Square().

Referenced by Collide(), and SCH_JUNCTION::HitTest().

◆ Collide() [2/4]

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

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

Definition at line 1174 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
virtualinherited

Reimplemented in SHAPE_ARC, SHAPE_COMPOUND, SHAPE_POLY_SET, SHAPE_RECT, and SHAPE_SEGMENT.

Definition at line 1180 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
inlinevirtualinherited

◆ Distance()

int SHAPE::Distance ( const VECTOR2I aP) const
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.

Parameters
aPis the point to test
Returns
the distance from the shape to aP

Reimplemented in SHAPE_COMPOUND, and SHAPE_LINE_CHAIN.

Definition at line 108 of file shape.cpp.

References SHAPE::SquaredDistance().

◆ Format()

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

Reimplemented from SHAPE.

Definition at line 66 of file shape_segment.cpp.

References CIRCLE::Center, SHAPE::Format(), m_circle, CIRCLE::Radius, VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by PNS::VIA::Format().

◆ GetCenter()

◆ GetCircle()

const CIRCLE SHAPE_CIRCLE::GetCircle ( ) const
inline

Definition at line 118 of file shape_circle.h.

References m_circle.

◆ 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 54 of file shape.cpp.

References SHAPE_POLY_SET::COutline(), SHAPE_BASE::GetIndexableSubshapeCount(), SHAPE_BASE::GetIndexableSubshapes(), SHAPE_POLY_SET::OutlineCount(), and SHAPE_BASE::Type().

◆ GetIndexableSubshapeCount()

virtual size_t SHAPE_BASE::GetIndexableSubshapeCount ( ) const
inlinevirtualinherited

Reimplemented in SHAPE_COMPOUND, and SHAPE_POLY_SET.

Definition at line 113 of file shape.h.

Referenced by SHAPE::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 115 of file shape.h.

Referenced by SHAPE_COMPOUND::AddShape(), SHAPE::GetClearance(), and ROUTER_PREVIEW_ITEM::ViewDraw().

◆ GetRadius()

◆ HasIndexableSubshapes()

virtual bool SHAPE_BASE::HasIndexableSubshapes ( ) const
inlinevirtualinherited

Reimplemented in SHAPE_COMPOUND, and SHAPE_POLY_SET.

Definition at line 108 of file shape.h.

Referenced by ROUTER_PREVIEW_ITEM::ViewDraw().

◆ 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_CIRCLE::IsSolid ( ) const
inlineoverridevirtual

Implements SHAPE.

Definition at line 133 of file shape_circle.h.

◆ Move()

void SHAPE_CIRCLE::Move ( const VECTOR2I aVector)
inlineoverridevirtual

Implements SHAPE.

Definition at line 123 of file shape_circle.h.

References CIRCLE::Center, and m_circle.

◆ NewFacet()

FACET * SHAPE::NewFacet ( )
inherited

◆ operator=()

SHAPE_CIRCLE & SHAPE_CIRCLE::operator= ( const SHAPE_CIRCLE )
default

◆ Parse()

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

Reimplemented in SHAPE_LINE_CHAIN, and SHAPE_POLY_SET.

Definition at line 39 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 126 of file shape.cpp.

References SHAPE_POLY_SET::COutline(), ERROR_INSIDE, SHAPE_POLY_SET::OutlineCount(), SHAPE_LINE_CHAIN_BASE::PointInside(), and SHAPE::TransformToPolygon().

◆ Rotate()

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

Implements SHAPE.

Definition at line 128 of file shape_circle.h.

◆ SetCenter()

void SHAPE_CIRCLE::SetCenter ( const VECTOR2I aCenter)
inline

Definition at line 103 of file shape_circle.h.

References CIRCLE::Center, and m_circle.

Referenced by Collide(), and PNS::VIA::SetPos().

◆ SetRadius()

void SHAPE_CIRCLE::SetRadius ( int  aRadius)
inline

Definition at line 98 of file shape_circle.h.

References m_circle, and CIRCLE::Radius.

Referenced by PNS::VIA::SetDiameter().

◆ SquaredDistance()

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

◆ TransformToPolygon()

void SHAPE_CIRCLE::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 92 of file shape_segment.cpp.

References CIRCLE::Center, m_circle, CIRCLE::Radius, and TransformCircleToPolygon().

◆ Type()

◆ TypeName()

wxString SHAPE_BASE::TypeName ( ) const
inlineinherited

Definition at line 103 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
privateinherited

Definition at line 143 of file wrlfacet.h.

Referenced by SHAPE::CalcShape(), and SHAPE::NewFacet().

◆ m_circle

CIRCLE SHAPE_CIRCLE::m_circle
private

◆ 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 SHAPE_BASE::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 BOOST_AUTO_TEST_CASE(), 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: