KiCad PCB EDA Suite
Loading...
Searching...
No Matches
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
 
long long int CurrentLength () const
 
long long int MinTunableLength () const
 
int MinAmplitude () 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...
 
void SetTargetBaselineLength (int aLength)
 Sets the target length of the baseline. 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 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
 Minimum length of the base segment to target when resizing. More...
 
int m_targetBaseLen
 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 126 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 135 of file pns_meander.h.

References m_amplitude, m_baseIndex, m_currentTarget, m_meanCornerRadius, m_side, m_targetBaseLen, 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 186 of file pns_meander.h.

References m_amplitude.

Referenced by PNS::findAmplitudeForLength(), and Fit().

◆ BaseIndex()

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

Definition at line 178 of file pns_meander.h.

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 807 of file pns_meander.cpp.

References SEG::Length(), and m_clippedBaseSeg.

Referenced by PNS::findAmplitudeForLength(), MinTunableLength(), and PNS::MEANDER_PLACER_BASE::tuneLineLength().

◆ 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 276 of file pns_meander.h.

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 249 of file pns_meander.h.

References m_shapes.

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

◆ cornerRadius()

◆ CurrentLength()

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

Definition at line 813 of file pns_meander.cpp.

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

Referenced by PNS::findAmplitudeBinarySearch(), PNS::findAmplitudeForLength(), and PNS::MEANDER_PLACER_BASE::tuneLineLength().

◆ End()

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

Definition at line 241 of file pns_meander.h.

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 601 of file pns_meander.cpp.

References SEG::A, Amplitude(), SEG::B, PNS::MEANDER_PLACER_BASE::CheckFit(), End(), Fit(), genMeanderShape(), m2, m_amplitude, m_baseIndex, m_baselineOffset, m_baseSeg, m_dual, PNS::MEANDER_SETTINGS::m_maxAmplitude, m_p0, m_placer, m_shapes, m_side, PNS::MEANDER_SETTINGS::m_step, m_type, m_width, MinAmplitude(), 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 412 of file pns_meander.cpp.

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  aBaselineOffset = 0 
)
private

◆ IsDual()

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

Definition at line 225 of file pns_meander.h.

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 779 of file pns_meander.cpp.

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 767 of file pns_meander.cpp.

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 713 of file pns_meander.cpp.

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

◆ makeMiterShape()

◆ MinAmplitude()

int PNS::MEANDER_SHAPE::MinAmplitude ( ) const

◆ MinTunableLength()

long long int PNS::MEANDER_SHAPE::MinTunableLength ( ) const
Returns
the minumum tunable length according to settings.

Definition at line 819 of file pns_meander.cpp.

References BaselineLength(), and copy.

◆ miter()

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

Tell the turtle to draw an U-like shape.

Definition at line 429 of file pns_meander.cpp.

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 689 of file pns_meander.cpp.

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

Referenced by Resize(), and PNS::MEANDER_PLACER_BASE::tuneLineLength().

◆ 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 702 of file pns_meander.cpp.

References m_amplitude, and Recalculate().

Referenced by PNS::findAmplitudeBinarySearch().

◆ 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 170 of file pns_meander.h.

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 320 of file pns_meander.h.

References m_baselineOffset.

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

◆ SetTargetBaselineLength()

void PNS::MEANDER_SHAPE::SetTargetBaselineLength ( int  aLength)
inline

Sets the target length of the baseline.

When resizing, the meander will try to fit the baseline length into the specified value.

Parameters
aLengththe minimum baseline length.

Definition at line 331 of file pns_meander.h.

References m_targetBaseLen.

◆ Settings()

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

Definition at line 112 of file pns_meander.cpp.

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

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

◆ SetType()

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

Set the type of the meander.

Definition at line 154 of file pns_meander.h.

References m_type.

Referenced by MakeArc(), MakeCorner(), and PNS::MEANDER_PLACER_BASE::tuneLineLength().

◆ Side()

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

Definition at line 233 of file pns_meander.h.

References m_side.

◆ spacing()

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

◆ 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 402 of file pns_meander.cpp.

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 423 of file pns_meander.cpp.

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 162 of file pns_meander.h.

References m_type.

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

◆ updateBaseSegment()

void PNS::MEANDER_SHAPE::updateBaseSegment ( )
private

Return sanitized corner radius value.

Definition at line 830 of file pns_meander.cpp.

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 447 of file pns_meander.cpp.

References forward(), and miter().

Referenced by genMeanderShape().

◆ Width()

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

Definition at line 309 of file pns_meander.h.

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 334 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 380 of file pns_meander.h.

Referenced by Amplitude(), cornerRadius(), Fit(), genMeanderShape(), MakeEmpty(), MEANDER_SHAPE(), and Resize().

◆ m_baseIndex

int PNS::MEANDER_SHAPE::m_baseIndex
private

The current turtle direction.

Definition at line 407 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 383 of file pns_meander.h.

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

◆ m_baseSeg

SEG PNS::MEANDER_SHAPE::m_baseSeg
private

Base segment (clipped).

Definition at line 395 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 398 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 410 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 413 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 416 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 374 of file pns_meander.h.

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

◆ m_meanCornerRadius

int PNS::MEANDER_SHAPE::m_meanCornerRadius
private

Minimum length of the base segment to target when resizing.

Definition at line 386 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 392 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 371 of file pns_meander.h.

Referenced by cornerRadius(), Fit(), makeMiterShape(), MinAmplitude(), 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 404 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 401 of file pns_meander.h.

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

◆ m_targetBaseLen

int PNS::MEANDER_SHAPE::m_targetBaseLen
private

First point of the meandered line.

Definition at line 389 of file pns_meander.h.

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

◆ m_type

MEANDER_TYPE PNS::MEANDER_SHAPE::m_type
private

The placer that placed this meander.

Definition at line 368 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 377 of file pns_meander.h.

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


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