From 2ce4adc739bccf1d71c53b568e44b13a2c246e57 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Wed, 1 Nov 2023 14:11:40 +0000 Subject: [PATCH] Check physical_clearance rules in the router. Fixes https://gitlab.com/kicad/code/kicad/-/issues/16007 --- pcbnew/router/pns_kicad_iface.cpp | 32 +++++++++++++++++++------------ pcbnew/router/pns_node.h | 3 ++- 2 files changed, 22 insertions(+), 13 deletions(-) diff --git a/pcbnew/router/pns_kicad_iface.cpp b/pcbnew/router/pns_kicad_iface.cpp index 7f5576372a..dfe3a65b6a 100644 --- a/pcbnew/router/pns_kicad_iface.cpp +++ b/pcbnew/router/pns_kicad_iface.cpp @@ -325,18 +325,19 @@ bool PNS_PCBNEW_RULE_RESOLVER::QueryConstraint( PNS::CONSTRAINT_TYPE aType, switch ( aType ) { - case PNS::CONSTRAINT_TYPE::CT_CLEARANCE: hostType = CLEARANCE_CONSTRAINT; break; - case PNS::CONSTRAINT_TYPE::CT_WIDTH: hostType = TRACK_WIDTH_CONSTRAINT; break; - case PNS::CONSTRAINT_TYPE::CT_DIFF_PAIR_GAP: hostType = DIFF_PAIR_GAP_CONSTRAINT; break; - case PNS::CONSTRAINT_TYPE::CT_LENGTH: hostType = LENGTH_CONSTRAINT; break; - case PNS::CONSTRAINT_TYPE::CT_DIFF_PAIR_SKEW: hostType = SKEW_CONSTRAINT; break; - case PNS::CONSTRAINT_TYPE::CT_MAX_UNCOUPLED: hostType = MAX_UNCOUPLED_CONSTRAINT; break; - case PNS::CONSTRAINT_TYPE::CT_VIA_DIAMETER: hostType = VIA_DIAMETER_CONSTRAINT; break; - case PNS::CONSTRAINT_TYPE::CT_VIA_HOLE: hostType = HOLE_SIZE_CONSTRAINT; break; - case PNS::CONSTRAINT_TYPE::CT_HOLE_CLEARANCE: hostType = HOLE_CLEARANCE_CONSTRAINT; break; - case PNS::CONSTRAINT_TYPE::CT_EDGE_CLEARANCE: hostType = EDGE_CLEARANCE_CONSTRAINT; break; - case PNS::CONSTRAINT_TYPE::CT_HOLE_TO_HOLE: hostType = HOLE_TO_HOLE_CONSTRAINT; break; - default: return false; // should not happen + case PNS::CONSTRAINT_TYPE::CT_CLEARANCE: hostType = CLEARANCE_CONSTRAINT; break; + case PNS::CONSTRAINT_TYPE::CT_WIDTH: hostType = TRACK_WIDTH_CONSTRAINT; break; + case PNS::CONSTRAINT_TYPE::CT_DIFF_PAIR_GAP: hostType = DIFF_PAIR_GAP_CONSTRAINT; break; + case PNS::CONSTRAINT_TYPE::CT_LENGTH: hostType = LENGTH_CONSTRAINT; break; + case PNS::CONSTRAINT_TYPE::CT_DIFF_PAIR_SKEW: hostType = SKEW_CONSTRAINT; break; + case PNS::CONSTRAINT_TYPE::CT_MAX_UNCOUPLED: hostType = MAX_UNCOUPLED_CONSTRAINT; break; + case PNS::CONSTRAINT_TYPE::CT_VIA_DIAMETER: hostType = VIA_DIAMETER_CONSTRAINT; break; + case PNS::CONSTRAINT_TYPE::CT_VIA_HOLE: hostType = HOLE_SIZE_CONSTRAINT; break; + case PNS::CONSTRAINT_TYPE::CT_HOLE_CLEARANCE: hostType = HOLE_CLEARANCE_CONSTRAINT; break; + case PNS::CONSTRAINT_TYPE::CT_EDGE_CLEARANCE: hostType = EDGE_CLEARANCE_CONSTRAINT; break; + case PNS::CONSTRAINT_TYPE::CT_HOLE_TO_HOLE: hostType = HOLE_TO_HOLE_CONSTRAINT; break; + case PNS::CONSTRAINT_TYPE::CT_PHYSICAL_CLEARANCE: hostType = PHYSICAL_CLEARANCE_CONSTRAINT; break; + default: return false; // should not happen } BOARD_ITEM* parentA = aItemA ? aItemA->BoardItem() : nullptr; @@ -439,6 +440,7 @@ bool PNS_PCBNEW_RULE_RESOLVER::QueryConstraint( PNS::CONSTRAINT_TYPE aType, case PNS::CONSTRAINT_TYPE::CT_LENGTH: case PNS::CONSTRAINT_TYPE::CT_DIFF_PAIR_SKEW: case PNS::CONSTRAINT_TYPE::CT_MAX_UNCOUPLED: + case PNS::CONSTRAINT_TYPE::CT_PHYSICAL_CLEARANCE: aConstraint->m_Value = hostConstraint.GetValue(); aConstraint->m_RuleName = hostConstraint.GetName(); aConstraint->m_Type = aType; @@ -544,6 +546,12 @@ int PNS_PCBNEW_RULE_RESOLVER::Clearance( const PNS::ITEM* aA, const PNS::ITEM* a rv = constraint.m_Value.Min(); } } + + if( QueryConstraint( PNS::CONSTRAINT_TYPE::CT_PHYSICAL_CLEARANCE, aA, aB, layer, &constraint ) ) + { + if( constraint.m_Value.Min() > rv ) + rv = constraint.m_Value.Min(); + } } if( aUseClearanceEpsilon && rv > 0 ) diff --git a/pcbnew/router/pns_node.h b/pcbnew/router/pns_node.h index 18b5954df0..24e2ed633b 100644 --- a/pcbnew/router/pns_node.h +++ b/pcbnew/router/pns_node.h @@ -60,7 +60,8 @@ enum class CONSTRAINT_TYPE CT_EDGE_CLEARANCE = 8, CT_HOLE_TO_HOLE = 9, CT_DIFF_PAIR_SKEW = 10, - CT_MAX_UNCOUPLED = 11 + CT_MAX_UNCOUPLED = 11, + CT_PHYSICAL_CLEARANCE = 12 }; /**