KiCad PCB EDA Suite
SHAPE_CIRCLE Class Reference

#include <shape_circle.h>

Inheritance diagram for SHAPE_CIRCLE:
SHAPE

Public Member Functions

 SHAPE_CIRCLE ()
 
 SHAPE_CIRCLE (const VECTOR2I &aCenter, int aRadius)
 
 SHAPE_CIRCLE (const SHAPE_CIRCLE &aOther)
 
 ~SHAPE_CIRCLE ()
 
SHAPEClone () const override
 Function Clone() More...
 
const BOX2I BBox (int aClearance=0) const override
 Function BBox() More...
 
bool Collide (const SEG &aSeg, int aClearance=0) const override
 Function Collide() More...
 
void SetRadius (int aRadius)
 
void SetCenter (const VECTOR2I &aCenter)
 
int GetRadius () const
 
const VECTOR2I GetCenter () const
 
void Move (const VECTOR2I &aVector) override
 
bool IsSolid () const override
 
SHAPE_TYPE Type () const
 Function Type() More...
 
virtual bool Collide (const VECTOR2I &aP, int aClearance=0) const
 Function Collide() More...
 
virtual bool Collide (const SHAPE *aShape, int aClearance, VECTOR2I &aMTV) const
 Function Collide() More...
 
virtual bool Collide (const SHAPE *aShape, int aClearance=0) const
 
virtual VECTOR2I Centre () const
 Function Centre() More...
 
virtual bool Parse (std::stringstream &aStream)
 
virtual const std::string Format () const
 

Protected Types

typedef VECTOR2I::extended_type ecoord
 

Protected Attributes

SHAPE_TYPE m_type
 

type of our shape

More...
 

Private Attributes

int m_radius
 
VECTOR2I m_center
 

Detailed Description

Definition at line 30 of file shape_circle.h.

Member Typedef Documentation

typedef VECTOR2I::extended_type SHAPE::ecoord
protectedinherited

Definition at line 60 of file shape.h.

Constructor & Destructor Documentation

SHAPE_CIRCLE::SHAPE_CIRCLE ( )
inline

Definition at line 33 of file shape_circle.h.

Referenced by Clone().

33  :
34  SHAPE( SH_CIRCLE ), m_radius( 0 )
35  {}
SHAPE(SHAPE_TYPE aType)
Constructor.
Definition: shape.h:69
line chain (polyline)
Definition: shape.h:46
SHAPE_CIRCLE::SHAPE_CIRCLE ( const VECTOR2I aCenter,
int  aRadius 
)
inline

Definition at line 37 of file shape_circle.h.

37  :
38  SHAPE( SH_CIRCLE ), m_radius( aRadius ), m_center( aCenter )
39  {}
SHAPE(SHAPE_TYPE aType)
Constructor.
Definition: shape.h:69
VECTOR2I m_center
Definition: shape_circle.h:100
line chain (polyline)
Definition: shape.h:46
SHAPE_CIRCLE::SHAPE_CIRCLE ( const SHAPE_CIRCLE aOther)
inline

Definition at line 41 of file shape_circle.h.

41  :
42  SHAPE( SH_CIRCLE ),
43  m_radius( aOther.m_radius ),
44  m_center( aOther.m_center )
45  {};
SHAPE(SHAPE_TYPE aType)
Constructor.
Definition: shape.h:69
VECTOR2I m_center
Definition: shape_circle.h:100
line chain (polyline)
Definition: shape.h:46
SHAPE_CIRCLE::~SHAPE_CIRCLE ( )
inline

Definition at line 47 of file shape_circle.h.

48  {}

Member Function Documentation

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

Function BBox()

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

References m_center, and m_radius.

56  {
57  const VECTOR2I rc( m_radius + aClearance, m_radius + aClearance );
58 
59  return BOX2I( m_center - rc, rc * 2 );
60  }
BOX2< VECTOR2I > BOX2I
Definition: box2.h:468
VECTOR2I m_center
Definition: shape_circle.h:100
virtual VECTOR2I SHAPE::Centre ( ) const
inlinevirtualinherited

Function Centre()

Computes a center-of-mass of the shape

Returns
the center-of-mass point

Definition at line 150 of file shape.h.

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

151  {
152  return BBox( 0 ).Centre(); // if nothing better is available....
153  }
virtual const BOX2I BBox(int aClearance=0) const =0
Function BBox()
Vec Centre() const
Definition: box2.h:67
SHAPE* SHAPE_CIRCLE::Clone ( ) const
inlineoverridevirtual

Function Clone()

Returns a dynamically allocated copy of the shape

Return values
copyof the shape

Reimplemented from SHAPE.

Definition at line 50 of file shape_circle.h.

References SHAPE_CIRCLE().

51  {
52  return new SHAPE_CIRCLE( *this );
53  }
bool SHAPE_CIRCLE::Collide ( const SEG aSeg,
int  aClearance = 0 
) const
inlineoverridevirtual

Function Collide()

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

Returns
true, if there is a collision.

Implements SHAPE.

Definition at line 62 of file shape_circle.h.

References SEG::Distance(), m_center, and m_radius.

