96 if( cp == aTuneStart )
103 cp += ( s.
B - s.
A ).Resize( 2 );
118 int i_start = l.
Find( m );
119 int i_end = l.
Find( n );
121 if( i_start > i_end )
124 i_start = l.
Find( m );
128 aPre = l.
Slice( 0, i_start );
129 aPost = l.
Slice( i_end, -1 );
130 aTuned = l.
Slice( i_start, i_end );
138 if( minAmp == maxAmp )
147 if( minLen > targetLength )
150 if( maxLen < targetLength )
153 int minError = minLen - targetLength;
154 int maxError = maxLen - targetLength;
189 if( initialGuess >= minAmp && initialGuess <= maxAmp )
191 copy.Resize( minAmp );
204 long long int maxElongation = 0;
205 long long int minElongation = 0;
206 bool finished =
false;
225 if( maxElongation + maxEndElongation > aElongation )
229 m->SetType( endType );
235 long long int endMinElongation =
236 ( m->MinTunableLength() - m->BaselineLength() );
238 if( minElongation + endMinElongation >= aElongation )
250 maxElongation += m->CurrentLength() - m->BaselineLength();
251 minElongation += m->MinTunableLength() - m->BaselineLength();
255 long long int remainingElongation = aElongation;
256 int meanderCount = 0;
262 remainingElongation -= m->CurrentLength() - m->BaselineLength();
267 long long int lenReductionLeft = -remainingElongation;
268 int meandersLeft = meanderCount;
270 if( lenReductionLeft < 0 || !meandersLeft )
277 long long int lenReductionHere = lenReductionLeft / meandersLeft;
278 long long int initialLen = m->CurrentLength();
279 int minAmpl = m->MinAmplitude();
287 m->SetTargetBaselineLength( m->BaselineLength() );
290 lenReductionLeft -= initialLen - m->CurrentLength();
309 for(
auto& link : start.
LinkList() )
311 if(
const SOLID* solid = dyn_cast<const SOLID*>( link ) )
314 if( solid->GetPadToDie() > 0 )
316 length += solid->GetPadToDie();
324 if(
const SOLID* solid = dyn_cast<const SOLID*>( link ) )
326 if( solid->GetPadToDie() > 0 )
328 length += solid->GetPadToDie();
345 long long int aValue,
long long int aExpected,
long long int aTolerance )
const
347 if( aValue < aExpected - aTolerance )
349 else if( aValue > aExpected + aTolerance )
360 return static_cast<SEGMENT*
>( aStartItem )->Seg().NearestPoint( aStartPoint );
365 ARC* arc =
static_cast<ARC*
>( aStartItem );
367 if( (
VECTOR2I( arc->
Anchor( 0 ) - aStartPoint ) ).SquaredEuclideanNorm() <=
368 (
VECTOR2I( arc->
Anchor( 1 ) - aStartPoint ) ).SquaredEuclideanNorm() )
382 long long int total = 0;
387 const ITEM* start_item = aLine[0];
388 const ITEM* end_item = aLine[aLine.
Size() - 1];
389 bool start_via =
false;
390 bool end_via =
false;
398 start_via = aStartPad && ( !aStartPad->
LayersOverlap( start_item ) );
399 end_via = aEndPad && ( !aEndPad->
LayersOverlap( end_item ) );
401 for(
int idx = 0; idx < aLine.
Size(); idx++ )
403 const ITEM* item = aLine[idx];
405 if(
const LINE* l = dyn_cast<const LINE*>( item ) )
407 total += l->CLine().Length();
411 int layerPrev = aLine[idx - 1]->Layer();
412 int layerNext = aLine[idx + 1]->Layer();
414 if( layerPrev != layerNext )
421 int layerPrev = aStartPad->
Layer();
422 int layerNext = start_item->
Layer();
429 int layerPrev = end_item->
Layer();
430 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.
void cutTunedLine(const SHAPE_LINE_CHAIN &aOrigin, const VECTOR2I &aTuneStart, const VECTOR2I &aCursorPos, SHAPE_LINE_CHAIN &aPre, SHAPE_LINE_CHAIN &aTuned, SHAPE_LINE_CHAIN &aPost)
Extract the part of a track to be meandered, depending on the starting point and the cursor position.
MEANDER_PLACER_BASE(ROUTER *aRouter)
virtual ~MEANDER_PLACER_BASE()
MEANDER_SETTINGS m_settings
The current end point.
int compareWithTolerance(long long int aValue, long long int aExpected, long long int aTolerance=0) const
Compare aValue against aExpected with given tolerance.
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 PNS::ITEM *aItemA, const PNS::ITEM *aItemB, int aLayer, PNS::CONSTRAINT *aConstraint)=0
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
const SHAPE_LINE_CHAIN Reverse() const
Reverse point order in the line chain.
SHAPE_LINE_CHAIN & Simplify(bool aRemoveColinear=true)
Simplify the line chain by removing colinear adjacent segments and duplicate vertices.
int Split(const VECTOR2I &aP)
Insert the point aP belonging to one of the our segments, splitting the adjacent segment in two.
int FindSegment(const VECTOR2I &aP, int aThreshold=1) const
Search for segment containing point aP.
const SHAPE_LINE_CHAIN Slice(int aStartIndex, int aEndIndex=-1) const
Return a subset of this line chain containing the [start_index, end_index] range of points.
const VECTOR2I NearestPoint(const VECTOR2I &aP, bool aAllowInternalShapePoints=true) const
Find a point on the line chain that is closest to point aP.
const SEG CSegment(int aIndex) const
Return a constant copy of the aIndex segment in the line chain.
int Find(const VECTOR2I &aP, int aThreshold=0) const
Search for point aP.
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...