KiCad PCB EDA Suite
SHAPE_LINE_CHAIN Class Reference

SHAPE_LINE_CHAIN. More...

#include <shape_line_chain.h>

Inheritance diagram for SHAPE_LINE_CHAIN:
SHAPE

Classes

struct  compareOriginDistance
 
struct  INTERSECTION
 Struct INTERSECTION. More...
 

Public Types

typedef std::vector< INTERSECTIONINTERSECTIONS
 

Public Member Functions

 SHAPE_LINE_CHAIN ()
 Constructor Initializes an empty line chain. More...
 
 SHAPE_LINE_CHAIN (const SHAPE_LINE_CHAIN &aShape)
 Copy Constructor. More...
 
 SHAPE_LINE_CHAIN (const std::vector< int > &aV)
 
 SHAPE_LINE_CHAIN (const std::vector< wxPoint > &aV, bool aClosed=false)
 
 SHAPE_LINE_CHAIN (const std::vector< VECTOR2I > &aV, bool aClosed=false)
 
 SHAPE_LINE_CHAIN (const SHAPE_ARC &aArc, bool aClosed=false)
 
 SHAPE_LINE_CHAIN (const ClipperLib::Path &aPath)
 
virtual ~SHAPE_LINE_CHAIN ()
 
SHAPE_LINE_CHAINoperator= (const SHAPE_LINE_CHAIN &)=default
 
SHAPEClone () const override
 Function Clone() More...
 
void Clear ()
 Function Clear() Removes all points from the line chain. More...
 
void SetClosed (bool aClosed)
 Function SetClosed() More...
 
bool IsClosed () const
 Function IsClosed() More...
 
void SetWidth (int aWidth)
 Sets the width of all segments in the chain. More...
 
int Width () const
 Gets the current width of the segments in the chain. More...
 
int SegmentCount () const
 Function SegmentCount() More...
 
int PointCount () const
 Function PointCount() More...
 
SEG Segment (int aIndex)
 Function Segment() More...
 
const SEG CSegment (int aIndex) const
 Function CSegment() More...
 
void SetPoint (int aIndex, const VECTOR2I &aPos)
 Accessor Function to move a point to a specific location. More...
 
const VECTOR2ICPoint (int aIndex) const
 Function Point() More...
 
const std::vector< VECTOR2I > & CPoints () const
 
const VECTOR2ICLastPoint () const
 Returns the last point in the line chain. More...
 
const std::vector< SHAPE_ARC > & CArcs () const
 
const std::vector< ssize_t > & CShapes () const
 
const BOX2I BBox (int aClearance=0) const override
 Function BBox() More...
 
void GenerateBBoxCache ()
 
bool Collide (const VECTOR2I &aP, int aClearance=0) const override
 Function Collide() More...
 
bool Collide (const SEG &aSeg, int aClearance=0) const override
 Function Collide() More...
 
int Distance (const VECTOR2I &aP, bool aOutlineOnly=false) const
 Function Distance() More...
 
const SHAPE_LINE_CHAIN Reverse () const
 Function Reverse() More...
 
long long int Length () const
 Function Length() More...
 
void Append (int aX, int aY, bool aAllowDuplication=false)
 Function Append() More...
 
void Append (const VECTOR2I &aP, bool aAllowDuplication=false)
 Function Append() More...
 
void Append (const SHAPE_LINE_CHAIN &aOtherLine)
 Function Append() More...
 
void Append (const SHAPE_ARC &aArc)
 
void Insert (size_t aVertex, const VECTOR2I &aP)
 
void Insert (size_t aVertex, const SHAPE_ARC &aArc)
 
void Replace (int aStartIndex, int aEndIndex, const VECTOR2I &aP)
 Function Replace() More...
 
void Replace (int aStartIndex, int aEndIndex, const SHAPE_LINE_CHAIN &aLine)
 Function Replace() More...
 
void Remove (int aStartIndex, int aEndIndex)
 Function Remove() More...
 
void Remove (int aIndex)
 Function Remove() removes the aIndex-th point from the line chain. More...
 
int Split (const VECTOR2I &aP)
 Function Split() More...
 
int Find (const VECTOR2I &aP) const
 Function Find() More...
 
int FindSegment (const VECTOR2I &aP) const
 Function FindSegment() More...
 
const SHAPE_LINE_CHAIN Slice (int aStartIndex, int aEndIndex=-1) const
 Function Slice() More...
 
bool Intersects (const SHAPE_LINE_CHAIN &aChain) const
 
int Intersect (const SEG &aSeg, INTERSECTIONS &aIp) const
 Function Intersect() More...
 
int Intersect (const SHAPE_LINE_CHAIN &aChain, INTERSECTIONS &aIp) const
 Function Intersect() More...
 
int PathLength (const VECTOR2I &aP) const
 Function PathLength() More...
 
bool PointInside (const VECTOR2I &aPt, int aAccuracy=0, bool aUseBBoxCache=false) const
 Function PointInside() More...
 
bool PointOnEdge (const VECTOR2I &aP, int aAccuracy=0) const
 Function PointOnEdge() More...
 
int EdgeContainingPoint (const VECTOR2I &aP, int aAccuracy=0) const
 Function EdgeContainingPoint() More...
 
bool CheckClearance (const VECTOR2I &aP, const int aDist) const
 Function CheckClearance() More...
 
const OPT< INTERSECTIONSelfIntersecting () const
 Function SelfIntersecting() More...
 
SHAPE_LINE_CHAINSimplify ()
 Function Simplify() More...
 
void convertArc (ssize_t aArcIndex)
 Converts an arc to only a point chain by removing the arc and references. More...
 
ClipperLib::Path convertToClipper (bool aRequiredOrientation) const
 Creates a new Clipper path from the SHAPE_LINE_CHAIN in a given orientation. More...
 
int NearestSegment (const VECTOR2I &aP) const
 Find the segment nearest the given point. More...
 
const VECTOR2I NearestPoint (const VECTOR2I &aP) const
 Function NearestPoint() More...
 
const VECTOR2I NearestPoint (const SEG &aSeg, int &dist) const
 Function NearestPoint() More...
 
const std::string Format () const override
 
bool Parse (std::stringstream &aStream) override
 
bool operator!= (const SHAPE_LINE_CHAIN &aRhs) const
 
bool CompareGeometry (const SHAPE_LINE_CHAIN &aOther) const
 
void Move (const VECTOR2I &aVector) override
 
void Mirror (bool aX=true, bool aY=false, const VECTOR2I &aRef={ 0, 0 })
 Mirrors the line points about y or x (or both) More...
 
void Rotate (double aAngle, const VECTOR2I &aCenter=VECTOR2I(0, 0))
 Function Rotate rotates all vertices by a given angle. More...
 
bool IsSolid () const override
 
const VECTOR2I PointAlong (int aPathLength) const
 
double Area () const
 
size_t ArcCount () const
 
ssize_t ArcIndex (size_t aSegment) const
 
const SHAPE_ARCArc (size_t aArc) const
 
bool isArc (size_t aSegment) const
 
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...
 
FACETNewFacet ()
 
SGNODECalcShape (SGNODE *aParent, SGNODE *aColor, WRL1_ORDER aVertexOrder, float aCreaseLimit=0.74317, bool isVRML2=false)
 

Protected Types

typedef VECTOR2I::extended_type ecoord
 

Protected Attributes

SHAPE_TYPE m_type
 

type of our shape

More...
 

Private Types

typedef std::vector< VECTOR2I >::iterator point_iter
 
typedef std::vector< VECTOR2I >::const_iterator point_citer
 

Private Attributes

std::vector< VECTOR2Im_points
 array of vertices More...
 
std::vector< ssize_t > m_shapes
 Array of indices that refer to the index of the shape if the point is part of a larger shape, e.g. More...
 
std::vector< SHAPE_ARCm_arcs
 
bool m_closed
 is the line chain closed? More...
 
int m_width
 Width of the segments (for BBox calculations in RTree) TODO Adjust usage of SHAPE_LINE_CHAIN to account for where we need a width and where not Alternatively, we could split the class into a LINE_CHAIN (no width) and SHAPE_LINE_CHAIN that derives from SHAPE as well that does have a width. More...
 
BOX2I m_bbox
 cached bounding box More...
 

Static Private Attributes

static constexpr ssize_t SHAPE_IS_PT = -1
 

Detailed Description

SHAPE_LINE_CHAIN.

Represents a polyline (an zero-thickness chain of connected line segments). I purposedly didn't name it "polyline" to avoid confusion with the existing CPolyLine in pcbnew.

SHAPE_LINE_CHAIN class shall not be used for polygons!

Definition at line 54 of file shape_line_chain.h.

Member Typedef Documentation

◆ ecoord

typedef VECTOR2I::extended_type SHAPE::ecoord
protectedinherited

Definition at line 63 of file shape.h.

◆ INTERSECTIONS

Definition at line 76 of file shape_line_chain.h.

◆ point_citer

typedef std::vector<VECTOR2I>::const_iterator SHAPE_LINE_CHAIN::point_citer
private

Definition at line 58 of file shape_line_chain.h.

◆ point_iter

typedef std::vector<VECTOR2I>::iterator SHAPE_LINE_CHAIN::point_iter
private

Definition at line 57 of file shape_line_chain.h.

Constructor & Destructor Documentation

◆ SHAPE_LINE_CHAIN() [1/7]

SHAPE_LINE_CHAIN::SHAPE_LINE_CHAIN ( )
inline

Constructor Initializes an empty line chain.

Definition at line 83 of file shape_line_chain.h.

83  : SHAPE( SH_LINE_CHAIN ), m_closed( false ), m_width( 0 )
84  {}
SHAPE(SHAPE_TYPE aType)
Constructor.
Definition: shape.h:72
bool m_closed
is the line chain closed?
int m_width
Width of the segments (for BBox calculations in RTree) TODO Adjust usage of SHAPE_LINE_CHAIN to accou...
line segment
Definition: shape.h:47

Referenced by Clone().

◆ SHAPE_LINE_CHAIN() [2/7]

SHAPE_LINE_CHAIN::SHAPE_LINE_CHAIN ( const SHAPE_LINE_CHAIN aShape)
inline

Copy Constructor.

Definition at line 90 of file shape_line_chain.h.

91  : SHAPE( SH_LINE_CHAIN ),
92  m_points( aShape.m_points ),
93  m_shapes( aShape.m_shapes ),
94  m_arcs( aShape.m_arcs ),
95  m_closed( aShape.m_closed ),
96  m_width( aShape.m_width ),
97  m_bbox( aShape.m_bbox )
98  {}
BOX2I m_bbox
cached bounding box
SHAPE(SHAPE_TYPE aType)
Constructor.
Definition: shape.h:72
std::vector< SHAPE_ARC > m_arcs
bool m_closed
is the line chain closed?
std::vector< VECTOR2I > m_points
array of vertices
std::vector< ssize_t > m_shapes
Array of indices that refer to the index of the shape if the point is part of a larger shape,...
int m_width
Width of the segments (for BBox calculations in RTree) TODO Adjust usage of SHAPE_LINE_CHAIN to accou...
line segment
Definition: shape.h:47

◆ SHAPE_LINE_CHAIN() [3/7]

SHAPE_LINE_CHAIN::SHAPE_LINE_CHAIN ( const std::vector< int > &  aV)

Definition at line 39 of file shape_line_chain.cpp.

40  : SHAPE( SH_LINE_CHAIN ), m_closed( false ), m_width( 0 )
41 {
42  for(size_t i = 0; i < aV.size(); i+= 2 )
43  {
44  Append( aV[i], aV[i+1] );
45  }
46 }
SHAPE(SHAPE_TYPE aType)
Constructor.
Definition: shape.h:72
void Append(int aX, int aY, bool aAllowDuplication=false)
Function Append()
bool m_closed
is the line chain closed?
int m_width
Width of the segments (for BBox calculations in RTree) TODO Adjust usage of SHAPE_LINE_CHAIN to accou...
line segment
Definition: shape.h:47

References Append().

◆ SHAPE_LINE_CHAIN() [4/7]

SHAPE_LINE_CHAIN::SHAPE_LINE_CHAIN ( const std::vector< wxPoint > &  aV,
bool  aClosed = false 
)
inline

Definition at line 102 of file shape_line_chain.h.

103  : SHAPE( SH_LINE_CHAIN ), m_closed( aClosed ), m_width( 0 )
104  {
105  m_points.reserve( aV.size() );
106 
107  for( auto pt : aV )
108  m_points.emplace_back( pt.x, pt.y );
109 
110  m_shapes = std::vector<ssize_t>( aV.size(), ssize_t( SHAPE_IS_PT ) );
111  }
SHAPE(SHAPE_TYPE aType)
Constructor.
Definition: shape.h:72
bool m_closed
is the line chain closed?
std::vector< VECTOR2I > m_points
array of vertices
std::vector< ssize_t > m_shapes
Array of indices that refer to the index of the shape if the point is part of a larger shape,...
static constexpr ssize_t SHAPE_IS_PT
int m_width
Width of the segments (for BBox calculations in RTree) TODO Adjust usage of SHAPE_LINE_CHAIN to accou...
line segment
Definition: shape.h:47

References m_points, m_shapes, and SHAPE_IS_PT.

◆ SHAPE_LINE_CHAIN() [5/7]

SHAPE_LINE_CHAIN::SHAPE_LINE_CHAIN ( const std::vector< VECTOR2I > &  aV,
bool  aClosed = false 
)
inline

Definition at line 113 of file shape_line_chain.h.

114  : SHAPE( SH_LINE_CHAIN ), m_closed( aClosed ), m_width( 0 )
115  {
116  m_points = aV;
117  m_shapes = std::vector<ssize_t>( aV.size(), ssize_t( SHAPE_IS_PT ) );
118  }
SHAPE(SHAPE_TYPE aType)
Constructor.
Definition: shape.h:72
bool m_closed
is the line chain closed?
std::vector< VECTOR2I > m_points
array of vertices
std::vector< ssize_t > m_shapes
Array of indices that refer to the index of the shape if the point is part of a larger shape,...
static constexpr ssize_t SHAPE_IS_PT
int m_width
Width of the segments (for BBox calculations in RTree) TODO Adjust usage of SHAPE_LINE_CHAIN to accou...
line segment
Definition: shape.h:47

References m_points, m_shapes, and SHAPE_IS_PT.

◆ SHAPE_LINE_CHAIN() [6/7]

SHAPE_LINE_CHAIN::SHAPE_LINE_CHAIN ( const SHAPE_ARC aArc,
bool  aClosed = false 
)
inline

Definition at line 120 of file shape_line_chain.h.

121  : SHAPE( SH_LINE_CHAIN ),
122  m_closed( aClosed ),
123  m_width( 0 )
124  {
126  m_arcs.emplace_back( aArc );
127  m_shapes = std::vector<ssize_t>( m_points.size(), 0 );
128  }
SHAPE(SHAPE_TYPE aType)
Constructor.
Definition: shape.h:72
std::vector< SHAPE_ARC > m_arcs
bool m_closed
is the line chain closed?
const std::vector< VECTOR2I > & CPoints() const
std::vector< VECTOR2I > m_points
array of vertices
std::vector< ssize_t > m_shapes
Array of indices that refer to the index of the shape if the point is part of a larger shape,...
int m_width
Width of the segments (for BBox calculations in RTree) TODO Adjust usage of SHAPE_LINE_CHAIN to accou...
line segment
Definition: shape.h:47
const SHAPE_LINE_CHAIN ConvertToPolyline(double aAccuracy=500.0) const
Constructs a SHAPE_LINE_CHAIN of segments from a given arc.
Definition: shape_arc.cpp:274

References SHAPE_ARC::ConvertToPolyline(), CPoints(), m_arcs, m_points, and m_shapes.

