KiCad PCB EDA Suite
PNS::MEANDER_SHAPE Class Reference

The geometry of a single meander. More...

#include <pns_meander.h>

Public Member Functions

 MEANDER_SHAPE (MEANDER_PLACER_BASE *aPlacer, int aWidth, bool aIsDual=false)
 
void SetType (MEANDER_TYPE aType)
 Set the type of the meander. More...
 
MEANDER_TYPE Type () const
 
void SetBaseIndex (int aIndex)
 Set an auxiliary index of the segment being meandered in its original LINE. More...
 
int BaseIndex () const
 
int Amplitude () const
 
void MakeCorner (const VECTOR2I &aP1, const VECTOR2I &aP2=VECTOR2I(0, 0))
 Create a dummy meander shape representing a line corner. More...
 
void MakeArc (const SHAPE_ARC &aArc1, const SHAPE_ARC &aArc2=SHAPE_ARC())
 Create a dummy meander shape representing an arc corner. More...
 
void Resize (int aAmpl)
 Change the amplitude of the meander shape to aAmpl and recalculates the resulting line chain. More...
 
void Recalculate ()
 Recalculate the line chain representing the meander's shape. More...
 
bool IsDual () const
 
bool Side () const
 
VECTOR2I End () const
 
const SHAPE_LINE_CHAINCLine (int aShape) const
 
void MakeEmpty ()
 Replace the meander with straight bypass line(s), effectively clearing it. More...
 
bool Fit (MEANDER_TYPE aType, const SEG &aSeg, const VECTOR2I &aP, bool aSide)
 Attempt to fit a meander of a given type onto a segment, avoiding collisions with other board features. More...
 
const SEGBaseSegment () const
 Return the base segment the meander was fitted to. More...
 
int BaselineLength () const
 
int MaxTunableLength () const
 
const MEANDER_SETTINGSSettings () const
 
int Width () const
 
void SetBaselineOffset (int aOffset)
 Set the parallel offset between the base segment and the meandered line. More...
 

Private Member Functions

void start (SHAPE_LINE_CHAIN *aTarget, const VECTOR2D &aWhere, const VECTOR2D &aDir)
 Move turtle forward by aLength. More...
 
void forward (int aLength)
 Turn the turtle by aAngle. More...
 
void turn (const EDA_ANGLE &aAngle)
 Tell the turtle to draw a mitered corner of given radius and turn direction. More...
 
void miter (int aRadius, bool aSide)
 Tell the turtle to draw an U-like shape. More...
 
void uShape (int aSides, int aCorner, int aTop)
 Generate a 90-degree circular arc. More...
 
SHAPE_LINE_CHAIN makeMiterShape (const VECTOR2D &aP, const VECTOR2D &aDir, bool aSide)
 Produce a meander shape of given type. More...
 
SHAPE_LINE_CHAIN genMeanderShape (const VECTOR2D &aP, const VECTOR2D &aDir, bool aSide, MEANDER_TYPE aType, int aAmpl, int aBaselineOffset=0)
 Recalculate the clipped baseline after the parameters of the meander have been changed. More...
 
void updateBaseSegment ()
 Return sanitized corner radius value. More...
 
int cornerRadius () const
 Return sanitized spacing value. More...
 
int spacing () const
 The type of meander. More...
 

Private Attributes

MEANDER_TYPE m_type
 The placer that placed this meander. More...
 
MEANDER_PLACER_BASEm_placer
 Dual or single line. More...
 
bool m_dual
 Width of the line. More...
 
int m_width
 Amplitude of the meander. More...
 
int m_amplitude
 Offset wrs the base segment (dual only). More...
 
int m_baselineOffset
 Average radius of meander corners (for correction of DP meanders). More...
 
int m_meanCornerRadius
 First point of the meandered line. More...
 
VECTOR2I m_p0
 Base segment (unclipped). More...
 
SEG m_baseSeg
 Base segment (clipped). More...
 
SEG m_clippedBaseSeg
 Side (true = right). More...
 
bool m_side
 The actual shapes (0 used for single, both for dual). More...
 
SHAPE_LINE_CHAIN m_shapes [2]
 Index of the meandered segment in the base line. More...
 
int m_baseIndex
 The current turtle direction. More...
 
VECTOR2D m_currentDir
 The current turtle position. More...
 
VECTOR2D m_currentPos
 The line the turtle is drawing on. More...
 
SHAPE_LINE_CHAINm_currentTarget
 

Friends

class MEANDERED_LINE
 Start turtle drawing. More...
 

Detailed Description

The geometry of a single meander.

Definition at line 110 of file pns_meander.h.

Constructor & Destructor Documentation

◆ MEANDER_SHAPE()

PNS::MEANDER_SHAPE::MEANDER_SHAPE ( MEANDER_PLACER_BASE aPlacer,
int  aWidth,
bool  aIsDual = false 
)
inline
Parameters
aPlacerthe meander placer instance.
aWidthwidth of the meandered line.
aIsDualwhen true, the shape contains two meandered lines at a given offset (diff pairs).

Definition at line 119 of file pns_meander.h.

