KiCad PCB EDA Suite
Loading...
Searching...
No Matches
SHAPE_LINE_CHAIN_BASE Class Referenceabstract

#include <shape.h>

Inheritance diagram for SHAPE_LINE_CHAIN_BASE:
SHAPE SHAPE_BASE SHAPE_LINE_CHAIN SHAPE_POLY_SET::TRIANGULATED_POLYGON::TRI SHAPE_SIMPLE

Public Member Functions

 SHAPE_LINE_CHAIN_BASE (SHAPE_TYPE aType)
 
virtual ~SHAPE_LINE_CHAIN_BASE ()
 
virtual bool Collide (const VECTOR2I &aP, int aClearance=0, int *aActual=nullptr, VECTOR2I *aLocation=nullptr) const override
 Check if point aP lies closer to us than aClearance.
 
virtual bool Collide (const SEG &aSeg, int aClearance=0, int *aActual=nullptr, VECTOR2I *aLocation=nullptr) const override
 Check if segment aSeg lies closer to us than aClearance.
 
SEG::ecoord SquaredDistance (const VECTOR2I &aP, bool aOutlineOnly=false) const override
 
bool PointInside (const VECTOR2I &aPt, int aAccuracy=0, bool aUseBBoxCache=false) const override
 Check if point aP lies inside a closed shape.
 
bool PointOnEdge (const VECTOR2I &aP, int aAccuracy=0) const
 Check if point aP lies on an edge or vertex of the line chain.
 
int EdgeContainingPoint (const VECTOR2I &aP, int aAccuracy=0) const
 Check if point aP lies on an edge or vertex of the line chain.
 
virtual const VECTOR2I GetPoint (int aIndex) const =0
 
virtual const SEG GetSegment (int aIndex) const =0
 
virtual size_t GetPointCount () const =0
 
virtual size_t GetSegmentCount () const =0
 
virtual bool IsClosed () const =0
 
virtual BOX2I * GetCachedBBox () const
 
void TransformToPolygon (SHAPE_POLY_SET &aBuffer, int aError, ERROR_LOC aErrorLoc) const override
 Fills a SHAPE_POLY_SET with a polygon representation of this shape.
 
virtual SHAPE * Clone () const
 Return a dynamically allocated copy of the shape.
 
int GetClearance (const SHAPE *aOther) const
 Return the actual minimum distance between two shapes.
 
bool IsNull () const
 Return true if the shape is a null shape.
 
virtual bool Collide (const SHAPE *aShape, int aClearance, VECTOR2I *aActual) const
 Check if the boundary of shape (this) lies closer to the shape aShape than aClearance, indicating a collision.
 
virtual bool Collide (const SHAPE *aShape, int aClearance=0, int *aActual=nullptr, VECTOR2I *aLocation=nullptr) const
 Check if the boundary of shape (this) lies closer to the shape aShape than aClearance, indicating a collision.
 
virtual const BOX2I BBox (int aClearance=0) const =0
 Compute a bounding box of the shape, with a margin of aClearance a collision.
 
virtual VECTOR2I Centre () const
 Compute a center-of-mass of the shape.
 
virtual int Distance (const VECTOR2I &aP) const
 Returns the minimum distance from a given point to this shape.
 
bool NearestPoints (const SHAPE *aOther, VECTOR2I &aPtThis, VECTOR2I &aPtOther) const
 Return the two points that mark the closest distance between this shape and aOther.
 
virtual void Rotate (const EDA_ANGLE &aAngle, const VECTOR2I &aCenter={ 0, 0 })=0
 
virtual VECTOR2I GetStart () const
 
virtual VECTOR2I GetEnd () const
 
virtual int GetWidth () const
 
virtual void SetWidth (int aWidth)
 
virtual void Move (const VECTOR2I &aVector)=0
 
virtual bool IsSolid () const =0
 
virtual bool Parse (std::stringstream &aStream)
 