◆ SHAPE_LINE_CHAIN() [7/7]

SHAPE_LINE_CHAIN::SHAPE_LINE_CHAIN ( const ClipperLib::Path &  aPath)
inline

Definition at line 130 of file shape_line_chain.h.

130  :
131  SHAPE( SH_LINE_CHAIN ),
132  m_closed( true ),
133  m_width( 0 )
134  {
135  m_points.reserve( aPath.size() );
136  m_shapes = std::vector<ssize_t>( aPath.size(), ssize_t( SHAPE_IS_PT ) );
137 
138  for( const auto& point : aPath )
139  m_points.emplace_back( point.X, point.Y );
140  }
SHAPE(SHAPE_TYPE aType)
Constructor.
Definition: shape.h:72
bool m_closed
is the line chain closed?
std::vector< VECTOR2I > m_points
array of vertices
std::vector< ssize_t > m_shapes
Array of indices that refer to the index of the shape if the point is part of a larger shape,...
static constexpr ssize_t SHAPE_IS_PT
int m_width
Width of the segments (for BBox calculations in RTree) TODO Adjust usage of SHAPE_LINE_CHAIN to accou...
line segment
Definition: shape.h:47

References m_points, m_shapes, and SHAPE_IS_PT.

◆ ~SHAPE_LINE_CHAIN()

virtual SHAPE_LINE_CHAIN::~SHAPE_LINE_CHAIN ( )
inlinevirtual

Definition at line 142 of file shape_line_chain.h.

143  {}

Member Function Documentation

◆ Append() [1/4]

void SHAPE_LINE_CHAIN::Append ( int  aX,
int  aY,
bool  aAllowDuplication = false 
)
inline

Function Append()

Appends a new point at the end of the line chain.

Parameters
aXis X coordinate of the new point
aYis Y coordinate of the new point
aAllowDuplication= true to append the new point even it is the same as the last entered point false (default) to skip it if it is the same as the last entered point

Definition at line 406 of file shape_line_chain.h.

407  {
408  VECTOR2I v( aX, aY );
409  Append( v, aAllowDuplication );
410  }
VECTOR2 defines a general 2D-vector/point.
Definition: vector2d.h:61
void Append(int aX, int aY, bool aAllowDuplication=false)
Function Append()

Referenced by PNS_PCBNEW_DEBUG_DECORATOR::AddBox(), ZONE_FILLER::addHatchFillTypeOnZone(), POLYGON_GEOM_MANAGER::AddPoint(), PNS_PCBNEW_DEBUG_DECORATOR::AddPoint(), ZONE_CONTAINER::AddPolygon(), PNS_PCBNEW_DEBUG_DECORATOR::AddSegment(), SHAPE_SIMPLE::Append(), PNS::DIFF_PAIR::Append(), PNS::ArcHull(), PNS::NODE::AssembleLine(), PNS::DIFF_PAIR::BuildInitial(), DIRECTION_45::BuildInitialTrace(), CINFO3D_VISU::buildPadShapePolygon(), ZONE_FILLER::buildThermalSpokes(), SHAPE_POLY_SET::chamferFilletPolygon(), PNS::KEEP_TOPOLOGY_CONSTRAINT::Check(), PNS::OPTIMIZER::circleBreakouts(), PNS::clipToLoopStart(), KI_TEST::CommonTestData::CommonTestData(), GRID_HELPER::computeAnchors(), SCH_SHEET_PIN::ConstrainOnEdge(), SHAPE_ARC::ConvertToPolyline(), PNS::ConvexHull(), PLACEFILE_GERBER_WRITER::CreatePlaceFile(), PNS::OPTIMIZER::customBreakouts(), PNS::MEANDER_PLACER::doMove(), DIALOG_PAD_PRIMITIVE_POLY_PROPS::doValidate(), PNS::LINE::dragCorner45(), PNS::dragCornerInternal(), PNS::LINE::dragSegment45(), PNS::MEANDER_SHAPE::forward(), SHAPE_POLY_SET::fractureSingle(), PNS::MEANDER_SHAPE::genMeanderShape(), LIB_POLYLINE::HitTest(), IteratorFixture::IteratorFixture(), PNS::TOPOLOGY::LeadingRatLine(), PNS::MEANDER_SHAPE::MakeCorner(), PNS::MEANDER_SHAPE::makeMiterShape(), GEOM_TEST::MakeSquarePolyLine(), PNS::LINE_PLACER::mergeHead(), PNS::OPTIMIZER::mergeObtuse(), PNS::MEANDER_SHAPE::miter(), PNS::DP_MEANDER_PLACER::Move(), PNS::OctagonalHull(), ZONE_CREATE_HELPER::OnComplete(), PNS::LINE_PLACER::optimizeTailHeadTransition(), SHAPE_RECT::Outline(), SHAPE_POLY_SET::Parse(), PNS::LINE_PLACER::rhShoveOnly(), PNS::LINE_PLACER::rhStopAtNearestObstacle(), PNS::WALKAROUND::Route(), PNS::SegmentHull(), SHAPE_LINE_CHAIN(), MARKER_BASE::ShapeToPolygon(), PNS::WALKAROUND::singleStep(), Slice(), PNS::OPTIMIZER::smartPadsSingle(), PNS::MEANDER_SHAPE::start(), TestConcaveSquareFillet(), PNS::tightenSegment(), PNS::LINE_PLACER::Trace(), TransformCircleToPolygon(), unfracture(), SHAPE_POLY_SET::unfractureSingle(), POLYGON_GEOM_MANAGER::updateLeaderPoints(), and PNS::LINE::Walkaround().

◆ Append() [2/4]

void SHAPE_LINE_CHAIN::Append ( const VECTOR2I aP,
bool  aAllowDuplication = false 
)
inline

Function Append()

Appends a new point at the end of the line chain.

Parameters
aPthe new point
aAllowDuplication= true to append the new point even it is the same as the last entered point false (default) to skip it if it is the same as the last entered point

Definition at line 421 of file shape_line_chain.h.

422  {
423  if( m_points.size() == 0 )
424  m_bbox = BOX2I( aP, VECTOR2I( 0, 0 ) );
425 
426  if( m_points.size() == 0 || aAllowDuplication || CPoint( -1 ) != aP )
427  {
428  m_points.push_back( aP );
429  m_shapes.push_back( ssize_t( SHAPE_IS_PT ) );
430  m_bbox.Merge( aP );
431  }
432  }
BOX2I m_bbox
cached bounding box
BOX2< VECTOR2I > BOX2I
Definition: box2.h:521
VECTOR2< int > VECTOR2I
Definition: vector2d.h:594
const VECTOR2I & CPoint(int aIndex) const
Function Point()
std::vector< VECTOR2I > m_points
array of vertices
BOX2< Vec > & Merge(const BOX2< Vec > &aRect)
Function Merge modifies the position and size of the rectangle in order to contain aRect.
Definition: box2.h:385
std::vector< ssize_t > m_shapes
Array of indices that refer to the index of the shape if the point is part of a larger shape,...
static constexpr ssize_t SHAPE_IS_PT

References CPoint(), m_bbox, m_points, m_shapes, BOX2< Vec >::Merge(), and SHAPE_IS_PT.

◆ Append() [3/4]

void SHAPE_LINE_CHAIN::Append ( const SHAPE_LINE_CHAIN aOtherLine)

Function Append()

Appends another line chain at the end.

Parameters
aOtherLinethe line chain to be appended.

Definition at line 358 of file shape_line_chain.cpp.

359 {
360  assert( m_shapes.size() == m_points.size() );
361 
362  if( aOtherLine.PointCount() == 0 )
363  return;
364 
365  else if( PointCount() == 0 || aOtherLine.CPoint( 0 ) != CPoint( -1 ) )
366  {
367  const VECTOR2I p = aOtherLine.CPoint( 0 );
368  m_points.push_back( p );
369  m_shapes.push_back( ssize_t( SHAPE_IS_PT ) );
370  m_bbox.Merge( p );
371  }
372 
373  size_t num_arcs = m_arcs.size();
374  m_arcs.insert( m_arcs.end(), aOtherLine.m_arcs.begin(), aOtherLine.m_arcs.end() );
375 
376  for( int i = 1; i < aOtherLine.PointCount(); i++ )
377  {
378  const VECTOR2I p = aOtherLine.CPoint( i );
379  m_points.push_back( p );
380 
381  ssize_t arcIndex = aOtherLine.ArcIndex( i );
382 
383  if( arcIndex != ssize_t( SHAPE_IS_PT ) )
384  m_shapes.push_back( num_arcs + arcIndex );
385  else
386  m_shapes.push_back( ssize_t( SHAPE_IS_PT ) );
387 
388  m_bbox.Merge( p );
389  }
390 
391  assert( m_shapes.size() == m_points.size() );
392 }
BOX2I m_bbox
cached bounding box
VECTOR2 defines a general 2D-vector/point.
Definition: vector2d.h:61
int PointCount() const
Function PointCount()
std::vector< SHAPE_ARC > m_arcs
ssize_t ArcIndex(size_t aSegment) const
const VECTOR2I & CPoint(int aIndex) const
Function Point()
std::vector< VECTOR2I > m_points
array of vertices
BOX2< Vec > & Merge(const BOX2< Vec > &aRect)
Function Merge modifies the position and size of the rectangle in order to contain aRect.
Definition: box2.h:385
std::vector< ssize_t > m_shapes
Array of indices that refer to the index of the shape if the point is part of a larger shape,...
static constexpr ssize_t SHAPE_IS_PT

References ArcIndex(), CPoint(), m_arcs, m_bbox, m_points, m_shapes, BOX2< Vec >::Merge(), PointCount(), and SHAPE_IS_PT.

◆ Append() [4/4]

void SHAPE_LINE_CHAIN::Append ( const SHAPE_ARC aArc)

Definition at line 395 of file shape_line_chain.cpp.

396 {
397  auto& chain = aArc.ConvertToPolyline();
398 
399  for( auto& pt : chain.CPoints() )
400  {
401  m_points.push_back( pt );
402  m_shapes.push_back( m_arcs.size() );
403  }
404 
405  m_arcs.push_back( aArc );
406 
407  assert( m_shapes.size() == m_points.size() );
408 }
std::vector< SHAPE_ARC > m_arcs
std::vector< VECTOR2I > m_points
array of vertices
std::vector< ssize_t > m_shapes
Array of indices that refer to the index of the shape if the point is part of a larger shape,...
const SHAPE_LINE_CHAIN ConvertToPolyline(double aAccuracy=500.0) const
Constructs a SHAPE_LINE_CHAIN of segments from a given arc.
Definition: shape_arc.cpp:274

References SHAPE_ARC::ConvertToPolyline(), m_arcs, m_points, and m_shapes.

◆ Arc()

const SHAPE_ARC& SHAPE_LINE_CHAIN::Arc ( size_t  aArc) const
inline

Definition at line 742 of file shape_line_chain.h.

743  {
744  return m_arcs[aArc];
745  }
std::vector< SHAPE_ARC > m_arcs

References m_arcs.

Referenced by PNS::NODE::Add(), and PNS::LINE_PLACER::FixRoute().

◆ ArcCount()

size_t SHAPE_LINE_CHAIN::ArcCount ( ) const
inline

Definition at line 729 of file shape_line_chain.h.

730  {
731  return m_arcs.size();
732  }
std::vector< SHAPE_ARC > m_arcs

References m_arcs.

Referenced by PNS::LINE::ArcCount(), and ROUTER_PREVIEW_ITEM::drawLineChain().

◆ ArcIndex()

ssize_t SHAPE_LINE_CHAIN::ArcIndex ( size_t  aSegment) const
inline

Definition at line 734 of file shape_line_chain.h.

735  {
736  if( aSegment >= m_shapes.size() )
737  return SHAPE_IS_PT;
738 
739  return m_shapes[aSegment];
740  }
std::vector< ssize_t > m_shapes
Array of indices that refer to the index of the shape if the point is part of a larger shape,...
static constexpr ssize_t SHAPE_IS_PT

References m_shapes, and SHAPE_IS_PT.

Referenced by Append(), and PNS::LINE_PLACER::FixRoute().

◆ Area()

double SHAPE_LINE_CHAIN::Area ( ) const

Definition at line 996 of file shape_line_chain.cpp.

997 {
998  // see https://www.mathopenref.com/coordpolygonarea2.html
999 
1000  if( !m_closed )
1001  return 0.0;
1002 
1003  double area = 0.0;
1004  int size = m_points.size();
1005 
1006  for( int i = 0, j = size - 1; i < size; ++i )
1007  {
1008  area += ( (double) m_points[j].x + m_points[i].x ) * ( (double) m_points[j].y - m_points[i].y );
1009  j = i;
1010  }
1011 
1012  return -area * 0.5;
1013 }
bool m_closed
is the line chain closed?
std::vector< VECTOR2I > m_points
array of vertices

References m_closed, and m_points.

Referenced by ZONE_FILLER::addHatchFillTypeOnZone(), ZONE_CONTAINER::CalculateFilledArea(), DIALOG_BOARD_STATISTICS::getDataFromPCB(), polygonArea(), unfracture(), and SHAPE_POLY_SET::unfractureSingle().

◆ BBox()

const BOX2I SHAPE_LINE_CHAIN::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 332 of file shape_line_chain.h.

333  {
334  BOX2I bbox;
335  bbox.Compute( m_points );
336 
337  if( aClearance != 0 || m_width != 0 )
338  bbox.Inflate( aClearance + m_width );
339 
340  return bbox;
341  }
void Compute(const Container &aPointList)
Compute the bounding box from a given list of points.
Definition: box2.h:90
std::vector< VECTOR2I > m_points
array of vertices
BOX2< Vec > & Inflate(coord_type dx, coord_type dy)
Function Inflate inflates the rectangle horizontally by dx and vertically by dy.
Definition: box2.h:301
int m_width
Width of the segments (for BBox calculations in RTree) TODO Adjust usage of SHAPE_LINE_CHAIN to accou...

References BOX2< Vec >::Compute(), BOX2< Vec >::Inflate(), m_points, and m_width.

Referenced by SHAPE_SIMPLE::BBox(), POLY_GRID_PARTITION::build(), PNS::KEEP_TOPOLOGY_CONSTRAINT::Check(), AR_AUTOPLACER::fillMatrix(), DIALOG_BOARD_STATISTICS::getDataFromPCB(), Intersect(), and PolygonTriangulation::TesselatePolygon().

◆ CalcShape()

SGNODE * SHAPE::CalcShape ( SGNODE aParent,
SGNODE aColor,
WRL1_ORDER  aVertexOrder,
float  aCreaseLimit = 0.74317,
bool  isVRML2 = false 
)
inherited

Definition at line 713 of file wrlfacet.cpp.

