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

#include <shape_segment.h>

Inheritance diagram for SHAPE_SEGMENT:
SHAPE SHAPE_BASE

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
 Return a dynamically allocated copy of the shape. More...
 
const BOX2I BBox (int aClearance=0) const override
 Compute a bounding box of the shape, with a margin of aClearance a collision. More...
 
bool Collide (const SHAPE *aShape, int aClearance, VECTOR2I *aMTV) const override
 Check if the boundary of shape (this) lies closer to the shape aShape than aClearance, indicating a collision. More...
 
bool Collide (const SHAPE *aShape, int aClearance=0, int *aActual=nullptr, VECTOR2I *aLocation=nullptr) const override
 
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. More...
 
bool Collide (const VECTOR2I &aP, int aClearance=0, int *aActual=nullptr, VECTOR2I *aLocation=nullptr) const override
 Check if the boundary of shape (this) lies closer to the point aP than aClearance, indicating a collision. More...
 
void SetSeg (const SEG &aSeg)
 
const SEGGetSeg () const
 
void SetWidth (int aWidth)
 
int GetWidth () const
 
bool IsSolid () const override
 
void Rotate (const EDA_ANGLE &aAngle, const VECTOR2I &aCenter={ 0, 0 }) override
 
void Move (const VECTOR2I &aVector) override
 
bool Is45Degree (EDA_ANGLE aTollerance=EDA_ANGLE(1.0, DEGREES_T)) const
 
virtual const std::string Format (bool aCplusPlus=true) const override
 
int GetClearance (const SHAPE *aOther) const
 Return the actual minimum distance between two shapes. More...
 
bool IsNull () const
 Return true if the shape is a null shape. More...
 
virtual VECTOR2I Centre () const
 Compute a center-of-mass of the shape. More...
 
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. More...
 
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. More...
 

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
 
std::list< FACET * > facets
 

Detailed Description

Definition at line 37 of file shape_segment.h.

Member Typedef Documentation

◆ ecoord

typedef VECTOR2I::extended_type SHAPE::ecoord
protectedinherited

Definition at line 250 of file shape.h.

Constructor & Destructor Documentation

◆ SHAPE_SEGMENT() [1/3]

SHAPE_SEGMENT::SHAPE_SEGMENT ( )
inline

Definition at line 40 of file shape_segment.h.

Referenced by Clone().

◆ SHAPE_SEGMENT() [2/3]

SHAPE_SEGMENT::SHAPE_SEGMENT ( const VECTOR2I aA,
const VECTOR2I aB,
int  aWidth = 0 
)
inline

Definition at line 45 of file shape_segment.h.

◆ SHAPE_SEGMENT() [3/3]

SHAPE_SEGMENT::SHAPE_SEGMENT ( const SEG aSeg,
int  aWidth = 0 
)
inline

Definition at line 51 of file shape_segment.h.

◆ ~SHAPE_SEGMENT()

SHAPE_SEGMENT::~SHAPE_SEGMENT ( )
inline

Definition at line 57 of file shape_segment.h.

Member Function Documentation

◆ BBox()

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

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

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

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

Referenced by Collide().

◆ Clone()

SHAPE * SHAPE_SEGMENT::Clone ( ) const
inlineoverridevirtual

Return a dynamically allocated copy of the shape.

Return values
copyof the shape

Reimplemented from SHAPE.

Definition at line 59 of file shape_segment.h.

References m_seg, m_width, and SHAPE_SEGMENT().

◆ Collide() [1/4]

bool SHAPE_SEGMENT::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 80 of file shape_segment.h.

References SEG::A, SEG::B, Collide(), m_seg, m_width, SEG::NearestPoint(), SEG::Square(), and SEG::SquaredDistance().

◆ Collide() [2/4]

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

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

Definition at line 69 of file shape_segment.h.

References SHAPE::Collide().

Referenced by Collide(), and Collide().

◆ Collide() [3/4]

bool SHAPE_SEGMENT::Collide ( const SHAPE aShape,
int  aClearance = 0,
int *  aActual = nullptr,
VECTOR2I aLocation = nullptr 
) const
inlineoverridevirtual

Reimplemented from SHAPE.

Definition at line 74 of file shape_segment.h.

References SHAPE::Collide().

◆ Collide() [4/4]

