2015-02-18 00:29:54 +00:00
|
|
|
/*
|
|
|
|
* KiRouter - a push-and-(sometimes-)shove PCB router
|
|
|
|
*
|
|
|
|
* Copyright (C) 2013-2015 CERN
|
2023-09-23 17:33:32 +00:00
|
|
|
* Copyright (C) 2016-2023 KiCad Developers, see AUTHORS.txt for contributors.
|
2015-02-18 00:29:54 +00:00
|
|
|
* Author: Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
|
|
|
|
*
|
|
|
|
* 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_TOPOLOGY_H
|
|
|
|
#define __PNS_TOPOLOGY_H
|
|
|
|
|
|
|
|
#include <vector>
|
|
|
|
#include <set>
|
|
|
|
|
|
|
|
#include "pns_itemset.h"
|
|
|
|
|
2016-08-29 14:38:11 +00:00
|
|
|
namespace PNS {
|
|
|
|
|
2016-08-29 17:31:13 +00:00
|
|
|
class NODE;
|
|
|
|
class SEGMENT;
|
|
|
|
class JOINT;
|
|
|
|
class ITEM;
|
|
|
|
class SOLID;
|
|
|
|
class DIFF_PAIR;
|
|
|
|
|
|
|
|
class TOPOLOGY
|
2015-02-18 00:29:54 +00:00
|
|
|
{
|
2015-02-18 16:53:46 +00:00
|
|
|
public:
|
2022-08-29 20:21:46 +00:00
|
|
|
typedef std::set<const JOINT*> JOINT_SET;
|
2015-02-18 00:29:54 +00:00
|
|
|
|
2016-08-29 17:31:13 +00:00
|
|
|
TOPOLOGY( NODE* aNode ):
|
2015-02-18 16:53:46 +00:00
|
|
|
m_world( aNode ) {};
|
2015-02-18 00:29:54 +00:00
|
|
|
|
2016-08-29 17:31:13 +00:00
|
|
|
~TOPOLOGY() {};
|
2015-02-18 00:29:54 +00:00
|
|
|
|
2016-08-29 17:31:13 +00:00
|
|
|
bool SimplifyLine( LINE *aLine );
|
2022-08-29 20:21:46 +00:00
|
|
|
ITEM* NearestUnconnectedItem( const JOINT* aStart, int* aAnchor = nullptr,
|
2021-07-19 23:56:05 +00:00
|
|
|
int aKindMask = ITEM::ANY_T );
|
2022-07-14 16:38:39 +00:00
|
|
|
|
2023-03-06 19:48:42 +00:00
|
|
|
bool NearestUnconnectedAnchorPoint( const LINE* aTrack, VECTOR2I& aPoint, LAYER_RANGE& aLayers,
|
|
|
|
ITEM*& aItem );
|
2016-08-29 17:31:13 +00:00
|
|
|
bool LeadingRatLine( const LINE* aTrack, SHAPE_LINE_CHAIN& aRatLine );
|
2015-02-18 00:29:54 +00:00
|
|
|
|
2022-08-29 20:21:46 +00:00
|
|
|
const JOINT_SET ConnectedJoints( const JOINT* aStart );
|
|
|
|
const ITEM_SET ConnectedItems( const JOINT* aStart, int aKindMask = ITEM::ANY_T );
|
2016-08-29 17:31:13 +00:00
|
|
|
const ITEM_SET ConnectedItems( ITEM* aStart, int aKindMask = ITEM::ANY_T );
|
|
|
|
int64_t ShortestConnectionLength( ITEM* aFrom, ITEM* aTo );
|
2015-02-18 00:29:54 +00:00
|
|
|
|
2021-04-05 00:27:22 +00:00
|
|
|
/**
|
2021-07-19 23:56:05 +00:00
|
|
|
* Assemble a trivial path between two joints given a starting item.
|
|
|
|
*
|
|
|
|
* @param aStart is the item to assemble from.
|
|
|
|
* @param aTerminalJoints will be filled with the start and end points of the assembled path.
|
2021-12-05 18:35:28 +00:00
|
|
|
* @param aFollowLockedSegments if true will assemble a path including locked segments
|
2021-07-19 23:56:05 +00:00
|
|
|
* @return a set of items in the path.
|
2021-04-05 00:27:22 +00:00
|
|
|
*/
|
|
|
|
const ITEM_SET AssembleTrivialPath( ITEM* aStart,
|
2022-08-29 20:21:46 +00:00
|
|
|
std::pair<const JOINT*, const JOINT*>* aTerminalJoints = nullptr,
|
2021-12-05 18:35:28 +00:00
|
|
|
bool aFollowLockedSegments = false );
|
2021-04-05 00:27:22 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Like AssembleTrivialPath, but follows the track length algorithm, which discards segments
|
|
|
|
* that are fully inside pads, and truncates segments that cross into a pad (adding a straight-
|
|
|
|
* line segment from the intersection to the pad anchor).
|
|
|
|
*
|
2021-07-19 23:56:05 +00:00
|
|
|
* @note When changing this, sync with BOARD::GetTrackLength()
|
2021-04-05 00:27:22 +00:00
|
|
|
*
|
2021-07-19 23:56:05 +00:00
|
|
|
* @param aStart is the item to assemble a path from.
|
|
|
|
* @param aStartPad will be filled with the starting pad of the path, if found.
|
|
|
|
* @param aEndPad will be filled with the ending pad of the path, if found.
|
|
|
|
* @return an item set containing all the items in the path.
|
2021-04-05 00:27:22 +00:00
|
|
|
*/
|
|
|
|
const ITEM_SET AssembleTuningPath( ITEM* aStart, SOLID** aStartPad = nullptr,
|
|
|
|
SOLID** aEndPad = nullptr );
|
|
|
|
|
2016-08-29 17:31:13 +00:00
|
|
|
const DIFF_PAIR AssembleDiffPair( SEGMENT* aStart );
|
2015-02-18 00:29:54 +00:00
|
|
|
|
2016-08-29 17:31:13 +00:00
|
|
|
bool AssembleDiffPair( ITEM* aStart, DIFF_PAIR& aPair );
|
2015-02-18 00:29:54 +00:00
|
|
|
|
2016-08-29 17:31:13 +00:00
|
|
|
const std::set<ITEM*> AssembleCluster( ITEM* aStart, int aLayer );
|
2015-08-19 16:07:16 +00:00
|
|
|
|
2015-02-18 16:53:46 +00:00
|
|
|
private:
|
2021-11-22 00:33:32 +00:00
|
|
|
const int DP_PARALLELITY_THRESHOLD = 5;
|
|
|
|
|
2023-11-28 14:56:00 +00:00
|
|
|
bool followTrivialPath( LINE* aLine, bool aLeft, ITEM_SET& aSet,
|
2023-09-23 17:33:32 +00:00
|
|
|
const JOINT** aTerminalJoint = nullptr, bool aFollowLockedSegments = false );
|
2015-02-18 00:29:54 +00:00
|
|
|
|
2016-08-29 17:31:13 +00:00
|
|
|
NODE *m_world;
|
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
|