715 {
716  if( facets.empty() || !facets.front()->HasMinPoints() )
717  return NULL;
718 
719  std::vector< std::list< FACET* > > flist;
720 
721  // determine the max. index and size flist as appropriate
722  std::list< FACET* >::iterator sF = facets.begin();
723  std::list< FACET* >::iterator eF = facets.end();
724 
725  int maxIdx = 0;
726  int tmi;
727  float maxV = 0.0;
728  float tV = 0.0;
729 
730  while( sF != eF )
731  {
732  tV = (*sF)->CalcFaceNormal();
733  tmi = (*sF)->GetMaxIndex();
734 
735  if( tmi > maxIdx )
736  maxIdx = tmi;
737 
738  if( tV > maxV )
739  maxV = tV;
740 
741  ++sF;
742  }
743 
744  ++maxIdx;
745 
746  if( maxIdx < 3 )
747  return NULL;
748 
749  flist.resize( maxIdx );
750 
751  // create the lists of facets common to indices
752  sF = facets.begin();
753 
754  while( sF != eF )
755  {
756  (*sF)->Renormalize( tV );
757  (*sF)->CollectVertices( flist );
758  ++sF;
759  }
760 
761  // calculate the normals
762  size_t vs = flist.size();
763 
764  for( size_t i = 0; i < vs; ++i )
765  {
766  sF = flist[i].begin();
767  eF = flist[i].end();
768 
769  while( sF != eF )
770  {
771  (*sF)->CalcVertexNormal( i, flist[i], aCreaseLimit );
772  ++sF;
773  }
774  }
775 
776  std::vector< WRLVEC3F > vertices;
777  std::vector< WRLVEC3F > normals;
778  std::vector< SGCOLOR > colors;
779 
780  // push the facet data to the final output list
781  sF = facets.begin();
782  eF = facets.end();
783 
784  while( sF != eF )
785  {
786  (*sF)->GetData( vertices, normals, colors, aVertexOrder );
787  ++sF;
788  }
789 
790  flist.clear();
791 
792  if( vertices.size() < 3 )
793  return NULL;
794 
795  IFSG_SHAPE shapeNode( false );
796 
797  if( !isVRML2 )
798  {
799  shapeNode.NewNode( aParent );
800 
801  if( aColor )
802  {
803  if( NULL == S3D::GetSGNodeParent( aColor ) )
804  shapeNode.AddChildNode( aColor );
805  else
806  shapeNode.AddRefNode( aColor );
807  }
808  }
809 
810  std::vector< SGPOINT > lCPts; // vertex points in SGPOINT (double) format
811  std::vector< SGVECTOR > lCNorm; // per-vertex normals
812  vs = vertices.size();
813 
814  for( size_t i = 0; i < vs; ++i )
815  {
816  SGPOINT pt;
817  pt.x = vertices[i].x;
818  pt.y = vertices[i].y;
819  pt.z = vertices[i].z;
820  lCPts.push_back( pt );
821  lCNorm.emplace_back( normals[i].x, normals[i].y, normals[i].z );
822  }
823 
824  vertices.clear();
825  normals.clear();
826 
827  IFSG_FACESET fsNode( false );
828 
829  if( !isVRML2 )
830  fsNode.NewNode( shapeNode );
831  else
832  fsNode.NewNode( aParent );
833 
834  IFSG_COORDS cpNode( fsNode );
835  cpNode.SetCoordsList( lCPts.size(), &lCPts[0] );
836  IFSG_COORDINDEX ciNode( fsNode );
837 
838  for( int i = 0; i < (int)lCPts.size(); ++i )
839  ciNode.AddIndex( i );
840 
841  IFSG_NORMALS nmNode( fsNode );
842  nmNode.SetNormalList( lCNorm.size(), &lCNorm[0] );
843 
844  if( !colors.empty() )
845  {
846  IFSG_COLORS nmColor( fsNode );
847  nmColor.SetColorList( colors.size(), &colors[0] );
848  colors.clear();
849  }
850 
851  if( !isVRML2 )
852  return shapeNode.GetRawPtr();
853 
854  return fsNode.GetRawPtr();
855 }
double x
Definition: sg_base.h:70
IFSG_COORDS is the wrapper for SGCOORDS.
Definition: ifsg_coords.h:40
IFSG_COORDINDEX is the wrapper for SGCOORDINDEX.
IFSG_COLORS is the wrapper for SGCOLORS.
Definition: ifsg_colors.h:41
SGLIB_API SGNODE * GetSGNodeParent(SGNODE *aNode)
Definition: ifsg_api.cpp:636
double y
Definition: sg_base.h:71
IFSG_NORMALS is the wrapper for the SGNORMALS class.
Definition: ifsg_normals.h:40
#define NULL
std::list< FACET * > facets
Definition: wrlfacet.h:143
IFSG_FACESET is the wrapper for the SGFACESET class.
Definition: ifsg_faceset.h:40
double z
Definition: sg_base.h:72
static VRML_COLOR colors[VRML_COLOR_LAST]
IFSG_SHAPE is the wrapper for the SGSHAPE class.
Definition: ifsg_shape.h:40

References IFSG_NODE::AddChildNode(), IFSG_INDEX::AddIndex(), IFSG_NODE::AddRefNode(), colors, SHAPE::facets, IFSG_NODE::GetRawPtr(), S3D::GetSGNodeParent(), IFSG_FACESET::NewNode(), IFSG_SHAPE::NewNode(), NULL, IFSG_COLORS::SetColorList(), IFSG_COORDS::SetCoordsList(), IFSG_NORMALS::SetNormalList(), SGPOINT::x, SGPOINT::y, and SGPOINT::z.

Referenced by WRL1FACESET::TranslateToSG(), X3DIFACESET::TranslateToSG(), and WRL2FACESET::TranslateToSG().

◆ CArcs()

const std::vector<SHAPE_ARC>& SHAPE_LINE_CHAIN::CArcs ( ) const
inline
Returns
the vector of stored arcs

Definition at line 318 of file shape_line_chain.h.

319  {
320  return m_arcs;
321  }
std::vector< SHAPE_ARC > m_arcs

References m_arcs.

Referenced by ROUTER_PREVIEW_ITEM::drawLineChain().

◆ Centre()

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

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

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

Referenced by PNS_PCBNEW_RULE_RESOLVER::CollideHoles().

◆ CheckClearance()

bool SHAPE_LINE_CHAIN::CheckClearance ( const VECTOR2I aP,
const int  aDist 
) const

Function CheckClearance()

Checks if point aP is closer to (or on) an edge or vertex of the line chain.

Parameters
aPpoint to check
aDistdistance in internal units
Returns
true if the point is equal to or closer than aDist to the line chain.

Definition at line 664 of file shape_line_chain.cpp.

665 {
666  if( !PointCount() )
667  return false;
668 
669  else if( PointCount() == 1 )
670  return m_points[0] == aP;
671 
672  for( int i = 0; i < SegmentCount(); i++ )
673  {
674  const SEG s = CSegment( i );
675 
676  if( s.A == aP || s.B == aP )
677  return true;
678 
679  if( s.Distance( aP ) <= aDist )
680  return true;
681  }
682 
683  return false;
684 }
int Distance(const SEG &aSeg) const
Function Distance()
Definition: seg.h:202
int PointCount() const
Function PointCount()
std::vector< VECTOR2I > m_points
array of vertices
int SegmentCount() const
Function SegmentCount()
Definition: seg.h:39
const SEG CSegment(int aIndex) const
Function CSegment()
VECTOR2I A
Definition: seg.h:47
VECTOR2I B
Definition: seg.h:48

References SEG::A, SEG::B, CSegment(), SEG::Distance(), m_points, PointCount(), and SegmentCount().

◆ CLastPoint()

const VECTOR2I& SHAPE_LINE_CHAIN::CLastPoint ( ) const
inline

Returns the last point in the line chain.

Definition at line 310 of file shape_line_chain.h.

311  {
312  return m_points[PointCount() - 1];
313  }
int PointCount() const
Function PointCount()
std::vector< VECTOR2I > m_points
array of vertices

References m_points, and PointCount().

Referenced by POLYGON_GEOM_MANAGER::DeleteLastCorner(), and POLYGON_GEOM_MANAGER::updateLeaderPoints().

◆ Clear()

void SHAPE_LINE_CHAIN::Clear ( )
inline

Function Clear() Removes all points from the line chain.

Definition at line 153 of file shape_line_chain.h.

154  {
155  m_points.clear();
156  m_arcs.clear();
157  m_shapes.clear();
158  m_closed = false;
159  }
std::vector< SHAPE_ARC > m_arcs
bool m_closed
is the line chain closed?
std::vector< VECTOR2I > m_points
array of vertices
std::vector< ssize_t > m_shapes
Array of indices that refer to the index of the shape if the point is part of a larger shape,...

References m_arcs, m_closed, m_points, and m_shapes.

Referenced by PNS_PCBNEW_DEBUG_DECORATOR::AddPoint(), PNS::LINE_PLACER::buildInitialLine(), SHAPE_SIMPLE::Clear(), PNS::LINE::Clear(), PNS::DIFF_PAIR::Clear(), PNS::LINE::ClipToNearestObstacle(), KI_TEST::CommonTestData::CommonTestData(), PNS::MEANDER_PLACER::doMove(), PNS::LINE_PLACER::FixRoute(), PNS::LINE_PLACER::handlePullback(), PNS::LINE_PLACER::handleSelfIntersections(), PNS::LINE_PLACER::initPlacement(), IteratorFixture::IteratorFixture(), PNS::TOPOLOGY::LeadingRatLine(), PNS::MEANDER_SHAPE::MakeCorner(), PNS::DP_MEANDER_PLACER::Move(), PNS::SHOVE::onReverseCollidingVia(), PNS::LINE_PLACER::optimizeTailHeadTransition(), PNS::LINE_PLACER::reduceTail(), POLYGON_GEOM_MANAGER::Reset(), PNS::LINE_PLACER::SetLayer(), PNS::MEANDER_SHAPE::start(), PNS::tightenSegment(), PNS::LINE_PLACER::UnfixRoute(), and PNS::LINE::Walkaround().

◆ Clone()

SHAPE * SHAPE_LINE_CHAIN::Clone ( ) const
overridevirtual

Function Clone()

Returns a dynamically allocated copy of the shape

Return values
copyof the shape

Reimplemented from SHAPE.

Definition at line 919 of file shape_line_chain.cpp.

920 {
921  return new SHAPE_LINE_CHAIN( *this );
922 }
SHAPE_LINE_CHAIN()
Constructor Initializes an empty line chain.

References SHAPE_LINE_CHAIN().

Referenced by ROUTER_PREVIEW_ITEM::Line().

◆ Collide() [1/4]

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

550 {
551  return CollideShapes( this, aShape, aClearance, true, aMTV );
552 }
bool CollideShapes(const SHAPE *aA, const SHAPE *aB, int aClearance, bool aNeedMTV, VECTOR2I &aMTV)

References CollideShapes().

◆ Collide() [2/4]

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

Definition at line 555 of file shape_collisions.cpp.

556 {
557  VECTOR2I dummy;
558 
559  return CollideShapes( this, aShape, aClearance, false, dummy );
560 }
VECTOR2 defines a general 2D-vector/point.
Definition: vector2d.h:61
static LIB_PART * dummy()
Used to draw a dummy shape when a LIB_PART is not found in library.
bool CollideShapes(const SHAPE *aA, const SHAPE *aB, int aClearance, bool aNeedMTV, VECTOR2I &aMTV)

References CollideShapes(), and dummy().

◆ Collide() [3/4]

bool SHAPE_LINE_CHAIN::Collide ( const VECTOR2I aP,
int  aClearance = 0 
) const
overridevirtual

Function Collide()

Checks 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.
Returns
true, when a collision has been found

Reimplemented from SHAPE.

Definition at line 88 of file shape_line_chain.cpp.

89 {
90  // fixme: ugly!
91  SEG s( aP, aP );
92  return this->Collide( s, aClearance );
93 }
bool Collide(const VECTOR2I &aP, int aClearance=0) const override
Function Collide()
Definition: seg.h:39

Referenced by PNS::MEANDERED_LINE::CheckSelfIntersections(), SHAPE_SIMPLE::Collide(), and Collide().

◆ Collide() [4/4]

bool SHAPE_LINE_CHAIN::Collide ( const SEG aSeg,
int  aClearance = 0 
) const
overridevirtual

Function Collide()

Checks 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.
Returns
true, when a collision has been found

Implements SHAPE.

Definition at line 110 of file shape_line_chain.cpp.

111 {
112  BOX2I box_a( aSeg.A, aSeg.B - aSeg.A );
113  BOX2I::ecoord_type dist_sq = (BOX2I::ecoord_type) aClearance * aClearance;
114 
115  for( int i = 0; i < SegmentCount(); i++ )
116  {
117  const SEG& s = CSegment( i );
118  BOX2I box_b( s.A, s.B - s.A );
119 
120  BOX2I::ecoord_type d = box_a.SquaredDistance( box_b );
121 
122  if( d < dist_sq )
123  {
124  if( s.Collide( aSeg, aClearance ) )
125  return true;
126  }
127  }
128 
129  return false;
130 }
VECTOR2I ::extended_type ecoord_type
Definition: box2.h:50
int SegmentCount() const
Function SegmentCount()
Definition: seg.h:39
const SEG CSegment(int aIndex) const
Function CSegment()
VECTOR2I A
Definition: seg.h:47
bool Collide(const SEG &aSeg, int aClearance) const
Definition: seg.cpp:179
VECTOR2I B
Definition: seg.h:48

References SEG::A, SEG::B, SEG::Collide(), CSegment(), SegmentCount(), and BOX2< Vec >::SquaredDistance().

◆ CompareGeometry()

bool SHAPE_LINE_CHAIN::CompareGeometry ( const SHAPE_LINE_CHAIN aOther) const

Definition at line 896 of file shape_line_chain.cpp.

897 {
898  SHAPE_LINE_CHAIN a(*this), b( aOther );
899  a.Simplify();
900  b.Simplify();
901 
902  if( a.m_points.size() != b.m_points.size() )
903  return false;
904 
905  for( int i = 0; i < a.PointCount(); i++)
906  if( a.CPoint( i ) != b.CPoint( i ) )
907  return false;
908  return true;
909 }
SHAPE_LINE_CHAIN.

References CPoint(), m_points, and Simplify().

Referenced by PNS::LINE::CompareGeometry(), and PNS::SHOVE::processHullSet().

◆ convertArc()

void SHAPE_LINE_CHAIN::convertArc ( ssize_t  aArcIndex)

Converts an arc to only a point chain by removing the arc and references.

Parameters
aArcIndexindex of the arc to convert to points

Definition at line 66 of file shape_line_chain.cpp.

67 {
68  if( aArcIndex < 0 )
69  aArcIndex += m_arcs.size();
70 
71  if( aArcIndex >= static_cast<ssize_t>( m_arcs.size() ) )
72  return;
73 
74  // Clear the shapes references
75  for( auto& sh : m_shapes )
76  {
77  if( sh == aArcIndex )
78  sh = SHAPE_IS_PT;
79 
80  if( sh > aArcIndex )
81  --sh;
82  }
83 
84  m_arcs.erase( m_arcs.begin() + aArcIndex );
85 }
std::vector< SHAPE_ARC > m_arcs
std::vector< ssize_t > m_shapes
Array of indices that refer to the index of the shape if the point is part of a larger shape,...
static constexpr ssize_t SHAPE_IS_PT

References m_arcs, m_shapes, and SHAPE_IS_PT.

Referenced by Insert(), Remove(), Replace(), and SetPoint().

◆ convertToClipper()

ClipperLib::Path SHAPE_LINE_CHAIN::convertToClipper ( bool  aRequiredOrientation) const

Creates a new Clipper path from the SHAPE_LINE_CHAIN in a given orientation.

Definition at line 48 of file shape_line_chain.cpp.

49 {
50  ClipperLib::Path c_path;
51 
52  for( int i = 0; i < PointCount(); i++ )
53  {
54  const VECTOR2I& vertex = CPoint( i );
55  c_path.push_back( ClipperLib::IntPoint( vertex.x, vertex.y ) );
56  }
57 
58  if( Orientation( c_path ) != aRequiredOrientation )
59  ReversePath( c_path );
60 
61  return c_path;
62 }
VECTOR2 defines a general 2D-vector/point.
Definition: vector2d.h:61
int PointCount() const
Function PointCount()
const VECTOR2I & CPoint(int aIndex) const
Function Point()

References CPoint(), PointCount(), VECTOR2< T >::x, and VECTOR2< T >::y.

◆ CPoint()

const VECTOR2I& SHAPE_LINE_CHAIN::CPoint ( int  aIndex) const
inline

Function Point()

Returns a const reference to a given point in the line chain.

