From 5157c6c3b9a7c4e4c3878a88ef067623b536a9d8 Mon Sep 17 00:00:00 2001 From: Jon Evans Date: Mon, 10 May 2021 21:48:50 -0400 Subject: [PATCH] Use half copper thickness as the thickness of the start and end of vias Fixes https://gitlab.com/kicad/code/kicad/-/issues/8384 --- pcbnew/board_stackup_manager/board_stackup.cpp | 15 ++++++++++++--- pcbnew/board_stackup_manager/board_stackup.h | 7 ++++++- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/pcbnew/board_stackup_manager/board_stackup.cpp b/pcbnew/board_stackup_manager/board_stackup.cpp index b24555cc1b..007bd240e9 100644 --- a/pcbnew/board_stackup_manager/board_stackup.cpp +++ b/pcbnew/board_stackup_manager/board_stackup.cpp @@ -712,6 +712,7 @@ int BOARD_STACKUP::GetLayerDistance( PCB_LAYER_ID aFirstLayer, PCB_LAYER_ID aSec int total = 0; bool start = false; + bool half = false; for( BOARD_STACKUP_ITEM* item : m_list ) { @@ -725,17 +726,25 @@ int BOARD_STACKUP::GetLayerDistance( PCB_LAYER_ID aFirstLayer, PCB_LAYER_ID aSec if( !start && ( layer != UNDEFINED_LAYER && layer >= aFirstLayer ) ) { start = true; - continue; + half = true; } else if( !start ) continue; // Reached the stop copper layer? we're done if( start && ( layer != UNDEFINED_LAYER && layer >= aSecondLayer ) ) - break; + half = true; for( int sublayer = 0; sublayer < item->GetSublayersCount(); sublayer++ ) - total += item->GetThickness( sublayer ); + { + int subThickness = item->GetThickness( sublayer ); + total += half ? ( subThickness / 2 ) : subThickness; + } + + half = false; + + if( layer != UNDEFINED_LAYER && layer >= aSecondLayer ) + break; } return total; diff --git a/pcbnew/board_stackup_manager/board_stackup.h b/pcbnew/board_stackup_manager/board_stackup.h index 3f78a23597..e378923be3 100644 --- a/pcbnew/board_stackup_manager/board_stackup.h +++ b/pcbnew/board_stackup_manager/board_stackup.h @@ -277,7 +277,12 @@ public: * Calculate the distance (height) between the two given copper layers. * * This factors in the thickness of any dielectric and copper layers between the two given - * layers, but not the height of the given copper layers. + * layers, and half the height of the given start and end layers. This half-height calculation + * allows this to be used for consistent length measurements when calculating net length through + * a series of vias. A more advanced algorithm would be possible once we have a good concept of + * the start and end for a length measurment, but for now this will do. + * See https://gitlab.com/kicad/code/kicad/-/issues/8384 for more background. + * * @param aFirstLayer is a copper layer * @param aSecondLayer is a different copper layer * @return the height (in IU) between the two layers