From 6be6680d8ccc975ce3e1806c873af6d9bca15e21 Mon Sep 17 00:00:00 2001 From: Seth Hillbrand Date: Mon, 21 Oct 2024 13:29:12 -0700 Subject: [PATCH] Fix DRC error with arcs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When two arcs only barely overlapped, we cannot predict the actual point ends as they exist in the error margins. Since arc tracks have different radii by definition, rounding errors in calculating the overlap angle led to some mistaken identification of parallel segments. This adds an advanced config flag to set the preferred cutoff point (currently 0.001°) for whether two arcs actually overlap in shared angle space --- common/advanced_config.cpp | 7 +++++++ include/advanced_config.h | 6 ++++++ pcbnew/drc/drc_test_provider_diff_pair_coupling.cpp | 5 +++-- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/common/advanced_config.cpp b/common/advanced_config.cpp index 5f4f12dce1..ff8251e973 100644 --- a/common/advanced_config.cpp +++ b/common/advanced_config.cpp @@ -124,6 +124,7 @@ static const wxChar ExtensionSnapActivateOnHover[] = wxT( "ExtensionSnapActivate static const wxChar EnableSnapAnchorsDebug[] = wxT( "EnableSnapAnchorsDebug" ); static const wxChar EnableODB[] = wxT( "EnableODB" ); static const wxChar EnableJobset[] = wxT( "EnableJobset" ); +static const wxChar MinParallelAngle[] = wxT( "MinParallelAngle" ); } // namespace KEYS @@ -294,6 +295,8 @@ ADVANCED_CFG::ADVANCED_CFG() m_ExtensionSnapActivateOnHover = true; m_EnableSnapAnchorsDebug = false; + m_MinParallelAngle = 0.001; + loadFromConfigFile(); } @@ -563,6 +566,10 @@ void ADVANCED_CFG::loadSettings( wxConfigBase& aCfg ) &m_EnableSnapAnchorsDebug, m_EnableSnapAnchorsDebug ) ); + configParams.push_back( new PARAM_CFG_DOUBLE( true, AC_KEYS::MinParallelAngle, + &m_MinParallelAngle, m_MinParallelAngle, + 0.0, 45.0 ) ); + // Special case for trace mask setting...we just grab them and set them immediately // Because we even use wxLogTrace inside of advanced config wxString traceMasks; diff --git a/include/advanced_config.h b/include/advanced_config.h index 764cdd03ff..173370af95 100644 --- a/include/advanced_config.h +++ b/include/advanced_config.h @@ -708,6 +708,12 @@ public: */ bool m_EnableODB; + /** + * Minimum overlapping angle for which an arc is considered to be parallel + * to its paired arc. + */ + double m_MinParallelAngle; + ///@} private: diff --git a/pcbnew/drc/drc_test_provider_diff_pair_coupling.cpp b/pcbnew/drc/drc_test_provider_diff_pair_coupling.cpp index aea15d3279..14e7a9e110 100644 --- a/pcbnew/drc/drc_test_provider_diff_pair_coupling.cpp +++ b/pcbnew/drc/drc_test_provider_diff_pair_coupling.cpp @@ -18,6 +18,7 @@ */ +#include #include #include #include @@ -179,8 +180,8 @@ static bool commonParallelProjection( const PCB_ARC& p, const PCB_ARC& n, SHAPE_ clip_total_angle = p_end_angle - n_start_angle; } - // One arc starts exactly where the other ends - if( clip_total_angle == ANGLE_0 ) + // One arc starts approximately where the other ends + if( clip_total_angle <= EDA_ANGLE( ADVANCED_CFG::GetCfg().m_MinParallelAngle ) ) return false; VECTOR2I n_start_pt = n_center + VECTOR2I( KiROUND( n_radius ), 0 );