2015-02-18 00:29:54 +00:00
|
|
|
/*
|
|
|
|
* KiRouter - a push-and-(sometimes-)shove PCB router
|
|
|
|
*
|
|
|
|
* Copyright (C) 2013-2015 CERN
|
2022-12-04 04:52:21 +00:00
|
|
|
* Copyright (C) 2016-2022 KiCad Developers, see AUTHORS.txt for contributors.
|
2021-01-27 22:15:38 +00:00
|
|
|
*
|
|
|
|
* @author Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
|
2015-02-18 00:29:54 +00:00
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify it
|
|
|
|
* under the terms of the GNU General Public License as published by the
|
|
|
|
* Free Software Foundation, either version 3 of the License, or (at your
|
|
|
|
* option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful, but
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __PNS_MEANDER_H
|
|
|
|
#define __PNS_MEANDER_H
|
|
|
|
|
|
|
|
#include <math/vector2d.h>
|
2023-10-16 23:27:08 +00:00
|
|
|
#include <core/minoptmax.h>
|
2015-02-18 00:29:54 +00:00
|
|
|
|
|
|
|
#include <geometry/shape.h>
|
|
|
|
#include <geometry/shape_line_chain.h>
|
|
|
|
|
2016-08-29 14:38:11 +00:00
|
|
|
namespace PNS {
|
|
|
|
|
2016-08-29 17:31:13 +00:00
|
|
|
class MEANDER_PLACER_BASE;
|
2021-01-27 22:15:38 +00:00
|
|
|
class MEANDERED_LINE;
|
2015-02-18 00:29:54 +00:00
|
|
|
|
2021-01-27 22:15:38 +00:00
|
|
|
///< Shapes of available meanders.
|
2016-08-29 17:31:13 +00:00
|
|
|
enum MEANDER_TYPE {
|
2015-02-18 00:29:54 +00:00
|
|
|
MT_SINGLE, // _|^|_, single-sided
|
|
|
|
MT_START, // _|^|
|
|
|
|
MT_FINISH, // |^|_
|
|
|
|
MT_TURN, // |^| or |_|
|
|
|
|
MT_CHECK_START, // try fitting a start type, but don't produce a line
|
|
|
|
MT_CHECK_FINISH, // try fitting a finish type, but don't produce a line
|
|
|
|
MT_CORNER, // line corner
|
2021-08-09 20:00:35 +00:00
|
|
|
MT_ARC, // arc corner
|
2015-02-18 00:29:54 +00:00
|
|
|
MT_EMPTY // no meander (straight line)
|
|
|
|
};
|
|
|
|
|
2021-01-27 22:15:38 +00:00
|
|
|
///< Meander corner shape.
|
2016-08-29 17:31:13 +00:00
|
|
|
enum MEANDER_STYLE {
|
2016-08-15 15:16:49 +00:00
|
|
|
MEANDER_STYLE_ROUND = 1, // rounded (90 degree arc)
|
|
|
|
MEANDER_STYLE_CHAMFER // chamfered (45 degree segment)
|
|
|
|
};
|
|
|
|
|
2023-10-07 03:54:14 +00:00
|
|
|
///< Initial side the meander is placed on.
|
|
|
|
enum MEANDER_SIDE
|
|
|
|
{
|
|
|
|
MEANDER_SIDE_LEFT = -1,
|
|
|
|
MEANDER_SIDE_DEFAULT = 0,
|
|
|
|
MEANDER_SIDE_RIGHT = 1
|
|
|
|
};
|
|
|
|
|
2015-02-18 00:29:54 +00:00
|
|
|
/**
|
2021-01-27 22:15:38 +00:00
|
|
|
* Dimensions for the meandering algorithm.
|
2015-02-18 00:29:54 +00:00
|
|
|
*/
|
2016-08-29 17:31:13 +00:00
|
|
|
class MEANDER_SETTINGS
|
2015-02-18 00:29:54 +00:00
|
|
|
{
|
2023-10-16 23:27:08 +00:00
|
|
|
#define DEFAULT_TOLERANCE 100000
|
|
|
|
|
2015-02-18 00:29:54 +00:00
|
|
|
public:
|
|
|
|
|
2016-08-29 17:31:13 +00:00
|
|
|
MEANDER_SETTINGS()
|
2015-02-18 00:29:54 +00:00
|
|
|
{
|
|
|
|
m_minAmplitude = 100000;
|
|
|
|
m_maxAmplitude = 1000000;
|
|
|
|
m_step = 50000;
|
2019-10-31 13:00:01 +00:00
|
|
|
m_lenPadToDie = 0;
|
2015-02-18 00:29:54 +00:00
|
|
|
m_spacing = 600000;
|
2023-10-16 23:27:08 +00:00
|
|
|
SetTargetLength( 100000000 );
|
|
|
|
SetTargetSkew( 0 );
|
2023-10-11 10:48:43 +00:00
|
|
|
m_overrideCustomRules = false;
|
2016-08-15 15:16:49 +00:00
|
|
|
m_cornerStyle = MEANDER_STYLE_ROUND;
|
2015-02-18 00:29:54 +00:00
|
|
|
m_cornerRadiusPercentage = 100;
|
2022-11-29 00:13:51 +00:00
|
|
|
m_singleSided = false;
|
2023-10-16 12:12:17 +00:00
|
|
|
m_initialSide = MEANDER_SIDE_LEFT;
|
2023-10-23 17:48:45 +00:00
|
|
|
m_lengthTolerance = 0;
|
2023-11-12 09:17:03 +00:00
|
|
|
m_keepEndpoints = false;
|
2023-10-16 23:27:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void SetTargetLength( long long int aOpt )
|
|
|
|
{
|
|
|
|
m_targetLength.SetOpt( aOpt );
|
|
|
|
m_targetLength.SetMin( aOpt - DEFAULT_TOLERANCE );
|
|
|
|
m_targetLength.SetMax( aOpt + DEFAULT_TOLERANCE );
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetTargetLength( const MINOPTMAX<int>& aConstraint )
|
|
|
|
{
|
|
|
|
SetTargetLength( aConstraint.Opt() );
|
|
|
|
|
|
|
|
if( aConstraint.HasMin() )
|
|
|
|
m_targetLength.SetMin( aConstraint.Min() );
|
|
|
|
|
|
|
|
if( aConstraint.HasMax() )
|
|
|
|
m_targetLength.SetMax( aConstraint.Max() );
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetTargetSkew( int aOpt )
|
|
|
|
{
|
|
|
|
m_targetSkew.SetOpt( aOpt );
|
|
|
|
m_targetSkew.SetMin( aOpt - DEFAULT_TOLERANCE );
|
|
|
|
m_targetSkew.SetMax( aOpt + DEFAULT_TOLERANCE );
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetTargetSkew( const MINOPTMAX<int>& aConstraint )
|
|
|
|
{
|
|
|
|
SetTargetSkew( aConstraint.Opt() );
|
|
|
|
|
|
|
|
if( aConstraint.HasMin() )
|
|
|
|
m_targetSkew.SetMin( aConstraint.Min() );
|
|
|
|
|
|
|
|
if( aConstraint.HasMax() )
|
|
|
|
m_targetSkew.SetMax( aConstraint.Max() );
|
2015-02-18 00:29:54 +00:00
|
|
|
}
|
2015-02-18 16:53:46 +00:00
|
|
|
|
2021-01-27 22:15:38 +00:00
|
|
|
///< Minimum meandering amplitude.
|
2015-02-18 00:29:54 +00:00
|
|
|
int m_minAmplitude;
|
2021-07-19 23:56:05 +00:00
|
|
|
|
2021-01-27 22:15:38 +00:00
|
|
|
///< Maximum meandering amplitude.
|
2015-02-18 00:29:54 +00:00
|
|
|
int m_maxAmplitude;
|
2021-07-19 23:56:05 +00:00
|
|
|
|
2021-01-27 22:15:38 +00:00
|
|
|
///< Meandering period/spacing (see dialog picture for explanation).
|
2015-02-18 00:29:54 +00:00
|
|
|
int m_spacing;
|
2021-07-19 23:56:05 +00:00
|
|
|
|
2021-01-27 22:15:38 +00:00
|
|
|
///< Amplitude/spacing adjustment step.
|
2015-02-18 00:29:54 +00:00
|
|
|
int m_step;
|
2021-07-19 23:56:05 +00:00
|
|
|
|
2021-01-27 22:15:38 +00:00
|
|
|
///< Length PadToDie.
|
2019-10-31 13:00:01 +00:00
|
|
|
int m_lenPadToDie;
|
2021-07-19 23:56:05 +00:00
|
|
|
|
2021-01-27 22:15:38 +00:00
|
|
|
///< Desired length of the tuned line/diff pair (this is in nm, so allow more than board width).
|
2023-10-16 23:27:08 +00:00
|
|
|
MINOPTMAX<long long int> m_targetLength;
|
2021-07-19 23:56:05 +00:00
|
|
|
|
2023-10-11 10:48:43 +00:00
|
|
|
///< Target skew value for diff pair de-skewing.
|
2023-10-16 23:27:08 +00:00
|
|
|
MINOPTMAX<int> m_targetSkew;
|
2023-10-11 10:48:43 +00:00
|
|
|
|
2023-10-16 23:27:08 +00:00
|
|
|
bool m_overrideCustomRules;
|
2023-10-11 10:48:43 +00:00
|
|
|
|
2021-01-27 22:15:38 +00:00
|
|
|
///< Type of corners for the meandered line.
|
2016-08-29 17:31:13 +00:00
|
|
|
MEANDER_STYLE m_cornerStyle;
|
2021-07-19 23:56:05 +00:00
|
|
|
|
2021-01-27 22:15:38 +00:00
|
|
|
///< Rounding percentage (0 - 100).
|
2015-02-18 00:29:54 +00:00
|
|
|
int m_cornerRadiusPercentage;
|
2021-07-19 23:56:05 +00:00
|
|
|
|
2022-11-29 00:13:51 +00:00
|
|
|
///< Place meanders on one side.
|
|
|
|
bool m_singleSided;
|
|
|
|
|
2023-10-07 03:54:14 +00:00
|
|
|
///< Initial side when placing meanders at segment
|
2023-10-16 12:12:17 +00:00
|
|
|
MEANDER_SIDE m_initialSide;
|
2023-10-07 03:25:27 +00:00
|
|
|
|
2021-01-27 22:15:38 +00:00
|
|
|
///< Allowable tuning error.
|
2015-02-18 16:53:46 +00:00
|
|
|
int m_lengthTolerance;
|
2023-11-12 09:17:03 +00:00
|
|
|
|
|
|
|
///< Keep vertices between pre, tuned and post parts of the line.
|
|
|
|
bool m_keepEndpoints;
|
2015-02-18 00:29:54 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
2021-01-27 22:15:38 +00:00
|
|
|
* The geometry of a single meander.
|
2015-02-18 00:29:54 +00:00
|
|
|
*/
|
2016-08-29 17:31:13 +00:00
|
|
|
class MEANDER_SHAPE
|
2015-02-18 00:29:54 +00:00
|
|
|
{
|
2015-02-18 16:53:46 +00:00
|
|
|
public:
|
|
|
|
/**
|
2021-01-27 22:15:38 +00:00
|
|
|
* @param aPlacer the meander placer instance.
|
|
|
|
* @param aWidth width of the meandered line.
|
2015-02-18 16:53:46 +00:00
|
|
|
* @param aIsDual when true, the shape contains two meandered
|
2021-01-27 22:15:38 +00:00
|
|
|
* lines at a given offset (diff pairs).
|
2015-02-18 16:53:46 +00:00
|
|
|
*/
|
2016-08-29 17:31:13 +00:00
|
|
|
MEANDER_SHAPE( MEANDER_PLACER_BASE* aPlacer, int aWidth, bool aIsDual = false ) :
|
2015-02-18 16:53:46 +00:00
|
|
|
m_placer( aPlacer ),
|
|
|
|
m_dual( aIsDual ),
|
|
|
|
m_width( aWidth ),
|
|
|
|
m_baselineOffset( 0 )
|
2015-08-28 14:15:45 +00:00
|
|
|
{
|
2021-01-27 22:15:38 +00:00
|
|
|
// Do not leave uninitialized members, and keep static analyzer quiet:
|
2015-04-28 15:07:36 +00:00
|
|
|
m_type = MT_SINGLE;
|
|
|
|
m_amplitude = 0;
|
2022-12-04 04:52:21 +00:00
|
|
|
m_targetBaseLen = 0;
|
2015-04-28 15:07:36 +00:00
|
|
|
m_side = false;
|
|
|
|
m_baseIndex = 0;
|
2021-07-19 23:56:05 +00:00
|
|
|
m_currentTarget = nullptr;
|
2015-08-28 14:15:45 +00:00
|
|
|
m_meanCornerRadius = 0;
|
|
|
|
}
|
2015-02-18 16:53:46 +00:00
|
|
|
|
|
|
|
/**
|
2021-01-27 22:15:38 +00:00
|
|
|
* Set the type of the meander.
|
2015-02-18 16:53:46 +00:00
|
|
|
*/
|
2016-08-29 17:31:13 +00:00
|
|
|
void SetType( MEANDER_TYPE aType )
|
2015-02-18 16:53:46 +00:00
|
|
|
{
|
|
|
|
m_type = aType;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return the type of the meander.
|
|
|
|
*/
|
2016-08-29 17:31:13 +00:00
|
|
|
MEANDER_TYPE Type() const
|
2015-02-18 16:53:46 +00:00
|
|
|
{
|
|
|
|
return m_type;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2021-01-27 22:15:38 +00:00
|
|
|
* Set an auxiliary index of the segment being meandered in its original LINE.
|
2015-02-18 16:53:46 +00:00
|
|
|
*/
|
|
|
|
void SetBaseIndex( int aIndex )
|
|
|
|
{
|
|
|
|
m_baseIndex = aIndex;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2021-01-27 22:15:38 +00:00
|
|
|
* @return auxiliary index of the segment being meandered in its original LINE.
|
2015-02-18 16:53:46 +00:00
|
|
|
*/
|
|
|
|
int BaseIndex() const
|
|
|
|
{
|
|
|
|
return m_baseIndex;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return the amplitude of the meander shape.
|
|
|
|
*/
|
|
|
|
int Amplitude() const
|
|
|
|
{
|
|
|
|
return m_amplitude;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2021-01-27 22:15:38 +00:00
|
|
|
* Create a dummy meander shape representing a line corner. Used to define
|
2015-02-18 16:53:46 +00:00
|
|
|
* the starts/ends of meandered segments.
|
2021-01-27 22:15:38 +00:00
|
|
|
*
|
|
|
|
* @param aP1 corner point of the 1st line.
|
|
|
|
* @param aP2 corner point of the 2nd line (if m_dual == true).
|
2015-02-18 16:53:46 +00:00
|
|
|
*/
|
2021-07-26 23:47:26 +00:00
|
|
|
void MakeCorner( const VECTOR2I& aP1, const VECTOR2I& aP2 = VECTOR2I( 0, 0 ) );
|
2015-02-18 16:53:46 +00:00
|
|
|
|
2021-08-09 20:00:35 +00:00
|
|
|
/**
|
|
|
|
* Create a dummy meander shape representing an arc corner. Allows representing existing
|
|
|
|
* arc tracks so they can be reconstructed after length tuning.
|
|
|
|
*
|
|
|
|
* @param aArc1 Arc shape on the 1st line.
|
|
|
|
* @param aArc2 Arc shape on the 2nd line (if m_dual == true).
|
|
|
|
*/
|
|
|
|
void MakeArc( const SHAPE_ARC& aArc1, const SHAPE_ARC& aArc2 = SHAPE_ARC() );
|
|
|
|
|
2015-02-18 16:53:46 +00:00
|
|
|
/**
|
2021-01-27 22:15:38 +00:00
|
|
|
* Change the amplitude of the meander shape to aAmpl and recalculates the resulting
|
|
|
|
* line chain.
|
2015-02-18 16:53:46 +00:00
|
|
|
*
|
|
|
|
* @param aAmpl new amplitude.
|
|
|
|
*/
|
|
|
|
void Resize( int aAmpl );
|
|
|
|
|
|
|
|
/**
|
2021-01-27 22:15:38 +00:00
|
|
|
* Recalculate the line chain representing the meander's shape.
|
2015-02-18 16:53:46 +00:00
|
|
|
*/
|
|
|
|
void Recalculate();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return true if the shape represents 2 parallel lines (diff pair).
|
|
|
|
*/
|
|
|
|
bool IsDual() const
|
|
|
|
{
|
|
|
|
return m_dual;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return true if the meander is to the right of its base segment.
|
|
|
|
*/
|
|
|
|
bool Side() const
|
|
|
|
{
|
|
|
|
return m_side;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return end vertex of the base segment of the meander shape.
|
|
|
|
*/
|
|
|
|
VECTOR2I End() const
|
|
|
|
{
|
|
|
|
return m_clippedBaseSeg.B;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return the line chain representing the shape of the meander.
|
|
|
|
*/
|
|
|
|
const SHAPE_LINE_CHAIN& CLine( int aShape ) const
|
|
|
|
{
|
|
|
|
return m_shapes[aShape];
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2021-01-27 22:15:38 +00:00
|
|
|
* Replace the meander with straight bypass line(s), effectively clearing it.
|
2015-02-18 16:53:46 +00:00
|
|
|
*/
|
|
|
|
void MakeEmpty();
|
|
|
|
|
|
|
|
/**
|
2021-01-27 22:15:38 +00:00
|
|
|
* Attempt to fit a meander of a given type onto a segment, avoiding collisions with other
|
|
|
|
* board features.
|
2015-02-18 16:53:46 +00:00
|
|
|
*
|
2021-01-27 22:15:38 +00:00
|
|
|
* @param aType type of meander shape.
|
|
|
|
* @param aSeg base segment for meandering.
|
|
|
|
* @param aP start point of the meander.
|
|
|
|
* @param aSide side of aSeg to put the meander on (true = right).
|
2015-02-18 16:53:46 +00:00
|
|
|
* @return true on success.
|
|
|
|
*/
|
2016-08-29 17:31:13 +00:00
|
|
|
bool Fit( MEANDER_TYPE aType, const SEG& aSeg, const VECTOR2I& aP, bool aSide );
|
2015-02-18 16:53:46 +00:00
|
|
|
|
|
|
|
/**
|
2021-01-27 22:15:38 +00:00
|
|
|
* Return the base segment the meander was fitted to.
|
2015-02-18 16:53:46 +00:00
|
|
|
*
|
|
|
|
* @return the base segment.
|
|
|
|
*/
|
|
|
|
const SEG& BaseSegment() const
|
|
|
|
{
|
|
|
|
return m_clippedBaseSeg;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2021-01-27 22:15:38 +00:00
|
|
|
* @return length of the base segment for the meander (i.e.the minimum tuned length).
|
2015-02-18 16:53:46 +00:00
|
|
|
*/
|
|
|
|
int BaselineLength() const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return the length of the fitted line chain.
|
|
|
|
*/
|
2022-12-04 04:52:21 +00:00
|
|
|
long long int CurrentLength() const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return the minumum tunable length according to settings.
|
|
|
|
*/
|
|
|
|
long long int MinTunableLength() const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return the minumum possible amplitude according to settings.
|
|
|
|
*/
|
|
|
|
int MinAmplitude() const;
|
2015-02-18 16:53:46 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @return the current meandering settings.
|
|
|
|
*/
|
2016-08-29 17:31:13 +00:00
|
|
|
const MEANDER_SETTINGS& Settings() const;
|
2015-02-18 16:53:46 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @return width of the meandered line.
|
|
|
|
*/
|
|
|
|
int Width() const
|
|
|
|
{
|
|
|
|
return m_width;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2021-01-27 22:15:38 +00:00
|
|
|
* Set the parallel offset between the base segment and the meandered line. Used for
|
|
|
|
* dual meanders (diff pair) only.
|
2015-02-18 16:53:46 +00:00
|
|
|
*
|
2021-01-27 22:15:38 +00:00
|
|
|
* @param aOffset the offset.
|
2015-02-18 16:53:46 +00:00
|
|
|
*/
|
|
|
|
void SetBaselineOffset( int aOffset )
|
|
|
|
{
|
|
|
|
m_baselineOffset = aOffset;
|
|
|
|
}
|
|
|
|
|
2022-12-04 04:52:21 +00:00
|
|
|
/**
|
|
|
|
* Sets the target length of the baseline. When resizing, the meander will try to
|
|
|
|
* fit the baseline length into the specified value.
|
|
|
|
*
|
|
|
|
* @param aLength the minimum baseline length.
|
|
|
|
*/
|
|
|
|
void SetTargetBaselineLength( int aLength ) { m_targetBaseLen = aLength; }
|
|
|
|
|
2015-02-18 16:53:46 +00:00
|
|
|
private:
|
2016-08-29 17:31:13 +00:00
|
|
|
friend class MEANDERED_LINE;
|
2015-02-18 16:53:46 +00:00
|
|
|
|
2021-01-27 22:15:38 +00:00
|
|
|
///< Start turtle drawing
|
2015-02-18 16:53:46 +00:00
|
|
|
void start( SHAPE_LINE_CHAIN* aTarget, const VECTOR2D& aWhere, const VECTOR2D& aDir );
|
2021-01-27 22:15:38 +00:00
|
|
|
|
|
|
|
///< Move turtle forward by \a aLength.
|
2015-02-18 16:53:46 +00:00
|
|
|
void forward( int aLength );
|
2021-01-27 22:15:38 +00:00
|
|
|
|
|
|
|
///< Turn the turtle by \a aAngle
|
2022-01-20 21:26:04 +00:00
|
|
|
void turn( const EDA_ANGLE& aAngle );
|
2021-01-27 22:15:38 +00:00
|
|
|
|
|
|
|
///< Tell the turtle to draw a mitered corner of given radius and turn direction.
|
2016-08-15 15:16:49 +00:00
|
|
|
void miter( int aRadius, bool aSide );
|
2021-01-27 22:15:38 +00:00
|
|
|
|
|
|
|
///< Tell the turtle to draw an U-like shape.
|
2015-02-18 16:53:46 +00:00
|
|
|
void uShape( int aSides, int aCorner, int aTop );
|
|
|
|
|
2021-01-27 22:15:38 +00:00
|
|
|
///< Generate a 90-degree circular arc.
|
2021-07-26 23:47:26 +00:00
|
|
|
SHAPE_LINE_CHAIN makeMiterShape( const VECTOR2D& aP, const VECTOR2D& aDir, bool aSide );
|
2015-02-18 16:53:46 +00:00
|
|
|
|
2021-01-27 22:15:38 +00:00
|
|
|
///< Produce a meander shape of given type.
|
2021-07-26 23:47:26 +00:00
|
|
|
SHAPE_LINE_CHAIN genMeanderShape( const VECTOR2D& aP, const VECTOR2D& aDir, bool aSide,
|
2022-12-04 04:52:21 +00:00
|
|
|
MEANDER_TYPE aType, int aBaselineOffset = 0 );
|
2015-02-18 16:53:46 +00:00
|
|
|
|
2021-01-27 22:15:38 +00:00
|
|
|
///< Recalculate the clipped baseline after the parameters of the meander have been changed.
|
2015-02-18 16:53:46 +00:00
|
|
|
void updateBaseSegment();
|
|
|
|
|
2021-01-27 22:15:38 +00:00
|
|
|
///< Return sanitized corner radius value.
|
2015-02-18 16:53:46 +00:00
|
|
|
int cornerRadius() const;
|
|
|
|
|
2021-01-27 22:15:38 +00:00
|
|
|
///< Return sanitized spacing value.
|
2015-02-18 16:53:46 +00:00
|
|
|
int spacing() const;
|
|
|
|
|
2021-01-27 22:15:38 +00:00
|
|
|
///< The type of meander.
|
2016-08-29 17:31:13 +00:00
|
|
|
MEANDER_TYPE m_type;
|
2021-01-27 22:15:38 +00:00
|
|
|
|
|
|
|
///< The placer that placed this meander.
|
2016-08-29 17:31:13 +00:00
|
|
|
MEANDER_PLACER_BASE* m_placer;
|
2021-01-27 22:15:38 +00:00
|
|
|
|
|
|
|
///< Dual or single line.
|
2015-02-18 16:53:46 +00:00
|
|
|
bool m_dual;
|
2021-01-27 22:15:38 +00:00
|
|
|
|
|
|
|
///< Width of the line.
|
2015-02-18 16:53:46 +00:00
|
|
|
int m_width;
|
2021-01-27 22:15:38 +00:00
|
|
|
|
|
|
|
///< Amplitude of the meander.
|
2015-02-18 16:53:46 +00:00
|
|
|
int m_amplitude;
|
2021-01-27 22:15:38 +00:00
|
|
|
|
|
|
|
///< Offset wrs the base segment (dual only).
|
2015-02-18 16:53:46 +00:00
|
|
|
int m_baselineOffset;
|
2021-01-27 22:15:38 +00:00
|
|
|
|
|
|
|
///< Average radius of meander corners (for correction of DP meanders).
|
2015-08-21 14:37:44 +00:00
|
|
|
int m_meanCornerRadius;
|
2021-01-27 22:15:38 +00:00
|
|
|
|
2022-12-04 04:52:21 +00:00
|
|
|
///< Minimum length of the base segment to target when resizing.
|
|
|
|
int m_targetBaseLen;
|
|
|
|
|
2021-01-27 22:15:38 +00:00
|
|
|
///< First point of the meandered line.
|
2015-02-18 16:53:46 +00:00
|
|
|
VECTOR2I m_p0;
|
2021-01-27 22:15:38 +00:00
|
|
|
|
|
|
|
///< Base segment (unclipped).
|
2015-02-18 16:53:46 +00:00
|
|
|
SEG m_baseSeg;
|
2021-01-27 22:15:38 +00:00
|
|
|
|
|
|
|
///< Base segment (clipped).
|
2015-02-18 16:53:46 +00:00
|
|
|
SEG m_clippedBaseSeg;
|
2021-01-27 22:15:38 +00:00
|
|
|
|
|
|
|
///< Side (true = right).
|
2015-02-18 16:53:46 +00:00
|
|
|
bool m_side;
|
2021-01-27 22:15:38 +00:00
|
|
|
|
|
|
|
///< The actual shapes (0 used for single, both for dual).
|
2015-02-18 16:53:46 +00:00
|
|
|
SHAPE_LINE_CHAIN m_shapes[2];
|
2021-01-27 22:15:38 +00:00
|
|
|
|
|
|
|
///< Index of the meandered segment in the base line.
|
2015-02-18 16:53:46 +00:00
|
|
|
int m_baseIndex;
|
2021-01-27 22:15:38 +00:00
|
|
|
|
|
|
|
///< The current turtle direction.
|
2015-02-18 16:53:46 +00:00
|
|
|
VECTOR2D m_currentDir;
|
2021-01-27 22:15:38 +00:00
|
|
|
|
|
|
|
///< The current turtle position.
|
2015-02-18 16:53:46 +00:00
|
|
|
VECTOR2D m_currentPos;
|
2021-01-27 22:15:38 +00:00
|
|
|
|
|
|
|
///< The line the turtle is drawing on.
|
2015-02-18 16:53:46 +00:00
|
|
|
SHAPE_LINE_CHAIN* m_currentTarget;
|
2015-02-18 00:29:54 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2021-01-27 22:15:38 +00:00
|
|
|
* Represent a set of meanders fitted over a single or two lines.
|
2015-02-18 00:29:54 +00:00
|
|
|
*/
|
2016-08-29 17:31:13 +00:00
|
|
|
class MEANDERED_LINE
|
2015-02-18 00:29:54 +00:00
|
|
|
{
|
2015-02-18 16:53:46 +00:00
|
|
|
public:
|
2016-08-29 17:31:13 +00:00
|
|
|
MEANDERED_LINE()
|
2015-02-18 16:53:46 +00:00
|
|
|
{
|
2021-01-27 22:15:38 +00:00
|
|
|
// Do not leave uninitialized members, and keep static analyzer quiet:
|
2021-07-19 23:56:05 +00:00
|
|
|
m_placer = nullptr;
|
2015-04-28 15:07:36 +00:00
|
|
|
m_dual = false;
|
|
|
|
m_width = 0;
|
|
|
|
m_baselineOffset = 0;
|
2015-02-18 16:53:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param aPlacer the meander placer instance
|
|
|
|
* @param aIsDual when true, the meanders are generated for two coupled lines
|
|
|
|
*/
|
2016-08-29 17:31:13 +00:00
|
|
|
MEANDERED_LINE( MEANDER_PLACER_BASE* aPlacer, bool aIsDual = false ) :
|
2015-02-18 16:53:46 +00:00
|
|
|
m_placer( aPlacer ),
|
|
|
|
m_dual( aIsDual )
|
|
|
|
{
|
2021-01-27 22:15:38 +00:00
|
|
|
// Do not leave uninitialized members, and keep static analyzer quiet:
|
2015-04-28 15:07:36 +00:00
|
|
|
m_width = 0;
|
|
|
|
m_baselineOffset = 0;
|
2015-02-18 16:53:46 +00:00
|
|
|
}
|
|
|
|
|
2016-08-29 17:31:13 +00:00
|
|
|
~MEANDERED_LINE()
|
2015-11-09 12:11:27 +00:00
|
|
|
{
|
|
|
|
Clear();
|
|
|
|
}
|
|
|
|
|
2015-02-18 16:53:46 +00:00
|
|
|
/**
|
2021-01-27 22:15:38 +00:00
|
|
|
* Create a dummy meander shape representing a line corner. Used to define the starts/ends
|
|
|
|
* of meandered segments.
|
2015-02-18 16:53:46 +00:00
|
|
|
*
|
2021-01-27 22:15:38 +00:00
|
|
|
* @param aA corner point of the 1st line.
|
|
|
|
* @param aB corner point of the 2nd line (if m_dual == true).
|
2015-02-18 16:53:46 +00:00
|
|
|
*/
|
|
|
|
void AddCorner( const VECTOR2I& aA, const VECTOR2I& aB = VECTOR2I( 0, 0 ) );
|
|
|
|
|
2021-08-09 20:00:35 +00:00
|
|
|
/**
|
|
|
|
* Create a dummy meander shape representing an arc corner. Allows representing existing
|
|
|
|
* arc tracks so they can be reconstructed after length tuning.
|
|
|
|
*
|
|
|
|
* @param aArc1 Arc shape on the 1st line.
|
|
|
|
* @param aArc2 Arc shape on the 2nd line (if m_dual == true).
|
|
|
|
*/
|
|
|
|
void AddArc( 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.
|
|
|
|
*
|
|
|
|
* @param aArc1 Arc shape on the 1st line.
|
|
|
|
* @param aPt2 corner point of the 2nd line (if m_dual == true).
|
|
|
|
*/
|
|
|
|
void AddArcAndPt( const SHAPE_ARC& aArc1, const VECTOR2I& aPt2 );
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Create a dummy meander shape representing an arc corner. Allows representing existing
|
|
|
|
* arc tracks so they can be reconstructed after length tuning.
|
|
|
|
*
|
|
|
|
* @param aPt1 corner point of the 1st line.
|
|
|
|
* @param aArc2 Arc shape on the 2nd line (if m_dual == true).
|
|
|
|
*/
|
|
|
|
void AddPtAndArc( const VECTOR2I& aPt1, const SHAPE_ARC& aArc2 );
|
|
|
|
|
2015-02-18 16:53:46 +00:00
|
|
|
/**
|
2021-06-09 19:32:58 +00:00
|
|
|
* Add a new meander shape to the meandered line.
|
2015-02-18 16:53:46 +00:00
|
|
|
*
|
|
|
|
* @param aShape the meander shape to add
|
|
|
|
*/
|
2016-08-29 17:31:13 +00:00
|
|
|
void AddMeander( MEANDER_SHAPE* aShape );
|
2015-02-18 16:53:46 +00:00
|
|
|
|
|
|
|
/**
|
2021-01-27 22:15:38 +00:00
|
|
|
* Clear the line geometry, removing all corners and meanders.
|
2015-02-18 16:53:46 +00:00
|
|
|
*/
|
|
|
|
void Clear();
|
|
|
|
|
|
|
|
/**
|
2021-01-27 22:15:38 +00:00
|
|
|
* Set the line width.
|
2015-02-18 16:53:46 +00:00
|
|
|
*/
|
|
|
|
void SetWidth( int aWidth )
|
|
|
|
{
|
|
|
|
m_width = aWidth;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2021-01-27 22:15:38 +00:00
|
|
|
* Fit maximum amplitude meanders on a given segment and adds to the current line.
|
2015-02-18 16:53:46 +00:00
|
|
|
*
|
2021-01-27 22:15:38 +00:00
|
|
|
* @param aSeg the base segment to meander.
|
2021-09-28 17:19:58 +00:00
|
|
|
* @param aSide Side to start meandering the segment. True=left, False=Right
|
2021-01-27 22:15:38 +00:00
|
|
|
* @param aBaseIndex index of the base segment in the original line.
|
2015-02-18 16:53:46 +00:00
|
|
|
*/
|
2021-09-28 17:19:58 +00:00
|
|
|
void MeanderSegment( const SEG& aSeg, bool aSide, int aBaseIndex = 0 );
|
2015-02-18 16:53:46 +00:00
|
|
|
|
2016-08-29 17:31:13 +00:00
|
|
|
/// @copydoc MEANDER_SHAPE::SetBaselineOffset()
|
2015-02-18 16:53:46 +00:00
|
|
|
void SetBaselineOffset( int aOffset )
|
|
|
|
{
|
|
|
|
m_baselineOffset = aOffset;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2021-01-27 22:15:38 +00:00
|
|
|
* @return set of meander shapes for this line.
|
2015-02-18 16:53:46 +00:00
|
|
|
*/
|
2016-08-29 17:31:13 +00:00
|
|
|
std::vector<MEANDER_SHAPE*>& Meanders()
|
2015-02-18 16:53:46 +00:00
|
|
|
{
|
|
|
|
return m_meanders;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2021-01-27 22:15:38 +00:00
|
|
|
* Check if the given shape is intersecting with any other meander in the current line.
|
2015-02-18 16:53:46 +00:00
|
|
|
*
|
2021-01-27 22:15:38 +00:00
|
|
|
* @param aShape the shape to check.
|
|
|
|
* @param aClearance clearance value.
|
|
|
|
* @return true, if the meander shape is not colliding.
|
2015-02-18 16:53:46 +00:00
|
|
|
*/
|
2016-08-29 17:31:13 +00:00
|
|
|
bool CheckSelfIntersections( MEANDER_SHAPE* aShape, int aClearance );
|
2015-02-18 16:53:46 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @return the current meandering settings.
|
|
|
|
*/
|
2016-08-29 17:31:13 +00:00
|
|
|
const MEANDER_SETTINGS& Settings() const;
|
2015-02-18 16:53:46 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
VECTOR2I m_last;
|
|
|
|
|
2016-08-29 17:31:13 +00:00
|
|
|
MEANDER_PLACER_BASE* m_placer;
|
|
|
|
std::vector<MEANDER_SHAPE*> m_meanders;
|
2015-02-18 16:53:46 +00:00
|
|
|
|
|
|
|
bool m_dual;
|
|
|
|
int m_width;
|
|
|
|
int m_baselineOffset;
|
2015-02-18 00:29:54 +00:00
|
|
|
};
|
|
|
|
|
2016-08-29 14:38:11 +00:00
|
|
|
}
|
|
|
|
|
2015-02-18 00:29:54 +00:00
|
|
|
#endif // __PNS_MEANDER_H
|