bool SHAPE_SEGMENT::Collide ( const VECTOR2I aP,
int  aClearance = 0,
int *  aActual = nullptr,
VECTOR2I aLocation = nullptr 
) const
inlineoverridevirtual

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

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

Definition at line 103 of file shape_segment.h.

References m_seg, m_width, SEG::NearestPoint(), SEG::Square(), and SEG::SquaredDistance().

◆ Format()

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

Reimplemented from SHAPE.

Definition at line 30 of file shape_segment.cpp.

References SEG::A, SEG::B, SHAPE::Format(), m_seg, m_width, VECTOR2< T >::x, and VECTOR2< T >::y.

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

◆ GetClearance()

int SHAPE::GetClearance ( const SHAPE aOther) const
inherited

Return the actual minimum distance between two shapes.

Return values
distancein IU

Definition at line 49 of file shape.cpp.

References SHAPE_BASE::GetIndexableSubshapeCount(), and SHAPE_BASE::GetIndexableSubshapes().

◆ GetIndexableSubshapeCount()

virtual size_t SHAPE_BASE::GetIndexableSubshapeCount ( ) const
inlinevirtualinherited

Reimplemented in SHAPE_COMPOUND, and SHAPE_POLY_SET.

Definition at line 111 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 113 of file shape.h.

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

◆ GetSeg()

◆ GetWidth()

◆ HasIndexableSubshapes()

virtual bool SHAPE_BASE::HasIndexableSubshapes ( ) const
inlinevirtualinherited

Reimplemented in SHAPE_COMPOUND, and SHAPE_POLY_SET.

Definition at line 106 of file shape.h.

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

◆ Is45Degree()

bool SHAPE_SEGMENT::Is45Degree ( EDA_ANGLE  aTollerance = EDA_ANGLE( 1.0, DEGREES_T )) const

Definition at line 90 of file shape_segment.cpp.

References SEG::A, EDA_ANGLE::AsDegrees(), SEG::B, m_seg, and EDA_ANGLE::Normalize180().

◆ IsNull()

bool SHAPE::IsNull ( ) const
inlineinherited

Return true if the shape is a null shape.

Return values
trueif null :-)

Definition at line 164 of file shape.h.

References SHAPE_BASE::m_type, and SH_NULL.

◆ IsSolid()

bool SHAPE_SEGMENT::IsSolid ( ) const
inlineoverridevirtual

Implements SHAPE.

Definition at line 143 of file shape_segment.h.

◆ Move()

void SHAPE_SEGMENT::Move ( const VECTOR2I aVector)
inlineoverridevirtual

Implements SHAPE.

Definition at line 154 of file shape_segment.h.

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

◆ NewFacet()

FACET * SHAPE::NewFacet ( )
inherited

◆ Parse()

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

Reimplemented in SHAPE_LINE_CHAIN, and SHAPE_POLY_SET.

Definition at line 34 of file shape.cpp.

◆ Rotate()

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

Implements SHAPE.

Definition at line 148 of file shape_segment.h.

◆ SetSeg()

void SHAPE_SEGMENT::SetSeg ( const SEG aSeg)
inline

Definition at line 123 of file shape_segment.h.

References m_seg.

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

◆ SetWidth()

void SHAPE_SEGMENT::SetWidth ( int  aWidth)
inline

Definition at line 133 of file shape_segment.h.

References m_width.

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

◆ Type()

◆ TypeName()

wxString SHAPE_BASE::TypeName ( ) const
inlineinherited

Definition at line 101 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_seg

SEG SHAPE_SEGMENT::m_seg
private

Definition at line 165 of file shape_segment.h.

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

◆ m_type

SHAPE_TYPE SHAPE_BASE::m_type
protectedinherited

< type of our shape

Definition at line 117 of file shape.h.

Referenced by SHAPE::Format(), SHAPE::IsNull(), SHAPE_BASE::Type(), and SHAPE_BASE::TypeName().

◆ m_width

int SHAPE_SEGMENT::m_width
private

Definition at line 166 of file shape_segment.h.

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

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

Referenced by BOOST_AUTO_TEST_CASE(), DIRECTION_45::BuildInitialTrace(), CompareLength(), CIRCLE::Contains(), EDIT_TOOL::FilletTracks(), and CIRCLE::IntersectLine().


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