Parameters
aIndexindex of the point
Returns
const reference to the point

Definition at line 292 of file shape_line_chain.h.

293  {
294  if( aIndex < 0 )
295  aIndex += PointCount();
296  else if( aIndex >= PointCount() )
297  aIndex -= PointCount();
298 
299  return m_points[aIndex];
300  }
int PointCount() const
Function PointCount()
std::vector< VECTOR2I > m_points
array of vertices

References m_points, and PointCount().

Referenced by POLYGON_GEOM_MANAGER::AddPoint(), CINFO3D_VISU::AddSolidAreasShapesToContainer(), CLAYER_TRIANGLES::AddToMiddleContourns(), Append(), PNS::LINE::AppendVia(), ArePolylineEndPointsNearCircle(), ArePolylineMidPointsNearCircle(), BOOST_AUTO_TEST_CASE(), D_PAD::boundingRadius(), BuildConvexHull(), PNS::LINE_PLACER::buildInitialLine(), CINFO3D_VISU::buildPadShapeThickOutlineAsPolygon(), CINFO3D_VISU::buildPadShapeThickOutlineAsSegments(), SHAPE_POLY_SET::chamferFilletPolygon(), PNS::LINE::ChangedArea(), PNS::KEEP_TOPOLOGY_CONSTRAINT::Check(), DRC::checkClearancePadToPad(), DRC::checkClearanceSegmToPad(), CompareGeometry(), convertToClipper(), PNS::coupledBypass(), SHAPE_SIMPLE::CPoint(), PNS::LINE::CPoint(), PolygonTriangulation::createList(), CreatePadsShapesSection(), DIALOG_PAD_PRIMITIVE_POLY_PROPS::doValidate(), PNS::dragCornerInternal(), PNS::LINE::dragSegment45(), APERTURE_MACRO::DrawApertureMacroShape(), KIGFX::CAIRO_GAL_BASE::drawPoly(), KIGFX::OPENGL_GAL::DrawPolygon(), KIGFX::OPENGL_GAL::DrawPolyline(), PNS::LOGGER::dumpShape(), export_vrml_board(), export_vrml_padshape(), export_vrml_polygon(), export_vrml_zones(), DSN::SPECCTRA_DB::fillBOUNDARY(), AR_AUTOPLACER::fillMatrix(), Find(), PNS::LINE_PLACER::FixRoute(), HPGL_PLOTTER::FlashPadCustom(), PSLIKE_PLOTTER::FlashPadCustom(), GERBER_PLOTTER::FlashPadCustom(), DXF_PLOTTER::FlashPadCustom(), HPGL_PLOTTER::FlashPadRoundRect(), PSLIKE_PLOTTER::FlashPadRoundRect(), GERBER_PLOTTER::FlashPadRoundRect(), DXF_PLOTTER::FlashPadRoundRect(), PNS::TOPOLOGY::followTrivialPath(), PCB_IO::format(), PNS::MEANDER_SHAPE::genMeanderShape(), D_PAD::GetBoundingBox(), DRAWSEGMENT::GetMsgPanelInfo(), PNS::LINE_PLACER::handlePullback(), PNS::LINE_PLACER::handleSelfIntersections(), WS_DRAW_ITEM_POLYPOLYGONS::HitTest(), D_PAD::HitTest(), POLYGON_GEOM_MANAGER::IsSelfIntersecting(), DSN::SPECCTRA_DB::makePADSTACK(), PNS::LINE_PLACER::mergeHead(), PNS::MEANDER_SHAPE::miter(), PNS::LINE_PLACER::Move(), NearestPoint(), POLYGON_GEOM_MANAGER::NewPointClosesOutline(), operator!=(), BOOST_TEST_PRINT_NAMESPACE_OPEN::print_log_value< SHAPE_LINE_CHAIN >::operator()(), PNS::LINE_PLACER::optimizeTailHeadTransition(), BITMAPCONV_INFO::outputOnePolygon(), BRDITEMS_PLOTTER::PlotFilledAreas(), PlotLayerOutlines(), PLOTTER::PlotPoly(), DXF_PLOTTER::PlotPoly(), PlotWorkSheet(), PointAlong(), PNS::pointInside2(), polygon_Convert(), DRAWSEGMENT::Print(), ZONE_CONTAINER::PrintFilledArea(), GERBER_DRAW_ITEM::PrintGerberPoly(), D_PAD::PrintShape(), WS_DRAW_ITEM_POLYPOLYGONS::PrintWsItem(), PNS::SHOVE::processHullSet(), PNS::LINE_PLACER::removeLoops(), PNS::DIFF_PAIR_PLACER::routeHead(), PNS::OPTIMIZER::runSmartPads(), KIGFX::PREVIEW::POLYGON_ITEM::SetPoints(), PNS::shovedArea(), Simplify(), PNS_KICAD_IFACE_BASE::syncPad(), DXF_PLOTTER::ThickSegment(), ZONE_CONTAINER::TransformSolidAreasShapesToPolygonSet(), unfracture(), SHAPE_POLY_SET::unfractureSingle(), PNS::MEANDER_SHAPE::updateBaseSegment(), POLYGON_GEOM_MANAGER::updateLeaderPoints(), PNS::LINE::Walkaround(), PNS::SHOVE::walkaroundLoneVia(), HYPERLYNX_EXPORTER::writeNetObjects(), GBR_TO_PCB_EXPORTER::writePcbPolygonItem(), and GBR_TO_PCB_EXPORTER::writePcbZoneItem().

◆ CPoints()

const std::vector<VECTOR2I>& SHAPE_LINE_CHAIN::CPoints ( ) const
inline

Definition at line 302 of file shape_line_chain.h.

303  {
304  return m_points;
305  }
std::vector< VECTOR2I > m_points
array of vertices

References m_points.

Referenced by BOOST_AUTO_TEST_CASE(), KIGFX::GERBVIEW_PAINTER::draw(), KIGFX::GERBVIEW_PAINTER::drawPolygon(), PointInside(), and SHAPE_LINE_CHAIN().

◆ CSegment()

const SEG SHAPE_LINE_CHAIN::CSegment ( int  aIndex) const
inline

Function CSegment()

Returns a constant copy of the aIndex-th segment in the line chain.

Parameters
aIndexindex of the segment in the line chain. Negative values are counted from the end (i.e. -1 means the last segment in the line chain)
Returns
const SEG - aIndex-th segment in the line chain

Definition at line 254 of file shape_line_chain.h.

255  {
256  if( aIndex < 0 )
257  aIndex += SegmentCount();
258 
259  if( aIndex == (int)( m_points.size() - 1 ) && m_closed )
260  return SEG( const_cast<VECTOR2I&>( m_points[aIndex] ),
261  const_cast<VECTOR2I&>( m_points[0] ), aIndex );
262  else
263  return SEG( const_cast<VECTOR2I&>( m_points[aIndex] ),
264  const_cast<VECTOR2I&>( m_points[aIndex + 1] ), aIndex );
265  }
bool m_closed
is the line chain closed?
std::vector< VECTOR2I > m_points
array of vertices
int SegmentCount() const
Function SegmentCount()
Definition: seg.h:39

References m_closed, m_points, and SegmentCount().

Referenced by PNS::ArcHull(), PNS::LINE_PLACER::buildInitialLine(), PNS::PRESERVE_VERTEX_CONSTRAINT::Check(), CheckClearance(), PNS::NODE::CheckColliding(), PNS::DIFF_PAIR::CheckConnectionAngle(), PNS::checkGap(), PNS::MEANDERED_LINE::CheckSelfIntersections(), PNS::closestProjectedPoint(), Collide(), Collide(), PNS::COST_ESTIMATOR::CornerCost(), PNS::LINE::CountCorners(), PNS::coupledBypass(), PNS::DIFF_PAIR::CoupledLength(), PNS::LINE::CSegment(), PNS::MEANDER_PLACER_BASE::cutTunedLine(), Distance(), PNS::dragCornerInternal(), PNS::LINE::dragSegment45(), ROUTER_PREVIEW_ITEM::drawLineChain(), EdgeContainingPoint(), PNS::findCoupledVertices(), FindSegment(), PNS::DIFF_PAIR_PLACER::FixRoute(), PNS::LINE_PLACER::FixRoute(), PNS::LINE_PLACER::handlePullback(), PNS::LINE_PLACER::handleSelfIntersections(), Intersect(), PNS::LINE::Is45Degree(), Length(), PNS::OPTIMIZER::mergeDpStep(), PNS::LINE_PLACER::mergeHead(), PNS::OPTIMIZER::mergeObtuse(), PNS::OPTIMIZER::mergeStep(), PNS::NODE::NearestObstacle(), NearestPoint(), NearestSegment(), PathLength(), PointAlong(), PNS::LINE_PLACER::reduceTail(), PNS::LINE_PLACER::rhStopAtNearestObstacle(), POLY_GRID_PARTITION::scanCell(), PNS::SegmentHull(), SelfIntersecting(), PNS::OPTIMIZER::smartPadsSingle(), PNS::LINE::snapDraggedCorner(), PNS::LINE::snapToNeighbourSegments(), Split(), PNS::tightenSegment(), SHAPE_POLY_SET::unfractureSingle(), PNS::LINE::Walkaround(), and HYPERLYNX_EXPORTER::writeBoardInfo().

◆ CShapes()

const std::vector<ssize_t>& SHAPE_LINE_CHAIN::CShapes ( ) const
inline
Returns
the vector of values indicating shape type and location

Definition at line 326 of file shape_line_chain.h.

327  {
328  return m_shapes;
329  }
std::vector< ssize_t > m_shapes
Array of indices that refer to the index of the shape if the point is part of a larger shape,...

References m_shapes.

Referenced by BOOST_AUTO_TEST_CASE().

◆ Distance()

int SHAPE_LINE_CHAIN::Distance ( const VECTOR2I aP,
bool  aOutlineOnly = false 
) const

Function Distance()

Computes the minimum distance between the line chain and a point aP.

Parameters
aPthe point
Returns
minimum distance.

Definition at line 268 of file shape_line_chain.cpp.

269 {
270  int d = INT_MAX;
271 
272  if( IsClosed() && PointInside( aP ) && !aOutlineOnly )
273  return 0;
274 
275  for( int s = 0; s < SegmentCount(); s++ )
276  d = std::min( d, CSegment( s ).Distance( aP ) );
277 
278  return d;
279 }
int Distance(const SEG &aSeg) const
Function Distance()
Definition: seg.h:202
int SegmentCount() const
Function SegmentCount()
const SEG CSegment(int aIndex) const
Function CSegment()
bool PointInside(const VECTOR2I &aPt, int aAccuracy=0, bool aUseBBoxCache=false) const
Function PointInside()
bool IsClosed() const
Function IsClosed()

References CSegment(), SEG::Distance(), IsClosed(), PointInside(), and SegmentCount().

Referenced by Collide(), and D_PAD::GetBestAnchorPosition().

◆ EdgeContainingPoint()

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

Function EdgeContainingPoint()

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

Parameters
aPpoint to check
Returns
index of the first edge containing the point, otherwise negative

Definition at line 638 of file shape_line_chain.cpp.

639 {
640  if( !PointCount() )
641  return -1;
642 
643  else if( PointCount() == 1 )
644  {
645  VECTOR2I dist = m_points[0] - aPt;
646  return ( hypot( dist.x, dist.y ) <= aAccuracy + 1 ) ? 0 : -1;
647  }
648 
649  for( int i = 0; i < SegmentCount(); i++ )
650  {
651  const SEG s = CSegment( i );
652 
653  if( s.A == aPt || s.B == aPt )
654  return i;
655 
656  if( s.Distance( aPt ) <= aAccuracy + 1 )
657  return i;
658  }
659 
660  return -1;
661 }
int Distance(const SEG &aSeg) const
Function Distance()
Definition: seg.h:202
static const int dist[10][10]
Definition: ar_matrix.cpp:326
VECTOR2 defines a general 2D-vector/point.
Definition: vector2d.h:61
int PointCount() const
Function PointCount()
std::vector< VECTOR2I > m_points
array of vertices
int SegmentCount() const
Function SegmentCount()
Definition: seg.h:39
const SEG CSegment(int aIndex) const
Function CSegment()
VECTOR2I A
Definition: seg.h:47
VECTOR2I B
Definition: seg.h:48

References SEG::A, SEG::B, CSegment(), dist, SEG::Distance(), m_points, PointCount(), and SegmentCount().

Referenced by PointOnEdge(), and PNS::LINE::Walkaround().

◆ Find()

int SHAPE_LINE_CHAIN::Find ( const VECTOR2I aP) const

Function Find()

Searches for point aP.

Parameters
aPthe point to be looked for
Returns
index of the correspoinding point in the line chain or negative when not found.

Definition at line 321 of file shape_line_chain.cpp.

322 {
323  for( int s = 0; s < PointCount(); s++ )
324  if( CPoint( s ) == aP )
325  return s;
326 
327  return -1;
328 }
int PointCount() const
Function PointCount()
const VECTOR2I & CPoint(int aIndex) const
Function Point()

References CPoint(), and PointCount().

Referenced by PNS::MEANDER_PLACER_BASE::cutTunedLine(), PNS::DRAGGER::dragViaMarkObstacles(), PNS::DRAGGER::dragViaWalkaround(), PNS::NODE::FindLinesBetweenJoints(), Split(), and PNS::LINE::Walkaround().

◆ FindSegment()

int SHAPE_LINE_CHAIN::FindSegment ( const VECTOR2I aP) const

Function FindSegment()

Searches for segment containing point aP.

Parameters
aPthe point to be looked for
Returns
index of the correspoinding segment in the line chain or negative when not found.

Definition at line 331 of file shape_line_chain.cpp.

332 {
333  for( int s = 0; s < SegmentCount(); s++ )
334  if( CSegment( s ).Distance( aP ) <= 1 )
335  return s;
336 
337  return -1;
338 }
int Distance(const SEG &aSeg) const
Function Distance()
Definition: seg.h:202
int SegmentCount() const
Function SegmentCount()
const SEG CSegment(int aIndex) const
Function CSegment()

References CSegment(), SEG::Distance(), and SegmentCount().

Referenced by PNS::MEANDER_PLACER_BASE::cutTunedLine().

◆ Format()

const std::string SHAPE_LINE_CHAIN::Format ( ) const
overridevirtual

Reimplemented from SHAPE.

Definition at line 878 of file shape_line_chain.cpp.

879 {
880  std::stringstream ss;
881 
882  ss << m_points.size() << " " << ( m_closed ? 1 : 0 ) << " " << m_arcs.size() << " ";
883 
884  for( int i = 0; i < PointCount(); i++ )
885  ss << m_points[i].x << " " << m_points[i].y << " " << m_shapes[i];
886 
887  for( size_t i = 0; i < m_arcs.size(); i++ )
888  ss << m_arcs[i].GetCenter().x << " " << m_arcs[i].GetCenter().y << " "
889  << m_arcs[i].GetP0().x << " " << m_arcs[i].GetP0().y << " "
890  << m_arcs[i].GetCentralAngle();
891 
892  return ss.str();
893 }
int PointCount() const
Function PointCount()
std::vector< SHAPE_ARC > m_arcs
bool m_closed
is the line chain closed?
std::vector< VECTOR2I > m_points
array of vertices
std::vector< ssize_t > m_shapes
Array of indices that refer to the index of the shape if the point is part of a larger shape,...

References m_arcs, m_closed, m_points, m_shapes, and PointCount().

◆ GenerateBBoxCache()

void SHAPE_LINE_CHAIN::GenerateBBoxCache ( )
inline

Definition at line 343 of file shape_line_chain.h.