virtual const std::string Format (bool aCplusPlus=true) const
 
FACET * NewFacet ()
 
SGNODE * CalcShape (SGNODE *aParent, SGNODE *aColor, WRL1_ORDER aVertexOrder, float aCreaseLimit=0.74317, bool isVRML2=false)
 
SHAPE_TYPE Type () const
 Return the type of the shape.
 
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.
 

Protected Types

typedef VECTOR2I::extended_type ecoord
 

Protected Attributes

SHAPE_TYPE m_type
 type of our shape
 

Private Attributes

std::list< FACET * > facets
 

Detailed Description

Definition at line 315 of file shape.h.

Member Typedef Documentation

◆ ecoord

typedef VECTOR2I::extended_type SHAPE::ecoord
protectedinherited

Definition at line 311 of file shape.h.

Constructor & Destructor Documentation

◆ SHAPE_LINE_CHAIN_BASE()

◆ ~SHAPE_LINE_CHAIN_BASE()

virtual SHAPE_LINE_CHAIN_BASE::~SHAPE_LINE_CHAIN_BASE ( )
inlinevirtual

Definition at line 323 of file shape.h.

Member Function Documentation

◆ BBox()

◆ CalcShape()

◆ Centre()

◆ Clone()

virtual SHAPE * SHAPE::Clone ( ) const
inlinevirtualinherited

◆ Collide() [1/4]

bool SHAPE::Collide ( const SHAPE * aShape,
int aClearance,
VECTOR2I * aActual ) const
virtualinherited

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
[out]aActualis the actual collision point
Returns
true, if there is a collision.

Reimplemented in SHAPE_COMPOUND, SHAPE_RECT, and SHAPE_SEGMENT.

Definition at line 1652 of file shape_collisions.cpp.

References collideShapes(), and SHAPE().

◆ Collide() [2/4]

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

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
[out]aActualan optional pointer to an int to store the actual distance in the event of a collision.
[out]aLocationan option pointer to a point to store a nearby location in the event of a collision.
Returns
true, if there is a collision.

Reimplemented in SHAPE_ARC, SHAPE_COMPOUND, SHAPE_ELLIPSE, SHAPE_POLY_SET, SHAPE_RECT, and SHAPE_SEGMENT.

Definition at line 1658 of file shape_collisions.cpp.

References collideShapes(), and SHAPE().

◆ Collide() [3/4]

bool SHAPE_LINE_CHAIN_BASE::Collide ( const SEG & aSeg,
int aClearance = 0,
int * aActual = nullptr,
VECTOR2I * aLocation = nullptr ) const
overridevirtual

Check if segment aSeg lies closer to us than aClearance.

Parameters
aSegthe segment to check for collisions with
aClearanceminimum distance that does not qualify as a collision.
aActualan optional pointer to an int to store the actual distance in the event of a collision.
aLocation
Returns
true, when a collision has been found

Implements SHAPE.

Reimplemented in SHAPE_LINE_CHAIN, and SHAPE_SIMPLE.

Definition at line 761 of file shape_line_chain.cpp.

References SEG::A, VECTOR2< int32_t >::ECOORD_MAX, GetSegment(), GetSegmentCount(), IsClosed(), SEG::NearestPoint(), PointInside(), SEG::Square(), and SEG::SquaredDistance().

◆ Collide() [4/4]

bool SHAPE_LINE_CHAIN_BASE::Collide ( const VECTOR2I & aP,
int aClearance = 0,
int * aActual = nullptr,
VECTOR2I * aLocation = nullptr ) const
overridevirtual

Check if point aP lies closer to us than aClearance.

Parameters
aPthe point to check for collisions with
aClearanceminimum distance that does not qualify as a collision.
aActualan optional pointer to an int to store the actual distance in the event of a collision.
aLocation
Returns
true, when a collision has been found

Reimplemented from SHAPE.

Reimplemented in SHAPE_LINE_CHAIN.

