KiCad PCB EDA Suite
SHAPE_SEGMENT Class Reference

#include <shape_segment.h>

Inheritance diagram for SHAPE_SEGMENT:
SHAPE

Public Member Functions

 SHAPE_SEGMENT ()
 
 SHAPE_SEGMENT (const VECTOR2I &aA, const VECTOR2I &aB, int aWidth=0)
 
 SHAPE_SEGMENT (const SEG &aSeg, int aWidth=0)
 
 ~SHAPE_SEGMENT ()
 
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...
 
bool Collide (const VECTOR2I &aP, int aClearance=0) const override
 Function Collide() More...
 
void SetSeg (const SEG &aSeg)
 
const SEGGetSeg () const
 
void SetWidth (int aWidth)
 
int GetWidth () const
 
bool IsSolid () const override
 
void Move (const VECTOR2I &aVector) override
 
SHAPE_TYPE Type () const
 Function Type() 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

SEG m_seg
 
int m_width
 

Detailed Description

Definition at line 31 of file shape_segment.h.

Member Typedef Documentation

typedef VECTOR2I::extended_type SHAPE::ecoord
protectedinherited

Definition at line 60 of file shape.h.

Constructor & Destructor Documentation

SHAPE_SEGMENT::SHAPE_SEGMENT ( )
inline

Definition at line 34 of file shape_segment.h.

Referenced by Clone().

34  :
35  SHAPE( SH_SEGMENT ), m_width( 0 ) {};
SHAPE(SHAPE_TYPE aType)
Constructor.
Definition: shape.h:69
axis-aligned rectangle
Definition: shape.h:44
SHAPE_SEGMENT::SHAPE_SEGMENT ( const VECTOR2I aA,
const VECTOR2I aB,
int  aWidth = 0 
)
inline

Definition at line 37 of file shape_segment.h.

37  :
38  SHAPE( SH_SEGMENT ), m_seg( aA, aB ), m_width( aWidth ) {};
SHAPE(SHAPE_TYPE aType)
Constructor.
Definition: shape.h:69
axis-aligned rectangle
Definition: shape.h:44
SHAPE_SEGMENT::SHAPE_SEGMENT ( const SEG aSeg,
int  aWidth = 0 
)
inline

Definition at line 40 of file shape_segment.h.

40  :
41  SHAPE( SH_SEGMENT ), m_seg( aSeg ), m_width( aWidth ) {};
SHAPE(SHAPE_TYPE aType)
Constructor.
Definition: shape.h:69
axis-aligned rectangle
Definition: shape.h:44
SHAPE_SEGMENT::~SHAPE_SEGMENT ( )
inline

Definition at line 43 of file shape_segment.h.

43 {};

Member Function Documentation

const BOX2I SHAPE_SEGMENT::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 50 of file shape_segment.h.

References SEG::A, SEG::B, BOX2< Vec >::Inflate(), m_seg, and m_width.

51  {
52  return BOX2I( m_seg.A, m_seg.B - m_seg.A ).Inflate( aClearance + ( m_width + 1 ) / 2 );
53  }
BOX2< VECTOR2I > BOX2I
Definition: box2.h:468
BOX2< Vec > & Inflate(coord_type dx, coord_type dy)
Function Inflate inflates the rectangle horizontally by dx and vertically by dy.
Definition: box2.h:266
VECTOR2I A
Definition: seg.h:47
VECTOR2I B
Definition: seg.h:48
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_SEGMENT::Clone ( ) const
inlineoverridevirtual

Function Clone()

Returns a dynamically allocated copy of the shape

Return values
copyof the shape

Reimplemented from SHAPE.

Definition at line 45 of file shape_segment.h.

References m_seg, m_width, and SHAPE_SEGMENT().

46  {
47  return new SHAPE_SEGMENT( m_seg, m_width );
48  }
bool SHAPE_SEGMENT::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 55 of file shape_segment.h.

References SEG::Distance(), m_seg, and m_width.

Referenced by Collide().

56  {
57  return m_seg.Distance( aSeg ) < ( m_width + 1 ) / 2 + aClearance;
58  }
int Distance(const SEG &aSeg) const
Function Distance()
Definition: seg.h:186
bool SHAPE_SEGMENT::Collide ( const VECTOR2I aP,
int  aClearance = 0 
) const
inlineoverridevirtual

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 from SHAPE.

Definition at line 60 of file shape_segment.h.

References SEG::Distance(), m_seg, and m_width.

61  {
62  return m_seg.Distance( aP ) < ( m_width + 1 ) / 2 + aClearance;
63  }
int Distance(const SEG &aSeg) const
Function Distance()
Definition: seg.h:186
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 }
int SHAPE_SEGMENT::GetWidth ( void  ) const
inline

Definition at line 80 of file shape_segment.h.

References m_width.

Referenced by PNS::ApproximateSegmentAsRect(), Collide(), PNS::SegmentHull(), ROUTER_PREVIEW_ITEM::ViewDraw(), and PNS::SEGMENT::Width().

81  {
82  return m_width;
83  }
bool SHAPE_SEGMENT::IsSolid ( ) const
inlineoverridevirtual

Implements SHAPE.

Definition at line 85 of file shape_segment.h.

86  {
87  return true;
88  }
void SHAPE_SEGMENT::Move ( const VECTOR2I aVector)
inlineoverridevirtual

Implements SHAPE.

Definition at line 90 of file shape_segment.h.

References SEG::A, SEG::B, and m_seg.

91  {
92  m_seg.A += aVector;
93  m_seg.B += aVector;
94  }
VECTOR2I A
Definition: seg.h:47
VECTOR2I B
Definition: seg.h:48
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_SEGMENT::SetSeg ( const SEG aSeg)
inline

Definition at line 65 of file shape_segment.h.

References m_seg.

Referenced by PNS::SEGMENT::SetEnds(), and PNS::SEGMENT::SwapEnds().

66  {
67  m_seg = aSeg;
68  }
void SHAPE_SEGMENT::SetWidth ( int  aWidth)
inline

Definition at line 75 of file shape_segment.h.

References m_width.

Referenced by PNS::SEGMENT::SetWidth().

76  {
77  m_width = aWidth;
78  }
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

SEG SHAPE_SEGMENT::m_seg
private

Definition at line 97 of file shape_segment.h.

Referenced by BBox(), Clone(), Collide(), GetSeg(), Move(), and SetSeg().

SHAPE_TYPE SHAPE::m_type
protectedinherited

type of our shape

Definition at line 165 of file shape.h.

Referenced by SHAPE::Type().

int SHAPE_SEGMENT::m_width
private

Definition at line 98 of file shape_segment.h.

Referenced by BBox(), Clone(), Collide(), GetWidth(), and SetWidth().


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