From 724feccdb8b2779a4cbdeb52da14f433fa955835 Mon Sep 17 00:00:00 2001 From: Jon Evans Date: Sun, 8 Dec 2024 11:05:39 -0500 Subject: [PATCH] Ratsnest: account for coincident anchors on different layers When a net happens to have only coincident items on different layers, the triangulator was not considering the item layers when optimizing them away. Add a special case to ensure that the ratsnest edges will exist in this situation. Fixes https://gitlab.com/kicad/code/kicad/-/issues/18982 --- pcbnew/ratsnest/ratsnest_data.cpp | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/pcbnew/ratsnest/ratsnest_data.cpp b/pcbnew/ratsnest/ratsnest_data.cpp index 93d0bd6274..d89750163d 100644 --- a/pcbnew/ratsnest/ratsnest_data.cpp +++ b/pcbnew/ratsnest/ratsnest_data.cpp @@ -203,10 +203,28 @@ public: anchorChains[anchors.size() - 1].push_back( n ); } - if( anchors.size() < 2 ) + if( anchors.empty() ) { return; } + else if( anchors.size() == 1 ) + { + // The anchors all have the same position, but may not have overlapping layers. + prev = nullptr; + + for( const std::shared_ptr& n : m_allNodes ) + { + if( prev && !( prev->Parent()->GetLayerSet() & n->Parent()->GetLayerSet() ).any() ) + { + // Use a minimal but non-zero distance or the edge will be ignored + mstEdges.emplace_back( prev, n, 1 ); + } + + prev = n; + } + + return; + } else if( areNodesColinear( anchors ) ) { // special case: all nodes are on the same line - there's no