From 89228e1ebe86b56162d86d2c3949c621f6a7cf13 Mon Sep 17 00:00:00 2001 From: Tomasz Wlostowski Date: Mon, 22 Nov 2021 01:33:32 +0100 Subject: [PATCH] router: increase parallelity detection threshold for AssembleDiffPair() Partially fixes the misrecognized diff pairs issue. Fixes: https://gitlab.com/kicad/code/kicad/-/issues/8567 --- pcbnew/router/pns_topology.cpp | 4 ++-- pcbnew/router/pns_topology.h | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/pcbnew/router/pns_topology.cpp b/pcbnew/router/pns_topology.cpp index 32d5584c25..6f902a5403 100644 --- a/pcbnew/router/pns_topology.cpp +++ b/pcbnew/router/pns_topology.cpp @@ -463,7 +463,7 @@ bool TOPOLOGY::AssembleDiffPair( ITEM* aStart, DIFF_PAIR& aPair ) s->Width() == refSeg->Width() ) { int dist = s->Seg().Distance( refSeg->Seg() ); - bool isParallel = refSeg->Seg().ApproxParallel( s->Seg() ); + bool isParallel = refSeg->Seg().ApproxParallel( refSeg->Seg(), DP_PARALLELITY_THRESHOLD ); SEG p_clip, n_clip; bool isCoupled = commonParallelProjection( refSeg->Seg(), s->Seg(), p_clip, @@ -496,7 +496,7 @@ bool TOPOLOGY::AssembleDiffPair( ITEM* aStart, DIFF_PAIR& aPair ) int gap = -1; - if( refSeg->Seg().ApproxParallel( coupledSeg->Seg() ) ) + if( refSeg->Seg().ApproxParallel( coupledSeg->Seg(), DP_PARALLELITY_THRESHOLD ) ) { // Segments are parallel -> compute pair gap const VECTOR2I refDir = refSeg->Anchor( 1 ) - refSeg->Anchor( 0 ); diff --git a/pcbnew/router/pns_topology.h b/pcbnew/router/pns_topology.h index f02a566580..e7be18f977 100644 --- a/pcbnew/router/pns_topology.h +++ b/pcbnew/router/pns_topology.h @@ -88,6 +88,8 @@ public: const std::set AssembleCluster( ITEM* aStart, int aLayer ); private: + const int DP_PARALLELITY_THRESHOLD = 5; + bool followTrivialPath( LINE* aLine, bool aLeft, ITEM_SET& aSet, std::set& aVisited, JOINT** aTerminalJoint = nullptr );