KiCad PCB EDA Suite
Loading...
Searching...
No Matches
pns_topology.h
Go to the documentation of this file.
1/*
2 * KiRouter - a push-and-(sometimes-)shove PCB router
3 *
4 * Copyright (C) 2013-2015 CERN
5 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
6 * Author: Tomasz Wlostowski <[email protected]>
7 *
8 * This program is free software: you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the
10 * Free Software Foundation, either version 3 of the License, or (at your
11 * option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License along
19 * with this program. If not, see <http://www.gnu.org/licenses/>.
20 */
21
22#ifndef __PNS_TOPOLOGY_H
23#define __PNS_TOPOLOGY_H
24
25#include <vector>
26#include <set>
27
28#include "pns_itemset.h"
29
30namespace PNS {
31
32class NODE;
33class SEGMENT;
34class JOINT;
35class ITEM;
36class SOLID;
37class DIFF_PAIR;
38class ROUTER_IFACE;
39class LINKED_ITEM;
40class VIA;
41
43{
44public:
45
46 struct CLUSTER
47 {
48 const ITEM* m_key = nullptr;
49 std::vector<ITEM*> m_items;
50 };
51
52 typedef std::set<const JOINT*> JOINT_SET;
53
54 TOPOLOGY( NODE* aNode ):
55 m_world( aNode ) {};
56
58
59 bool SimplifyLine( LINE *aLine );
60 ITEM* NearestUnconnectedItem( const JOINT* aStart, int* aAnchor = nullptr,
61 int aKindMask = ITEM::ANY_T );
62
63 bool NearestUnconnectedAnchorPoint( const LINE* aTrack, VECTOR2I& aPoint, PNS_LAYER_RANGE& aLayers,
64 ITEM*& aItem );
65 bool LeadingRatLine( const LINE* aTrack, SHAPE_LINE_CHAIN& aRatLine );
66
67 const JOINT_SET ConnectedJoints( const JOINT* aStart );
68 const ITEM_SET ConnectedItems( const JOINT* aStart, int aKindMask = ITEM::ANY_T );
69 const ITEM_SET ConnectedItems( ITEM* aStart, int aKindMask = ITEM::ANY_T );
70 int64_t ShortestConnectionLength( ITEM* aFrom, ITEM* aTo );
71
80 const ITEM_SET AssembleTrivialPath( ITEM* aStart,
81 std::pair<const JOINT*, const JOINT*>* aTerminalJoints = nullptr,
82 bool aFollowLockedSegments = false );
83
96 const ITEM_SET AssembleTuningPath( ROUTER_IFACE* aRouterIface, ITEM* aStart, SOLID** aStartPad = nullptr,
97 SOLID** aEndPad = nullptr );
98
100
101 bool AssembleDiffPair( ITEM* aStart, DIFF_PAIR& aPair );
102
103 const CLUSTER AssembleCluster( ITEM* aStart, int aLayer, double aAreaExpansionLimit = 0.0, NET_HANDLE aExcludedNet = nullptr );
104
105private:
107
109 {
111 const JOINT* m_end;
113
114 PATH_RESULT() : m_end( nullptr ), m_length( 0 ) {}
115 };
116
118 {
121 int64_t m_length;
122
124 m_endPad( nullptr ),
125 m_length( -1 )
126 {
127 }
128 };
129
130 std::vector<LINE> findLinesFromVia( ROUTER_IFACE* aRouterIface, VIA* aVia, const std::set<ITEM*>& aVisited );
131
132 WALK_RESULT walkTuningPath( ROUTER_IFACE* aRouterIface, LINE& aStartLine, bool aStartFromBack,
133 const std::set<ITEM*>& aVisited );
134
135 PATH_RESULT followBranch( const JOINT* aStartJoint, LINKED_ITEM* aPrev,
136 std::set<ITEM*>& aVisited, bool aFollowLockedSegments );
137
138 ITEM_SET followTrivialPath( LINE* aLine, const JOINT** aTerminalJointA,
139 const JOINT** aTerminalJointB,
140 bool aFollowLockedSegments = false );
141
143};
144
145}
146
147#endif
Basic class for a differential pair.
Base class for PNS router board items.
Definition pns_item.h:98
A 2D point on a given set of layers and belonging to a certain net, that links together a number of b...
Definition pns_joint.h:43
Represents a track on a PCB, connecting two non-trivial joints (that is, vias, pads,...
Definition pns_line.h:62
Keep the router "world" - i.e.
Definition pns_node.h:240
ITEM * NearestUnconnectedItem(const JOINT *aStart, int *aAnchor=nullptr, int aKindMask=ITEM::ANY_T)
std::set< const JOINT * > JOINT_SET
bool LeadingRatLine(const LINE *aTrack, SHAPE_LINE_CHAIN &aRatLine)
std::vector< LINE > findLinesFromVia(ROUTER_IFACE *aRouterIface, VIA *aVia, const std::set< ITEM * > &aVisited)
const DIFF_PAIR AssembleDiffPair(SEGMENT *aStart)
WALK_RESULT walkTuningPath(ROUTER_IFACE *aRouterIface, LINE &aStartLine, bool aStartFromBack, const std::set< ITEM * > &aVisited)
ITEM_SET followTrivialPath(LINE *aLine, const JOINT **aTerminalJointA, const JOINT **aTerminalJointB, bool aFollowLockedSegments=false)
const ITEM_SET ConnectedItems(const JOINT *aStart, int aKindMask=ITEM::ANY_T)
bool NearestUnconnectedAnchorPoint(const LINE *aTrack, VECTOR2I &aPoint, PNS_LAYER_RANGE &aLayers, ITEM *&aItem)
const CLUSTER AssembleCluster(ITEM *aStart, int aLayer, double aAreaExpansionLimit=0.0, NET_HANDLE aExcludedNet=nullptr)
const JOINT_SET ConnectedJoints(const JOINT *aStart)
const ITEM_SET AssembleTuningPath(ROUTER_IFACE *aRouterIface, ITEM *aStart, SOLID **aStartPad=nullptr, SOLID **aEndPad=nullptr)
Like AssembleTrivialPath, but follows the track length algorithm, which discards segments that are fu...
int64_t ShortestConnectionLength(ITEM *aFrom, ITEM *aTo)
const int DP_PARALLELITY_THRESHOLD
TOPOLOGY(NODE *aNode)
PATH_RESULT followBranch(const JOINT *aStartJoint, LINKED_ITEM *aPrev, std::set< ITEM * > &aVisited, bool aFollowLockedSegments)
const ITEM_SET AssembleTrivialPath(ITEM *aStart, std::pair< const JOINT *, const JOINT * > *aTerminalJoints=nullptr, bool aFollowLockedSegments=false)
Assemble a trivial path between two joints given a starting item.
bool SimplifyLine(LINE *aLine)
Represent a contiguous set of PCB layers.
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
Push and Shove diff pair dimensions (gap) settings dialog.
void * NET_HANDLE
Definition pns_item.h:55
std::vector< ITEM * > m_items
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:687