136 if( i.index_our < n )
144 if( ipoint == head.
CPoint( 0 ) || ipoint == tail.
CPoint( -1 ) )
211 bool pullback_1 =
false;
218 if( pullback_1 || pullback_2 )
233 PNS_DBG(
Dbg(), Message, wxString::Format(
"Placer: pullback triggered [%d] [%s %s]",
273 int reduce_index = -1;
300 if( reduce_index >= 0 )
302 PNS_DBG(
Dbg(), Message, wxString::Format(
"Placer: reducing tail: %d" , reduce_index ) );
306 tail.
Remove( reduce_index + 1, -1 );
335 PNS_DBG(
Dbg(), Message, wxT(
"Merge failed: not enough head segs." ) );
341 PNS_DBG(
Dbg(), Message, wxT(
"Merge failed: head and tail discontinuous." ) );
365 if( dir_head.
Angle( dir_tail ) & ForbiddenAngles )
382 PNS_DBG(
Dbg(), Message, wxString::Format(
"Placer: merge %d, new direction: %s" , n_head,
396 int idx = l.
Split( aP );
406 PNS_DBG(
Dbg(), AddPoint, aP,
BLUE, 500000, wxString::Format(
"hug-target-check-%d", idx ) );
407 PNS_DBG(
Dbg(), AddShape, &l2,
BLUE, 500000, wxT(
"hug-target-line" ) );
409 if( dist < thresholdDist )
420 thresholdDist = dist;
430 std::vector<int> dists;
431 std::vector<VECTOR2I> pts;
437 int accumulatedDist = 0;
445 dists.push_back( ( aCursor - s.
A ).EuclideanNorm() );
446 pts.push_back( s.
A );
449 if( pn != s.
A && pn != s.
B )
451 dists.push_back( ( pn - aCursor ).EuclideanNorm() );
455 accumulatedDist += s.
Length();
457 if ( accumulatedDist > lengthThreshold )
464 dists.push_back( ( aCursor - lastP ).EuclideanNorm() );
465 pts.push_back( lastP );
467 int minDistLoc = std::numeric_limits<int>::max();
469 int minDistGlob = std::numeric_limits<int>::max();
472 for(
int i = 0; i < dists.size(); i++ )
476 if( d < minDistGlob )
483 if( dists.size() >= 3 )
485 for(
int i = 0; i < dists.size() - 3; i++ )
487 if( dists[i + 2] > dists[i + 1] && dists[i] > dists[i + 1] )
489 int d = dists[i + 1];
498 if( dists.back() < minDistLoc && minPLoc >= 0 )
500 minDistLoc = dists.back();
501 minPLoc = dists.size() - 1;
507 minDistLoc = minDistGlob;
518 preferred = minPGlob;
525 int thresholdDist = 0;
533 int minDist = std::numeric_limits<int>::max();
537 for(
int i = 0; i < pts.size() ; i++)
573 PNS_DBG(
Dbg(), BeginGroup, wxString::Format(
"walk-round-%d", round ), 0 );
577 PNS_DBG(
Dbg(), AddItem, &l1,
BLUE, 20000, wxT(
"walk-base-l1" ) );
589 double hugThresholdLengthComplete =
593 std::optional<LINE> bestLine;
601 : std::numeric_limits<int>::max();
603 : std::numeric_limits<int>::max();
608 LINE tmpHead, tmpTail;
626 LINE tmpHead, tmpTail;
638 if( len_ccw < len_cw )
642 int bestLength = len_cw < len_ccw ? len_cw : len_ccw;
644 if( bestLength < hugThresholdLengthComplete && bestLine.has_value() )
646 walkFull.
SetShape( bestLine->CLine() );
652 bool validCw =
false;
653 bool validCcw =
false;
654 int distCcw = std::numeric_limits<int>::max();
655 int distCw = std::numeric_limits<int>::max();
664 distCw = ( aP - l_cw.
CPoint( -1 ) ).EuclideanNorm();
666 PNS_DBG(
Dbg(), AddShape, &l_cw,
MAGENTA, 200000, wxString::Format(
"wh-result-cw %s",
667 validCw ?
"non-colliding"
676 distCcw = ( aP - l_ccw.
CPoint( -1 ) ).EuclideanNorm();
678 PNS_DBG(
Dbg(), AddShape, &l_ccw,
MAGENTA, 200000, wxString::Format(
"wh-result-ccw %s",
679 validCcw ?
"non-colliding"
684 if( distCw < distCcw && validCw )
711 PNS_DBG(
Dbg(), AddItem, &walkFull,
GREEN, 200000, wxT(
"walk-full" ) );
716 wxString::Format(
"walk-via ok %d", aViaOk ? 1 : 0 ) );
719 aWalkLine = walkFull;
735 switch(
Settings().OptimizerEffort() )
759 PNS_DBG(
Dbg(), AddItem, &walkFull,
GREEN, 100000, wxString::Format(
"collision check fail" ) );
789 PNS_DBG(
Dbg(), AddItem, &aNewHead,
GREEN, 100000, wxString::Format(
"walk-new-head" ) );
790 PNS_DBG(
Dbg(), AddItem, &aNewTail,
BLUE, 100000, wxT(
"walk-new-tail" ) );
819 if( ( nearest - aP ).EuclideanNorm() <
m_head.
Width() / 2 )
828 if( !
Settings().AllowDRCViolations() )
832 if( obs && obs->m_distFirst != INT_MAX )
850 LINE newTail( aOldTail );
851 LINE newHead( aOldTail );
899 PNS_DBG(
Dbg(), AddItem, &newHead,
BLUE, 500000, wxT(
"head-post-split" ) );
928 LINE newHead( walkSolids );
931 PNS_DBG(
Dbg(), AddPoint, newHead.
Via().
Pos(),
RED, 1000000, wxString::Format(
"SVIA [%d]", viaOk?1:0 ) );
946 switch(
Settings().OptimizerEffort() )
1043 int tailLookbackSegments = 3;
1048 int threshold = std::min( tail.
PointCount(), tailLookbackSegments + 1 );
1056 int end = std::min(2, head.
PointCount() - 1 );
1095 bool go_back =
false;
1100 PNS_DBG(
Dbg(), Message, wxString::Format(
"routeStep: direction: %s head: %d, tail: %d shapes" ,
1105 PNS_DBG(
Dbg(), BeginGroup, wxT(
"route-step" ), 0 );
1110 for( i = 0; i < n_iter; i++ )
1114 LINE newHead, newTail;
1116 if( !go_back &&
Settings().FollowMouse() )
1126 if( !
routeHead( aP, newHead, newTail ) )
1145 PNS_DBG(
Dbg(), AddItem, &newHead,
LIGHTGREEN, 100000, wxString::Format(
"new_head [fail: %d]", fail?1:0 ) );
1180 if( !fail &&
Settings().FollowMouse() )
1284 std::unique_ptr<SEGMENT> s_new[2] = {
Clone( *s_old ),
Clone( *s_old ) };
1286 s_new[0]->SetEnds( s_old->
Seg().
A, aP );
1287 s_new[1]->SetEnds( aP, s_old->
Seg().
B );
1290 aNode->
Add( std::move( s_new[0] ),
true );
1291 aNode->
Add( std::move( s_new[1] ),
true );
1310 ARC* a_old =
static_cast<ARC*
>( aArc );
1313 std::unique_ptr<ARC> a_new[2] = {
Clone( *a_old ),
Clone( *a_old ) };
1315 a_new[0]->Arc().ConstructFromStartEndCenter( o_arc.
GetP0(), aP, o_arc.
GetCenter(),
1318 a_new[1]->Arc().ConstructFromStartEndCenter( aP, o_arc.
GetP1(), o_arc.
GetCenter(),
1322 aNode->
Add( std::move( a_new[0] ),
true );
1323 aNode->
Add( std::move( a_new[1] ),
true );
1387 SEG seg =
static_cast<SEGMENT*
>( aStartItem )->Seg();
1391 else if( aP == seg.
B )
1397 double angle =
static_cast<SOLID*
>( aStartItem )->GetOrientation().AsDegrees();
1402 PNS_DBG(
Dbg(), Message, wxString::Format(
"Posture: init %s, last seg %s",
1452 wxLogTrace( wxT(
"PNS" ), wxT(
"world %p, intitial-direction %s layer %d" ),
1469 if( aEndItem && aEndItem->
Owner() )
1470 eiDepth =
static_cast<const NODE*
>( aEndItem->
Owner() )->Depth();
1480 bool reachesEnd =
route( aP );
1494 && aEndItem && latestNode->
Depth() >= eiDepth
1513 bool realEnd =
false;
1542 if( !
Settings().AllowDRCViolations() )
1593 p_pre_last = l.
CPoint( -2 );
1622 for(
int i = 0; i < lastV; i++ )
1624 ssize_t arcIndex = l.
ArcIndex( i );
1626 if( arcIndex < 0 || ( lastArc >= 0 && i == lastV - 1 && !l.
IsPtOnArc( lastV ) ) )
1632 std::unique_ptr<SEGMENT> sp = std::make_unique<SEGMENT>( seg );
1633 lastItem = sp.get();
1640 if( arcIndex == lastArc )
1647 std::unique_ptr<ARC> ap = std::make_unique<ARC>( arc );
1648 lastItem = ap.get();
1660 if( realEnd && lastItem )
1710 std::optional<VECTOR2I> ret;
1762 m_shove->RewindToLastLockedNode();
1784 std::set<LINKED_ITEM *> toErase;
1785 aNode->
Add( aLatest,
true );
1787 for(
int s = 0; s < aLatest.
LinkCount(); s++ )
1792 std::vector<LINE> lines;
1801 int removedCount = 0;
1804 for(
LINE& line : lines )
1808 if( !( line.ContainsLink( seg ) ) && line.SegmentCount() )
1811 toErase.insert( ss );
1817 PNS_DBG(
Dbg(), Message, wxString::Format(
"total segs removed: %d/%d", removedCount, total ) );
1823 aNode->
Remove( aLatest );
1837 std::set<ITEM*> cleanup;
1845 SEG refSeg =
static_cast<SEGMENT*
>( aItem )->Seg();
1851 if( neighbor == aItem
1853 || !neighbor->LayersOverlap( aItem ) )
1859 !=
static_cast<const SEGMENT*
>( aItem )->Width() )
1864 const SEG& testSeg =
static_cast<const SEGMENT*
>( neighbor )->Seg();
1868 const JOINT* nA = aNode->
FindJoint( neighbor->Anchor( 0 ), neighbor );
1869 const JOINT* nB = aNode->
FindJoint( neighbor->Anchor( 1 ), neighbor );
1871 if( ( nA == aJoint && nB->
LinkCount() == 1 ) ||
1872 ( nB == aJoint && nA->
LinkCount() == 1 ) )
1874 cleanup.insert( neighbor );
1880 for(
ITEM* item : added )
1888 processJoint( jA, item );
1889 processJoint( jB, item );
1892 for(
ITEM* seg : cleanup )
1962 PNS_DBG(
Dbg(), Message, wxString::Format( wxT(
"buildInitialLine: m_direction %s, guessedDir %s, tail points %d" ),
2003 PNS_DBG(
Dbg(), AddItem, &aHead,
CYAN, 10000, wxT(
"initial-trace" ) );
2021 for(
int attempt = 0; attempt < 2; attempt++)
2032 aHead =
LINE( aHead, line );
2090 st.
pts.push_back(pt);
constexpr Vec ClosestPointTo(const Vec &aPoint) const
Return the point in this rect that is closest to the provided point.
Represent route directions & corner angles in a 45-degree metric.
const SHAPE_LINE_CHAIN BuildInitialTrace(const VECTOR2I &aP0, const VECTOR2I &aP1, bool aStartDiagonal=false, CORNER_MODE aMode=CORNER_MODE::MITERED_45) const
Build a 2-segment line chain between points aP0 and aP1 and following 45-degree routing regime.
AngleType Angle(const DIRECTION_45 &aOther) const
Return the type of angle between directions (this) and aOther.
AngleType
Represent kind of angle formed by vectors heading in two DIRECTION_45s.
Directions
Available directions, there are 8 of them, as on a rectilinear map (north = up) + an extra undefined ...
@ ROUNDED_90
H/V with filleted corners.
@ MITERED_90
H/V only (90-degree corners)
@ ROUNDED_45
H/V/45 with filleted corners.
@ MITERED_45
H/V/45 with mitered corners (default)
const std::string Format() const
Format the direction in a human readable word.
KICAD_T Type() const
Returns the type of object.
void SetDebugDecorator(DEBUG_DECORATOR *aDecorator)
Assign a debug decorator allowing this algo to draw extra graphics for visual debugging.
void SetLogger(LOGGER *aLogger)
virtual LOGGER * Logger()
ROUTER * Router() const
Return current router settings.
ROUTING_SETTINGS & Settings() const
Return the logger object, allowing to dump geometry to a file.
DEBUG_DECORATOR * Dbg() const
void SetWidth(int aWidth) override
FIXED_TAIL(int aLineCount=1)
bool PopStage(STAGE &aStage)
void AddStage(const VECTOR2I &aStart, int aLayer, bool placingVias, DIRECTION_45 direction, NODE *aNode)
std::vector< STAGE > m_stages
const std::vector< ITEM * > & CItems() const
Base class for PNS router board items.
BOARD_ITEM * Parent() const
const PNS_LAYER_RANGE & Layers() const
virtual NET_HANDLE Net() const
PnsKind Kind() const
Return the type (kind) of the item.
void SetNet(NET_HANDLE aNet)
void SetLayer(int aLayer)
bool OfKind(int aKindMask) const
A 2D point on a given set of layers and belonging to a certain net, that links together a number of b...
int LinkCount(int aMask=-1) const
bool IsLineCorner(bool aAllowLockedSegs=false) const
Checks if a joint connects two segments of the same net, layer, and width.
const ITEM_SET & CLinks() const
bool mergeHead()
Moves "established" segments from the head to the tail if certain conditions are met.
bool SplitAdjacentArcs(NODE *aNode, ITEM *aArc, const VECTOR2I &aP)
Snaps the point aP to arc aArc.
bool handleSelfIntersections()
Check if the head of the track intersects its tail.
LINE_PLACER(ROUTER *aRouter)
bool SetLayer(int aLayer) override
Set the current routing layer.
NODE * m_lastNode
Postprocessed world state (including marked collisions & removed loops)
bool route(const VECTOR2I &aP)
Re-route the current track to point aP.
void updatePStart(const LINE &tail)
bool AbortPlacement() override
std::unique_ptr< SHOVE > m_shove
The shove engine.
const LINE Trace() const
Return the complete routed line.
bool splitHeadTail(const LINE &aNewLine, const LINE &aOldTail, LINE &aNewHead, LINE &aNewTail)
bool handlePullback()
Deal with pull-back: reduces the tail if head trace is moved backwards wrs to the current tail direct...
void setWorld(NODE *aWorld)
Set the board to route.
void UpdateSizes(const SIZES_SETTINGS &aSizes) override
Perform on-the-fly update of the width, via diameter & drill size from a settings class.
bool reduceTail(const VECTOR2I &aEnd)
Attempt to reduce the number of segments in the tail by trying to replace a certain number of latest ...
void SetOrthoMode(bool aOrthoMode) override
Function SetOrthoMode()
LINE m_tail
routing "tail": part of the track that has been already fixed due to collisions with obstacles
MOUSE_TRAIL_TRACER m_mouseTrailTracer
bool Start(const VECTOR2I &aP, ITEM *aStartItem) override
Start routing a single track at point aP, taking item aStartItem as anchor (unless NULL).
std::optional< VECTOR2I > m_last_p_end
bool optimizeTailHeadTransition()
Try to reduce the corner count of the most recent part of tail/head by merging obtuse/collinear segme...
bool HasPlacedAnything() const override
void routeStep(const VECTOR2I &aP)
Perform a single routing algorithm step, for the end point aP.
bool buildInitialLine(const VECTOR2I &aP, LINE &aHead, bool aForceNoVia=false)
NODE * m_currentNode
Current world state.
bool cursorDistMinimum(const SHAPE_LINE_CHAIN &aL, const VECTOR2I &aCursor, double lengthThreshold, SHAPE_LINE_CHAIN &aOut)
LINE m_head
the volatile part of the track from the previously analyzed point to the current routing destination
void removeLoops(NODE *aNode, LINE &aLatest)
Searches aNode for traces concurrent to aLatest and removes them.
VECTOR2I m_fixStart
start point of the last 'fix'
bool rhMarkObstacles(const VECTOR2I &aP, LINE &aNewHead, LINE &aNewTail)
NODE * m_world
pointer to world to search colliding items
DIRECTION_45 m_initial_direction
routing direction for new traces
NODE * CurrentNode(bool aLoopsRemoved=false) const override
Return the most recent world state.
bool SplitAdjacentSegments(NODE *aNode, ITEM *aSeg, const VECTOR2I &aP)
Snaps the point aP to segment aSeg.
void setInitialDirection(const DIRECTION_45 &aDirection)
Set preferred direction of the very first track segment to be laid.
void updateLeadingRatLine()
Draw the "leading" rats nest line, which connects the end of currently routed track and the nearest y...
bool routeHead(const VECTOR2I &aP, LINE &aNewHead, LINE &aNewTail)
Compute the head trace between the current start point (m_p_start) and point aP, starting with direct...
bool rhWalkOnly(const VECTOR2I &aP, LINE &aNewHead, LINE &aNewTail)
void FlipPosture() override
Toggle the current posture (straight/diagonal) of the trace head.
const VIA makeVia(const VECTOR2I &aP)
bool rhShoveOnly(const VECTOR2I &aP, LINE &aNewHead, LINE &aNewTail)
< Route step shove mode.
bool rhWalkBase(const VECTOR2I &aP, LINE &aWalkLine, int aCollisionMask, bool &aViaOk)
bool CommitPlacement() override
VECTOR2I m_p_start
current routing start (end of tail, beginning of head)
void GetModifiedNets(std::vector< NET_HANDLE > &aNets) const override
Function GetModifiedNets.
bool Move(const VECTOR2I &aP, ITEM *aEndItem) override
Move the end of the currently routed trace to the point aP, taking aEndItem as anchor (if not NULL).
void simplifyNewLine(NODE *aNode, LINKED_ITEM *aLatest)
Assemble a line starting from segment or arc aLatest, removes collinear segments and redundant vertic...
DIRECTION_45 m_direction
current routing direction
void initPlacement()
Initialize placement of a new line with given parameters.
const ITEM_SET Traces() override
Return the complete routed line, as a single-member ITEM_SET.
bool FixRoute(const VECTOR2I &aP, ITEM *aEndItem, bool aForceFinish) override
Commit the currently routed track to the parent node taking aP as the final end point and aEndItem as...
std::optional< VECTOR2I > UnfixRoute() override
bool ToggleVia(bool aEnabled) override
Enable/disable a via at the end of currently routed trace.
bool clipAndCheckCollisions(const VECTOR2I &aP, const SHAPE_LINE_CHAIN &aL, SHAPE_LINE_CHAIN &aOut, int &thresholdDist)
Represents a track on a PCB, connecting two non-trivial joints (that is, vias, pads,...
void SetViaDrill(int aDrill)
const VECTOR2I & CPoint(int aIdx) const
void SetShape(const SHAPE_LINE_CHAIN &aLine)
Return the shape of the line.
const SHAPE_LINE_CHAIN & CLine() const
int CountCorners(int aAngles) const
SHAPE_LINE_CHAIN & Line()
void AppendVia(const VIA &aVia)
void SetViaDiameter(int aDiameter)
int ShapeCount() const
Return the aIdx-th point of the line.
void SetWidth(int aWidth)
Return line width.
void SetBlockingObstacle(ITEM *aObstacle)
const SEG CSegment(int aIdx) const
Set line width.
int Width() const
Return true if the line is geometrically identical as line aOther.
LINKED_ITEM * GetLink(int aIndex) const
Erase the linking information. Used to detach the line from the owning node.
void SetTolerance(int toll)
void SetDefaultDirections(DIRECTION_45 aInitDirection, DIRECTION_45 aLastSegDir)
void SetMouseDisabled(bool aDisabled=true)
Disables the mouse-trail portion of the posture solver; leaving only the manual posture switch and th...
void AddTrailPoint(const VECTOR2I &aP)
DIRECTION_45 GetPosture(const VECTOR2I &aP)
bool IsManuallyForced() const
Keep the router "world" - i.e.
NODE * Branch()
Create a lightweight copy (called branch) of self that tracks the changes (added/removed items) wrs t...
int FindLinesBetweenJoints(const JOINT &aA, const JOINT &aB, std::vector< LINE > &aLines)
Find the joints corresponding to the ends of line aLine.
std::vector< ITEM * > ITEM_VECTOR
int GetClearance(const ITEM *aA, const ITEM *aB, bool aUseClearanceEpsilon=true) const
Return the pre-set worst case clearance between any pair of items.
void GetUpdatedItems(ITEM_VECTOR &aRemoved, ITEM_VECTOR &aAdded)
Return the list of items removed and added in this branch with respect to the root branch.
OPT_OBSTACLE CheckColliding(const ITEM *aItem, int aKindMask=ITEM::ANY_T)
Check if the item collides with anything else in the world, and if found, returns the obstacle.
const JOINT * FindJoint(const VECTOR2I &aPos, int aLayer, NET_HANDLE aNet) const
Search for a joint at a given position, layer and belonging to given net.
std::optional< OBSTACLE > OPT_OBSTACLE
void FindLineEnds(const LINE &aLine, JOINT &aA, JOINT &aB)
Destroy all child nodes. Applicable only to the root node.
bool Add(std::unique_ptr< SEGMENT > aSegment, bool aAllowRedundant=false)
Add an item to the current node.
OPT_OBSTACLE NearestObstacle(const LINE *aLine, const COLLISION_SEARCH_OPTIONS &aOpts=COLLISION_SEARCH_OPTIONS())
Follow the line in search of an obstacle that is nearest to the starting to the line's starting point...
void Remove(ARC *aArc)
Remove an item from this branch.
const LINE AssembleLine(LINKED_ITEM *aSeg, int *aOriginSegmentIndex=nullptr, bool aStopAtLockedJoints=false, bool aFollowLockedSegments=false)
Follow the joint map to assemble a line connecting two non-trivial joints starting from segment aSeg.
Perform various optimizations of the lines being routed, attempting to make the lines shorter and les...
void SetCollisionMask(int aMask)
void SetEffortLevel(int aEffort)
static bool Optimize(LINE *aLine, int aEffortLevel, NODE *aWorld, const VECTOR2I &aV=VECTOR2I(0, 0))
@ SMART_PADS
Reroute pad exits.
@ FANOUT_CLEANUP
Simplify pad-pad and pad-via connections if possible.
@ MERGE_SEGMENTS
Reduce corner cost iteratively.
@ MERGE_COLINEAR
Merge co-linear segments.
const ITEM_OWNER * Owner() const
Return the owner of this item, or NULL if there's none.
virtual int GetNetCode(NET_HANDLE aNet) const =0
virtual void DisplayRatline(const SHAPE_LINE_CHAIN &aRatline, NET_HANDLE aNetCode)=0
virtual NET_HANDLE GetOrphanedNetHandle()=0
ROUTER_IFACE * GetInterface() const
int ViaForcePropIterationLimit() const
double WalkaroundHugLengthThreshold() const
bool GetFixAllSegments() const
PNS_MODE Mode() const
Set the routing mode.
DIRECTION_45::CORNER_MODE GetCornerMode() const
int Width() const override
void SetWidth(int aWidth) override
int GetLayerBottom() const
bool TrackWidthIsExplicit() const
bool LeadingRatLine(const LINE *aTrack, SHAPE_LINE_CHAIN &aRatLine)
const VECTOR2I & Pos() const
bool PushoutForce(NODE *aNode, const VECTOR2I &aDirection, VECTOR2I &aForce, int aCollisionMask=ITEM::ANY_T, int aMaxIterations=10)
void SetPos(const VECTOR2I &aPos)
void SetIterationLimit(const int aIterLimit)
void SetSolidsOnly(bool aSolidsOnly)
void SetItemMask(int aMask)
WALKAROUND_STATUS Route(const LINE &aInitialPath, LINE &aWalkPath, bool aOptimize=true)
Represent a contiguous set of PCB layers.
bool Overlaps(const PNS_LAYER_RANGE &aOther) const
const VECTOR2I NearestPoint(const VECTOR2I &aP) const
Compute a point on the segment (this) that is closest to point aP.
int Length() const
Return the length (this).
bool Contains(const SEG &aSeg) const
VECTOR2I LineProject(const VECTOR2I &aP) const
Compute the perpendicular projection point of aP on a line passing through ends of the segment.
SEG Reversed() const
Returns the center point of the line.
const VECTOR2I & GetP1() const
const VECTOR2I & GetP0() const
const VECTOR2I & GetCenter() const
bool PointOnEdge(const VECTOR2I &aP, int aAccuracy=0) const
Check if point aP lies on an edge or vertex of the line chain.
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
bool IsPtOnArc(size_t aPtIndex) const
const SHAPE_ARC & Arc(size_t aArc) const
void SetPoint(int aIndex, const VECTOR2I &aPos)
Move a point to a specific location.
int Split(const VECTOR2I &aP, bool aExact=false)
Insert the point aP belonging to one of the our segments, splitting the adjacent segment in two.
int ShapeCount() const
Return the number of shapes (line segments or arcs) in this line chain.
int Intersect(const SEG &aSeg, INTERSECTIONS &aIp) const
Find all intersection points between our line chain and the segment aSeg.
void Simplify(int aMaxError=0)
Simplify the line chain by removing colinear adjacent segments and duplicate vertices.
int PointCount() const
Return the number of points (vertices) in this line chain.
void Replace(int aStartIndex, int aEndIndex, const VECTOR2I &aP)
Replace points with indices in range [start_index, end_index] with a single point aP.
ssize_t ArcIndex(size_t aSegment) const
Return the arc index for the given segment index.
void Clear()
Remove all points from the line chain.
const SHAPE_LINE_CHAIN Slice(int aStartIndex, int aEndIndex=-1) const
Return a subset of this line chain containing the [start_index, end_index] range of points.
const std::vector< SHAPE_ARC > & CArcs() const
void Append(int aX, int aY, bool aAllowDuplication=false)
Append a new point at the end of the line chain.
const VECTOR2I & CPoint(int aIndex) const
Return a reference to a given point in the line chain.
const VECTOR2I NearestPoint(const VECTOR2I &aP, bool aAllowInternalShapePoints=true) const
Find a point on the line chain that is closest to point aP.
int SegmentCount() const
Return the number of segments in this line chain.
void Remove(int aStartIndex, int aEndIndex)
Remove the range of points [start_index, end_index] from the line chain.
const SEG CSegment(int aIndex) const
Return a constant copy of the aIndex segment in the line chain.
bool IsArcSegment(size_t aSegment) const
void RemoveShape(int aPointIndex)
Remove the shape at the given index from the line chain.
std::vector< INTERSECTION > INTERSECTIONS
long long int Length() const
Return length of the line chain in Euclidean metric.
int Find(const VECTOR2I &aP, int aThreshold=0) const
Search for point aP.
const BOX2I BBox(int aClearance=0) const override
Compute a bounding box of the shape, with a margin of aClearance a collision.
Push and Shove diff pair dimensions (gap) settings dialog.
@ RM_MarkObstacles
Ignore collisions, mark obstacles.
@ RM_Walkaround
Only walk around.
std::unique_ptr< typename std::remove_const< T >::type > Clone(const T &aItem)
static DIRECTION_45::AngleType angle(const VECTOR2I &a, const VECTOR2I &b)
#define PNS_DBG(dbg, method,...)
#define PNS_DBGN(dbg, method)
std::vector< FIX_POINT > pts
WALKAROUND_STATUS statusCcw
WALKAROUND_STATUS statusCw
Represent an intersection between two line segments.
@ PCB_PAD_T
class PAD, a pad in a footprint
VECTOR2< int32_t > VECTOR2I