119 :
120 m_placer( aPlacer ),
121 m_dual( aIsDual ),
122 m_width( aWidth ),
124 {
125 // Do not leave uninitialized members, and keep static analyzer quiet:
127 m_amplitude = 0;
128 m_side = false;
129 m_baseIndex = 0;
130 m_currentTarget = nullptr;
132 }
MEANDER_TYPE m_type
The placer that placed this meander.
Definition: pns_meander.h:333
MEANDER_PLACER_BASE * m_placer
Dual or single line.
Definition: pns_meander.h:336
int m_baselineOffset
Average radius of meander corners (for correction of DP meanders).
Definition: pns_meander.h:348
int m_width
Amplitude of the meander.
Definition: pns_meander.h:342
bool m_side
The actual shapes (0 used for single, both for dual).
Definition: pns_meander.h:363
int m_baseIndex
The current turtle direction.
Definition: pns_meander.h:369
SHAPE_LINE_CHAIN * m_currentTarget
Definition: pns_meander.h:378
bool m_dual
Width of the line.
Definition: pns_meander.h:339
int m_meanCornerRadius
First point of the meandered line.
Definition: pns_meander.h:351
int m_amplitude
Offset wrs the base segment (dual only).
Definition: pns_meander.h:345
@ MT_SINGLE
Definition: pns_meander.h:38

References m_amplitude, m_baseIndex, m_currentTarget, m_meanCornerRadius, m_side, m_type, and PNS::MT_SINGLE.

Member Function Documentation

◆ Amplitude()

int PNS::MEANDER_SHAPE::Amplitude ( ) const
inline
Returns
the amplitude of the meander shape.

Definition at line 169 of file pns_meander.h.

170 {
171 return m_amplitude;
172 }

References m_amplitude.

Referenced by Fit().

◆ BaseIndex()

int PNS::MEANDER_SHAPE::BaseIndex ( ) const
inline
Returns
auxiliary index of the segment being meandered in its original LINE.

Definition at line 161 of file pns_meander.h.

162 {
163 return m_baseIndex;
164 }

References m_baseIndex.

◆ BaselineLength()

int PNS::MEANDER_SHAPE::BaselineLength ( ) const
Returns
length of the base segment for the meander (i.e.the minimum tuned length).

Definition at line 646 of file pns_meander.cpp.

647{
648 return m_clippedBaseSeg.Length();
649}
SEG m_clippedBaseSeg
Side (true = right).
Definition: pns_meander.h:360
int Length() const
Return the length (this).
Definition: seg.h:351

References SEG::Length(), and m_clippedBaseSeg.

◆ BaseSegment()

const SEG & PNS::MEANDER_SHAPE::BaseSegment ( ) const
inline

Return the base segment the meander was fitted to.

Returns
the base segment.

Definition at line 259 of file pns_meander.h.

260 {
261 return m_clippedBaseSeg;
262 }

References m_clippedBaseSeg.

Referenced by PNS::MEANDERED_LINE::AddMeander(), and PNS::MEANDERED_LINE::CheckSelfIntersections().

◆ CLine()

const SHAPE_LINE_CHAIN & PNS::MEANDER_SHAPE::CLine ( int  aShape) const
inline
Returns
the line chain representing the shape of the meander.

Definition at line 232 of file pns_meander.h.

233 {
234 return m_shapes[aShape];
235 }
SHAPE_LINE_CHAIN m_shapes[2]
Index of the meandered segment in the base line.
Definition: pns_meander.h:366

References m_shapes.

Referenced by PNS::DP_MEANDER_PLACER::CheckFit(), PNS::MEANDER_PLACER::CheckFit(), PNS::MEANDERED_LINE::CheckSelfIntersections(), MaxTunableLength(), and updateBaseSegment().

◆ cornerRadius()

int PNS::MEANDER_SHAPE::cornerRadius ( ) const
private

Return sanitized spacing value.

Definition at line 186 of file pns_meander.cpp.

187{
188 // TODO: fix diff-pair meandering so we can use non-100% radii
189 int rPercent = m_dual ? 100 : Settings().m_cornerRadiusPercentage;
190
191 return (int64_t) spacing() * rPercent / 200;
192}
int m_cornerRadiusPercentage
Allowable tuning error.
Definition: pns_meander.h:98
int spacing() const
The type of meander.
const MEANDER_SETTINGS & Settings() const
Definition: pns_meander.cpp:33

References PNS::MEANDER_SETTINGS::m_cornerRadiusPercentage, m_dual, Settings(), and spacing().

Referenced by genMeanderShape(), and PNS::MEANDERED_LINE::MeanderSegment().

◆ End()

VECTOR2I PNS::MEANDER_SHAPE::End ( ) const
inline
Returns
end vertex of the base segment of the meander shape.

Definition at line 224 of file pns_meander.h.

225 {
226 return m_clippedBaseSeg.B;
227 }
VECTOR2I B
Definition: seg.h:50

References SEG::B, and m_clippedBaseSeg.

Referenced by Fit().

◆ Fit()

