KiCad PCB EDA Suite
SHAPE Class Referenceabstract

Class SHAPE. More...

#include <shape.h>

Inheritance diagram for SHAPE:
SHAPE_ARC SHAPE_CIRCLE SHAPE_LINE_CHAIN SHAPE_POLY_SET SHAPE_RECT SHAPE_SEGMENT SHAPE_SIMPLE

Public Member Functions

 SHAPE (SHAPE_TYPE aType)
 Constructor. More...
 
virtual ~SHAPE ()
 
SHAPE_TYPE Type () const
 Function Type() More...
 
virtual SHAPEClone () const
 Function Clone() 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 bool Collide (const SEG &aSeg, int aClearance=0) const =0
 Function Collide() More...
 
virtual const BOX2I BBox (int aClearance=0) const =0
 Function BBox() More...
 
virtual VECTOR2I Centre () const
 Function Centre() More...
 
virtual void Move (const VECTOR2I &aVector)=0
 
virtual bool IsSolid () const =0
 
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...
 

Detailed Description

Class SHAPE.

Represents an abstract shape on 2D plane.

Definition at line 58 of file shape.h.

Member Typedef Documentation

◆ ecoord

Definition at line 61 of file shape.h.

Constructor & Destructor Documentation

◆ SHAPE()

SHAPE::SHAPE ( SHAPE_TYPE  aType)
inline

Constructor.

Creates an empty shape of type aType

Definition at line 70 of file shape.h.

70  : m_type( aType )
71  {}
SHAPE_TYPE m_type
type of our shape
Definition: shape.h:166

◆ ~SHAPE()

virtual SHAPE::~SHAPE ( )
inlinevirtual

Definition at line 74 of file shape.h.

75  {}

Member Function Documentation

◆ BBox()

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

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.

Implemented in SHAPE_POLY_SET, SHAPE_LINE_CHAIN, SHAPE_SIMPLE, SHAPE_RECT, SHAPE_ARC, SHAPE_CIRCLE, and SHAPE_SEGMENT.

Referenced by boundingBox(), Centre(), PNS::VIA::ChangedArea(), SHAPE_INDEX_LIST< PNS::ITEM * >::Query(), SHAPE_INDEX< T >::Query(), SHAPE_INDEX_LIST< T, >::query_iterator::query_iterator(), SHAPE_INDEX_LIST< T, >::SHAPE_ENTRY::SHAPE_ENTRY(), and ROUTER_PREVIEW_ITEM::ViewBBox().

◆ Centre()

virtual VECTOR2I SHAPE::Centre ( ) const
inlinevirtual

Function Centre()

Computes a center-of-mass of the shape

Returns
the center-of-mass point

Definition at line 151 of file shape.h.

152  {
153  return BBox( 0 ).Centre(); // if nothing better is available....
154  }
virtual const BOX2I BBox(int aClearance=0) const =0
Function BBox()
Vec Centre() const
Definition: box2.h:77

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

◆ Clone()

virtual SHAPE* SHAPE::Clone ( ) const
inlinevirtual

Function Clone()

Returns a dynamically allocated copy of the shape

Return values
copyof the shape

Reimplemented in SHAPE_POLY_SET, SHAPE_LINE_CHAIN, SHAPE_RECT, SHAPE_SIMPLE, SHAPE_ARC, SHAPE_CIRCLE, and SHAPE_SEGMENT.

Definition at line 94 of file shape.h.

95  {
96  assert( false );
97  return NULL;
98  };

Referenced by PNS::SOLID::SOLID(), and ROUTER_PREVIEW_ITEM::Update().

◆ Collide() [1/4]

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

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, SHAPE_ARC, and SHAPE_SEGMENT.

Definition at line 107 of file shape.h.

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

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

◆ Collide() [2/4]

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

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 545 of file shape_collisions.cpp.

546 {
547  return CollideShapes( this, aShape, aClearance, true, aMTV );
548 }
bool CollideShapes(const SHAPE *aA, const SHAPE *aB, int aClearance, bool aNeedMTV, VECTOR2I &aMTV)

References CollideShapes().

◆ Collide() [3/4]

bool SHAPE::Collide ( const SHAPE aShape,
int  aClearance = 0 
) const
virtual

Definition at line 551 of file shape_collisions.cpp.

552 {
553  VECTOR2I dummy;
554 
555  return CollideShapes( this, aShape, aClearance, false, dummy );
556 }
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)

References CollideShapes(), and dummy().

◆ Collide() [4/4]

virtual bool SHAPE::Collide ( const SEG aSeg,
int  aClearance = 0 
) const
pure virtual

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.

Implemented in SHAPE_POLY_SET, SHAPE_LINE_CHAIN, SHAPE_SIMPLE, SHAPE_RECT, SHAPE_ARC, SHAPE_CIRCLE, and SHAPE_SEGMENT.

◆ Format()

const std::string SHAPE::Format ( ) const
virtual

Reimplemented in SHAPE_POLY_SET, and SHAPE_LINE_CHAIN.

Definition at line 35 of file shape.cpp.

36 {
37  assert( false );
38  return std::string( "" );
39 }

Referenced by SHAPE_FILE_IO::Write().

◆ IsSolid()

virtual bool SHAPE::IsSolid ( ) const
pure virtual

◆ Move()

virtual void SHAPE::Move ( const VECTOR2I aVector)
pure virtual

◆ Parse()

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

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 }

◆ Type()

SHAPE_TYPE SHAPE::Type ( ) const
inline

Function Type()

Returns the type of the shape.

Return values
thetype

Definition at line 83 of file shape.h.

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

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

Member Data Documentation

◆ m_type

SHAPE_TYPE SHAPE::m_type
protected

type of our shape

Definition at line 166 of file shape.h.

Referenced by Type().


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