24#ifndef PCBNEW_LENGTH_CALCULATION_H
25#define PCBNEW_LENGTH_CALCULATION_H
32#include <unordered_set>
207 const PAD* aStartPad =
nullptr,
const PAD* aEndPad =
nullptr )
const;
220 const PAD* aEndPad =
nullptr,
bool aWithLayerLengths =
false )
const;
253 const std::vector<LENGTH_CALCULATION_ITEM*>& aLines );
264 std::vector<LENGTH_CALCULATION_ITEM*>& aLines,
265 std::map<
VECTOR2I, std::unordered_set<LENGTH_CALCULATION_ITEM*>>& aLinesPositionMap,
266 const std::map<
VECTOR2I, std::unordered_set<LENGTH_CALCULATION_ITEM*>>& aPadsPositionMap );
271 static void mergeLines( std::vector<LENGTH_CALCULATION_ITEM*>& aLines,
272 std::map<
VECTOR2I, std::unordered_set<LENGTH_CALCULATION_ITEM*>>& aLinesPositionMap );
A base class derived from BOARD_ITEM for items that can be connected and have a net,...
Information pertinent to a Pcbnew printed circuit board.
Lightweight class which holds a pad, via, or a routed trace outline.
void CalculateViaLayers(const BOARD *aBoard)
Calculates active via payers for a proxied VIA object.
PCB_LAYER_ID m_layerEnd
The end board layer for the proxied object.
MERGE_STATUS m_mergeStatus
Flags whether this item has already been merged with another.
void SetPad(PAD *aPad)
Sets the parent PAD associated with this item.
SHAPE_LINE_CHAIN & GetLine() const
Gets the SHAPE_LINE_CHAIN associated with this item.
PCB_LAYER_ID m_layerStart
The start board layer for the proxied object.
SHAPE_LINE_CHAIN m_line
A proxied SHAPE_LINE_CHAIN object. Line is empty if not proxying a SHAPE_LINE_CHAIN.
TYPE
The type of routing object this item proxies.
MERGE_STATUS GetMergeStatus() const
Gets the MERGE_STATUS of this item.
void SetLayers(const PCB_LAYER_ID aStart, const PCB_LAYER_ID aEnd=PCB_LAYER_ID::UNDEFINED_LAYER)
Sets the first and last layers associated with this item.
TYPE m_type
The routing object type of the proxied parent.
MERGE_STATUS
Whether this item is UNMERGED, it has been merged and should be used (MERGED_IN_USE),...
PAD * m_pad
A proxied PAD object. Set to nullptr if not proxying a PAD.
void SetMergeStatus(const MERGE_STATUS aStatus)
Sets the MERGE_STATUS of this item.
PCB_VIA * m_via
A proxied PVIAAD object. Set to nullptr if not proxying a VIA.
TYPE Type() const
Gets the routing item type.
void SetLine(const SHAPE_LINE_CHAIN &aLine)
Sets the source SHAPE_LINE_CHAIN of this item.
PCB_LAYER_ID GetEndLayer() const
Gets the end board layer for the proxied item.
PCB_LAYER_ID GetStartLayer() const
Gets the start board layer for the proxied item.
void SetVia(PCB_VIA *aVia)
Sets the VIA associated with this item.
PCB_VIA * GetVia() const
Gets the VIA associated with this item.
std::tuple< PCB_LAYER_ID, PCB_LAYER_ID > GetLayers() const
Gets the upper and lower layers for the proxied item.
PAD * GetPad() const
Gets the parent PAD associated with this item.
Class which calculates lengths (and associated routing statistics) in a BOARD context.
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 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.
int stackupHeight(PCB_LAYER_ID aFirstLayer, PCB_LAYER_ID aSecondLayer) const
Returns the stackup distance between the two given layers.
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.
LENGTH_CALCULATION(BOARD *aBoard)
Construct the calculator in the given BOARD context.
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.
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.
BOARD * m_board
The parent board for all items.
void inferViaInPad(const PAD *aPad, const LENGTH_CALCULATION_ITEM &aItem, LENGTH_DETAILS &aDetails) const
Infers if there is a via in the given pad.
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_CALCULATION_ITEM GetLengthCalculationItem(BOARD_CONNECTED_ITEM *aBoardItem) const
Return a LENGTH_CALCULATION_ITEM constructed from the given BOARD_CONNECTED_ITEM.
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.
MERGE_POINT
Enum to describe whether track merging is attempted from the start or end of a track segment.
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.
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
PCB_LAYER_ID
A quick note on layer IDs:
Holds length measurement result details and statistics.
std::unique_ptr< std::map< PCB_LAYER_ID, int64_t > > LayerLengths
int64_t TotalLength() const
Struct to control which optimisations the length calculation code runs on the given path objects.
bool InferViaInPad
Determines if there is a via-in-pad present on the board but not in the item set.
bool OptimiseViaLayers
Optimise via layers for height calculations, ensuring only the distance between routed segments is co...
bool MergeTracks
Merges all contiguous (end-to-end, same layer) tracks.
bool OptimiseTracesInPads
Optimises the electrical length of tracks within pads.