bool PNS::MEANDER_SHAPE::Fit ( MEANDER_TYPE  aType,
const SEG aSeg,
const VECTOR2I aP,
bool  aSide 
)

Attempt to fit a meander of a given type onto a segment, avoiding collisions with other board features.

Parameters
aTypetype of meander shape.
aSegbase segment for meandering.
aPstart point of the meander.
aSideside of aSeg to put the meander on (true = right).
Returns
true on success.

Definition at line 432 of file pns_meander.cpp.

433{
434 const MEANDER_SETTINGS& st = Settings();
435
436 bool checkMode = false;
437 MEANDER_TYPE prim1, prim2;
438
439 if( aType == MT_CHECK_START )
440 {
441 prim1 = MT_START;
442 prim2 = MT_TURN;
443 checkMode = true;
444 }
445 else if( aType == MT_CHECK_FINISH )
446 {
447 prim1 = MT_TURN;
448 prim2 = MT_FINISH;
449 checkMode = true;
450 }
451
452 if( checkMode )
453 {
456
457 m1.SetBaselineOffset( m_baselineOffset );
458 m2.SetBaselineOffset( m_baselineOffset );
459
460 bool c1 = m1.Fit( prim1, aSeg, aP, aSide );
461 bool c2 = false;
462
463 if( c1 )
464 c2 = m2.Fit( prim2, aSeg, m1.End(), !aSide );
465
466 if( c1 && c2 )
467 {
468 m_type = prim1;
469 m_shapes[0] = m1.m_shapes[0];
470 m_shapes[1] = m1.m_shapes[1];
471 m_baseSeg =aSeg;
472 m_p0 = aP;
473 m_side = aSide;
474 m_amplitude = m1.Amplitude();
475 m_dual = m1.m_dual;
476 m_baseSeg = m1.m_baseSeg;
477 m_baseIndex = m1.m_baseIndex;
479 m_baselineOffset = m1.m_baselineOffset;
480 return true;
481 }
482 else
483 {
484 return false;
485 }
486 }
487
488 int minAmpl = st.m_minAmplitude;
489 int maxAmpl = st.m_maxAmplitude;
490
491 if( m_dual )
492 {
493 minAmpl = std::max( minAmpl, 2 * std::abs( m_baselineOffset ) );
494 maxAmpl = std::max( maxAmpl, 2 * std::abs( m_baselineOffset ) );
495 }
496
497 for( int ampl = maxAmpl; ampl >= minAmpl; ampl -= st.m_step )
498 {
499 if( m_dual )
500 {
501 m_shapes[0] = genMeanderShape( aP, aSeg.B - aSeg.A, aSide, aType, ampl,
503 m_shapes[1] = genMeanderShape( aP, aSeg.B - aSeg.A, aSide, aType, ampl,
505 }
506 else
507 {
508 m_shapes[0] = genMeanderShape( aP, aSeg.B - aSeg.A, aSide, aType, ampl, 0 );
509 }
510
511 m_type = aType;
512 m_baseSeg = aSeg;
513 m_p0 = aP;
514 m_side = aSide;
515 m_amplitude = ampl;
516
518
519 if( m_placer->CheckFit( this ) )
520 return true;
521 }
522
523 return false;
524}
virtual bool CheckFit(MEANDER_SHAPE *aShape)
Checks if it's OK to place the shape aShape (i.e.
SEG m_baseSeg
Base segment (clipped).
Definition: pns_meander.h:357
MEANDER_SHAPE(MEANDER_PLACER_BASE *aPlacer, int aWidth, bool aIsDual=false)
Definition: pns_meander.h:119
void updateBaseSegment()
Return sanitized corner radius value.
SHAPE_LINE_CHAIN genMeanderShape(const VECTOR2D &aP, const VECTOR2D &aDir, bool aSide, MEANDER_TYPE aType, int aAmpl, int aBaselineOffset=0)
Recalculate the clipped baseline after the parameters of the meander have been changed.
VECTOR2I m_p0
Base segment (unclipped).
Definition: pns_meander.h:354
VECTOR2I A
Definition: seg.h:49
std::vector< std::pair< ssize_t, ssize_t > > m_shapes
Array of indices that refer to the index of the shape if the point is part of a larger shape,...
MEANDER_TYPE
Shapes of available meanders.
Definition: pns_meander.h:37
@ MT_TURN
Definition: pns_meander.h:41
@ MT_CHECK_START
Definition: pns_meander.h:42
@ MT_CHECK_FINISH
Definition: pns_meander.h:43
@ MT_START
Definition: pns_meander.h:39
@ MT_FINISH
Definition: pns_meander.h:40
EDA_ANGLE abs(const EDA_ANGLE &aAngle)
Definition: eda_angle.h:412

References SEG::A, std::abs(), Amplitude(), SEG::B, PNS::MEANDER_PLACER_BASE::CheckFit(), End(), Fit(), genMeanderShape(), m_amplitude, m_baseIndex, m_baselineOffset, m_baseSeg, m_dual, PNS::MEANDER_SETTINGS::m_maxAmplitude, PNS::MEANDER_SETTINGS::m_minAmplitude, m_p0, m_placer, m_shapes, m_side, PNS::MEANDER_SETTINGS::m_step, m_type, m_width, PNS::MT_CHECK_FINISH, PNS::MT_CHECK_START, PNS::MT_FINISH, PNS::MT_START, PNS::MT_TURN, SetBaselineOffset(), Settings(), and updateBaseSegment().

Referenced by Fit(), and PNS::MEANDERED_LINE::MeanderSegment().

◆ forward()

void PNS::MEANDER_SHAPE::forward ( int  aLength)
private

Turn the turtle by aAngle.

Definition at line 272 of file pns_meander.cpp.

273{
274 m_currentPos += m_currentDir.Resize( aLength );
276}
VECTOR2D m_currentDir
The current turtle position.
Definition: pns_meander.h:372
VECTOR2D m_currentPos
The line the turtle is drawing on.
Definition: pns_meander.h:375
void Append(int aX, int aY, bool aAllowDuplication=false)
Append a new point at the end of the line chain.
VECTOR2< T > Resize(T aNewLength) const
Return a vector of the same direction, but length specified in aNewLength.
Definition: vector2d.h:367

References SHAPE_LINE_CHAIN::Append(), m_currentDir, m_currentPos, m_currentTarget, and VECTOR2< T >::Resize().

Referenced by genMeanderShape(), and uShape().

◆ genMeanderShape()

SHAPE_LINE_CHAIN PNS::MEANDER_SHAPE::genMeanderShape ( const VECTOR2D aP,
const VECTOR2D aDir,
bool  aSide,
MEANDER_TYPE  aType,
int  aAmpl,
int  aBaselineOffset = 0 
)
private

Recalculate the clipped baseline after the parameters of the meander have been changed.

Definition at line 313 of file pns_meander.cpp.

316{
317 int cr = cornerRadius();
318 int offset = aBaselineOffset;
319 int spc = spacing();
320
321 if( aSide )
322 offset *= -1;
323
324 VECTOR2D dir_u_b( aDir.Resize( offset ) );
325 VECTOR2D dir_v_b( dir_u_b.Perpendicular() );
326
327 if( 2 * cr > aAmpl )
328 {
329 cr = aAmpl / 2;
330 }
331
332 if( 2 * cr > spc )
333 {
334 cr = spc / 2;
335 }
336
338
340
341 start( &lc, aP + dir_v_b, aDir );
342
343 switch( aType )
344 {
345 case MT_EMPTY:
346 {
347 lc.Append( aP + dir_v_b + aDir );
348 break;
349 }
350 case MT_START:
351 {
352 miter( cr - offset, false );
353 uShape( aAmpl - 2 * cr + std::abs( offset ), cr + offset, spc - 2 * cr );
354 forward( std::min( cr - offset, cr + offset ) );
355 forward( std::abs( offset ) );
356 break;
357 }
358
359 case MT_FINISH:
360 {
361 start( &lc, aP - dir_u_b, aDir );
362 turn( -ANGLE_90 );
363 forward( std::min( cr - offset, cr + offset ) );
364 forward( std::abs( offset ) );
365 uShape( aAmpl - 2 * cr + std::abs( offset ), cr + offset, spc - 2 * cr );
366 miter( cr - offset, false );
367 break;
368 }
369
370 case MT_TURN:
371 {
372 start( &lc, aP - dir_u_b, aDir );
373 turn( -ANGLE_90 );
374 forward( std::abs( offset ) );
375 uShape( aAmpl - cr, cr + offset, spc - 2 * cr );
376 forward( std::abs( offset ) );
377 break;
378 }
379
380 case MT_SINGLE:
381 {
382 miter( cr - offset, false );
383 uShape( aAmpl - 2 * cr + std::abs( offset ), cr + offset, spc - 2 * cr );
384 miter( cr - offset, false );
385 lc.Append( aP + dir_v_b + aDir.Resize( 2 * spc ) );
386 break;
387 }
388
389 default:
390 break;
391 }
392
393 if( aSide )
394 {
395 SEG axis( aP, aP + aDir );
396
397 lc.Mirror( axis );
398 }
399
400 return lc;
401}
void start(SHAPE_LINE_CHAIN *aTarget, const VECTOR2D &aWhere, const VECTOR2D &aDir)
Move turtle forward by aLength.
void miter(int aRadius, bool aSide)
Tell the turtle to draw an U-like shape.
int cornerRadius() const
Return sanitized spacing value.
void turn(const EDA_ANGLE &aAngle)
Tell the turtle to draw a mitered corner of given radius and turn direction.
void forward(int aLength)
Turn the turtle by aAngle.
void uShape(int aSides, int aCorner, int aTop)
Generate a 90-degree circular arc.
Definition: seg.h:42
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
void Mirror(bool aX=true, bool aY=false, const VECTOR2I &aRef={ 0, 0 })
Mirror the line points about y or x (or both).
static constexpr EDA_ANGLE & ANGLE_90
Definition: eda_angle.h:425
@ MT_EMPTY
Definition: pns_meander.h:46

References std::abs(), ANGLE_90, SHAPE_LINE_CHAIN::Append(), cornerRadius(), forward(), m_meanCornerRadius, SHAPE_LINE_CHAIN::Mirror(), miter(), PNS::MT_EMPTY, PNS::MT_FINISH, PNS::MT_SINGLE, PNS::MT_START, PNS::MT_TURN, VECTOR2< T >::Perpendicular(), VECTOR2< T >::Resize(), spacing(), start(), turn(), and uShape().

Referenced by Fit(), MakeEmpty(), and Recalculate().

◆ IsDual()

bool PNS::MEANDER_SHAPE::IsDual ( ) const
inline
Returns
true if the shape represents 2 parallel lines (diff pair).

Definition at line 208 of file pns_meander.h.

209 {
210 return m_dual;
211 }

References m_dual.

◆ MakeArc()

void PNS::MEANDER_SHAPE::MakeArc ( const SHAPE_ARC aArc1,
const SHAPE_ARC aArc2 = SHAPE_ARC() 
)

Create a dummy meander shape representing an arc corner.

Allows representing existing arc tracks so they can be reconstructed after length tuning.

Parameters
aArc1Arc shape on the 1st line.
aArc2Arc shape on the 2nd line (if m_dual == true).

Definition at line 616 of file pns_meander.cpp.

617{
619 m_shapes[0].Clear();
620 m_shapes[1].Clear();
621 m_shapes[0].Append( aArc1 );
622 m_shapes[1].Append( aArc2 );
623 m_clippedBaseSeg.A = aArc1.GetP1();
624 m_clippedBaseSeg.B = aArc1.GetP1();
625}
void SetType(MEANDER_TYPE aType)
Set the type of the meander.
Definition: pns_meander.h:137
const VECTOR2I & GetP1() const
Definition: shape_arc.h:113
void Clear()
Remove all points from the line chain.
@ MT_CORNER
Definition: pns_meander.h:44

References SEG::A, SHAPE_LINE_CHAIN::Append(), SEG::B, SHAPE_LINE_CHAIN::Clear(), SHAPE_ARC::GetP1(), m_clippedBaseSeg, m_shapes, PNS::MT_CORNER, and SetType().

Referenced by PNS::MEANDERED_LINE::AddArc().

◆ MakeCorner()

void PNS::MEANDER_SHAPE::MakeCorner ( const VECTOR2I aP1,
const VECTOR2I aP2 = VECTOR2I( 0, 0 ) 
)

Create a dummy meander shape representing a line corner.

Used to define the starts/ends of meandered segments.

Parameters
aP1corner point of the 1st line.
aP2corner point of the 2nd line (if m_dual == true).

Definition at line 604 of file pns_meander.cpp.

605{
607 m_shapes[0].Clear();
608 m_shapes[1].Clear();
609 m_shapes[0].Append( aP1 );
610 m_shapes[1].Append( aP2 );
611 m_clippedBaseSeg.A = aP1;
612 m_clippedBaseSeg.B = aP1;
613}

References SEG::A, SHAPE_LINE_CHAIN::Append(), SEG::B, SHAPE_LINE_CHAIN::Clear(), m_clippedBaseSeg, m_shapes, PNS::MT_CORNER, and SetType().

Referenced by PNS::MEANDERED_LINE::AddCorner().

◆ MakeEmpty()

void PNS::MEANDER_SHAPE::MakeEmpty ( )

Replace the meander with straight bypass line(s), effectively clearing it.

Definition at line 551 of file pns_meander.cpp.

552{
554
556
558
560
561 if( m_dual )
563}

References SEG::A, SEG::B, genMeanderShape(), m_baselineOffset, m_clippedBaseSeg, m_dual, m_p0, m_shapes, m_side, m_type, PNS::MT_EMPTY, and updateBaseSegment().

◆ makeMiterShape()

SHAPE_LINE_CHAIN PNS::MEANDER_SHAPE::makeMiterShape ( const VECTOR2D aP,
const VECTOR2D aDir,
bool  aSide 
)
private

Produce a meander shape of given type.

Definition at line 209 of file pns_meander.cpp.

211{
213
214 if( aDir.EuclideanNorm( ) == 0.0f )
215 {
216 lc.Append( aP );
217 return lc;
218 }
219
220 VECTOR2D dir_u( aDir );
221 VECTOR2D dir_v( aDir.Perpendicular( ) );
222 VECTOR2D p = aP;
223 lc.Append( ( int ) p.x, ( int ) p.y );
224
225 // fixme: refactor
227 {
229 {
230 VECTOR2D center = aP + dir_v * ( aSide ? -1.0 : 1.0 );
231
232 lc.Append( SHAPE_ARC( center, aP, ( aSide ? -ANGLE_90 : ANGLE_90 ) ) );
233 }
234 break;
235
237 {
238 double radius = (double) aDir.EuclideanNorm();
239 double correction = 0;
240
241 if( m_dual && radius > m_meanCornerRadius )
242 correction = (double)( -2 * abs(m_baselineOffset) ) * tan( 22.5 * M_PI / 180.0 );
243
244 VECTOR2D dir_cu = dir_u.Resize( correction );
245 VECTOR2D dir_cv = dir_v.Resize( correction );
246
247 p = aP - dir_cu;
248 lc.Append( ( int ) p.x, ( int ) p.y );
249 p = aP + dir_u + (dir_v + dir_cv) * ( aSide ? -1.0 : 1.0 );
250 lc.Append( ( int ) p.x, ( int ) p.y );
251 }
252 break;
253 }
254
255 p = aP + dir_u + dir_v * ( aSide ? -1.0 : 1.0 );
256 lc.Append( ( int ) p.x, ( int ) p.y );
257
258 return lc;
259}
virtual const MEANDER_SETTINGS & MeanderSettings() const
Return the current meandering configuration.
MEANDER_STYLE m_cornerStyle
Rounding percentage (0 - 100).
Definition: pns_meander.h:95
T EuclideanNorm() const
Compute the Euclidean norm of the vector, which is defined as sqrt(x ** 2 + y ** 2).
Definition: vector2d.h:291
VECTOR2< T > Perpendicular() const
Compute the perpendicular vector.
Definition: vector2d.h:305
@ MEANDER_STYLE_ROUND
Definition: pns_meander.h:51
@ MEANDER_STYLE_CHAMFER
Definition: pns_meander.h:52
constexpr double correction

References std::abs(), ANGLE_90, SHAPE_LINE_CHAIN::Append(), correction, VECTOR2< T >::EuclideanNorm(), m_baselineOffset, PNS::MEANDER_SETTINGS::m_cornerStyle, m_dual, m_meanCornerRadius, m_placer, PNS::MEANDER_STYLE_CHAMFER, PNS::MEANDER_STYLE_ROUND, PNS::MEANDER_PLACER_BASE::MeanderSettings(), VECTOR2< T >::Perpendicular(), VECTOR2< T >::Resize(), VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by miter().

◆ MaxTunableLength()

int PNS::MEANDER_SHAPE::MaxTunableLength ( ) const
Returns
the length of the fitted line chain.

Definition at line 652 of file pns_meander.cpp.

653{
654 return CLine( 0 ).Length();
655}
const SHAPE_LINE_CHAIN & CLine(int aShape) const
Definition: pns_meander.h:232
long long int Length() const
Return length of the line chain in Euclidean metric.

References CLine(), and SHAPE_LINE_CHAIN::Length().

◆ miter()

void PNS::MEANDER_SHAPE::miter ( int  aRadius,
bool  aSide 
)
private

Tell the turtle to draw an U-like shape.

Definition at line 285 of file pns_meander.cpp.

286{
287 if( aRadius <= 0 )
288 {
289 turn( aSide ? ANGLE_90 : -ANGLE_90 );
290 return;
291 }
292
293 VECTOR2D dir = m_currentDir.Resize( (double) aRadius );
294 SHAPE_LINE_CHAIN lc = makeMiterShape( m_currentPos, dir, aSide );
295
296 m_currentPos = lc.CPoint( -1 );
297 turn( aSide ? ANGLE_90 : -ANGLE_90 );
298
299 m_currentTarget->Append( lc );
300}
SHAPE_LINE_CHAIN makeMiterShape(const VECTOR2D &aP, const VECTOR2D &aDir, bool aSide)
Produce a meander shape of given type.
const VECTOR2I & CPoint(int aIndex) const
Return a reference to a given point in the line chain.

References ANGLE_90, SHAPE_LINE_CHAIN::Append(), SHAPE_LINE_CHAIN::CPoint(), m_currentDir, m_currentPos, m_currentTarget, makeMiterShape(), VECTOR2< T >::Resize(), and turn().

Referenced by genMeanderShape(), and uShape().

◆ Recalculate()

void PNS::MEANDER_SHAPE::Recalculate ( )

Recalculate the line chain representing the meander's shape.

Definition at line 527 of file pns_meander.cpp.

References SEG::A, SEG::B, genMeanderShape(), m_amplitude, m_baselineOffset, m_baseSeg, m_dual, m_p0, m_shapes, m_side, m_type, and updateBaseSegment().

Referenced by Resize().

◆ Resize()

void PNS::MEANDER_SHAPE::Resize ( int  aAmpl)

Change the amplitude of the meander shape to aAmpl and recalculates the resulting line chain.

Parameters
aAmplnew amplitude.

Definition at line 540 of file pns_meander.cpp.

541{
542 if( aAmpl < 0 )
543 return;
544
545 m_amplitude = aAmpl;
546
547 Recalculate();
548}
void Recalculate()
Recalculate the line chain representing the meander's shape.

References m_amplitude, and Recalculate().

◆ SetBaseIndex()

void PNS::MEANDER_SHAPE::SetBaseIndex ( int  aIndex)
inline

Set an auxiliary index of the segment being meandered in its original LINE.

Definition at line 153 of file pns_meander.h.

154 {
155 m_baseIndex = aIndex;
156 }

References m_baseIndex.

Referenced by PNS::MEANDERED_LINE::MeanderSegment().

◆ SetBaselineOffset()

void PNS::MEANDER_SHAPE::SetBaselineOffset ( int  aOffset)
inline

Set the parallel offset between the base segment and the meandered line.

Used for dual meanders (diff pair) only.

Parameters
aOffsetthe offset.

Definition at line 293 of file pns_meander.h.

294 {
295 m_baselineOffset = aOffset;
296 }

References m_baselineOffset.

Referenced by Fit(), and PNS::MEANDERED_LINE::MeanderSegment().

◆ Settings()

const MEANDER_SETTINGS & PNS::MEANDER_SHAPE::Settings ( ) const
Returns
the current meandering settings.

Definition at line 33 of file pns_meander.cpp.

34{
35 return m_placer->MeanderSettings();
36}

References m_placer, and PNS::MEANDER_PLACER_BASE::MeanderSettings().

Referenced by cornerRadius(), Fit(), and spacing().

◆ SetType()

void PNS::MEANDER_SHAPE::SetType ( MEANDER_TYPE  aType)
inline

Set the type of the meander.

Definition at line 137 of file pns_meander.h.

138 {
139 m_type = aType;
140 }

References m_type.

Referenced by MakeArc(), and MakeCorner().

◆ Side()

bool PNS::MEANDER_SHAPE::Side ( ) const
inline
Returns
true if the meander is to the right of its base segment.

Definition at line 216 of file pns_meander.h.

217 {
218 return m_side;
219 }

References m_side.

◆ spacing()

int PNS::MEANDER_SHAPE::spacing ( ) const
private

The type of meander.

Definition at line 195 of file pns_meander.cpp.

196{
197 if( !m_dual )
198 {
199 return std::max( m_width + m_placer->Clearance(), Settings().m_spacing );
200 }
201 else
202 {
203 int sp = m_width + m_placer->Clearance() + ( 2 * std::abs( m_baselineOffset ) );
204 return std::max( sp, Settings().m_spacing );
205 }
206}
virtual int Clearance()
Return the clearance of the track(s) being length tuned.

References std::abs(), PNS::MEANDER_PLACER_BASE::Clearance(), m_baselineOffset, m_dual, m_placer, m_width, and Settings().

Referenced by cornerRadius(), genMeanderShape(), and PNS::MEANDERED_LINE::MeanderSegment().

◆ start()

void PNS::MEANDER_SHAPE::start ( SHAPE_LINE_CHAIN aTarget,
const VECTOR2D aWhere,
const VECTOR2D aDir 
)
private

Move turtle forward by aLength.

Definition at line 262 of file pns_meander.cpp.

263{
264 m_currentTarget = aTarget;
266 m_currentTarget->Append( aWhere );
267 m_currentDir = aDir;
268 m_currentPos = aWhere;
269}

References SHAPE_LINE_CHAIN::Append(), SHAPE_LINE_CHAIN::Clear(), m_currentDir, m_currentPos, and m_currentTarget.

Referenced by genMeanderShape().

◆ turn()

void PNS::MEANDER_SHAPE::turn ( const EDA_ANGLE aAngle)
private

Tell the turtle to draw a mitered corner of given radius and turn direction.

Definition at line 279 of file pns_meander.cpp.

280{
281 RotatePoint( m_currentDir, aAngle );
282}
void RotatePoint(int *pX, int *pY, const EDA_ANGLE &aAngle)
Definition: trigo.cpp:183

References m_currentDir, and RotatePoint().

Referenced by genMeanderShape(), and miter().

◆ Type()

MEANDER_TYPE PNS::MEANDER_SHAPE::Type ( ) const
inline
Returns
the type of the meander.

Definition at line 145 of file pns_meander.h.

146 {
147 return m_type;
148 }

References m_type.

Referenced by PNS::MEANDERED_LINE::CheckSelfIntersections().

◆ updateBaseSegment()

void PNS::MEANDER_SHAPE::updateBaseSegment ( )
private

Return sanitized corner radius value.

Definition at line 658 of file pns_meander.cpp.

659{
660 if( m_dual )
661 {
662 VECTOR2I midpA = ( CLine( 0 ).CPoint( 0 ) + CLine( 1 ).CPoint( 0 ) ) / 2;
663 VECTOR2I midpB = ( CLine( 0 ).CPoint( -1 ) + CLine( 1 ).CPoint( -1 ) ) / 2;
664
667 }
668 else
669 {
672 }
673}
VECTOR2I LineProject(const VECTOR2I &aP) const
Compute the perpendicular projection point of aP on a line passing through ends of the segment.
Definition: seg.cpp:302

References SEG::A, SEG::B, CLine(), SHAPE_LINE_CHAIN::CPoint(), SEG::LineProject(), m_baseSeg, m_clippedBaseSeg, and m_dual.

Referenced by Fit(), MakeEmpty(), and Recalculate().

◆ uShape()

void PNS::MEANDER_SHAPE::uShape ( int  aSides,
int  aCorner,
int  aTop 
)
private

Generate a 90-degree circular arc.

Definition at line 303 of file pns_meander.cpp.

304{
305 forward( aSides );
306 miter( aCorner, true );
307 forward( aTop );
308 miter( aCorner, true );
309 forward( aSides );
310}

References forward(), and miter().

Referenced by genMeanderShape().

◆ Width()

int PNS::MEANDER_SHAPE::Width ( ) const
inline
Returns
width of the meandered line.

Definition at line 282 of file pns_meander.h.

283 {
284 return m_width;
285 }

References m_width.

Referenced by PNS::DP_MEANDER_PLACER::CheckFit(), and PNS::MEANDER_PLACER::CheckFit().

Friends And Related Function Documentation

◆ MEANDERED_LINE

friend class MEANDERED_LINE
friend

Start turtle drawing.

Definition at line 299 of file pns_meander.h.

Member Data Documentation

◆ m_amplitude

int PNS::MEANDER_SHAPE::m_amplitude
private

Offset wrs the base segment (dual only).

Definition at line 345 of file pns_meander.h.

Referenced by Amplitude(), Fit(), MEANDER_SHAPE(), Recalculate(), and Resize().

◆ m_baseIndex

int PNS::MEANDER_SHAPE::m_baseIndex
private

The current turtle direction.

Definition at line 369 of file pns_meander.h.

Referenced by BaseIndex(), Fit(), MEANDER_SHAPE(), and SetBaseIndex().

◆ m_baselineOffset

int PNS::MEANDER_SHAPE::m_baselineOffset
private

Average radius of meander corners (for correction of DP meanders).

Definition at line 348 of file pns_meander.h.

Referenced by Fit(), MakeEmpty(), makeMiterShape(), Recalculate(), SetBaselineOffset(), and spacing().

◆ m_baseSeg

SEG PNS::MEANDER_SHAPE::m_baseSeg
private

Base segment (clipped).

Definition at line 357 of file pns_meander.h.

Referenced by Fit(), Recalculate(), and updateBaseSegment().

◆ m_clippedBaseSeg

SEG PNS::MEANDER_SHAPE::m_clippedBaseSeg
private

Side (true = right).

Definition at line 360 of file pns_meander.h.

Referenced by BaselineLength(), BaseSegment(), End(), MakeArc(), MakeCorner(), MakeEmpty(), and updateBaseSegment().

◆ m_currentDir

VECTOR2D PNS::MEANDER_SHAPE::m_currentDir
private

The current turtle position.

Definition at line 372 of file pns_meander.h.

Referenced by forward(), miter(), start(), and turn().

◆ m_currentPos

VECTOR2D PNS::MEANDER_SHAPE::m_currentPos
private

The line the turtle is drawing on.

Definition at line 375 of file pns_meander.h.

Referenced by forward(), miter(), and start().

◆ m_currentTarget

SHAPE_LINE_CHAIN* PNS::MEANDER_SHAPE::m_currentTarget
private

Definition at line 378 of file pns_meander.h.

Referenced by forward(), MEANDER_SHAPE(), miter(), and start().

◆ m_dual

bool PNS::MEANDER_SHAPE::m_dual
private

Width of the line.

Definition at line 339 of file pns_meander.h.

Referenced by cornerRadius(), Fit(), IsDual(), MakeEmpty(), makeMiterShape(), Recalculate(), spacing(), and updateBaseSegment().

◆ m_meanCornerRadius

int PNS::MEANDER_SHAPE::m_meanCornerRadius
private

First point of the meandered line.

Definition at line 351 of file pns_meander.h.

Referenced by genMeanderShape(), makeMiterShape(), and MEANDER_SHAPE().

◆ m_p0

VECTOR2I PNS::MEANDER_SHAPE::m_p0
private

Base segment (unclipped).

Definition at line 354 of file pns_meander.h.

Referenced by Fit(), MakeEmpty(), and Recalculate().

◆ m_placer

MEANDER_PLACER_BASE* PNS::MEANDER_SHAPE::m_placer
private

Dual or single line.

Definition at line 336 of file pns_meander.h.

Referenced by Fit(), makeMiterShape(), Settings(), and spacing().

◆ m_shapes

SHAPE_LINE_CHAIN PNS::MEANDER_SHAPE::m_shapes[2]
private

Index of the meandered segment in the base line.

Definition at line 366 of file pns_meander.h.

Referenced by CLine(), Fit(), MakeArc(), MakeCorner(), MakeEmpty(), and Recalculate().

◆ m_side

bool PNS::MEANDER_SHAPE::m_side
private

The actual shapes (0 used for single, both for dual).

Definition at line 363 of file pns_meander.h.

Referenced by Fit(), MakeEmpty(), MEANDER_SHAPE(), Recalculate(), and Side().

◆ m_type

MEANDER_TYPE PNS::MEANDER_SHAPE::m_type
private

The placer that placed this meander.

Definition at line 333 of file pns_meander.h.

Referenced by Fit(), MakeEmpty(), MEANDER_SHAPE(), Recalculate(), SetType(), and Type().

◆ m_width

int PNS::MEANDER_SHAPE::m_width
private

Amplitude of the meander.

Definition at line 342 of file pns_meander.h.

Referenced by Fit(), spacing(), and Width().


The documentation for this class was generated from the following files: