48 double base_len = aBase.
Length();
70 double thr = (double) m.
spacing();
78 if( remaining > 3.0 * thr )
82 for(
int i = 0; i < 2; i++ )
98 for(
int i = 0; i < 2; i++ )
141 if( remaining <
Settings( ).m_step )
173 return (int64_t)
spacing() * rPercent / 200;
184 return std::max( sp,
Settings().m_spacing );
202 lc.
Append( (
int ) p.x, (
int ) p.y );
213 double angleStep = M_PI / 2.0 / (double) ArcSegments;
215 double correction = 12.0 * radius * ( 1.0 - cos( angleStep / 2.0 ) );
227 for(
int i = ArcSegments - 1; i >= 0; i-- )
229 double alpha = (double) i / (
double) ( ArcSegments - 1 ) * M_PI / 2.0;
230 p = aP + shift + dir_uu * cos( alpha ) + dir_vv * ( aSide ? -1.0 : 1.0 ) * ( 1.0 - sin( alpha ) );
231 lc.
Append( (
int ) p.x, (
int ) p.y );
239 double correction = 0;
241 correction = (double)( -2 * abs(
m_baselineOffset) ) * tan( 22.5 * M_PI / 180.0 );
247 lc.
Append( (
int ) p.x, (
int ) p.y );
248 p = aP + dir_u + (dir_v + dir_cv) * ( aSide ? -1.0 : 1.0 );
249 lc.
Append( (
int ) p.x, (
int ) p.y );
254 p = aP + dir_u + dir_v * ( aSide ? -1.0 : 1.0 );
255 lc.
Append( (
int ) p.x, (
int ) p.y );
307 turn( aSide ? -90 : 90 );
324 miter( aCorner,
true );
326 miter( aCorner,
true );
332 bool aSide,
MEANDER_TYPE aType,
int aAmpl,
int aBaselineOffset )
336 int offset = aBaselineOffset;
343 VECTOR2D dir_v_b( dir_u_b.Perpendicular() );
359 start( &lc, aP + dir_v_b, aDir );
365 lc.
Append( aP + dir_v_b + aDir );
370 miter( cr - offset,
false );
371 uShape( aAmpl - 2 * cr + std::abs( offset ), cr + offset, spc - 2 * cr );
372 forward( std::min( cr - offset, cr + offset ) );
380 start( &lc, aP - dir_u_b, aDir );
382 forward( std::min( cr - offset, cr + offset ) );
384 uShape( aAmpl - 2 * cr + std::abs( offset ), cr + offset, spc - 2 * cr );
385 miter( cr - offset,
false );
391 start( &lc, aP - dir_u_b, aDir );
394 uShape( aAmpl - cr, cr + offset, spc - 2 * cr );
401 miter( cr - offset,
false );
402 uShape( aAmpl - 2 * cr + std::abs( offset ), cr + offset, spc - 2 * cr );
403 miter( cr - offset,
false );
414 SEG axis( aP, aP + aDir );
426 for(
int i =
m_meanders.size() - 1; i >= 0; i-- )
441 for(
int j = n - 1; j >= 0; j-- )
454 bool checkMode =
false;
478 bool c1 = m1.
Fit( prim1, aSeg, aP, aSide );
482 c2 = m2.
Fit( prim2, aSeg, m1.
End(), !aSide );
512 for(
int ampl = maxAmpl; ampl >= minAmpl; ampl -= st.
m_step )
double EuclideanNorm(const wxPoint &vector)
Euclidean norm of a 2D vector.
int Length() const
Return the length (this).
SHAPE_LINE_CHAIN genMeanderShape(VECTOR2D aP, 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.
long long int Length() const
Function Length()
int m_minAmplitude
Maximum meandering amplitude.
void uShape(int aSides, int aCorner, int aTop)
Generate a 90-degree circular arc.
void SetBaselineOffset(int aOffset)
Set the parallel offset between the base segment and the meandered line.
bool CheckSelfIntersections(MEANDER_SHAPE *aShape, int aClearance)
Check if the given shape is intersecting with any other meander in the current line.
int BaselineLength() const
bool m_side
The actual shapes (0 used for single, both for dual).
The geometry of a single meander.
Implementation of conversion functions that require both schematic and board internal units.
void SetPoint(int aIndex, const VECTOR2I &aPos)
Accessor Function to move a point to a specific location.
MEANDER_PLACER_BASE * m_placer
VECTOR2< T > Perpendicular() const
Compute the perpendicular vector.
MEANDER_TYPE
Shapes of available meanders.
VECTOR2I m_p0
Base segment (unclipped).
void AddCorner(const VECTOR2I &aA, const VECTOR2I &aB=VECTOR2I(0, 0))
Create a dummy meander shape representing a line corner.
void MeanderSegment(const SEG &aSeg, int aBaseIndex=0)
Fit maximum amplitude meanders on a given segment and adds to the current line.
SHAPE_LINE_CHAIN * m_currentTarget
std::vector< MEANDER_SHAPE * > m_meanders
void Clear()
Clear the line geometry, removing all corners and meanders.
int m_baseIndex
The current turtle direction.
MEANDER_TYPE Type() const
Dimensions for the meandering algorithm.
void Recalculate()
Recalculate the line chain representing the meander's shape.
virtual bool CheckFit(MEANDER_SHAPE *aShape)
Checks if it's OK to place the shape aShape (i.e.
MEANDER_STYLE m_cornerStyle
Rounding percentage (0 - 100).
int PointCount() const
Function PointCount()
const MEANDER_SETTINGS & Settings() const
void Append(int aX, int aY, bool aAllowDuplication=false)
Function Append()
virtual bool Collide(const VECTOR2I &aP, int aClearance=0, int *aActual=nullptr, VECTOR2I *aLocation=nullptr) const override
Check if point aP lies closer to us than aClearance.
void Resize(int aAmpl)
Change the amplitude of the meander shape to aAmpl and recalculates the resulting line chain.
void miter(int aRadius, bool aSide)
Tell the turtle to draw an U-like shape.
const VECTOR2I & CPoint(int aIndex) const
Function Point()
void MakeCorner(VECTOR2I aP1, VECTOR2I aP2=VECTOR2I(0, 0))
Create a dummy meander shape representing a line corner.
int m_step
Length PadToDie.
VECTOR2I LineProject(const VECTOR2I &aP) const
Compute the perpendicular projection point of aP on a line passing through ends of the segment.
bool ApproxParallel(const SEG &aSeg) const
void start(SHAPE_LINE_CHAIN *aTarget, const VECTOR2D &aWhere, const VECTOR2D &aDir)
Move turtle forward by aLength.
void AddMeander(MEANDER_SHAPE *aShape)
Add a new meander shape the the meandered line.
VECTOR2I::extended_type ecoord
MEANDER_TYPE m_type
The placer that placed this meander.
SHAPE_LINE_CHAIN makeMiterShape(VECTOR2D aP, VECTOR2D aDir, bool aSide)
Reflect a point onto other side of a given segment.
const SHAPE_LINE_CHAIN & CLine(int aShape) const
int m_cornerRadiusPercentage
Allowable tuning error.
int m_meanCornerRadius
First point of the meandered line.
const SEG & BaseSegment() const
Return the base segment the meander was fitted to.
void turn(int aAngle)
Tell the turtle to draw a mitered corner of given radius and turn direction.
MEANDER_PLACER_BASE * m_placer
Dual or single line.
int m_width
Amplitude of the meander.
SHAPE_LINE_CHAIN m_shapes[2]
Index of the meandered segment in the base line.
int MaxTunableLength() const
int SegmentCount() const
Function SegmentCount()
void forward(int aLength)
Turn the turtle by aAngle.
int m_baselineOffset
Average radius of meander corners (for correction of DP meanders).
const MEANDER_SETTINGS & Settings() const
int m_amplitude
Offset wrs the base segment (dual only).
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 feature...
int m_cornerArcSegments
Target skew value for diff pair de-skewing.
VECTOR2< T > Resize(T aNewLength) const
Return a vector of the same direction, but length specified in aNewLength.
void MakeEmpty()
Replace the meander with straight bypass line(s), effectively clearing it.
VECTOR2< T > Rotate(double aAngle) const
Rotate the vector by a given angle.
void SetBaseIndex(int aIndex)
Set an auxiliary index of the segment being meandered in its original LINE.
const SEG CSegment(int aIndex) const
Function CSegment()
extended_type Dot(const VECTOR2< T > &aVector) const
Compute dot product of self with aVector.
int cornerRadius() const
Return sanitized spacing value.
SEG m_baseSeg
Base segment (clipped).
T rescale(T aNumerator, T aValue, T aDenominator)
Function rescale()
void Clear()
Function Clear() Removes all points from the line chain.
VECTOR2I reflect(VECTOR2I aP, const SEG &aLine)
Produce a meander shape of given type.
void updateBaseSegment()
Return sanitized corner radius value.
bool m_dual
Width of the line.
int m_spacing
Amplitude/spacing adjustment step.
T EuclideanNorm() const
Compute the Euclidean norm of the vector, which is defined as sqrt(x ** 2 + y ** 2).
int spacing() const
The type of meander.
Push and Shove diff pair dimensions (gap) settings dialog.
VECTOR2D m_currentPos
The line the turtle is drawing on.
virtual const MEANDER_SETTINGS & MeanderSettings() const
Return the current meandering configuration.
void SetType(MEANDER_TYPE aType)
Set the type of the meander.
SEG m_clippedBaseSeg
Side (true = right).
VECTOR2D m_currentDir
The current turtle position.
int m_maxAmplitude
Meandering period/spacing (see dialog picture for explanation).
bool Contains(const SEG &aSeg) const