21#ifndef PCBNEW_NET_CHAIN_BRIDGING_H
22#define PCBNEW_NET_CHAIN_BRIDGING_H
60 if( !aFootprint || aNetChain.
IsEmpty() )
63 std::vector<const PAD*> chainPads;
72 chainPads.push_back(
pad );
75 if( chainPads.size() < 2 )
78 int firstNet = chainPads.front()->GetNetCode();
80 auto crossesNet = [firstNet](
const PAD* p ) {
return p->GetNetCode() != firstNet; };
82 if( !std::any_of( chainPads.begin() + 1, chainPads.end(), crossesNet ) )
87 for(
size_t i = 0; i < chainPads.size(); ++i )
89 for(
size_t j = i + 1; j < chainPads.size(); ++j )
91 if( chainPads[i]->GetNetCode() == chainPads[j]->GetNetCode() )
95 -
VECTOR2D( chainPads[j]->GetCenter() );
96 maxSpan = std::max( maxSpan,
delta.EuclideanNorm() );
109 if( !aBoard || aNetChain.
IsEmpty() )
137 if( !aBoard || aNetChain.
IsEmpty() )
142 if( lengthIU <= 0.0 )
148 return { lengthIU, delayIU };
159 long long adjusted =
static_cast<long long>( aValue ) - aDelta;
161 return static_cast<int>( std::clamp( adjusted,
163 static_cast<long long>( std::numeric_limits<int>::max() ) ) );
194 if( !aBoard || aNetChain.
IsEmpty() )
207 std::tie( std::ignore, tLen, std::ignore, tDelay, std::ignore ) =
210 if( tLen > 0.0 && tDelay > 0.0 )
212 delayIUPerMm = tDelay / ( tLen /
pcbIUScale.IU_PER_MM );
228inline std::vector<CHAIN_BRIDGE>
231 std::vector<CHAIN_BRIDGE> bridges;
233 if( !aBoard || aNetChain.
IsEmpty() )
243 std::vector<PAD*> chainPads;
245 for(
PAD*
pad : fp->Pads() )
250 chainPads.push_back(
pad );
253 if( chainPads.size() < 2 )
256 for(
size_t i = 0; i < chainPads.size(); ++i )
258 for(
size_t j = i + 1; j < chainPads.size(); ++j )
260 if( chainPads[i]->GetNetCode() == chainPads[j]->GetNetCode() )
264 -
VECTOR2D( chainPads[j]->GetCenter() );
265 double length =
delta.EuclideanNorm();
266 double delay = delayIUPerMm * length /
pcbIUScale.IU_PER_MM;
268 bridges.push_back(
CHAIN_BRIDGE{ chainPads[i], chainPads[j], length, delay } );
constexpr EDA_IU_SCALE pcbIUScale
Information pertinent to a Pcbnew printed circuit board.
std::tuple< int, double, double, double, double > GetTrackLength(const PCB_TRACK &aTrack) const
Return data on the length and number of track segments connected to a given track.
const FOOTPRINTS & Footprints() const
const TRACKS & Tracks() const
Handle the data for a net.
const wxString & GetNetChain() const
double ChainBridgingDelayPerMm(const BOARD *aBoard, const wxString &aNetChain)
Compute both the chain bridging length and its associated propagation delay (in internal delay IU,...
constexpr double DEFAULT_PROPAGATION_DELAY_PS_PER_MM
std::tuple< double, double > BoardChainBridging(const BOARD *aBoard, const wxString &aNetChain)
std::vector< CHAIN_BRIDGE > EnumerateChainBridges(const BOARD *aBoard, const wxString &aNetChain)
Enumerate every per-pad-pair bridge edge contributed by every footprint on the board to the named cha...
int SubtractBridgingClamped(int aValue, long long aDelta)
Saturating subtract for bridge-adjusting MINOPTMAX<int> bounds without overflow when the delta is in ...
double BoardChainBridgingLength(const BOARD *aBoard, const wxString &aNetChain)
Sum chain bridging length across every footprint on the board.
double FootprintChainBridgingLength(const FOOTPRINT *aFootprint, const wxString &aNetChain)
Compute the bridging length contributed by a single footprint to a net chain.
One series-component bridge edge inside a chain graph.
VECTOR2< double > VECTOR2D