344  {
346 
347  if( m_width != 0 )
349  }
BOX2I m_bbox
cached bounding box
void Compute(const Container &aPointList)
Compute the bounding box from a given list of points.
Definition: box2.h:90
std::vector< VECTOR2I > m_points
array of vertices
BOX2< Vec > & Inflate(coord_type dx, coord_type dy)
Function Inflate inflates the rectangle horizontally by dx and vertically by dy.
Definition: box2.h:301
int m_width
Width of the segments (for BBox calculations in RTree) TODO Adjust usage of SHAPE_LINE_CHAIN to accou...

References BOX2< Vec >::Compute(), BOX2< Vec >::Inflate(), m_bbox, m_points, and m_width.

Referenced by SHAPE_POLY_SET::BuildBBoxCaches(), and ZONE_FILLER::buildThermalSpokes().

◆ Insert() [1/2]

void SHAPE_LINE_CHAIN::Insert ( size_t  aVertex,
const VECTOR2I aP 
)

Definition at line 411 of file shape_line_chain.cpp.

412 {
413  if( m_shapes[aVertex] != SHAPE_IS_PT )
414  convertArc( aVertex );
415 
416  m_points.insert( m_points.begin() + aVertex, aP );
417  m_shapes.insert( m_shapes.begin() + aVertex, ssize_t( SHAPE_IS_PT ) );
418 
419  assert( m_shapes.size() == m_points.size() );
420 }
void convertArc(ssize_t aArcIndex)
Converts an arc to only a point chain by removing the arc and references.
std::vector< VECTOR2I > m_points
array of vertices
std::vector< ssize_t > m_shapes
Array of indices that refer to the index of the shape if the point is part of a larger shape,...
static constexpr ssize_t SHAPE_IS_PT

References convertArc(), m_points, m_shapes, and SHAPE_IS_PT.

Referenced by PNS::LINE::dragSegment45().

◆ Insert() [2/2]

void SHAPE_LINE_CHAIN::Insert ( size_t  aVertex,
const SHAPE_ARC aArc 
)

Step 1: Find the position for the new arc in the existing arc vector

Step 2: Add the arc polyline points to the chain

Step 3: Add the vector of indices to the shape vector

Definition at line 423 of file shape_line_chain.cpp.

424 {
425  if( m_shapes[aVertex] != SHAPE_IS_PT )
426  convertArc( aVertex );
427 
429  size_t arc_pos = m_arcs.size();
430 
431  for( auto arc_it = m_shapes.rbegin() ;
432  arc_it != m_shapes.rend() + aVertex;
433  arc_it++ )
434  {
435  if( *arc_it != SHAPE_IS_PT )
436  arc_pos = ( *arc_it )++;
437  }
438 
439  m_arcs.insert( m_arcs.begin() + arc_pos, aArc );
440 
442  auto& chain = aArc.ConvertToPolyline();
443  m_points.insert( m_points.begin() + aVertex,
444  chain.CPoints().begin(), chain.CPoints().end() );
445 
447  std::vector<size_t> new_points( chain.PointCount(), arc_pos );
448  m_shapes.insert( m_shapes.begin() + aVertex, new_points.begin(), new_points.end() );
449  assert( m_shapes.size() == m_points.size() );
450 }
void convertArc(ssize_t aArcIndex)
Converts an arc to only a point chain by removing the arc and references.
std::vector< SHAPE_ARC > m_arcs
std::vector< VECTOR2I > m_points
array of vertices
std::vector< ssize_t > m_shapes
Array of indices that refer to the index of the shape if the point is part of a larger shape,...
static constexpr ssize_t SHAPE_IS_PT
const SHAPE_LINE_CHAIN ConvertToPolyline(double aAccuracy=500.0) const
Constructs a SHAPE_LINE_CHAIN of segments from a given arc.
Definition: shape_arc.cpp:274

References convertArc(), SHAPE_ARC::ConvertToPolyline(), m_arcs, m_points, m_shapes, and SHAPE_IS_PT.

◆ Intersect() [1/2]

int SHAPE_LINE_CHAIN::Intersect ( const SEG aSeg,
INTERSECTIONS aIp 
) const

Function Intersect()

Finds all intersection points between our line chain and the segment aSeg.

Parameters
aSegthe segment chain to find intersections with
aIpreference to a vector to store found intersections. Intersection points are sorted with increasing distances from point aSeg.a.
Returns
number of intersections found

Definition at line 468 of file shape_line_chain.cpp.

469 {
470  for( int s = 0; s < SegmentCount(); s++ )
471  {
472  OPT_VECTOR2I p = CSegment( s ).Intersect( aSeg );
473 
474  if( p )
475  {
476  INTERSECTION is;
477  is.our = CSegment( s );
478  is.their = aSeg;
479  is.p = *p;
480  aIp.push_back( is );
481  }
482  }
483 
484  compareOriginDistance comp( aSeg.A );
485  sort( aIp.begin(), aIp.end(), comp );
486 
487  return aIp.size();
488 }
OPT_VECTOR2I Intersect(const SEG &aSeg, bool aIgnoreEndpoints=false, bool aLines=false) const
Function Intersect()
Definition: seg.cpp:144
OPT< VECTOR2I > OPT_VECTOR2I
Definition: seg.h:37
int SegmentCount() const
Function SegmentCount()
const SEG CSegment(int aIndex) const
Function CSegment()
VECTOR2I A
Definition: seg.h:47

References SEG::A, CSegment(), SEG::Intersect(), SHAPE_LINE_CHAIN::INTERSECTION::our, SHAPE_LINE_CHAIN::INTERSECTION::p, SegmentCount(), and SHAPE_LINE_CHAIN::INTERSECTION::their.

Referenced by PNS::OPTIMIZER::customBreakouts(), CN_ITEM::GetAnchor(), PNS::LINE_PLACER::handleSelfIntersections(), Intersects(), PNS::NODE::NearestObstacle(), POLYGON_GEOM_MANAGER::updateLeaderPoints(), and PNS::LINE::Walkaround().

◆ Intersect() [2/2]

int SHAPE_LINE_CHAIN::Intersect ( const SHAPE_LINE_CHAIN aChain,
INTERSECTIONS aIp 
) const

Function Intersect()

Finds all intersection points between our line chain and the line chain aChain.

Parameters
aChainthe line chain to find intersections with
aIpreference to a vector to store found intersections. Intersection points are sorted with increasing path lengths from the starting point of aChain.
Returns
number of intersections found

Definition at line 509 of file shape_line_chain.cpp.

510 {
511  BOX2I bb_other = aChain.BBox();
512 
513  for( int s1 = 0; s1 < SegmentCount(); s1++ )
514  {
515  const SEG& a = CSegment( s1 );
516  const BOX2I bb_cur( a.A, a.B - a.A );
517 
518  if( !bb_other.Intersects( bb_cur ) )
519  continue;
520 
521  for( int s2 = 0; s2 < aChain.SegmentCount(); s2++ )
522  {
523  const SEG& b = aChain.CSegment( s2 );
524  INTERSECTION is;
525 
526  if( a.Collinear( b ) )
527  {
528  is.our = a;
529  is.their = b;
530 
531  if( a.Contains( b.A ) ) { is.p = b.A; addIntersection(aIp, PointCount(), is); }
532  if( a.Contains( b.B ) ) { is.p = b.B; addIntersection(aIp, PointCount(), is); }
533  if( b.Contains( a.A ) ) { is.p = a.A; addIntersection(aIp, PointCount(), is); }
534  if( b.Contains( a.B ) ) { is.p = a.B; addIntersection(aIp, PointCount(), is); }
535  }
536  else
537  {
538  OPT_VECTOR2I p = a.Intersect( b );
539 
540  if( p )
541  {
542  is.p = *p;
543  is.our = a;
544  is.their = b;
545  addIntersection(aIp, PointCount(), is);
546  }
547  }
548  }
549  }
550 
551  return aIp.size();
552 }
OPT_VECTOR2I Intersect(const SEG &aSeg, bool aIgnoreEndpoints=false, bool aLines=false) const
Function Intersect()
Definition: seg.cpp:144
int PointCount() const
Function PointCount()
bool Intersects(const BOX2< Vec > &aRect) const
Function Intersects.
Definition: box2.h:235
const BOX2I BBox(int aClearance=0) const override
Function BBox()
OPT< VECTOR2I > OPT_VECTOR2I
Definition: seg.h:37
int SegmentCount() const
Function SegmentCount()
bool Collinear(const SEG &aSeg) const
Function Collinear()
Definition: seg.h:238
Definition: seg.h:39
const SEG CSegment(int aIndex) const
Function CSegment()
VECTOR2I A
Definition: seg.h:47
static void addIntersection(SHAPE_LINE_CHAIN::INTERSECTIONS &aIps, int aPc, const SHAPE_LINE_CHAIN::INTERSECTION &aP)
bool Contains(const SEG &aSeg) const
Definition: seg.h:294
VECTOR2I B
Definition: seg.h:48

References SEG::A, addIntersection(), SEG::B, BBox(), SEG::Collinear(), SEG::Contains(), CSegment(), SEG::Intersect(), BOX2< Vec >::Intersects(), SHAPE_LINE_CHAIN::INTERSECTION::our, SHAPE_LINE_CHAIN::INTERSECTION::p, PointCount(), SegmentCount(), and SHAPE_LINE_CHAIN::INTERSECTION::their.

◆ Intersects()

bool SHAPE_LINE_CHAIN::Intersects ( const SHAPE_LINE_CHAIN aChain) const

Definition at line 912 of file shape_line_chain.cpp.

913 {
915  return Intersect( aChain, dummy ) != 0;
916 }
int Intersect(const SEG &aSeg, INTERSECTIONS &aIp) const
Function Intersect()
std::vector< INTERSECTION > INTERSECTIONS
static LIB_PART * dummy()
Used to draw a dummy shape when a LIB_PART is not found in library.

References dummy(), and Intersect().

Referenced by PNS::DIFF_PAIR::BuildInitial().

◆ isArc()

bool SHAPE_LINE_CHAIN::isArc ( size_t  aSegment) const
inline

Definition at line 747 of file shape_line_chain.h.

748  {
749  return aSegment < m_shapes.size() && m_shapes[aSegment] != SHAPE_IS_PT;
750  }
std::vector< ssize_t > m_shapes
Array of indices that refer to the index of the shape if the point is part of a larger shape,...
static constexpr ssize_t SHAPE_IS_PT

References m_shapes, and SHAPE_IS_PT.

Referenced by PNS::LINE::Is45Degree(), and PNS::OPTIMIZER::mergeStep().

◆ IsClosed()

bool SHAPE_LINE_CHAIN::IsClosed ( ) const
inline

◆ IsSolid()

bool SHAPE_LINE_CHAIN::IsSolid ( ) const
inlineoverridevirtual

Implements SHAPE.

Definition at line 720 of file shape_line_chain.h.

721  {
722  return false;
723  }

◆ Length()

long long int SHAPE_LINE_CHAIN::Length ( ) const

◆ Mirror()

void SHAPE_LINE_CHAIN::Mirror ( bool  aX = true,
bool  aY = false,
const VECTOR2I aRef = { 0, 0 } 
)

Mirrors the line points about y or x (or both)

Parameters
aXIf true, mirror about the y axis (flip X coordinate)
aYIf true, mirror about the x axis (flip Y coordinate)
aRefsets the reference point about which to mirror

Definition at line 165 of file shape_line_chain.cpp.

166 {
167  for( auto& pt : m_points )
168  {
169  if( aX )
170  pt.x = -pt.x + 2 * aRef.x;
171 
172  if( aY )
173  pt.y = -pt.y + 2 * aRef.y;
174  }
175 
176  for( auto& arc : m_arcs )
177  arc.Mirror( aX, aY, aRef );
178 }
std::vector< SHAPE_ARC > m_arcs
std::vector< VECTOR2I > m_points
array of vertices

References m_arcs, m_points, VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by D_PAD::MirrorXPrimitives().

◆ Move()

void SHAPE_LINE_CHAIN::Move ( const VECTOR2I aVector)
inlineoverridevirtual

Implements SHAPE.

Definition at line 695 of file shape_line_chain.h.

696  {
697  for( auto& pt : m_points )
698  pt += aVector;
699 
700  for( auto& arc : m_arcs )
701  arc.Move( aVector );
702  }
std::vector< SHAPE_ARC > m_arcs
std::vector< VECTOR2I > m_points
array of vertices

References m_arcs, and m_points.

Referenced by ZONE_FILLER::addHatchFillTypeOnZone(), ZONE_FILLER::buildThermalSpokes(), PLACEFILE_GERBER_WRITER::CreatePlaceFile(), and SHAPE_SIMPLE::Move().

◆ NearestPoint() [1/2]

const VECTOR2I SHAPE_LINE_CHAIN::NearestPoint ( const VECTOR2I aP) const

Function NearestPoint()

Finds a point on the line chain that is closest to point aP.

Returns
the nearest point.

Definition at line 818 of file shape_line_chain.cpp.

819 {
820  int min_d = INT_MAX;
821  int nearest = 0;
822 
823  for( int i = 0; i < SegmentCount(); i++ )
824  {
825  int d = CSegment( i ).Distance( aP );
826 
827  if( d < min_d )
828  {
829  min_d = d;
830  nearest = i;
831  }
832  }
833 
834  return CSegment( nearest ).NearestPoint( aP );
835 }
int Distance(const SEG &aSeg) const
Function Distance()
Definition: seg.h:202
const VECTOR2I NearestPoint(const VECTOR2I &aP) const
Function NearestPoint()
Definition: seg.h:392
int SegmentCount() const
Function SegmentCount()
const SEG CSegment(int aIndex) const
Function CSegment()

References CSegment(), SEG::Distance(), SEG::NearestPoint(), and SegmentCount().

Referenced by GRID_HELPER::computeAnchors(), PNS::MEANDER_PLACER_BASE::cutTunedLine(), PNS::DRAGGER::dragShove(), PNS::MoveDiagonal(), and PNS::DRAGGER::optimizeAndUpdateDraggedLine().

◆ NearestPoint() [2/2]

const VECTOR2I SHAPE_LINE_CHAIN::NearestPoint ( const SEG aSeg,
int &  dist 
) const

Function NearestPoint()

Finds a point on the line chain that is closest to the line defined by the points of segment aSeg, also returns the distance.

Parameters
aSegSegment defining the line.
distreference receiving the distance to the nearest point.
Returns
the nearest point.

Definition at line 838 of file shape_line_chain.cpp.

839 {
840  int nearest = 0;
841 
842  dist = INT_MAX;
843  for( int i = 0; i < PointCount(); i++ )
844  {
845  int d = aSeg.LineDistance( CPoint( i ) );
846 
847  if( d < dist )
848  {
849  dist = d;
850  nearest = i;
851  }
852  }
853 
854  return CPoint( nearest );
855 }
static const int dist[10][10]
Definition: ar_matrix.cpp:326
int LineDistance(const VECTOR2I &aP, bool aDetermineSide=false) const
Function LineDistance()
Definition: seg.h:375
int PointCount() const
Function PointCount()
const VECTOR2I & CPoint(int aIndex) const
Function Point()

References CPoint(), dist, SEG::LineDistance(), and PointCount().

◆ NearestSegment()

int SHAPE_LINE_CHAIN::NearestSegment ( const VECTOR2I aP) const

Find the segment nearest the given point.

Parameters
aPpoint to compare with
Returns
the index of the segment closest to the point

Definition at line 858 of file shape_line_chain.cpp.

859 {
860  int min_d = INT_MAX;
861  int nearest = 0;
862 
863  for( int i = 0; i < SegmentCount(); i++ )
864  {
865  int d = CSegment( i ).Distance( aP );
866 
867  if( d < min_d )
868  {
869  min_d = d;
870  nearest = i;
871  }
872  }
873 
874  return nearest;
875 }
int Distance(const SEG &aSeg) const
Function Distance()
Definition: seg.h:202
int SegmentCount() const
Function SegmentCount()
const SEG CSegment(int aIndex) const
Function CSegment()

