92 if( minAmp == maxAmp )
101 if( minLen > targetLength )
104 if( maxLen < targetLength )
107 int minError = minLen - targetLength;
108 int maxError = maxLen - targetLength;
143 if( initialGuess >= minAmp && initialGuess <= maxAmp )
145 copy.Resize( minAmp );
158 long long int maxElongation = 0;
159 long long int minElongation = 0;
160 bool finished =
false;
179 if( maxElongation + maxEndElongation > aElongation )
183 m->SetType( endType );
189 long long int endMinElongation =
190 ( m->MinTunableLength() - m->BaselineLength() );
192 if( minElongation + endMinElongation >= aElongation )
204 maxElongation += m->CurrentLength() - m->BaselineLength();
205 minElongation += m->MinTunableLength() - m->BaselineLength();
209 long long int remainingElongation = aElongation;
210 int meanderCount = 0;
216 remainingElongation -= m->CurrentLength() - m->BaselineLength();
221 long long int lenReductionLeft = -remainingElongation;
222 int meandersLeft = meanderCount;
224 if( lenReductionLeft < 0 || !meandersLeft )
231 long long int lenReductionHere = lenReductionLeft / meandersLeft;
232 long long int initialLen = m->CurrentLength();
233 int minAmpl = m->MinAmplitude();
241 m->SetTargetBaselineLength( m->BaselineLength() );
244 lenReductionLeft -= initialLen - m->CurrentLength();
263 for(
auto& link : start.
LinkList() )
265 if(
const SOLID* solid = dyn_cast<const SOLID*>( link ) )
268 if( solid->GetPadToDie() > 0 )
270 length += solid->GetPadToDie();
278 if(
const SOLID* solid = dyn_cast<const SOLID*>( link ) )
280 if( solid->GetPadToDie() > 0 )
282 length += solid->GetPadToDie();
302 return static_cast<SEGMENT*
>( aStartItem )->Seg().NearestPoint( aStartPoint );
307 ARC* arc =
static_cast<ARC*
>( aStartItem );
309 if( (
VECTOR2I( arc->
Anchor( 0 ) - aStartPoint ) ).SquaredEuclideanNorm() <=
310 (
VECTOR2I( arc->
Anchor( 1 ) - aStartPoint ) ).SquaredEuclideanNorm() )
324 long long int total = 0;
329 const ITEM* start_item = aLine[0];
330 const ITEM* end_item = aLine[aLine.
Size() - 1];
331 bool start_via =
false;
332 bool end_via =
false;
340 start_via = aStartPad && ( !aStartPad->
LayersOverlap( start_item ) );
341 end_via = aEndPad && ( !aEndPad->
LayersOverlap( end_item ) );
343 for(
int idx = 0; idx < aLine.
Size(); idx++ )
345 const ITEM* item = aLine[idx];
347 if(
const LINE* l = dyn_cast<const LINE*>( item ) )
349 total += l->CLine().Length();
353 int layerPrev = aLine[idx - 1]->Layer();
354 int layerNext = aLine[idx + 1]->Layer();
356 if( layerPrev != layerNext )
363 int layerPrev = aStartPad->
Layer();
364 int layerNext = start_item->
Layer();
371 int layerPrev = end_item->
Layer();
372 int layerNext = aEndPad->
Layer();
ROUTER * Router() const
Return current router settings.
virtual VECTOR2I Anchor(int n) const override
const std::vector< ITEM * > & CItems() const
Base class for PNS router board items.
PnsKind Kind() const
Return the type (kind) of the item.
virtual int Layer() const
bool OfKind(int aKindMask) const
bool LayersOverlap(const ITEM *aOther) const
Return true if the set of layers spanned by aOther overlaps our layers.
A 2D point on a given set of layers and belonging to a certain net, that links together a number of b...
const std::vector< ITEM * > & LinkList() const
Represents a track on a PCB, connecting two non-trivial joints (that is, vias, pads,...
Represent a set of meanders fitted over a single or two lines.
std::vector< MEANDER_SHAPE * > & Meanders()
virtual void UpdateSettings(const MEANDER_SETTINGS &aSettings)
void tuneLineLength(MEANDERED_LINE &aTuned, long long int aElongation)
Take a set of meanders in aTuned and tunes their length to extend the original line length by aElonga...
virtual void SpacingStep(int aSign)
Increase/decrease the current meandering spacing by one step.
int m_currentWidth
Meander settings.
MEANDER_PLACER_BASE(ROUTER *aRouter)
virtual ~MEANDER_PLACER_BASE()
MEANDER_SETTINGS m_settings
The current end point.
virtual int Clearance()
Return the clearance of the track(s) being length tuned.
virtual const MEANDER_SETTINGS & MeanderSettings() const
Return the current meandering configuration.
NODE * m_world
Width of the meandered trace(s).
VECTOR2I getSnappedStartPoint(LINKED_ITEM *aStartItem, VECTOR2I aStartPoint)
long long int lineLength(const ITEM_SET &aLine, const SOLID *aStartPad, const SOLID *aEndPad) const
Calculate the total length of the line represented by an item set (tracks and vias)
int GetTotalPadToDieLength(const LINE &aLine) const
virtual void AmplitudeStep(int aSign)
Increase/decreases the current meandering amplitude by one step.
Dimensions for the meandering algorithm.
int m_minAmplitude
Maximum meandering amplitude.
int m_step
Length PadToDie.
int m_maxAmplitude
Meandering period/spacing (see dialog picture for explanation).
int m_spacing
Amplitude/spacing adjustment step.
The geometry of a single meander.
void SetType(MEANDER_TYPE aType)
Set the type of the meander.
long long int CurrentLength() const
void Recalculate()
Recalculate the line chain representing the meander's shape.
void Resize(int aAmpl)
Change the amplitude of the meander shape to aAmpl and recalculates the resulting line chain.
int BaselineLength() const
void FindLineEnds(const LINE &aLine, JOINT &aA, JOINT &aB)
Destroy all child nodes. Applicable only to the root node.
virtual const ITEM_SET Traces()=0
Function Traces()
virtual int CurrentLayer() const =0
Function CurrentLayer()
virtual int StackupHeight(int aFirstLayer, int aSecondLayer) const =0
ROUTER_IFACE * GetInterface() const
RULE_RESOLVER * GetRuleResolver() const
virtual bool QueryConstraint(CONSTRAINT_TYPE aType, const ITEM *aItemA, const ITEM *aItemB, int aLayer, CONSTRAINT *aConstraint)=0
Push and Shove diff pair dimensions (gap) settings dialog.
MEANDER_TYPE
Shapes of available meanders.
int findAmplitudeForLength(MEANDER_SHAPE *m, int targetLength, int minAmp, int maxAmp)
const int LENGTH_TARGET_TOLERANCE
int findAmplitudeBinarySearch(MEANDER_SHAPE &aCopy, int targetLength, int minAmp, int maxAmp)
EDA_ANGLE abs(const EDA_ANGLE &aAngle)
An abstract function object, returning a design rule (clearance, diff pair gap, etc) required between...
VECTOR2< int32_t > VECTOR2I