39std::pair<int, int> effectiveLeadSize(
const PTH_LEAD_DEF& aLead )
80 const wxString& GetID()
const override
82 static const wxString
id =
"IPC-2222B";
86 const wxString& GetDisplayName()
const override {
return GetID(); }
88 int GetLevelCount()
const override {
return 3; }
90 wxString GetLevelName(
int aLevel )
const override
92 switch( std::clamp( aLevel, 0, GetLevelCount() - 1 ) )
94 case 0:
return _(
"A (General)" );
95 case 1:
return _(
"B (Moderate)" );
96 default:
return _(
"C (High density)" );
100 int GetMinHoleAddend(
int aLevel )
const override
102 return MIN_HOLE_ADDED[std::clamp( aLevel, 0, GetLevelCount() - 1 )];
105 int GetMaxHoleAddend(
int aLevel )
const override
107 return MAX_HOLE_ADDED[std::clamp( aLevel, 0, GetLevelCount() - 1 )];
110 PTH_HOLE_SIZE_RESULT ComputeHoleSize(
int aLevel,
const PTH_LEAD_DEF& aLead )
const override
112 const int level = std::clamp( aLevel, 0, GetLevelCount() - 1 );
114 const auto [leadMin, leadMax] = effectiveLeadSize( aLead );
116 PTH_HOLE_SIZE_RESULT
result;
117 result.m_leadMin = leadMin;
118 result.m_leadMax = leadMax;
119 result.m_holeMin = leadMax + GetMinHoleAddend( level );
120 result.m_holeMax = leadMin + GetMaxHoleAddend( level );
132 const int64_t mid = (
static_cast<int64_t
>( aRange.
m_holeMin ) + aRange.
m_holeMax ) / 2;
134 if( aRoundingStep <= 0 )
135 return static_cast<int>( mid );
140 hole = ( mid + aRoundingStep - 1 ) / aRoundingStep * aRoundingStep;
142 hole = ( mid + aRoundingStep / 2 ) / aRoundingStep * aRoundingStep;
146 hole = (
static_cast<int64_t
>( aRange.
m_holeMin ) + aRoundingStep - 1 ) / aRoundingStep * aRoundingStep;
148 return static_cast<int>( hole );
156 if( aId == standard->GetID() )
166 static const IPC2222_HOLE_SIZE_STANDARD ipc2222b_std;
168 static const std::vector<const PTH_HOLE_SIZE_STANDARD*> standards = {
constexpr EDA_IU_SCALE pcbIUScale
constexpr BOX2I KiROUND(const BOX2D &aBoxD)
A source of hole size rules for a plated through hole.
int ComputeRecommendedPthHoleSize(const PTH_HOLE_SIZE_RESULT &aRange, int aRoundingStep, PTH_HOLE_ROUNDING aRounding)
Choose a recommended hole within an allowable range.
const PTH_HOLE_SIZE_STANDARD * FindPthHoleSizeStandard(const wxString &aId)
Find a hole size standard in the registry by its ID (e.g.
const std::vector< const PTH_HOLE_SIZE_STANDARD * > & GetPthHoleSizeStandards()
constexpr int mmToIU(double mm) const
wxString result
Test unit parsing edge cases and error handling.