References CSegment(), SEG::Distance(), and SegmentCount().

Referenced by SCH_SHEET_PIN::ConstrainOnEdge().

◆ NewFacet()

FACET * SHAPE::NewFacet ( )
inherited

Definition at line 705 of file wrlfacet.cpp.

706 {
707  FACET* fp = new FACET;
708  facets.push_back( fp );
709  return fp;
710 }
Definition: wrlfacet.h:41
std::list< FACET * > facets
Definition: wrlfacet.h:143

References SHAPE::facets.

Referenced by WRL1FACESET::TranslateToSG(), X3DIFACESET::TranslateToSG(), and WRL2FACESET::TranslateToSG().

◆ operator!=()

bool SHAPE_LINE_CHAIN::operator!= ( const SHAPE_LINE_CHAIN aRhs) const
inline

Definition at line 679 of file shape_line_chain.h.

680  {
681  if( PointCount() != aRhs.PointCount() )
682  return true;
683 
684  for( int i = 0; i < PointCount(); i++ )
685  {
686  if( CPoint( i ) != aRhs.CPoint( i ) )
687  return true;
688  }
689 
690  return false;
691  }
int PointCount() const
Function PointCount()
const VECTOR2I & CPoint(int aIndex) const
Function Point()

References CPoint(), and PointCount().

◆ operator=()

SHAPE_LINE_CHAIN& SHAPE_LINE_CHAIN::operator= ( const SHAPE_LINE_CHAIN )
default

◆ Parse()

bool SHAPE_LINE_CHAIN::Parse ( std::stringstream &  aStream)
overridevirtual

Reimplemented from SHAPE.

Definition at line 924 of file shape_line_chain.cpp.

925 {
926  size_t n_pts;
927  size_t n_arcs;
928 
929  m_points.clear();
930  aStream >> n_pts;
931 
932  // Rough sanity check, just make sure the loop bounds aren't absolutely outlandish
933  if( n_pts > aStream.str().size() )
934  return false;
935 
936  aStream >> m_closed;
937  aStream >> n_arcs;
938 
939  if( n_arcs > aStream.str().size() )
940  return false;
941 
942  for( size_t i = 0; i < n_pts; i++ )
943  {
944  int x, y;
945  ssize_t ind;
946  aStream >> x;
947  aStream >> y;
948  m_points.emplace_back( x, y );
949 
950  aStream >> ind;
951  m_shapes.push_back( ind );
952  }
953 
954  for( size_t i = 0; i < n_arcs; i++ )
955  {
956  VECTOR2I p0, pc;
957  double angle;
958 
959  aStream >> pc.x;
960  aStream >> pc.y;
961  aStream >> p0.x;
962  aStream >> p0.y;
963  aStream >> angle;
964 
965  m_arcs.emplace_back( pc, p0, angle );
966  }
967 
968  return true;
969 }
VECTOR2 defines a general 2D-vector/point.
Definition: vector2d.h:61
std::vector< SHAPE_ARC > m_arcs
bool m_closed
is the line chain closed?
std::vector< VECTOR2I > m_points
array of vertices
std::vector< ssize_t > m_shapes
Array of indices that refer to the index of the shape if the point is part of a larger shape,...
static DIRECTION_45::AngleType angle(const VECTOR2I &a, const VECTOR2I &b)

References PNS::angle(), m_arcs, m_closed, m_points, m_shapes, VECTOR2< T >::x, and VECTOR2< T >::y.

◆ PathLength()

int SHAPE_LINE_CHAIN::PathLength ( const VECTOR2I aP) const

Function PathLength()

Computes the walk path length from the beginning of the line chain and the point aP belonging to our line.

Returns
: path length in Euclidean metric or negative if aP does not belong to the line chain.

Definition at line 555 of file shape_line_chain.cpp.

556 {
557  int sum = 0;
558 
559  for( int i = 0; i < SegmentCount(); i++ )
560  {
561  const SEG seg = CSegment( i );
562  int d = seg.Distance( aP );
563 
564  if( d <= 1 )
565  {
566  sum += ( aP - seg.A ).EuclideanNorm();
567  return sum;
568  }
569  else
570  sum += seg.Length();
571  }
572 
573  return -1;
574 }
double EuclideanNorm(const wxPoint &vector)
Euclidean norm of a 2D vector.
Definition: trigo.h:128
int Length() const
Function Length()
Definition: seg.h:314
int Distance(const SEG &aSeg) const
Function Distance()
Definition: seg.h:202
int SegmentCount() const
Function SegmentCount()
Definition: seg.h:39
const SEG CSegment(int aIndex) const
Function CSegment()
VECTOR2I A
Definition: seg.h:47

References SEG::A, CSegment(), SEG::Distance(), EuclideanNorm(), SEG::Length(), and SegmentCount().

Referenced by PNS::NODE::NearestObstacle(), and PNS::LINE::Walkaround().

◆ PointAlong()

const VECTOR2I SHAPE_LINE_CHAIN::PointAlong ( int  aPathLength) const

Definition at line 972 of file shape_line_chain.cpp.

973 {
974  int total = 0;
975 
976  if( aPathLength == 0 )
977  return CPoint( 0 );
978 
979  for( int i = 0; i < SegmentCount(); i++ )
980  {
981  const SEG& s = CSegment( i );
982  int l = s.Length();
983 
984  if( total + l >= aPathLength )
985  {
986  VECTOR2I d( s.B - s.A );
987  return s.A + d.Resize( aPathLength - total );
988  }
989 
990  total += l;
991  }
992 
993  return CPoint( -1 );
994 }
int Length() const
Function Length()
Definition: seg.h:314
VECTOR2 defines a general 2D-vector/point.
Definition: vector2d.h:61
const VECTOR2I & CPoint(int aIndex) const
Function Point()
int SegmentCount() const
Function SegmentCount()
Definition: seg.h:39
VECTOR2< T > Resize(T aNewLength) const
Function Resize returns a vector of the same direction, but length specified in aNewLength.
Definition: vector2d.h:392
const SEG CSegment(int aIndex) const
Function CSegment()
VECTOR2I A
Definition: seg.h:47
VECTOR2I B
Definition: seg.h:48

References SEG::A, SEG::B, CPoint(), CSegment(), SEG::Length(), VECTOR2< T >::Resize(), and SegmentCount().

◆ PointCount()

int SHAPE_LINE_CHAIN::PointCount ( ) const
inline

Function PointCount()

Returns the number of points (vertices) in this line chain

Returns
number of points

Definition at line 222 of file shape_line_chain.h.

223  {
224  return m_points.size();
225  }
std::vector< VECTOR2I > m_points
array of vertices

References m_points.

Referenced by POLYGON_GEOM_MANAGER::AddPoint(), CINFO3D_VISU::AddSolidAreasShapesToContainer(), CLAYER_TRIANGLES::AddToMiddleContourns(), Append(), PNS::LINE::AppendVia(), ArePolylineEndPointsNearCircle(), ArePolylineMidPointsNearCircle(), BOOST_AUTO_TEST_CASE(), D_PAD::boundingRadius(), BuildConvexHull(), CINFO3D_VISU::buildPadShapeThickOutlineAsPolygon(), CINFO3D_VISU::buildPadShapeThickOutlineAsSegments(), DRAWSEGMENT::BuildPolyPointsList(), PNS::LINE::ChangedArea(), PNS::KEEP_TOPOLOGY_CONSTRAINT::Check(), CheckClearance(), DRC::checkClearancePadToPad(), DRC::checkClearanceSegmToPad(), CLastPoint(), convertToClipper(), PNS::coupledBypass(), CPoint(), PolygonTriangulation::createList(), CreatePadsShapesSection(), PLACEFILE_GERBER_WRITER::CreatePlaceFile(), POLYGON_GEOM_MANAGER::DeleteLastCorner(), DIALOG_PAD_PRIMITIVE_POLY_PROPS::doValidate(), PNS::LINE::dragSegment45(), KIGFX::GERBVIEW_PAINTER::draw(), APERTURE_MACRO::DrawApertureMacroShape(), KIGFX::CAIRO_GAL_BASE::drawPoly(), KIGFX::OPENGL_GAL::DrawPolyline(), PNS::LOGGER::dumpShape(), EdgeContainingPoint(), export_vrml_board(), export_vrml_padshape(), export_vrml_polygon(), export_vrml_zones(), DSN::SPECCTRA_DB::fillBOUNDARY(), AR_AUTOPLACER::fillMatrix(), Find(), PNS::LINE_PLACER::FixRoute(), HPGL_PLOTTER::FlashPadCustom(), PSLIKE_PLOTTER::FlashPadCustom(), GERBER_PLOTTER::FlashPadCustom(), DXF_PLOTTER::FlashPadCustom(), HPGL_PLOTTER::FlashPadRoundRect(), PSLIKE_PLOTTER::FlashPadRoundRect(), GERBER_PLOTTER::FlashPadRoundRect(), DXF_PLOTTER::FlashPadRoundRect(), PCB_IO::format(), Format(), PNS::MEANDER_SHAPE::genMeanderShape(), D_PAD::GetBoundingBox(), SHAPE_POLY_SET::GetRelativeIndices(), PNS::LINE_PLACER::handlePullback(), PNS::LINE_PLACER::handleSelfIntersections(), WS_DRAW_ITEM_POLYPOLYGONS::HitTest(), D_PAD::HitTest(), Intersect(), POLYGON_GEOM_MANAGER::IsPolygonInProgress(), DRAWSEGMENT::IsPolyShapeValid(), POLYGON_GEOM_MANAGER::IsSelfIntersecting(), DSN::SPECCTRA_DB::makePADSTACK(), PNS::OPTIMIZER::mergeObtuse(), NearestPoint(), POLYGON_GEOM_MANAGER::NewPointClosesOutline(), operator!=(), BOOST_TEST_PRINT_NAMESPACE_OPEN::print_log_value< SHAPE_LINE_CHAIN >::operator()(), PNS::LINE_PLACER::optimizeTailHeadTransition(), BITMAPCONV_INFO::outputOnePolygon(), BRDITEMS_PLOTTER::PlotFilledAreas(), PlotLayerOutlines(), PLOTTER::PlotPoly(), DXF_PLOTTER::PlotPoly(), PlotWorkSheet(), SHAPE_SIMPLE::PointCount(), PNS::LINE::PointCount(), PointInside(), PNS::pointInside2(), polygon_Convert(), DRAWSEGMENT::Print(), ZONE_CONTAINER::PrintFilledArea(), GERBER_DRAW_ITEM::PrintGerberPoly(), D_PAD::PrintShape(), WS_DRAW_ITEM_POLYPOLYGONS::PrintWsItem(), PNS::SHOVE::processHullSet(), Remove(), Replace(), PNS::OPTIMIZER::runSmartPads(), SetPoint(), KIGFX::PREVIEW::POLYGON_ITEM::SetPoints(), PNS::shovedArea(), Simplify(), Slice(), PNS_KICAD_IFACE_BASE::syncPad(), DXF_PLOTTER::ThickSegment(), ZONE_CONTAINER::TransformSolidAreasShapesToPolygonSet(), POLYGON_GEOM_MANAGER::updateLeaderPoints(), PNS::LINE::Walkaround(), PNS::SHOVE::walkaroundLoneVia(), GBR_TO_PCB_EXPORTER::writePcbPolygonItem(), and GBR_TO_PCB_EXPORTER::writePcbZoneItem().

◆ PointInside()

bool SHAPE_LINE_CHAIN::PointInside ( const VECTOR2I aPt,
int  aAccuracy = 0,
bool  aUseBBoxCache = false 
) const

Function PointInside()

Checks if point aP lies inside a polygon (any type) defined by the line chain. For closed shapes only.

Parameters
aPtpoint to check
aUseBBoxCachegives better peformance if the bounding boxe caches have been generated.
Returns
true if the point is inside the shape (edge is not treated as being inside).

To check for interior points, we draw a line in the positive x direction from the point. If it intersects an even number of segments, the point is outside the line chain (it had to first enter and then exit). Otherwise, it is inside the chain.

Note: slope might be denormal here in the case of a horizontal line but we require our y to move from above to below the point (or vice versa)

Note: we open-code CPoint() here so that we don't end up calculating the size of the vector number-of-points times. This has a non-trivial impact on zone fill times.

Definition at line 577 of file shape_line_chain.cpp.

578 {
579  /*
580  * Don't check the bounding box unless it's cached. Building it is about the same speed as
581  * the rigorous test below and so just slows things down by doing potentially two tests.
582  */
583  if( aUseBBoxCache && !m_bbox.Contains( aPt ) )
584  return false;
585 
586  if( !m_closed || PointCount() < 3 )
587  return false;
588 
589  bool inside = false;
590 
602  const std::vector<VECTOR2I>& points = CPoints();
603  int pointCount = points.size();
604 
605  for( int i = 0; i < pointCount; )
606  {
607  const auto p1 = points[ i++ ];
608  const auto p2 = points[ i == pointCount ? 0 : i ];
609  const auto diff = p2 - p1;
610 
611  if( diff.y != 0 )
612  {
613  const int d = rescale( diff.x, ( aPt.y - p1.y ), diff.y );
614 
615  if( ( ( p1.y > aPt.y ) != ( p2.y > aPt.y ) ) && ( aPt.x - p1.x < d ) )
616  inside = !inside;
617  }
618  }
619 
620  // If accuracy is 0 then we need to make sure the point isn't actually on the edge.
621  // If accuracy is 1 then we don't really care whether or not the point is *exactly* on the
622  // edge, so we skip edge processing for performance.
623  // If accuracy is > 1, then we use "OnEdge(accuracy-1)" as a proxy for "Inside(accuracy)".
624  if( aAccuracy == 0 )
625  return inside && !PointOnEdge( aPt );
626  else if( aAccuracy == 1 )
627  return inside;
628  else
629  return inside || PointOnEdge( aPt, aAccuracy - 1 );
630 }
BOX2I m_bbox
cached bounding box
bool PointOnEdge(const VECTOR2I &aP, int aAccuracy=0) const
Function PointOnEdge()
int PointCount() const
Function PointCount()
bool m_closed
is the line chain closed?
const std::vector< VECTOR2I > & CPoints() const
bool Contains(const Vec &aPoint) const
Function Contains.
Definition: box2.h:150
T rescale(T aNumerator, T aValue, T aDenominator)
Function rescale()
Definition: util.h:84

References BOX2< Vec >::Contains(), CPoints(), m_bbox, m_closed, PointCount(), PointOnEdge(), rescale(), VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by SHAPE_POLY_SET::containsSingle(), Distance(), LIB_POLYLINE::HitTest(), MARKER_BASE::HitTestMarker(), and PNS::LINE::Walkaround().

◆ PointOnEdge()

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

Function PointOnEdge()

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

Parameters
aPpoint to check
Returns
true if the point lies on the edge.

Definition at line 633 of file shape_line_chain.cpp.

634 {
635  return EdgeContainingPoint( aPt, aAccuracy ) >= 0;
636 }
int EdgeContainingPoint(const VECTOR2I &aP, int aAccuracy=0) const
Function EdgeContainingPoint()

References EdgeContainingPoint().

Referenced by PNS::SHOVE::checkBumpDirection(), LIB_POLYLINE::HitTest(), and PointInside().

◆ Remove() [1/2]

void SHAPE_LINE_CHAIN::Remove ( int  aStartIndex,
int  aEndIndex 
)

Function Remove()

Removes the range of points [start_index, end_index] from the line chain.

Parameters
aStartIndexstart of the point range to be replaced (inclusive)
aEndIndexend of the point range to be replaced (inclusive)

Definition at line 237 of file shape_line_chain.cpp.

