2015-02-18 00:29:54 +00:00
|
|
|
/*
|
|
|
|
* KiRouter - a push-and-(sometimes-)shove PCB router
|
|
|
|
*
|
|
|
|
* Copyright (C) 2013-2015 CERN
|
2021-01-27 22:15:38 +00:00
|
|
|
* Copyright (C) 2016-2021 KiCad Developers, see AUTHORS.txt for contributors.
|
|
|
|
*
|
|
|
|
* @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_PLACER_BASE_H
|
|
|
|
#define __PNS_MEANDER_PLACER_BASE_H
|
|
|
|
|
|
|
|
#include <math/vector2d.h>
|
|
|
|
|
|
|
|
#include <geometry/shape_line_chain.h>
|
|
|
|
|
|
|
|
#include "pns_node.h"
|
|
|
|
#include "pns_line.h"
|
|
|
|
#include "pns_placement_algo.h"
|
|
|
|
#include "pns_meander.h"
|
|
|
|
|
2016-08-29 14:38:11 +00:00
|
|
|
namespace PNS {
|
|
|
|
|
2016-08-29 17:31:13 +00:00
|
|
|
class ROUTER;
|
|
|
|
class SHOVE;
|
|
|
|
class OPTIMIZER;
|
2015-02-18 00:29:54 +00:00
|
|
|
|
|
|
|
/**
|
2021-01-27 22:15:38 +00:00
|
|
|
* Base class for Single trace & Differential pair meandering tools, as both of them share a
|
|
|
|
* lot of code.
|
2015-02-18 00:29:54 +00:00
|
|
|
*/
|
2016-08-29 17:31:13 +00:00
|
|
|
class MEANDER_PLACER_BASE : public PLACEMENT_ALGO
|
2015-02-18 00:29:54 +00:00
|
|
|
{
|
|
|
|
public:
|
2021-01-27 22:15:38 +00:00
|
|
|
///< Result of the length tuning operation
|
2015-02-18 00:29:54 +00:00
|
|
|
enum TUNING_STATUS {
|
|
|
|
TOO_SHORT = 0,
|
|
|
|
TOO_LONG,
|
|
|
|
TUNED
|
|
|
|
};
|
|
|
|
|
2016-08-29 17:31:13 +00:00
|
|
|
MEANDER_PLACER_BASE( ROUTER* aRouter );
|
|
|
|
virtual ~MEANDER_PLACER_BASE();
|
2015-02-18 00:29:54 +00:00
|
|
|
|
|
|
|
/**
|
2021-01-27 22:15:38 +00:00
|
|
|
* Return a string describing the status and length of the tuned traces.
|
2015-02-18 00:29:54 +00:00
|
|
|
*/
|
2019-12-20 14:11:39 +00:00
|
|
|
virtual const wxString TuningInfo( EDA_UNITS aUnits ) const = 0;
|
2015-02-18 16:53:46 +00:00
|
|
|
|
2015-02-18 00:29:54 +00:00
|
|
|
/**
|
2021-01-27 22:15:38 +00:00
|
|
|
* Return the tuning status (too short, too long, etc.) of the trace(s) being tuned.
|
2015-02-18 00:29:54 +00:00
|
|
|
*/
|
2015-02-18 16:53:46 +00:00
|
|
|
virtual TUNING_STATUS TuningStatus() const = 0;
|
2015-02-18 00:29:54 +00:00
|
|
|
|
|
|
|
/**
|
2021-01-27 22:15:38 +00:00
|
|
|
* Increase/decreases the current meandering amplitude by one step.
|
2015-02-18 00:29:54 +00:00
|
|
|
*
|
|
|
|
* @param aSign direction (negative = decrease, positive = increase).
|
|
|
|
*/
|
|
|
|
virtual void AmplitudeStep( int aSign );
|
2015-02-18 16:53:46 +00:00
|
|
|
|
2015-02-18 00:29:54 +00:00
|
|
|
/**
|
2021-01-27 22:15:38 +00:00
|
|
|
* Increase/decrease the current meandering spacing by one step.
|
2015-02-18 00:29:54 +00:00
|
|
|
*
|
|
|
|
* @param aSign direction (negative = decrease, positive = increase).
|
|
|
|
*/
|
|
|
|
virtual void SpacingStep( int aSign );
|
|
|
|
|
2021-06-19 20:04:58 +00:00
|
|
|
/**
|
|
|
|
* Return the clearance of the track(s) being length tuned
|
|
|
|
*
|
|
|
|
* @return clearance value in internal units
|
|
|
|
*/
|
|
|
|
virtual int Clearance();
|
|
|
|
|
2015-02-18 00:29:54 +00:00
|
|
|
/**
|
2021-01-27 22:15:38 +00:00
|
|
|
* Return the current meandering configuration.
|
2015-02-18 00:29:54 +00:00
|
|
|
*
|
|
|
|
* @return the settings
|
|
|
|
*/
|
2016-08-29 17:31:13 +00:00
|
|
|
virtual const MEANDER_SETTINGS& MeanderSettings() const;
|
2015-02-18 16:53:46 +00:00
|
|
|
|
2015-02-18 00:29:54 +00:00
|
|
|
/*
|
2021-01-27 22:15:38 +00:00
|
|
|
* Set the current meandering configuration.
|
2015-02-18 00:29:54 +00:00
|
|
|
*
|
2021-01-27 22:15:38 +00:00
|
|
|
* @param aSettings the settings.
|
2015-02-18 00:29:54 +00:00
|
|
|
*/
|
2016-08-29 17:31:13 +00:00
|
|
|
virtual void UpdateSettings( const MEANDER_SETTINGS& aSettings);
|
2015-02-18 16:53:46 +00:00
|
|
|
|
2015-02-18 00:29:54 +00:00
|
|
|
/**
|
2021-01-27 22:15:38 +00:00
|
|
|
* Checks if it's OK to place the shape aShape (i.e. if it doesn't cause DRC violations
|
|
|
|
* or collide with other meanders).
|
2015-02-18 00:29:54 +00:00
|
|
|
*
|
2021-01-27 22:15:38 +00:00
|
|
|
* @param aShape the shape to check.
|
|
|
|
* @return true if the shape fits.
|
2015-02-18 00:29:54 +00:00
|
|
|
*/
|
2016-08-29 17:31:13 +00:00
|
|
|
virtual bool CheckFit( MEANDER_SHAPE* aShape )
|
2015-02-18 16:53:46 +00:00
|
|
|
{
|
2015-02-18 00:29:54 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2019-10-31 13:00:01 +00:00
|
|
|
int GetTotalPadToDieLength( const LINE& aLine ) const;
|
|
|
|
|
2015-02-18 00:29:54 +00:00
|
|
|
protected:
|
|
|
|
/**
|
2021-01-27 22:15:38 +00:00
|
|
|
* Take a set of meanders in \a aTuned and tunes their length to extend the original line
|
|
|
|
* length by \a aElongation.
|
2015-02-18 00:29:54 +00:00
|
|
|
*/
|
2019-09-03 23:38:58 +00:00
|
|
|
void tuneLineLength( MEANDERED_LINE& aTuned, long long int aElongation );
|
2015-02-18 00:29:54 +00:00
|
|
|
|
|
|
|
/**
|
2021-01-27 22:15:38 +00:00
|
|
|
* Compare \a aValue against \a aExpected with given tolerance.
|
2015-02-18 00:29:54 +00:00
|
|
|
*/
|
2021-01-27 22:15:38 +00:00
|
|
|
int compareWithTolerance( long long int aValue, long long int aExpected,
|
|
|
|
long long int aTolerance = 0 ) const;
|
2015-02-18 00:29:54 +00:00
|
|
|
|
2021-01-04 13:54:29 +00:00
|
|
|
VECTOR2I getSnappedStartPoint( LINKED_ITEM* aStartItem, VECTOR2I aStartPoint );
|
|
|
|
|
2021-04-20 23:31:10 +00:00
|
|
|
/**
|
|
|
|
* Calculate the total length of the line represented by an item set (tracks and vias)
|
|
|
|
* @param aLine
|
|
|
|
* @return
|
|
|
|
*/
|
2022-08-02 03:23:07 +00:00
|
|
|
long long int lineLength( const ITEM_SET& aLine, const SOLID* aStartPad, const SOLID* aEndPad ) const;
|
2021-04-20 23:31:10 +00:00
|
|
|
|
2021-01-27 22:15:38 +00:00
|
|
|
///< Pointer to world to search colliding items.
|
2019-10-31 13:00:01 +00:00
|
|
|
NODE* m_world;
|
|
|
|
|
2021-01-27 22:15:38 +00:00
|
|
|
///< Width of the meandered trace(s).
|
2015-02-18 00:29:54 +00:00
|
|
|
int m_currentWidth;
|
2021-01-27 22:15:38 +00:00
|
|
|
|
|
|
|
///< Meander settings.
|
2016-08-29 17:31:13 +00:00
|
|
|
MEANDER_SETTINGS m_settings;
|
2021-01-27 22:15:38 +00:00
|
|
|
|
|
|
|
///< The current end point.
|
2015-02-18 00:29:54 +00:00
|
|
|
VECTOR2I m_currentEnd;
|
2022-08-02 03:23:07 +00:00
|
|
|
|
|
|
|
SOLID* m_startPad_p;
|
|
|
|
SOLID* m_endPad_p;
|
|
|
|
SOLID* m_startPad_n;
|
|
|
|
SOLID* m_endPad_n;
|
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_PLACER_BASE_H
|