Definition at line 373 of file shape_line_chain.cpp.

References VECTOR2< int32_t >::ECOORD_MAX, GetSegment(), GetSegmentCount(), IsClosed(), SEG::NearestPoint(), PointInside(), and SEG::Square().

Referenced by Collide().

◆ Distance()

int SHAPE::Distance ( const VECTOR2I & aP) const
virtualinherited

Returns the minimum distance from a given point to this shape.

Always returns zero if the point is inside a closed shape and aOutlineOnly is false.

Parameters
aPis the point to test
Returns
the distance from the shape to aP

Reimplemented in SHAPE_COMPOUND, and SHAPE_LINE_CHAIN.

Definition at line 105 of file shape.cpp.

References SquaredDistance().

◆ EdgeContainingPoint()

int SHAPE_LINE_CHAIN_BASE::EdgeContainingPoint ( const VECTOR2I & aP,
int aAccuracy = 0 ) const

Check if point aP lies on an edge or vertex of the line chain.

Parameters
aPpoint to check
aAccuracyis the error limit for the test.
Returns
index of the first edge containing the point, otherwise negative

Definition at line 2081 of file shape_line_chain.cpp.

References SEG::A, SEG::B, GetPoint(), GetPointCount(), GetSegment(), GetSegmentCount(), SEG::SquaredDistance(), and VECTOR2< T >::SquaredDistance().

Referenced by PointOnEdge().

◆ Format()

const std::string SHAPE::Format ( bool aCplusPlus = true) const
virtualinherited

◆ GetCachedBBox()

virtual BOX2I * SHAPE_LINE_CHAIN_BASE::GetCachedBBox ( ) const
inlinevirtual

Reimplemented in SHAPE_LINE_CHAIN.

Definition at line 382 of file shape.h.

Referenced by PointInside().

◆ GetClearance()

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

Return the actual minimum distance between two shapes.

Return values
distancein IU

POLY_SETs contain a bunch of polygons that are triangulated. But there are way more triangles than necessary for collision detection. Triangles check three vertices each but for the outline, we only need one. These are also fractured, so we don't need to worry about holes

Definition at line 51 of file shape.cpp.

References SHAPE_POLY_SET::COutline(), SHAPE_BASE::GetIndexableSubshapeCount(), SHAPE_BASE::GetIndexableSubshapes(), SHAPE_POLY_SET::OutlineCount(), SH_POLY_SET, SHAPE(), and SHAPE_BASE::Type().

Referenced by BOOST_AUTO_TEST_CASE(), and BOOST_AUTO_TEST_CASE().

◆ GetEnd()

virtual VECTOR2I SHAPE::GetEnd ( ) const
inlinevirtualinherited

Reimplemented in SHAPE_ARC, and SHAPE_SEGMENT.

Definition at line 297 of file shape.h.

◆ 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(), and SHAPE::GetClearance().

◆ GetPoint()

virtual const VECTOR2I SHAPE_LINE_CHAIN_BASE::GetPoint ( int aIndex) const
pure virtual

◆ GetPointCount()

virtual size_t SHAPE_LINE_CHAIN_BASE::GetPointCount ( ) const
pure virtual

◆ GetSegment()

◆ GetSegmentCount()

◆ GetStart()

virtual VECTOR2I SHAPE::GetStart ( ) const
inlinevirtualinherited

Reimplemented in SHAPE_ARC, and SHAPE_SEGMENT.

Definition at line 296 of file shape.h.

Referenced by CADSTAR_PCB_ARCHIVE_LOADER::loadCoppers().

◆ GetWidth()

virtual int SHAPE::GetWidth ( ) const
inlinevirtualinherited

◆ HasIndexableSubshapes()

virtual bool SHAPE_BASE::HasIndexableSubshapes ( ) const
inlinevirtualinherited

Reimplemented in SHAPE_COMPOUND, and SHAPE_POLY_SET.

Definition at line 106 of file shape.h.