238 {
239  assert( m_shapes.size() == m_points.size() );
240  if( aEndIndex < 0 )
241  aEndIndex += PointCount();
242 
243  if( aStartIndex < 0 )
244  aStartIndex += PointCount();
245 
246  if( aStartIndex >= PointCount() )
247  return;
248 
249  aEndIndex = std::min( aEndIndex, PointCount() );
250  std::set<size_t> extra_arcs;
251 
252  // Remove any overlapping arcs in the point range
253  for( int i = aStartIndex; i < aEndIndex; i++ )
254  {
255  if( m_shapes[i] != SHAPE_IS_PT )
256  extra_arcs.insert( m_shapes[i] );
257  }
258 
259  for( auto arc : extra_arcs )
260  convertArc( arc );
261 
262  m_shapes.erase( m_shapes.begin() + aStartIndex, m_shapes.begin() + aEndIndex + 1 );
263  m_points.erase( m_points.begin() + aStartIndex, m_points.begin() + aEndIndex + 1 );
264  assert( m_shapes.size() == m_points.size() );
265 }
void convertArc(ssize_t aArcIndex)
Converts an arc to only a point chain by removing the arc and references.
int PointCount() const
Function PointCount()
std::vector< VECTOR2I > m_points
array of vertices
std::vector< ssize_t > m_shapes
Array of indices that refer to the index of the shape if the point is part of a larger shape,...
static constexpr ssize_t SHAPE_IS_PT

References convertArc(), m_points, m_shapes, PointCount(), and SHAPE_IS_PT.

Referenced by POLYGON_GEOM_MANAGER::AddPoint(), PNS::LINE_PLACER::buildInitialLine(), PNS::LINE::ClipToNearestObstacle(), POLYGON_GEOM_MANAGER::DeleteLastCorner(), PNS::DIFF_PAIR_PLACER::FixRoute(), PNS::LINE_PLACER::handlePullback(), PNS::LINE_PLACER::handleSelfIntersections(), PNS::LINE_PLACER::mergeHead(), PNS::LINE_PLACER::reduceTail(), Remove(), Replace(), and PNS::WALKAROUND::Route().

◆ Remove() [2/2]

void SHAPE_LINE_CHAIN::Remove ( int  aIndex)
inline

Function Remove() removes the aIndex-th point from the line chain.

Parameters
aIndexis the index of the point to be removed.

Definition at line 484 of file shape_line_chain.h.

485  {
486  Remove( aIndex, aIndex );
487  }
void Remove(int aStartIndex, int aEndIndex)
Function Remove()

References Remove().

◆ Replace() [1/2]

void SHAPE_LINE_CHAIN::Replace ( int  aStartIndex,
int  aEndIndex,
const VECTOR2I aP 
)

Function Replace()

Replaces points with indices in range [start_index, end_index] with a single point aP.

Parameters
aStartIndexstart of the point range to be replaced (inclusive)
aEndIndexend of the point range to be replaced (inclusive)
aPreplacement point

Definition at line 181 of file shape_line_chain.cpp.

182 {
183  if( aEndIndex < 0 )
184  aEndIndex += PointCount();
185 
186  if( aStartIndex < 0 )
187  aStartIndex += PointCount();
188 
189  aEndIndex = std::min( aEndIndex, PointCount() - 1 );
190 
191  // N.B. This works because convertArc changes m_shapes on the first run
192  for( int ind = aStartIndex; ind <= aEndIndex; ind++ )
193  {
194  if( m_shapes[ind] != SHAPE_IS_PT )
195  convertArc( ind );
196  }
197 
198  if( aStartIndex == aEndIndex )
199  m_points[aStartIndex] = aP;
200  else
201  {
202  m_points.erase( m_points.begin() + aStartIndex + 1, m_points.begin() + aEndIndex + 1 );
203  m_points[aStartIndex] = aP;
204 
205  m_shapes.erase( m_shapes.begin() + aStartIndex + 1, m_shapes.begin() + aEndIndex + 1 );
206  }
207 
208  assert( m_shapes.size() == m_points.size() );
209 }
void convertArc(ssize_t aArcIndex)
Converts an arc to only a point chain by removing the arc and references.
int PointCount() const
Function PointCount()
std::vector< VECTOR2I > m_points
array of vertices
std::vector< ssize_t > m_shapes
Array of indices that refer to the index of the shape if the point is part of a larger shape,...
static constexpr ssize_t SHAPE_IS_PT

References convertArc(), m_points, m_shapes, PointCount(), and SHAPE_IS_PT.

Referenced by PNS::coupledBypass(), PNS::LINE::dragSegment45(), PNS::OPTIMIZER::mergeDpStep(), PNS::OPTIMIZER::mergeObtuse(), PNS::OPTIMIZER::mergeStep(), PNS::LINE_PLACER::optimizeTailHeadTransition(), and PNS::Tighten().

◆ Replace() [2/2]

void SHAPE_LINE_CHAIN::Replace ( int  aStartIndex,
int  aEndIndex,
const SHAPE_LINE_CHAIN aLine 
)

Function Replace()

Replaces points with indices in range [start_index, end_index] with the points from line chain aLine.

Parameters
aStartIndexstart of the point range to be replaced (inclusive)
aEndIndexend of the point range to be replaced (inclusive)
aLinereplacement line chain.

Definition at line 212 of file shape_line_chain.cpp.

213 {
214  if( aEndIndex < 0 )
215  aEndIndex += PointCount();
216 
217  if( aStartIndex < 0 )
218  aStartIndex += PointCount();
219 
220  Remove( aStartIndex, aEndIndex );
221 
222  // The total new arcs index is added to the new arc indices
223  size_t prev_arc_count = m_arcs.size();
224  auto new_shapes = aLine.m_shapes;
225 
226  for( auto& shape : new_shapes )
227  shape += prev_arc_count;
228 
229  m_shapes.insert( m_shapes.begin() + aStartIndex, new_shapes.begin(), new_shapes.end() );
230  m_points.insert( m_points.begin() + aStartIndex, aLine.m_points.begin(), aLine.m_points.end() );
231  m_arcs.insert( m_arcs.end(), aLine.m_arcs.begin(), aLine.m_arcs.end() );
232 
233  assert( m_shapes.size() == m_points.size() );
234 }
int PointCount() const
Function PointCount()
std::vector< SHAPE_ARC > m_arcs
std::vector< VECTOR2I > m_points
array of vertices
void Remove(int aStartIndex, int aEndIndex)
Function Remove()
std::vector< ssize_t > m_shapes
Array of indices that refer to the index of the shape if the point is part of a larger shape,...

References m_arcs, m_points, m_shapes, PointCount(), and Remove().

◆ Reverse()

const SHAPE_LINE_CHAIN SHAPE_LINE_CHAIN::Reverse ( ) const

Function Reverse()

Reverses point order in the line chain.

Returns
line chain with reversed point order (original A-B-C-D: returned D-C-B-A)

Definition at line 133 of file shape_line_chain.cpp.

134 {
135  SHAPE_LINE_CHAIN a( *this );
136 
137  reverse( a.m_points.begin(), a.m_points.end() );
138  reverse( a.m_shapes.begin(), a.m_shapes.end() );
139  reverse( a.m_arcs.begin(), a.m_arcs.end() );
140 
141  for( auto& sh : a.m_shapes )
142  {
143  if( sh != SHAPE_IS_PT )
144  sh = a.m_arcs.size() - sh - 1;
145  }
146 
147 
148  a.m_closed = m_closed;
149 
150  return a;
151 }
bool m_closed
is the line chain closed?
static constexpr ssize_t SHAPE_IS_PT
SHAPE_LINE_CHAIN.

References m_arcs, m_closed, m_points, m_shapes, and SHAPE_IS_PT.

Referenced by PNS::ArcHull(), PNS::KEEP_TOPOLOGY_CONSTRAINT::Check(), PNS::coupledBypass(), PNS::MEANDER_PLACER_BASE::cutTunedLine(), PNS::LINE::dragCorner45(), PNS::DP_GATEWAY::Reverse(), PNS::LINE::Reverse(), PNS::SegmentHull(), and PNS::OPTIMIZER::smartPadsSingle().

◆ Rotate()

void SHAPE_LINE_CHAIN::Rotate ( double  aAngle,
const VECTOR2I aCenter = VECTOR2I( 0, 0 ) 
)

Function Rotate rotates all vertices by a given angle.

Parameters
aCenteris the rotation center
aAnglerotation angle in radians

Definition at line 96 of file shape_line_chain.cpp.

97 {
98  for( auto& pt : m_points )
99  {
100  pt -= aCenter;
101  pt = pt.Rotate( aAngle );
102  pt += aCenter;
103  }
104 
105  for( auto& arc : m_arcs )
106  arc.Rotate( aAngle, aCenter );
107 }
std::vector< SHAPE_ARC > m_arcs
std::vector< VECTOR2I > m_points
array of vertices
VECTOR2< T > Rotate(double aAngle) const
Function Rotate rotates the vector by a given angle.
Definition: vector2d.h:377

References m_arcs, m_points, and VECTOR2< T >::Rotate().

Referenced by ZONE_FILLER::buildThermalSpokes(), and PLACEFILE_GERBER_WRITER::CreatePlaceFile().

◆ Segment()

SEG SHAPE_LINE_CHAIN::Segment ( int  aIndex)
inline

Function Segment()

Returns a copy of the aIndex-th segment in the line chain.

Parameters
aIndexindex of the segment in the line chain. Negative values are counted from the end (i.e. -1 means the last segment in the line chain)
Returns
SEG - aIndex-th segment in the line chain

Definition at line 235 of file shape_line_chain.h.

236  {
237  if( aIndex < 0 )
238  aIndex += SegmentCount();
239 
240  if( aIndex == (int)( m_points.size() - 1 ) && m_closed )
241  return SEG( m_points[aIndex], m_points[0], aIndex );
242  else
243  return SEG( m_points[aIndex], m_points[aIndex + 1], aIndex );
244  }
bool m_closed
is the line chain closed?
std::vector< VECTOR2I > m_points
array of vertices
int SegmentCount() const
Function SegmentCount()
Definition: seg.h:39

References m_closed, m_points, and SegmentCount().

Referenced by POLY_GRID_PARTITION::build(), POLY_GRID_PARTITION::checkClearance(), PNS::DIFF_PAIR::CoupledSegmentPairs(), PNS::WALKAROUND::Route(), and unfracture().

◆ SegmentCount()

int SHAPE_LINE_CHAIN::SegmentCount ( ) const
inline

Function SegmentCount()

Returns number of segments in this line chain.

Returns
number of segments

Definition at line 207 of file shape_line_chain.h.

208  {
209  int c = m_points.size() - 1;
210  if( m_closed )
211  c++;
212 
213  return std::max( 0, c );
214  }
bool m_closed
is the line chain closed?
std::vector< VECTOR2I > m_points
array of vertices

References m_closed, and m_points.

Referenced by POLY_GRID_PARTITION::build(), PNS::LINE_PLACER::buildInitialLine(), PNS::PRESERVE_VERTEX_CONSTRAINT::Check(), CheckClearance(), PNS::NODE::CheckColliding(), PNS::DIFF_PAIR::CheckConnectionAngle(), PNS::checkGap(), PNS::MEANDERED_LINE::CheckSelfIntersections(), PNS::closestProjectedPoint(), Collide(), Collide(), PNS::COST_ESTIMATOR::CornerCost(), PNS::LINE::CountCorners(), PNS::DIFF_PAIR::CoupledLength(), PNS::DIFF_PAIR::CoupledSegmentPairs(), CSegment(), Distance(), PNS::LINE::dragCorner45(), PNS::dragCornerInternal(), PNS::LINE::dragSegment45(), ROUTER_PREVIEW_ITEM::drawLineChain(), KIGFX::OPENGL_GAL::DrawPolygon(), EdgeContainingPoint(), PNS::DIFF_PAIR::Empty(), PNS::findCoupledVertices(), FindSegment(), PNS::DIFF_PAIR_PLACER::FixRoute(), PNS::LINE_PLACER::FixRoute(), PNS::LINE_PLACER::handlePullback(), PNS::DP_MEANDER_PLACER::HasPlacedAnything(), PNS::DIFF_PAIR_PLACER::HasPlacedAnything(), Intersect(), PNS::LINE::Is45Degree(), Length(), PNS::OPTIMIZER::mergeDpSegments(), PNS::OPTIMIZER::mergeDpStep(), PNS::OPTIMIZER::mergeFull(), PNS::LINE_PLACER::mergeHead(), PNS::OPTIMIZER::mergeObtuse(), PNS::OPTIMIZER::mergeStep(), PNS::NODE::NearestObstacle(), NearestPoint(), NearestSegment(), PNS::LINE_PLACER::optimizeTailHeadTransition(), PathLength(), PointAlong(), PNS::pointInside2(), PNS::LINE_PLACER::reduceTail(), PNS::WALKAROUND::Route(), Segment(), PNS::LINE::SegmentCount(), SelfIntersecting(), PNS::OPTIMIZER::smartPadsSingle(), PNS::LINE::snapDraggedCorner(), PNS::LINE::snapToNeighbourSegments(), Split(), POLYGON_GEOM_MANAGER::updateLeaderPoints(), and PNS::LINE::Walkaround().

◆ SelfIntersecting()

const OPT< SHAPE_LINE_CHAIN::INTERSECTION > SHAPE_LINE_CHAIN::SelfIntersecting ( ) const

Function SelfIntersecting()

Checks if the line chain is self-intersecting.

Returns
(optional) first found self-intersection point.

Definition at line 687 of file shape_line_chain.cpp.

688 {
689  for( int s1 = 0; s1 < SegmentCount(); s1++ )
690  {
691  for( int s2 = s1 + 1; s2 < SegmentCount(); s2++ )
692  {
693  const VECTOR2I s2a = CSegment( s2 ).A, s2b = CSegment( s2 ).B;
694 
695  if( s1 + 1 != s2 && CSegment( s1 ).Contains( s2a ) )
696  {
697  INTERSECTION is;
698  is.our = CSegment( s1 );
699  is.their = CSegment( s2 );
700  is.p = s2a;
701  return is;
702  }
703  else if( CSegment( s1 ).Contains( s2b ) &&
704  // for closed polylines, the ending point of the
705  // last segment == starting point of the first segment
706  // this is a normal case, not self intersecting case
707  !( IsClosed() && s1 == 0 && s2 == SegmentCount()-1 ) )
708  {
709  INTERSECTION is;
710  is.our = CSegment( s1 );
711  is.their = CSegment( s2 );
712  is.p = s2b;
713  return is;
714  }
715  else
716  {
717  OPT_VECTOR2I p = CSegment( s1 ).Intersect( CSegment( s2 ), true );
718 
719  if( p )
720  {
721  INTERSECTION is;
722  is.our = CSegment( s1 );
723  is.their = CSegment( s2 );
724  is.p = *p;
725  return is;
726  }
727  }
728  }
729  }
730 
732 }
OPT_VECTOR2I Intersect(const SEG &aSeg, bool aIgnoreEndpoints=false, bool aLines=false) const
Function Intersect()
Definition: seg.cpp:144
VECTOR2 defines a general 2D-vector/point.
Definition: vector2d.h:61
OPT< VECTOR2I > OPT_VECTOR2I
Definition: seg.h:37
int SegmentCount() const
Function SegmentCount()
const SEG CSegment(int aIndex) const
Function CSegment()
VECTOR2I A
Definition: seg.h:47
boost::optional< T > OPT
Definition: optional.h:7
bool IsClosed() const
Function IsClosed()
VECTOR2I B
Definition: seg.h:48

