From 8d3e1eb52a1355401b7cf56d5ae465c4d682d3e0 Mon Sep 17 00:00:00 2001 From: Mike Williams Date: Fri, 3 Mar 2023 16:48:40 -0500 Subject: [PATCH] Continue From End: support other placement algos --- pcbnew/router/pns_router.cpp | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/pcbnew/router/pns_router.cpp b/pcbnew/router/pns_router.cpp index 4766ff0314..d81f013783 100644 --- a/pcbnew/router/pns_router.cpp +++ b/pcbnew/router/pns_router.cpp @@ -486,18 +486,22 @@ bool ROUTER::getNearestRatnestAnchor( VECTOR2I& aOtherEnd, LAYER_RANGE& aOtherEn if( GetCurrentNets().empty() ) return false; - PNS::LINE_PLACER* placer = dynamic_cast( Placer() ); + PLACEMENT_ALGO* placer = Placer(); - if( placer == nullptr ) + if( placer == nullptr || placer->Traces().Size() == 0 ) + return false; + + LINE* trace = dynamic_cast( placer->Traces()[0] ); + + if( trace == nullptr ) return false; - PNS::LINE trace = placer->Trace(); PNS::NODE* lastNode = placer->CurrentNode( true ); PNS::TOPOLOGY topo( lastNode ); // If the user has drawn a line, get the anchor nearest to the line end - if( trace.SegmentCount() > 0 ) - return topo.NearestUnconnectedAnchorPoint( &trace, aOtherEnd, aOtherEndLayers ); + if( trace->SegmentCount() > 0 ) + return topo.NearestUnconnectedAnchorPoint( trace, aOtherEnd, aOtherEndLayers ); // Otherwise, find the closest anchor to our start point @@ -565,12 +569,16 @@ bool ROUTER::Finish() bool ROUTER::ContinueFromEnd() { - LINE_PLACER* placer = dynamic_cast( Placer() ); + PLACEMENT_ALGO* placer = Placer(); - if( placer == nullptr ) + if( placer == nullptr || placer->Traces().Size() == 0 ) + return false; + + LINE* current = dynamic_cast( placer->Traces()[0] ); + + if( current == nullptr ) return false; - LINE current = placer->Trace(); int currentLayer = GetCurrentLayer(); VECTOR2I currentEnd = placer->CurrentEnd(); VECTOR2I otherEnd; @@ -585,11 +593,11 @@ bool ROUTER::ContinueFromEnd() // Commit whatever we've fixed and restart routing from the other end int nextLayer = otherEndLayers.Overlaps( currentLayer ) ? currentLayer : otherEndLayers.Start(); - if( !StartRouting( otherEnd, ¤t, nextLayer ) ) + if( !StartRouting( otherEnd, current, nextLayer ) ) return false; // Attempt to route to our current position - Move( currentEnd, ¤t ); + Move( currentEnd, current ); return true; }