KiCad PCB EDA Suite
ratsnest_data.h
Go to the documentation of this file.
1/*
2 * This program source code file is part of KICAD, a free EDA CAD application.
3 *
4 * Copyright (C) 2013-2015 CERN
5 * Copyright (C) 2019-2022 KiCad Developers, see AUTHORS.txt for contributors.
6 *
7 * @author Maciej Suminski <[email protected]>
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version 2
12 * of the License, or (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, you may find one here:
21 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
22 * or you may search the http://www.gnu.org website for the version 2 license,
23 * or you may write to the Free Software Foundation, Inc.,
24 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
25 */
26
32#ifndef RATSNEST_DATA_H
33#define RATSNEST_DATA_H
34
35#include <core/typeinfo.h>
36#include <math/box2.h>
37
38#include <set>
39#include <vector>
40
42
43class BOARD_ITEM;
45class CN_CLUSTER;
46
48{
49 bool operator()( const std::shared_ptr<CN_ANCHOR>& aItem,
50 const std::shared_ptr<CN_ANCHOR>& bItem ) const
51 {
52 if( aItem->Pos().x == bItem->Pos().x )
53 return aItem->Pos().y < bItem->Pos().y;
54 else
55 return aItem->Pos().x < bItem->Pos().x;
56 }
57};
58
62class RN_NET
63{
64public:
65 RN_NET();
66
70 void MarkDirty() { m_dirty = true; }
71
78 bool IsDirty() const { return m_dirty; }
79
83 void Update();
84 void Clear();
85
86 void AddCluster( std::shared_ptr<CN_CLUSTER> aCluster );
87
88 unsigned int GetNodeCount() const { return m_nodes.size(); }
89
90 const std::vector<CN_EDGE>& GetEdges() const { return m_rnEdges; }
91 std::vector<CN_EDGE>& GetEdges() { return m_rnEdges; }
92
93 bool NearestBicoloredPair( const RN_NET& aOtherNet, VECTOR2I* aPos1, VECTOR2I* aPos2 ) const;
94
95protected:
97 void compute();
98
100 void kruskalMST( const std::vector<CN_EDGE> &aEdges );
101
104 void optimizeRNEdges();
105
106protected:
108 std::multiset<std::shared_ptr<CN_ANCHOR>, CN_PTR_CMP> m_nodes;
109
111 std::vector<CN_EDGE> m_boardEdges;
112
114 std::vector<CN_EDGE> m_rnEdges;
115
118
119 class TRIANGULATOR_STATE;
120
121 std::shared_ptr<TRIANGULATOR_STATE> m_triangulator;
122};
123
124#endif /* RATSNEST_DATA_H */
A base class derived from BOARD_ITEM for items that can be connected and have a net,...
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:50
Describe ratsnest for a single net.
Definition: ratsnest_data.h:63
unsigned int GetNodeCount() const
Definition: ratsnest_data.h:88
void MarkDirty()
Mark ratsnest for given net as 'dirty', i.e.
Definition: ratsnest_data.h:70
std::shared_ptr< TRIANGULATOR_STATE > m_triangulator
std::multiset< std::shared_ptr< CN_ANCHOR >, CN_PTR_CMP > m_nodes
< Vector of nodes
void kruskalMST(const std::vector< CN_EDGE > &aEdges)
Find optimal ends of RNEdges.
bool NearestBicoloredPair(const RN_NET &aOtherNet, VECTOR2I *aPos1, VECTOR2I *aPos2) const
void Update()
Recompute ratsnest for a net.
std::vector< CN_EDGE > & GetEdges()
Definition: ratsnest_data.h:91
const std::vector< CN_EDGE > & GetEdges() const
Definition: ratsnest_data.h:90
std::vector< CN_EDGE > m_rnEdges
Flag indicating necessity of recalculation of ratsnest for a net.
bool m_dirty
std::vector< CN_EDGE > m_boardEdges
Vector of edges that makes ratsnest for a given net.
void optimizeRNEdges()
void compute()
< Recompute ratsnest from scratch.
bool IsDirty() const
Return state of the 'dirty' flag, indicating that ratsnest for a given net is invalid and requires an...
Definition: ratsnest_data.h:78
void Clear()
void AddCluster(std::shared_ptr< CN_CLUSTER > aCluster)
bool operator()(const std::shared_ptr< CN_ANCHOR > &aItem, const std::shared_ptr< CN_ANCHOR > &bItem) const
Definition: ratsnest_data.h:49