◆ IsClosed()

virtual bool SHAPE_LINE_CHAIN_BASE::IsClosed ( ) const
pure virtual

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

◆ Move()

◆ NearestPoints()

bool SHAPE::NearestPoints ( const SHAPE * aOther,
VECTOR2I & aPtThis,
VECTOR2I & aPtOther ) const
inherited

◆ 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 36 of file shape.cpp.

◆ PointInside()

bool SHAPE_LINE_CHAIN_BASE::PointInside ( const VECTOR2I & aPt,
int aAccuracy = 0,
bool aUseBBoxCache = false ) const
overridevirtual

Check if point aP lies inside a closed shape.

Always returns false if this shape is not closed.

Parameters
aPtpoint to check.
aAccuracyis the allowable tolerance of the cheack.
aUseBBoxCachegives better performance if the bounding box caches have been generated.
Returns
true if the point is inside the shape (edge is not treated as being inside).

Reimplemented from SHAPE.

Definition at line 2024 of file shape_line_chain.cpp.

References GetCachedBBox(), GetPoint(), GetPointCount(), IsClosed(), PointOnEdge(), rescale(), VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by Collide(), Collide(), Collide(), Collide(), Collide(), Collide(), Collide(), and SquaredDistance().

◆ PointOnEdge()

bool SHAPE_LINE_CHAIN_BASE::PointOnEdge ( const VECTOR2I & aP,
int aAccuracy = 0 ) const

Check if point aP lies on an edge or vertex of the line chain.

Parameters
aPpoint to check.
aAccuracyis the error limit for the test.
Returns
true if the point lies on the edge.

Definition at line 2075 of file shape_line_chain.cpp.

References EdgeContainingPoint().

Referenced by getPNSLine(), FABMASTER::loadZones(), SHAPE_LINE_CHAIN::PointInside(), PointInside(), PNS::LINE_PLACER::splitHeadTail(), and PNS::LINE::Walkaround().

◆ Rotate()

virtual void SHAPE::Rotate ( const EDA_ANGLE & aAngle,
const VECTOR2I & aCenter = { 0, 0 } )
pure virtualinherited

◆ SetWidth()

virtual void SHAPE::SetWidth ( int aWidth)
inlinevirtualinherited

Reimplemented in SHAPE_ARC, SHAPE_LINE_CHAIN, and SHAPE_SEGMENT.

Definition at line 300 of file shape.h.

◆ SquaredDistance()

SEG::ecoord SHAPE_LINE_CHAIN_BASE::SquaredDistance ( const VECTOR2I & aP,
bool aOutlineOnly = false ) const
overridevirtual

◆ TransformToPolygon()

void SHAPE_LINE_CHAIN_BASE::TransformToPolygon ( SHAPE_POLY_SET & aBuffer,
int aError,
ERROR_LOC aErrorLoc ) const
inlineoverridevirtual

Fills a SHAPE_POLY_SET with a polygon representation of this shape.

Parameters
[out]aBufferwill be filled with the polygonal representation of this shape.
aErrorcontrols the maximum allowed deviation when converting rounded shapes to segments
aErrorLoccontrols where the error is placed when approximating rounded shapes

Implements SHAPE.

Reimplemented in SHAPE_SIMPLE.

Definition at line 384 of file shape.h.

◆ Type()

◆ TypeName()

wxString SHAPE_BASE::TypeName ( ) const
inlineinherited

Definition at line 101 of file shape.h.

References m_type, and SHAPE_TYPE_asString().

Referenced by Collide(), Collide(), Collide(), Collide(), Collide(), Collide(), Collide(), and Collide().

Member Data Documentation

◆ facets

std::list< FACET* > SHAPE::facets
privateinherited

Definition at line 140 of file wrlfacet.h.

Referenced by CalcShape(), and NewFacet().

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

◆ MIN_PRECISION_IU

const int SHAPE::MIN_PRECISION_IU = 4
staticinherited

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