KiCad PCB EDA Suite
SHAPE Class Referenceabstract

Class SHAPE. More...

#include <shape.h>

Inheritance diagram for SHAPE:
SHAPE_CIRCLE SHAPE_CONVEX SHAPE_LINE_CHAIN SHAPE_POLY_SET SHAPE_RECT SHAPE_SEGMENT

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 57 of file shape.h.

Member Typedef Documentation

Definition at line 60 of file shape.h.

Constructor & Destructor Documentation

SHAPE::SHAPE ( SHAPE_TYPE  aType)
inline

Constructor.

Creates an empty shape of type aType

Definition at line 69 of file shape.h.

69  : m_type( aType )
70  {}
SHAPE_TYPE m_type
type of our shape
Definition: shape.h:165
virtual SHAPE::~SHAPE ( )
inlinevirtual

Definition at line 73 of file shape.h.

74  {}

Member Function Documentation

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_CONVEX, SHAPE_RECT, 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().

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 150 of file shape.h.

References 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
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_CONVEX, SHAPE_CIRCLE, and SHAPE_SEGMENT.

Definition at line 93 of file shape.h.

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

94  {
95  assert( false );
96  return NULL;
97  };
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, 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
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 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
virtual

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)
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_CONVEX, SHAPE_RECT, SHAPE_CIRCLE, and SHAPE_SEGMENT.

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

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 }
virtual bool SHAPE::IsSolid ( ) const
pure virtual
virtual void SHAPE::Move ( const VECTOR2I aVector)
pure virtual
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 }
SHAPE_TYPE SHAPE::Type ( ) const
inline

Function Type()

Returns the type of the shape.

Return values
thetype

Definition at line 82 of file shape.h.

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

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

Member Data Documentation

SHAPE_TYPE SHAPE::m_type
protected

type of our shape

Definition at line 165 of file shape.h.

Referenced by Type().


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