Referenced by Collide().

63  {
64  int rc = aClearance + m_radius;
65 
66  return aSeg.Distance( m_center ) < rc;
67  }
VECTOR2I m_center
Definition: shape_circle.h:100
int Distance(const SEG &aSeg) const
Function Distance()
Definition: seg.h:195
virtual bool SHAPE::Collide ( const VECTOR2I aP,
int  aClearance = 0 
) const
inlinevirtualinherited

Function Collide()

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

Returns
true, if there is a collision.

Reimplemented in SHAPE_POLY_SET, SHAPE_LINE_CHAIN, and SHAPE_SEGMENT.

Definition at line 106 of file shape.h.

Referenced by collide(), PNS::ITEM::collideSimple(), and PNS::HIT_VISITOR::operator()().

107  {
108  return Collide( SEG( aP, aP ), aClearance );
109  }
virtual bool Collide(const VECTOR2I &aP, int aClearance=0) const
Function Collide()
Definition: shape.h:106
Definition: seg.h:36
bool SHAPE::Collide ( const SHAPE aShape,
int  aClearance,
VECTOR2I aMTV 
) const
virtualinherited

Function Collide()

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

Definition at line 456 of file shape_collisions.cpp.

References CollideShapes().

457 {
458  return CollideShapes( this, aShape, aClerance, true, aMTV );
459 }
bool CollideShapes(const SHAPE *aA, const SHAPE *aB, int aClearance, bool aNeedMTV, VECTOR2I &aMTV)
bool SHAPE::Collide ( const SHAPE aShape,
int  aClearance = 0 
) const
virtualinherited

Definition at line 462 of file shape_collisions.cpp.

References CollideShapes(), and dummy().

463 {
464  VECTOR2I dummy;
465 
466  return CollideShapes( this, aShape, aClerance, false, dummy );
467 }
static LIB_PART * dummy()
Used when a LIB_PART is not found in library to draw a dummy shape This component is a 400 mils squar...
bool CollideShapes(const SHAPE *aA, const SHAPE *aB, int aClearance, bool aNeedMTV, VECTOR2I &aMTV)
const std::string SHAPE::Format ( ) const
virtualinherited

Reimplemented in SHAPE_POLY_SET, and SHAPE_LINE_CHAIN.

Definition at line 35 of file shape.cpp.

Referenced by SHAPE_FILE_IO::Write().

36 {
37  assert( false );
38  return std::string( "" );
39 }
const VECTOR2I SHAPE_CIRCLE::GetCenter ( ) const
inline
int SHAPE_CIRCLE::GetRadius ( ) const
inline
bool SHAPE_CIRCLE::IsSolid ( ) const
inlineoverridevirtual

Implements SHAPE.

Definition at line 94 of file shape_circle.h.

95  {
96  return true;
97  }
void SHAPE_CIRCLE::Move ( const VECTOR2I aVector)
inlineoverridevirtual

Implements SHAPE.

Definition at line 89 of file shape_circle.h.

References m_center.

90  {
91  m_center += aVector;
92  }
VECTOR2I m_center
Definition: shape_circle.h:100
bool SHAPE::Parse ( std::stringstream &  aStream)
virtualinherited

Reimplemented in SHAPE_POLY_SET, and SHAPE_LINE_CHAIN.

Definition at line 28 of file shape.cpp.

29 {
30  assert( false );
31  return false;
32 }
void SHAPE_CIRCLE::SetCenter ( const VECTOR2I aCenter)
inline

Definition at line 74 of file shape_circle.h.

References m_center.

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

75  {
76  m_center = aCenter;
77  }
VECTOR2I m_center
Definition: shape_circle.h:100
void SHAPE_CIRCLE::SetRadius ( int  aRadius)
inline

Definition at line 69 of file shape_circle.h.

References m_radius.

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

70  {
71  m_radius = aRadius;
72  }
SHAPE_TYPE SHAPE::Type ( ) const
inlineinherited

Function Type()

Returns the type of the shape.

Return values
thetype

Definition at line 82 of file shape.h.

References SHAPE::m_type.

Referenced by PNS::DP_GATEWAYS::BuildFromPrimitivePair(), CollideShapes(), PNS::OPTIMIZER::computeBreakouts(), PNS::LOGGER::dumpShape(), PNS::SOLID::Hull(), ROUTER_PREVIEW_ITEM::ViewDraw(), and SHAPE_FILE_IO::Write().

83  {
84  return m_type;
85  }
SHAPE_TYPE m_type
type of our shape
Definition: shape.h:165

Member Data Documentation

VECTOR2I SHAPE_CIRCLE::m_center
private

Definition at line 100 of file shape_circle.h.

Referenced by BBox(), Collide(), GetCenter(), Move(), and SetCenter().

int SHAPE_CIRCLE::m_radius
private

Definition at line 99 of file shape_circle.h.

Referenced by BBox(), Collide(), GetRadius(), and SetRadius().

SHAPE_TYPE SHAPE::m_type
protectedinherited

type of our shape

Definition at line 165 of file shape.h.

Referenced by SHAPE::Type().


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