From 2e120528c8c38a9f917f13edf5b17a9ed352da2d Mon Sep 17 00:00:00 2001 From: Roberto Fernandez Bautista Date: Tue, 28 Sep 2021 18:30:27 +0100 Subject: [PATCH] Length Tuner: Allow single meander when it fits on its own --- pcbnew/router/pns_meander.cpp | 41 ++++++++++++++++++++--------------- 1 file changed, 24 insertions(+), 17 deletions(-) diff --git a/pcbnew/router/pns_meander.cpp b/pcbnew/router/pns_meander.cpp index 16af813518..9aa6ae3814 100644 --- a/pcbnew/router/pns_meander.cpp +++ b/pcbnew/router/pns_meander.cpp @@ -71,6 +71,25 @@ void MEANDERED_LINE::MeanderSegment( const SEG& aBase, bool aSide, int aBaseInde bool fail = false; double remaining = base_len - ( m_last - aBase.A ).EuclideanNorm(); + auto addSingleIfFits = [&]() + { + fail = true; + + for( int i = 0; i < 2; i++ ) + { + bool checkSide = ( i == 0 ) ? side : !side; + + if( m.Fit( MT_SINGLE, aBase, m_last, checkSide ) ) + { + AddMeander( new MEANDER_SHAPE( m ) ); + fail = false; + started = false; + side = !checkSide; + break; + } + } + }; + if( remaining < Settings( ).m_step ) break; @@ -93,23 +112,7 @@ void MEANDERED_LINE::MeanderSegment( const SEG& aBase, bool aSide, int aBaseInde } if( !turning ) - { - fail = true; - - for( int i = 0; i < 2; i++ ) - { - bool checkSide = ( i == 0 ) ? side : !side; - - if( m.Fit( MT_SINGLE, aBase, m_last, checkSide ) ) - { - AddMeander( new MEANDER_SHAPE( m ) ); - fail = false; - started = false; - side = !checkSide; - break; - } - } - } + addSingleIfFits(); } else { @@ -142,6 +145,10 @@ void MEANDERED_LINE::MeanderSegment( const SEG& aBase, bool aSide, int aBaseInde break; } + else if( !turning && remaining > thr * 2.0 ) + { + addSingleIfFits(); + } else { fail = true;