From a33e2ed9b1ae49400a1ce360a803641da0745db9 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Mon, 30 Nov 2020 19:01:27 +0100 Subject: [PATCH] gendrill_file_writer_base: better algo to sort holes: Holes were correctly sorted by size, but inside the same hole size the holes were strangely sorted. Now holes are sorted by hole size, and (inside the same size) by position. From master branch --- .../exporters/gendrill_file_writer_base.cpp | 23 +++---------------- 1 file changed, 3 insertions(+), 20 deletions(-) diff --git a/pcbnew/exporters/gendrill_file_writer_base.cpp b/pcbnew/exporters/gendrill_file_writer_base.cpp index 97f0e5dc8c..fbe5021907 100644 --- a/pcbnew/exporters/gendrill_file_writer_base.cpp +++ b/pcbnew/exporters/gendrill_file_writer_base.cpp @@ -3,7 +3,7 @@ * * Copyright (C) 2017 Jean_Pierre Charras * Copyright (C) 2015 SoftPLC Corporation, Dick Hollenbeck - * Copyright (C) 1992-2017 KiCad Developers, see change_log.txt for contributors. + * Copyright (C) 1992-2020 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -44,24 +44,7 @@ static bool CmpHoleSorting( const HOLE_INFO& a, const HOLE_INFO& b ) if( a.m_Hole_Diameter != b.m_Hole_Diameter ) return a.m_Hole_Diameter < b.m_Hole_Diameter; - // group by components when possible - const D_PAD* pada = dyn_cast( a.m_ItemParent ); - const D_PAD* padb = dyn_cast( b.m_ItemParent ); - - if( pada && padb ) - { - // cmp == 0 means the pads have the same parent, therfore the same reference - int cmp = pada->GetParent() - padb->GetParent(); - - if( cmp ) - return cmp < 0; - } - else if( pada || padb ) // in this case, other item is a via. Sort via first - { - return padb != nullptr; - } - - // At this point, sort by position, as last sort criteria + // At this point (same diameter), sort by X then Y position. if( a.m_Hole_Pos.x != b.m_Hole_Pos.x ) return a.m_Hole_Pos.x < b.m_Hole_Pos.x; @@ -151,7 +134,7 @@ void GENDRILL_WRITER_BASE::buildHolesList( DRILL_LAYER_PAIR aLayerPair, } } - // Sort holes per increasing diameter value + // Sort holes per increasing diameter value (and for each dimater, by position) sort( m_holeListBuffer.begin(), m_holeListBuffer.end(), CmpHoleSorting ); // build the tool list