KiCad PCB EDA Suite
|
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. | |
MEANDER_TYPE | Type () const |
void | SetBaseIndex (int aIndex) |
Set an auxiliary index of the segment being meandered in its original LINE. | |
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. | |
void | MakeArc (const SHAPE_ARC &aArc1, const SHAPE_ARC &aArc2=SHAPE_ARC()) |
Create a dummy meander shape representing an arc corner. | |
void | Resize (int aAmpl) |
Change the amplitude of the meander shape to aAmpl and recalculates the resulting line chain. | |
void | Recalculate () |
Recalculate the line chain representing the meander's shape. | |
bool | IsDual () const |
bool | Side () const |
VECTOR2I | End () const |
const SHAPE_LINE_CHAIN & | CLine (int aShape) const |
void | MakeEmpty () |
Replace the meander with straight bypass line(s), effectively clearing it. | |
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. | |
const SEG & | BaseSegment () const |
Return the base segment the meander was fitted to. | |
int | BaselineLength () const |
long long int | CurrentLength () const |
long long int | MinTunableLength () const |
int | MinAmplitude () const |
const MEANDER_SETTINGS & | Settings () const |
int | Width () const |
void | SetBaselineOffset (int aOffset) |
Set the parallel offset between the base segment and the meandered line. | |
void | SetTargetBaselineLength (int aLength) |
Sets the target length of the baseline. | |
Private Member Functions | |
void | start (SHAPE_LINE_CHAIN *aTarget, const VECTOR2D &aWhere, const VECTOR2D &aDir) |
Move turtle forward by aLength. | |
void | forward (int aLength) |
Turn the turtle by aAngle. | |
void | turn (const EDA_ANGLE &aAngle) |
Tell the turtle to draw a mitered corner of given radius and turn direction. | |
void | miter (int aRadius, bool aSide) |
Tell the turtle to draw an U-like shape. | |
void | uShape (int aSides, int aCorner, int aTop) |
Generate a 90-degree circular arc. | |
SHAPE_LINE_CHAIN | makeMiterShape (const VECTOR2D &aP, const VECTOR2D &aDir, bool aSide) |
Produce a meander shape of given type. | |
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. | |
void | updateBaseSegment () |
Return sanitized corner radius value. | |
int | cornerRadius () const |
Return sanitized spacing value. | |
int | spacing () const |
The type of meander. | |
Private Attributes | |
MEANDER_TYPE | m_type |
The placer that placed this meander. | |
MEANDER_PLACER_BASE * | m_placer |
Dual or single line. | |
bool | m_dual |
Width of the line. | |
int | m_width |
Amplitude of the meander. | |
int | m_amplitude |
Offset wrs the base segment (dual only). | |
int | m_baselineOffset |
Average radius of meander corners (for correction of DP meanders). | |
int | m_meanCornerRadius |
Minimum length of the base segment to target when resizing. | |
int | m_targetBaseLen |
First point of the meandered line. | |
VECTOR2I | m_p0 |
Base segment (unclipped). | |
SEG | m_baseSeg |
Base segment (clipped). | |
SEG | m_clippedBaseSeg |
Side (true = right). | |
bool | m_side |
The actual shapes (0 used for single, both for dual). | |
SHAPE_LINE_CHAIN | m_shapes [2] |
Index of the meandered segment in the base line. | |
int | m_baseIndex |
The current turtle direction. | |
VECTOR2D | m_currentDir |
The current turtle position. | |
VECTOR2D | m_currentPos |
The line the turtle is drawing on. | |
SHAPE_LINE_CHAIN * | m_currentTarget |
Friends | |
class | MEANDERED_LINE |
Start turtle drawing. | |
The geometry of a single meander.
Definition at line 127 of file pns_meander.h.
|
inline |
aPlacer | the meander placer instance. |
aWidth | width of the meandered line. |
aIsDual | when true, the shape contains two meandered lines at a given offset (diff pairs). |
Definition at line 136 of file pns_meander.h.
References m_amplitude, m_baseIndex, m_currentTarget, m_meanCornerRadius, m_side, m_targetBaseLen, m_type, and PNS::MT_SINGLE.
|
inline |
Definition at line 187 of file pns_meander.h.
References m_amplitude.
Referenced by PNS::findAmplitudeForLength(), and Fit().
|
inline |
Definition at line 179 of file pns_meander.h.
References m_baseIndex.
int PNS::MEANDER_SHAPE::BaselineLength | ( | ) | const |
Definition at line 808 of file pns_meander.cpp.
References SEG::Length(), and m_clippedBaseSeg.
Referenced by PNS::findAmplitudeForLength(), MinTunableLength(), and PNS::MEANDER_PLACER_BASE::tuneLineLength().
|
inline |
Return the base segment the meander was fitted to.
Definition at line 277 of file pns_meander.h.
References m_clippedBaseSeg.
Referenced by PNS::MEANDERED_LINE::AddMeander(), and PNS::MEANDERED_LINE::CheckSelfIntersections().
|
inline |
Definition at line 250 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().
|
private |
Return sanitized spacing value.
Definition at line 302 of file pns_meander.cpp.
References std::abs(), DEG2RAD(), m_amplitude, m_baselineOffset, PNS::MEANDER_SETTINGS::m_cornerRadiusPercentage, PNS::MEANDER_SETTINGS::m_cornerStyle, m_placer, m_width, PNS::MEANDER_STYLE_ROUND, PNS::MEANDER_PLACER_BASE::MeanderSettings(), Settings(), and spacing().
Referenced by genMeanderShape(), and PNS::MEANDERED_LINE::MeanderSegment().
long long int PNS::MEANDER_SHAPE::CurrentLength | ( | ) | const |
Definition at line 814 of file pns_meander.cpp.
References CLine(), and SHAPE_LINE_CHAIN::Length().
Referenced by PNS::findAmplitudeBinarySearch(), PNS::findAmplitudeForLength(), and PNS::MEANDER_PLACER_BASE::tuneLineLength().
|
inline |
Definition at line 242 of file pns_meander.h.
References SEG::B, and m_clippedBaseSeg.
Referenced by 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.
aType | type of meander shape. |
aSeg | base segment for meandering. |
aP | start point of the meander. |
aSide | side of aSeg to put the meander on (true = right). |
Definition at line 602 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().
|
private |
Turn the turtle by aAngle.
Definition at line 413 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().
|
private |
Recalculate the clipped baseline after the parameters of the meander have been changed.
Definition at line 458 of file pns_meander.cpp.
References std::abs(), ANGLE_90, SHAPE_LINE_CHAIN::Append(), cornerRadius(), forward(), m_amplitude, m_meanCornerRadius, m_targetBaseLen, 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().
|
inline |
Definition at line 226 of file pns_meander.h.
References m_dual.
Create a dummy meander shape representing an arc corner.
Allows representing existing arc tracks so they can be reconstructed after length tuning.
aArc1 | Arc shape on the 1st line. |
aArc2 | Arc shape on the 2nd line (if m_dual == true). |
Definition at line 780 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().
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.
aP1 | corner point of the 1st line. |
aP2 | corner point of the 2nd line (if m_dual == true). |
Definition at line 768 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().
void PNS::MEANDER_SHAPE::MakeEmpty | ( | ) |
Replace the meander with straight bypass line(s), effectively clearing it.
Definition at line 714 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().
|
private |
Produce a meander shape of given type.
Definition at line 343 of file pns_meander.cpp.
References ANGLE_90, SHAPE_LINE_CHAIN::Append(), SHAPE_ARC::ConstructFromStartEndAngle(), correction, DEG2RAD(), 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().
int PNS::MEANDER_SHAPE::MinAmplitude | ( | ) | const |
Definition at line 284 of file pns_meander.cpp.
References std::abs(), correction, DEG2RAD(), m_baselineOffset, PNS::MEANDER_SETTINGS::m_cornerStyle, PNS::MEANDER_SETTINGS::m_minAmplitude, m_placer, m_width, PNS::MEANDER_STYLE_ROUND, PNS::MEANDER_PLACER_BASE::MeanderSettings(), and Settings().
Referenced by Fit().
long long int PNS::MEANDER_SHAPE::MinTunableLength | ( | ) | const |
Definition at line 820 of file pns_meander.cpp.
References BaselineLength(), and copy.
|
private |
Tell the turtle to draw an U-like shape.
Definition at line 430 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().
void PNS::MEANDER_SHAPE::Recalculate | ( | ) |
Recalculate the line chain representing the meander's shape.
Definition at line 690 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().
void PNS::MEANDER_SHAPE::Resize | ( | int | aAmpl | ) |
Change the amplitude of the meander shape to aAmpl and recalculates the resulting line chain.
aAmpl | new amplitude. |
Definition at line 703 of file pns_meander.cpp.
References m_amplitude, and Recalculate().
Referenced by PNS::findAmplitudeBinarySearch().
|
inline |
Set an auxiliary index of the segment being meandered in its original LINE.
Definition at line 171 of file pns_meander.h.
References m_baseIndex.
Referenced by PNS::MEANDERED_LINE::MeanderSegment().
|
inline |
Set the parallel offset between the base segment and the meandered line.
Used for dual meanders (diff pair) only.
aOffset | the offset. |
Definition at line 321 of file pns_meander.h.
References m_baselineOffset.
Referenced by Fit(), and PNS::MEANDERED_LINE::MeanderSegment().
|
inline |
Sets the target length of the baseline.
When resizing, the meander will try to fit the baseline length into the specified value.
aLength | the minimum baseline length. |
Definition at line 332 of file pns_meander.h.
References m_targetBaseLen.
const MEANDER_SETTINGS & PNS::MEANDER_SHAPE::Settings | ( | ) | const |
Definition at line 113 of file pns_meander.cpp.
References m_placer, and PNS::MEANDER_PLACER_BASE::MeanderSettings().
Referenced by cornerRadius(), Fit(), MinAmplitude(), and spacing().
|
inline |
Set the type of the meander.
Definition at line 155 of file pns_meander.h.
References m_type.
Referenced by MakeArc(), MakeCorner(), and PNS::MEANDER_PLACER_BASE::tuneLineLength().
|
inline |
Definition at line 234 of file pns_meander.h.
References m_side.
|
private |
The type of meander.
Definition at line 329 of file pns_meander.cpp.
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().
|
private |
Move turtle forward by aLength.
Definition at line 403 of file pns_meander.cpp.
References SHAPE_LINE_CHAIN::Append(), SHAPE_LINE_CHAIN::Clear(), m_currentDir, m_currentPos, and m_currentTarget.
Referenced by genMeanderShape().
|
private |
Tell the turtle to draw a mitered corner of given radius and turn direction.
Definition at line 424 of file pns_meander.cpp.
References m_currentDir, and RotatePoint().
Referenced by genMeanderShape(), and miter().
|
inline |
Definition at line 163 of file pns_meander.h.
References m_type.
Referenced by PNS::MEANDERED_LINE::CheckSelfIntersections().
|
private |
Return sanitized corner radius value.
Definition at line 831 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().
|
private |
Generate a 90-degree circular arc.
Definition at line 448 of file pns_meander.cpp.
References forward(), and miter().
Referenced by genMeanderShape().
|
inline |
Definition at line 310 of file pns_meander.h.
References m_width.
Referenced by PNS::DP_MEANDER_PLACER::CheckFit(), and PNS::MEANDER_PLACER::CheckFit().
|
friend |
Start turtle drawing.
Definition at line 335 of file pns_meander.h.
|
private |
Offset wrs the base segment (dual only).
Definition at line 381 of file pns_meander.h.
Referenced by Amplitude(), cornerRadius(), Fit(), genMeanderShape(), MakeEmpty(), MEANDER_SHAPE(), and Resize().
|
private |
The current turtle direction.
Definition at line 408 of file pns_meander.h.
Referenced by BaseIndex(), Fit(), MEANDER_SHAPE(), and SetBaseIndex().
|
private |
Average radius of meander corners (for correction of DP meanders).
Definition at line 384 of file pns_meander.h.
Referenced by cornerRadius(), Fit(), MakeEmpty(), makeMiterShape(), MinAmplitude(), Recalculate(), SetBaselineOffset(), and spacing().
|
private |
Base segment (clipped).
Definition at line 396 of file pns_meander.h.
Referenced by Fit(), Recalculate(), and updateBaseSegment().
|
private |
Side (true = right).
Definition at line 399 of file pns_meander.h.
Referenced by BaselineLength(), BaseSegment(), End(), MakeArc(), MakeCorner(), MakeEmpty(), and updateBaseSegment().
|
private |
|
private |
The line the turtle is drawing on.
Definition at line 414 of file pns_meander.h.
|
private |
Definition at line 417 of file pns_meander.h.
Referenced by forward(), MEANDER_SHAPE(), miter(), and start().
|
private |
Width of the line.
Definition at line 375 of file pns_meander.h.
Referenced by Fit(), IsDual(), MakeEmpty(), makeMiterShape(), Recalculate(), spacing(), and updateBaseSegment().
|
private |
Minimum length of the base segment to target when resizing.
Definition at line 387 of file pns_meander.h.
Referenced by genMeanderShape(), makeMiterShape(), and MEANDER_SHAPE().
|
private |
Base segment (unclipped).
Definition at line 393 of file pns_meander.h.
Referenced by Fit(), MakeEmpty(), and Recalculate().
|
private |
Dual or single line.
Definition at line 372 of file pns_meander.h.
Referenced by cornerRadius(), Fit(), makeMiterShape(), MinAmplitude(), Settings(), and spacing().
|
private |
Index of the meandered segment in the base line.
Definition at line 405 of file pns_meander.h.
Referenced by CLine(), Fit(), MakeArc(), MakeCorner(), MakeEmpty(), and Recalculate().
|
private |
The actual shapes (0 used for single, both for dual).
Definition at line 402 of file pns_meander.h.
Referenced by Fit(), MakeEmpty(), MEANDER_SHAPE(), Recalculate(), and Side().
|
private |
First point of the meandered line.
Definition at line 390 of file pns_meander.h.
Referenced by genMeanderShape(), MEANDER_SHAPE(), and SetTargetBaselineLength().
|
private |
The placer that placed this meander.
Definition at line 369 of file pns_meander.h.
Referenced by Fit(), MakeEmpty(), MEANDER_SHAPE(), Recalculate(), SetType(), and Type().
|
private |
Amplitude of the meander.
Definition at line 378 of file pns_meander.h.
Referenced by cornerRadius(), Fit(), MinAmplitude(), spacing(), and Width().