References SEG::A, SEG::B, CSegment(), SEG::Intersect(), IsClosed(), SHAPE_LINE_CHAIN::INTERSECTION::our, SHAPE_LINE_CHAIN::INTERSECTION::p, SegmentCount(), and SHAPE_LINE_CHAIN::INTERSECTION::their.

Referenced by PNS::DIFF_PAIR::BuildInitial(), PNS::clipToLoopStart(), DIALOG_PAD_PRIMITIVE_POLY_PROPS::doValidate(), and PNS::SHOVE::processHullSet().

◆ SetClosed()

void SHAPE_LINE_CHAIN::SetClosed ( bool  aClosed)
inline

Function SetClosed()

Marks the line chain as closed (i.e. with a segment connecting the last point with the first point).

Parameters
aClosedwhether the line chain is to be closed or not.

Definition at line 168 of file shape_line_chain.h.

169  {
170  m_closed = aClosed;
171  }
bool m_closed
is the line chain closed?

References m_closed.

Referenced by ZONE_FILLER::addHatchFillTypeOnZone(), ZONE_CONTAINER::AddPolygon(), PNS::ArcHull(), POLY_GRID_PARTITION::build(), CINFO3D_VISU::buildPadShapePolygon(), KI_TEST::BuildRectChain(), ZONE_FILLER::buildThermalSpokes(), SHAPE_POLY_SET::chamferFilletPolygon(), PNS::KEEP_TOPOLOGY_CONSTRAINT::Check(), CN_ZONE::CN_ZONE(), KI_TEST::CommonTestData::CommonTestData(), GRID_HELPER::computeAnchors(), Convert_path_polygon_to_polygon_blocks_and_dummy_blocks(), PNS::ConvexHull(), PLACEFILE_GERBER_WRITER::CreatePlaceFile(), DIALOG_PAD_PRIMITIVE_POLY_PROPS::doValidate(), KIGFX::GERBVIEW_PAINTER::draw(), SHAPE_POLY_SET::fractureSingle(), LIB_POLYLINE::HitTest(), IteratorFixture::IteratorFixture(), GEOM_TEST::MakeSquarePolyLine(), SHAPE_POLY_SET::NewHole(), SHAPE_POLY_SET::NewOutline(), PNS::OctagonalHull(), SHAPE_RECT::Outline(), SHAPE_POLY_SET::Parse(), BRDITEMS_PLOTTER::Plot_1_EdgeModule(), polygonArea(), PNS::SegmentHull(), SHAPE_SIMPLE::SHAPE_SIMPLE(), MARKER_BASE::ShapeToPolygon(), TestConcaveSquareFillet(), TransformCircleToPolygon(), unfracture(), SHAPE_POLY_SET::unfractureSingle(), and PNS::LINE::Walkaround().

◆ SetPoint()

void SHAPE_LINE_CHAIN::SetPoint ( int  aIndex,
const VECTOR2I aPos 
)
inline

Accessor Function to move a point to a specific location.

Parameters
aIndexIndex (wrapping) of the point to move
aPosNew absolute location of the point

Definition at line 272 of file shape_line_chain.h.

273  {
274  if( aIndex < 0 )
275  aIndex += PointCount();
276  else if( aIndex >= PointCount() )
277  aIndex -= PointCount();
278 
279  m_points[aIndex] = aPos;
280 
281  if( m_shapes[aIndex] != SHAPE_IS_PT )
282  convertArc( m_shapes[aIndex] );
283  }
void convertArc(ssize_t aArcIndex)
Converts an arc to only a point chain by removing the arc and references.
int PointCount() const
Function PointCount()
std::vector< VECTOR2I > m_points
array of vertices
std::vector< ssize_t > m_shapes
Array of indices that refer to the index of the shape if the point is part of a larger shape,...
static constexpr ssize_t SHAPE_IS_PT

References convertArc(), m_points, m_shapes, PointCount(), and SHAPE_IS_PT.

Referenced by PNS::LINE_PLACER::buildInitialLine(), PNS::LINE::dragCornerFree(), and PNS::MEANDER_SHAPE::genMeanderShape().

◆ SetWidth()

void SHAPE_LINE_CHAIN::SetWidth ( int  aWidth)
inline

Sets the width of all segments in the chain.

Parameters
aWidthwidth in internal units

Definition at line 187 of file shape_line_chain.h.

188  {
189  m_width = aWidth;
190  }
int m_width
Width of the segments (for BBox calculations in RTree) TODO Adjust usage of SHAPE_LINE_CHAIN to accou...

References m_width.

Referenced by PNS::LINE::SetShape(), and PNS::LINE::SetWidth().

◆ Simplify()

SHAPE_LINE_CHAIN & SHAPE_LINE_CHAIN::Simplify ( )

Function Simplify()

Simplifies the line chain by removing colinear adjacent segments and duplicate vertices.

Returns
reference to self.

Definition at line 735 of file shape_line_chain.cpp.

736 {
737  std::vector<VECTOR2I> pts_unique;
738  std::vector<ssize_t> shapes_unique;
739 
740  if( PointCount() < 2 )
741  {
742  return *this;
743  }
744  else if( PointCount() == 2 )
745  {
746  if( m_points[0] == m_points[1] )
747  m_points.pop_back();
748 
749  return *this;
750  }
751 
752  int i = 0;
753  int np = PointCount();
754 
755  // stage 1: eliminate duplicate vertices
756  while( i < np )
757  {
758  int j = i + 1;
759 
760  while( j < np && m_points[i] == m_points[j] && m_shapes[i] == m_shapes[j] )
761  j++;
762 
763  pts_unique.push_back( CPoint( i ) );
764  shapes_unique.push_back( m_shapes[i] );
765 
766  i = j;
767  }
768 
769  m_points.clear();
770  m_shapes.clear();
771  np = pts_unique.size();
772 
773  i = 0;
774 
775  // stage 1: eliminate collinear segments
776  while( i < np - 2 )
777  {
778  const VECTOR2I p0 = pts_unique[i];
779  const VECTOR2I p1 = pts_unique[i + 1];
780  int n = i;
781 
782  while( n < np - 2
783  && ( SEG( p0, p1 ).LineDistance( pts_unique[n + 2] ) <= 1
784  || SEG( p0, p1 ).Collinear( SEG( p1, pts_unique[n + 2] ) ) ) )
785  n++;
786 
787  m_points.push_back( p0 );
788  m_shapes.push_back( shapes_unique[i] );
789 
790  if( n > i )
791  i = n;
792 
793  if( n == np )
794  {
795  m_points.push_back( pts_unique[n - 1] );
796  m_shapes.push_back( shapes_unique[n - 1] );
797  return *this;
798  }
799 
800  i++;
801  }
802 
803  if( np > 1 )
804  {
805  m_points.push_back( pts_unique[np - 2] );
806  m_shapes.push_back( shapes_unique[np - 2] );
807  }
808 
809  m_points.push_back( pts_unique[np - 1] );
810  m_shapes.push_back( shapes_unique[np - 1] );
811 
812  assert( m_points.size() == m_shapes.size() );
813 
814  return *this;
815 }
VECTOR2 defines a general 2D-vector/point.
Definition: vector2d.h:61
int PointCount() const
Function PointCount()
const VECTOR2I & CPoint(int aIndex) const
Function Point()
std::vector< VECTOR2I > m_points
array of vertices
Definition: seg.h:39
std::vector< ssize_t > m_shapes
Array of indices that refer to the index of the shape if the point is part of a larger shape,...

References CPoint(), m_points, m_shapes, and PointCount().

Referenced by PNS::DIFF_PAIR_PLACER::attemptWalk(), DIRECTION_45::BuildInitialTrace(), PNS::LINE::ChangedArea(), CN_ZONE::CN_ZONE(), CompareGeometry(), PNS::DIFF_PAIR::CoupledSegmentPairs(), PNS::MEANDER_PLACER_BASE::cutTunedLine(), PNS::MEANDER_PLACER::doMove(), DIALOG_PAD_PRIMITIVE_POLY_PROPS::doValidate(), PNS::LINE::dragCorner45(), PNS::LINE::dragCornerFree(), PNS::LINE::dragSegment45(), PNS::OPTIMIZER::mergeDpStep(), PNS::OPTIMIZER::mergeFull(), PNS::LINE_PLACER::mergeHead(), PNS::OPTIMIZER::mergeStep(), PNS::DP_MEANDER_PLACER::Move(), PNS::SHOVE::onCollidingSolid(), PNS::LINE_PLACER::optimizeTailHeadTransition(), PNS::SHOVE::processHullSet(), PNS::LINE_PLACER::rhShoveOnly(), PNS::LINE_PLACER::rhStopAtNearestObstacle(), PNS::WALKAROUND::Route(), PNS::OPTIMIZER::runSmartPads(), PNS::TOPOLOGY::SimplifyLine(), PNS::LINE_PLACER::simplifyNewLine(), PNS::OPTIMIZER::smartPadsSingle(), PNS::Tighten(), PNS::LINE_PLACER::Trace(), and PNS::LINE::Walkaround().

◆ Slice()

const SHAPE_LINE_CHAIN SHAPE_LINE_CHAIN::Slice ( int  aStartIndex,
int  aEndIndex = -1 
) const

Function Slice()

Returns a subset of this line chain containing the [start_index, end_index] range of points.

Parameters
aStartIndexstart of the point range to be returned (inclusive)
aEndIndexend of the point range to be returned (inclusive)
Returns
cut line chain.

Definition at line 341 of file shape_line_chain.cpp.

342 {
343  SHAPE_LINE_CHAIN rv;
344 
345  if( aEndIndex < 0 )
346  aEndIndex += PointCount();
347 
348  if( aStartIndex < 0 )
349  aStartIndex += PointCount();
350 
351  for( int i = aStartIndex; i <= aEndIndex && static_cast<size_t>( i ) < m_points.size(); i++ )
352  rv.Append( m_points[i] );
353 
354  return rv;
355 }
int PointCount() const
Function PointCount()
void Append(int aX, int aY, bool aAllowDuplication=false)
Function Append()
std::vector< VECTOR2I > m_points
array of vertices
SHAPE_LINE_CHAIN.

References Append(), m_points, and PointCount().

Referenced by PNS::KEEP_TOPOLOGY_CONSTRAINT::Check(), PNS::clipToLoopStart(), PNS::LINE::ClipVertexRange(), PNS::MEANDER_PLACER_BASE::cutTunedLine(), PNS::LINE::dragCorner45(), PNS::dragCornerInternal(), PNS::LINE_PLACER::optimizeTailHeadTransition(), PNS::LINE_PLACER::reduceToNearestObstacle(), PNS::Tighten(), and PNS::LINE::Walkaround().

◆ Split()

int SHAPE_LINE_CHAIN::Split ( const VECTOR2I aP)

Function Split()

Inserts the point aP belonging to one of the our segments, splitting the adjacent segment in two.

Parameters
aPthe point to be inserted
Returns
index of the newly inserted point (or a negative value if aP does not lie on our line)

Definition at line 282 of file shape_line_chain.cpp.

283 {
284  int ii = -1;
285  int min_dist = 2;
286 
287  int found_index = Find( aP );
288 
289  for( int s = 0; s < SegmentCount(); s++ )
290  {
291  const SEG seg = CSegment( s );
292  int dist = seg.Distance( aP );
293 
294  // make sure we are not producing a 'slightly concave' primitive. This might happen
295  // if aP lies very close to one of already existing points.
296  if( dist < min_dist && seg.A != aP && seg.B != aP )
297  {
298  min_dist = dist;
299  if( found_index < 0 )
300  ii = s;
301  else if( s < found_index )
302  ii = s;
303  }
304  }
305 
306  if( ii < 0 )
307  ii = found_index;
308 
309  if( ii >= 0 )
310  {
311  m_points.insert( m_points.begin() + ii + 1, aP );
312  m_shapes.insert( m_shapes.begin() + ii + 1, ssize_t( SHAPE_IS_PT ) );
313 
314  return ii + 1;
315  }
316 
317  return -1;
318 }
int Find(const VECTOR2I &aP) const
Function Find()
int Distance(const SEG &aSeg) const
Function Distance()
Definition: seg.h:202
static const int dist[10][10]
Definition: ar_matrix.cpp:326
std::vector< VECTOR2I > m_points
array of vertices
int SegmentCount() const
Function SegmentCount()
Definition: seg.h:39
std::vector< ssize_t > m_shapes
Array of indices that refer to the index of the shape if the point is part of a larger shape,...
const SEG CSegment(int aIndex) const
Function CSegment()
static constexpr ssize_t SHAPE_IS_PT
VECTOR2I A
Definition: seg.h:47
VECTOR2I B
Definition: seg.h:48

References SEG::A, SEG::B, CSegment(), dist, SEG::Distance(), Find(), m_points, m_shapes, SegmentCount(), and SHAPE_IS_PT.

Referenced by PNS::clipToLoopStart(), PNS::LINE::ClipToNearestObstacle(), PNS::MEANDER_PLACER_BASE::cutTunedLine(), PNS::LINE_PLACER::reduceToNearestObstacle(), and PNS::LINE::Walkaround().

◆ Type()

SHAPE_TYPE SHAPE::Type ( ) const
inlineinherited

Function Type()

Returns the type of the shape.

Return values
thetype

Definition at line 85 of file shape.h.

86  {
87  return m_type;
88  }
SHAPE_TYPE m_type
type of our shape
Definition: shape.h:168

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

◆ Width()

int SHAPE_LINE_CHAIN::Width ( ) const
inline

Gets the current width of the segments in the chain.

Returns
width in internal units

Definition at line 196 of file shape_line_chain.h.

197  {
198  return m_width;
199  }
int m_width
Width of the segments (for BBox calculations in RTree) TODO Adjust usage of SHAPE_LINE_CHAIN to accou...

References m_width.

Member Data Documentation

◆ m_arcs

std::vector<SHAPE_ARC> SHAPE_LINE_CHAIN::m_arcs
private

◆ m_bbox

BOX2I SHAPE_LINE_CHAIN::m_bbox
private

cached bounding box

Definition at line 778 of file shape_line_chain.h.

Referenced by Append(), GenerateBBoxCache(), and PointInside().

◆ m_closed

bool SHAPE_LINE_CHAIN::m_closed
private

is the line chain closed?

Definition at line 769 of file shape_line_chain.h.

Referenced by Area(), Clear(), CSegment(), Format(), IsClosed(), Parse(), PointInside(), Reverse(), Segment(), SegmentCount(), and SetClosed().

◆ m_points

◆ m_shapes

std::vector<ssize_t> SHAPE_LINE_CHAIN::m_shapes
private

Array of indices that refer to the index of the shape if the point is part of a larger shape, e.g.

arc or spline. If the value is -1, the point is just a point

Definition at line 764 of file shape_line_chain.h.

Referenced by Append(), ArcIndex(), Clear(), convertArc(), CShapes(), Format(), Insert(), isArc(), Parse(), Remove(), Replace(), Reverse(), SetPoint(), SHAPE_LINE_CHAIN(), Simplify(), and Split().

◆ m_type

SHAPE_TYPE SHAPE::m_type
protectedinherited

type of our shape

Definition at line 168 of file shape.h.

Referenced by SHAPE::Type().

◆ m_width

int SHAPE_LINE_CHAIN::m_width
private

Width of the segments (for BBox calculations in RTree) TODO Adjust usage of SHAPE_LINE_CHAIN to account for where we need a width and where not Alternatively, we could split the class into a LINE_CHAIN (no width) and SHAPE_LINE_CHAIN that derives from SHAPE as well that does have a width.

Not sure yet on the correct path.

Definition at line 775 of file shape_line_chain.h.

Referenced by BBox(), GenerateBBoxCache(), SetWidth(), and Width().

◆ SHAPE_IS_PT

constexpr ssize_t SHAPE_LINE_CHAIN::SHAPE_IS_PT = -1
staticprivate

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