KiCad PCB EDA Suite
|
Class which calculates lengths (and associated routing statistics) in a BOARD context. More...
#include <length_calculation.h>
Public Member Functions | |
LENGTH_CALCULATION (BOARD *aBoard) | |
Construct the calculator in the given BOARD context. | |
int64_t | CalculateLength (std::vector< LENGTH_CALCULATION_ITEM > &aItems, PATH_OPTIMISATIONS aOptimisations, const PAD *aStartPad=nullptr, const PAD *aEndPad=nullptr) const |
Calculates the electrical length of the given items. | |
LENGTH_DETAILS | CalculateLengthDetails (std::vector< LENGTH_CALCULATION_ITEM > &aItems, PATH_OPTIMISATIONS aOptimisations, const PAD *aStartPad=nullptr, const PAD *aEndPad=nullptr, bool aWithLayerLengths=false) const |
Calculates the electrical length of the given items. | |
LENGTH_CALCULATION_ITEM | GetLengthCalculationItem (BOARD_CONNECTED_ITEM *aBoardItem) const |
Return a LENGTH_CALCULATION_ITEM constructed from the given BOARD_CONNECTED_ITEM. | |
Static Public Member Functions | |
static void | OptimiseTraceInPad (SHAPE_LINE_CHAIN &aLine, const PAD *aPad, PCB_LAYER_ID aPcbLayer) |
Optimises the given trace / line to minimise the electrical path length within the given pad. | |
Protected Types | |
enum class | MERGE_POINT { START , END } |
Enum to describe whether track merging is attempted from the start or end of a track segment. More... | |
Protected Member Functions | |
int | stackupHeight (PCB_LAYER_ID aFirstLayer, PCB_LAYER_ID aSecondLayer) const |
Returns the stackup distance between the two given layers. | |
void | inferViaInPad (const PAD *aPad, const LENGTH_CALCULATION_ITEM &aItem, LENGTH_DETAILS &aDetails) const |
Infers if there is a via in the given pad. | |
Static Protected Member Functions | |
static void | optimiseTracesInPads (const std::vector< LENGTH_CALCULATION_ITEM * > &aPads, const std::vector< LENGTH_CALCULATION_ITEM * > &aLines) |
Optimises the given set of items to minimise the electrical path length. | |
static void | clipLineToPad (SHAPE_LINE_CHAIN &aLine, const PAD *aPad, PCB_LAYER_ID aLayer, bool aForward=true) |
Clips the given line to the minimal direct electrical length within the pad. | |
static void | optimiseViaLayers (const std::vector< LENGTH_CALCULATION_ITEM * > &aVias, std::vector< LENGTH_CALCULATION_ITEM * > &aLines, std::map< VECTOR2I, std::unordered_set< LENGTH_CALCULATION_ITEM * > > &aLinesPositionMap, const std::map< VECTOR2I, std::unordered_set< LENGTH_CALCULATION_ITEM * > > &aPadsPositionMap) |
Optimises the via layers. | |
static void | mergeLines (std::vector< LENGTH_CALCULATION_ITEM * > &aLines, std::map< VECTOR2I, std::unordered_set< LENGTH_CALCULATION_ITEM * > > &aLinesPositionMap) |
Merges any lines (traces) that are contiguous, on one layer, and with no junctions. | |
static void | mergeShapeLineChains (SHAPE_LINE_CHAIN &aPrimary, const SHAPE_LINE_CHAIN &aSecondary, MERGE_POINT aMergePoint) |
Merges two SHAPE_LINE_CHAINs where there is a shared endpoing. | |
Protected Attributes | |
BOARD * | m_board |
The parent board for all items. | |
Class which calculates lengths (and associated routing statistics) in a BOARD context.
Definition at line 192 of file length_calculation.h.
|
strongprotected |
Enum to describe whether track merging is attempted from the start or end of a track segment.
Enumerator | |
---|---|
START | |
END |
Definition at line 233 of file length_calculation.h.
|
inlineexplicit |
Construct the calculator in the given BOARD context.
Definition at line 196 of file length_calculation.h.
int64_t LENGTH_CALCULATION::CalculateLength | ( | std::vector< LENGTH_CALCULATION_ITEM > & | aItems, |
PATH_OPTIMISATIONS | aOptimisations, | ||
const PAD * | aStartPad = nullptr , |
||
const PAD * | aEndPad = nullptr |
||
) | const |
Calculates the electrical length of the given items.
aItems | is the vector of items making up the route |
aPathType | indicates whether this is an ordered route, or an unordered collection |
aOptimised | indicates whether this has been optimised for electrical length (e.g. clipping within pads) |
aStartPad | is the starting pad of the route |
aEndPad | is the ending pad of the route |
Definition at line 228 of file length_calculation.cpp.
References CalculateLengthDetails(), and LENGTH_DETAILS::TotalLength().
Referenced by PNS_KICAD_IFACE_BASE::CalculateRoutedPathLength().
LENGTH_DETAILS LENGTH_CALCULATION::CalculateLengthDetails | ( | std::vector< LENGTH_CALCULATION_ITEM > & | aItems, |
PATH_OPTIMISATIONS | aOptimisations, | ||
const PAD * | aStartPad = nullptr , |
||
const PAD * | aEndPad = nullptr , |
||
bool | aWithLayerLengths = false |
||
) | const |
Calculates the electrical length of the given items.
aItems | is the vector of items making up the route |
aPathType | indicates whether this is an ordered route, or an unordered collection |
aOptimised | indicates whether this has been optimised for electrical length (e.g. clipping within pads) |
aStartPad | is the starting pad of the route |
aEndPad | is the ending pad of the route |
aWithLayerLengths | indicates whether the layer length structure should be populated |
Definition at line 109 of file length_calculation.cpp.
References BOARD::GetDesignSettings(), PATH_OPTIMISATIONS::InferViaInPad, inferViaInPad(), LENGTH_DETAILS::LayerLengths, m_board, BOARD_DESIGN_SETTINGS::m_UseHeightForLengthCalcs, LENGTH_CALCULATION_ITEM::MERGED_RETIRED, mergeLines(), PATH_OPTIMISATIONS::MergeTracks, LENGTH_DETAILS::NumPads, LENGTH_DETAILS::NumVias, PATH_OPTIMISATIONS::OptimiseTracesInPads, optimiseTracesInPads(), PATH_OPTIMISATIONS::OptimiseViaLayers, optimiseViaLayers(), LENGTH_DETAILS::PadToDieLength, stackupHeight(), LENGTH_DETAILS::TrackLength, and LENGTH_DETAILS::ViaLength.
Referenced by CalculateLength(), and BOARD::GetTrackLength().
|
staticprotected |
Clips the given line to the minimal direct electrical length within the pad.
Definition at line 60 of file length_calculation.cpp.
References SEG::A, SEG::B, delta, ERROR_INSIDE, PAD::GetEffectivePolygon(), SHAPE_LINE_CHAIN::GetPoint(), PAD::GetPosition(), SHAPE_LINE_CHAIN::Insert(), SHAPE_LINE_CHAIN::IsPtOnArc(), SHAPE_LINE_CHAIN::PointCount(), SHAPE_LINE_CHAIN::Remove(), and SHAPE_LINE_CHAIN::Replace().
Referenced by OptimiseTraceInPad().
LENGTH_CALCULATION_ITEM LENGTH_CALCULATION::GetLengthCalculationItem | ( | BOARD_CONNECTED_ITEM * | aBoardItem | ) | const |
Return a LENGTH_CALCULATION_ITEM constructed from the given BOARD_CONNECTED_ITEM.
Definition at line 492 of file length_calculation.cpp.
References LENGTH_CALCULATION_ITEM::CalculateViaLayers(), LSET::copper_layers_begin(), LSET::copper_layers_end(), PCB_TRACK::GetEnd(), PCB_ARC::GetMid(), PCB_TRACK::GetStart(), PCB_TRACK::GetWidth(), m_board, pad, PCB_ARC_T, PCB_TRACE_T, PCB_VIA_T, LENGTH_CALCULATION_ITEM::SetLayers(), LENGTH_CALCULATION_ITEM::SetLine(), LENGTH_CALCULATION_ITEM::SetPad(), LENGTH_CALCULATION_ITEM::SetVia(), UNDEFINED_LAYER, and via.
Referenced by PCB_NET_INSPECTOR_PANEL::calculateNets(), and BOARD::GetTrackLength().
|
protected |
Infers if there is a via in the given pad.
Adds via details to the length details data structure if found.
Definition at line 208 of file length_calculation.cpp.
References B_Cu, LSET::Contains(), F_Cu, LENGTH_CALCULATION_ITEM::GetStartLayer(), PADSTACK::LayerSet(), LENGTH_DETAILS::NumVias, PAD::Padstack(), stackupHeight(), LENGTH_CALCULATION_ITEM::Type(), and LENGTH_DETAILS::ViaLength.
Referenced by CalculateLengthDetails().
|
staticprotected |
Merges any lines (traces) that are contiguous, on one layer, and with no junctions.
Definition at line 255 of file length_calculation.cpp.
References SHAPE_LINE_CHAIN::CArcs(), SHAPE_LINE_CHAIN::CLastPoint(), SHAPE_LINE_CHAIN::CPoint(), END, LENGTH_CALCULATION_ITEM::GetLine(), LENGTH_CALCULATION_ITEM::GetStartLayer(), LENGTH_CALCULATION_ITEM::MERGED_IN_USE, LENGTH_CALCULATION_ITEM::MERGED_RETIRED, mergeShapeLineChains(), LENGTH_CALCULATION_ITEM::SetMergeStatus(), START, and LENGTH_CALCULATION_ITEM::UNMERGED.
Referenced by CalculateLengthDetails().
|
staticprotected |
Merges two SHAPE_LINE_CHAINs where there is a shared endpoing.
aSecondary is merged in to aPrimary
Definition at line 334 of file length_calculation.cpp.
References SHAPE_LINE_CHAIN::Append(), SHAPE_LINE_CHAIN::CLastPoint(), SHAPE_LINE_CHAIN::CPoints(), SHAPE_LINE_CHAIN::GetPoint(), SHAPE_LINE_CHAIN::Insert(), and START.
Referenced by mergeLines().
|
static |
Optimises the given trace / line to minimise the electrical path length within the given pad.
Definition at line 474 of file length_calculation.cpp.
References SHAPE_LINE_CHAIN::CLastPoint(), clipLineToPad(), SHAPE_LINE_CHAIN::CPoint(), ERROR_INSIDE, PAD::FlashLayer(), PAD::GetEffectivePolygon(), and PAD::GetPosition().
Referenced by PNS::TOPOLOGY::AssembleTuningPath(), and optimiseTracesInPads().
|
staticprotected |
Optimises the given set of items to minimise the electrical path length.
At the moment only optimises lines attached to pads, future work could optimise paths through pads
Assumes that any polylines are only connected at either end, and not at midpoints
Definition at line 370 of file length_calculation.cpp.
References LENGTH_CALCULATION_ITEM::MERGED_IN_USE, OptimiseTraceInPad(), and pad.
Referenced by CalculateLengthDetails().
|
staticprotected |
Optimises the via layers.
Ensures that vias that are routed through only on one layer do not count towards total length calculations.
Definition at line 392 of file length_calculation.cpp.
References LSET::Contains(), LSET::CuStack(), LENGTH_CALCULATION_ITEM::GetPad(), LENGTH_CALCULATION_ITEM::GetStartLayer(), PADSTACK::LayerSet(), PAD::Padstack(), BASE_SET::set(), UNDEFINED_LAYER, and via.
Referenced by CalculateLengthDetails().
|
protected |
Returns the stackup distance between the two given layers.
Note: Can return 0 if the board design settings disallow stackup height calculations
Definition at line 236 of file length_calculation.cpp.
References BOARD_STACKUP::BuildDefaultStackupList(), BOARD::GetCopperLayerCount(), BOARD::GetDesignSettings(), BOARD_STACKUP::GetLayerDistance(), BOARD_DESIGN_SETTINGS::GetStackupDescriptor(), m_board, BOARD_DESIGN_SETTINGS::m_HasStackup, and BOARD_DESIGN_SETTINGS::m_UseHeightForLengthCalcs.
Referenced by CalculateLengthDetails(), and inferViaInPad().
|
protected |
The parent board for all items.
Definition at line 230 of file length_calculation.h.
Referenced by CalculateLengthDetails(), GetLengthCalculationItem(), and stackupHeight().