KiCad PCB EDA Suite
connectivity_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-2017 CERN
5  * @author Maciej Suminski <maciej.suminski@cern.ch>
6  * @author Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
7  *
8  * This program is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License
10  * as published by the Free Software Foundation; either version 2
11  * of the License, or (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, you may find one here:
20  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
21  * or you may search the http://www.gnu.org website for the version 2 license,
22  * or you may write to the Free Software Foundation, Inc.,
23  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
24  */
25 
26 #ifndef __CONNECTIVITY_DATA_H
27 #define __CONNECTIVITY_DATA_H
28 
29 #include <core/typeinfo.h>
30 #include <core/lockable.h>
31 
32 #include <wx/string.h>
33 #include <vector>
34 #include <memory>
35 
36 #include <math/vector2d.h>
38 #include <class_zone.h>
39 
40 class CN_CLUSTER;
42 class CN_EDGE;
43 class BOARD;
45 class BOARD_ITEM;
46 class ZONE_CONTAINER;
47 class RN_DATA;
48 class RN_NET;
49 class TRACK;
50 class D_PAD;
51 class MODULE;
52 class PROGRESS_REPORTER;
53 
55 {
56  int net;
59 };
60 
62 {
64  m_zone( aZone ),
65  m_lastPolys( aZone->GetFilledPolysList() )
66  {}
67 
70  std::vector<int> m_islands;
71 };
72 
74 {
75  int netCode;
77 };
78 
79 // a wrapper class encompassing the connectivity computation algorithm and the
81 {
82 public:
85 
86 
91  void Build( BOARD* aBoard );
92 
97  void Build( const std::vector<BOARD_ITEM*>& aItems );
98 
105  bool Add( BOARD_ITEM* aItem );
106 
113  bool Remove( BOARD_ITEM* aItem );
114 
121  bool Update( BOARD_ITEM* aItem );
122 
127  void Clear();
128 
133  int GetNetCount() const;
134 
139  RN_NET* GetRatsnestForNet( int aNet );
140 
145  void PropagateNets();
146 
147  bool CheckConnectivity( std::vector<CN_DISJOINT_NET_ENTRY>& aReport );
148 
155  void FindIsolatedCopperIslands( ZONE_CONTAINER* aZone, std::vector<int>& aIslands );
156  void FindIsolatedCopperIslands( std::vector<CN_ZONE_ISOLATED_ISLAND_LIST>& aZones );
157 
162  void RecalculateRatsnest();
163 
168  unsigned int GetUnconnectedCount() const;
169 
170  unsigned int GetNodeCount( int aNet = -1 ) const;
171 
172  unsigned int GetPadCount( int aNet = -1 ) const;
173 
174  const std::vector<TRACK*> GetConnectedTracks( const BOARD_CONNECTED_ITEM* aItem ) const;
175 
176  const std::vector<D_PAD*> GetConnectedPads( const BOARD_CONNECTED_ITEM* aItem ) const;
177 
178  const void GetConnectedPads( const BOARD_CONNECTED_ITEM* aItem, std::set<D_PAD*>* pads ) const;
179 
180  const std::vector<BOARD_CONNECTED_ITEM*> GetConnectedItems( const BOARD_CONNECTED_ITEM* aItem, const VECTOR2I& aAnchor, KICAD_T aTypes[] );
181 
182  void GetUnconnectedEdges( std::vector<CN_EDGE>& aEdges ) const;
183 
189  void ClearDynamicRatsnest();
190 
194  void HideDynamicRatsnest();
195 
201  void ComputeDynamicRatsnest( const std::vector<BOARD_ITEM*>& aItems );
202 
203  const std::vector<RN_DYNAMIC_LINE>& GetDynamicRatsnest() const
204  {
205  return m_dynamicRatsnest;
206  }
207 
214  const std::vector<BOARD_CONNECTED_ITEM*> GetConnectedItems( const BOARD_CONNECTED_ITEM* aItem,
215  const KICAD_T aTypes[] ) const;
216 
223  const std::vector<BOARD_CONNECTED_ITEM*> GetNetItems( int aNetCode,
224  const KICAD_T aTypes[] ) const;
225 
226  const std::vector<VECTOR2I> NearestUnconnectedTargets( const BOARD_CONNECTED_ITEM* aRef,
227  const VECTOR2I& aPos,
228  int aMaxCount = -1 );
229 
230  void BlockRatsnestItems( const std::vector<BOARD_ITEM*>& aItems );
231 
232  std::shared_ptr<CN_CONNECTIVITY_ALGO> GetConnectivityAlgo() const
233  {
234  return m_connAlgo;
235  }
236 
237  void MarkItemNetAsDirty( BOARD_ITEM* aItem );
238  void SetProgressReporter( PROGRESS_REPORTER* aReporter );
239 
240 #ifndef SWIG
241  const std::vector<CN_EDGE> GetRatsnestForComponent( MODULE* aComponent, bool aSkipInternalConnections = false );
242 #endif
243 
244 private:
245 
246  int countRelevantItems( const std::vector<BOARD_ITEM*>& aItems );
247  void updateRatsnest();
248  void addRatsnestCluster( const std::shared_ptr<CN_CLUSTER>& aCluster );
249 
250  std::unique_ptr<CONNECTIVITY_DATA> m_dynamicConnectivity;
251  std::shared_ptr<CN_CONNECTIVITY_ALGO> m_connAlgo;
252 
253  std::vector<RN_DYNAMIC_LINE> m_dynamicRatsnest;
254  std::vector<RN_NET*> m_nets;
255 
257 };
258 
259 #endif
Class ZONE_CONTAINER handles a list of polygons defining a copper zone.
Definition: class_zone.h:60
std::shared_ptr< CN_CONNECTIVITY_ALGO > GetConnectivityAlgo() const
Class BOARD_ITEM is a base class for any item which can be embedded within the BOARD container class...
A progress reporter for use in multi-threaded environments.
std::shared_ptr< CN_CONNECTIVITY_ALGO > m_connAlgo
PROGRESS_REPORTER * m_progressReporter
Classes to handle copper zones.
const SHAPE_POLY_SET m_lastPolys
BOARD_CONNECTED_ITEM * b
Class BOARD_CONNECTED_ITEM is a base class derived from BOARD_ITEM for items that can be connected an...
std::vector< RN_DYNAMIC_LINE > m_dynamicRatsnest
VECTOR2I anchorB
KICAD_T
Enum KICAD_T is the set of class identification values, stored in EDA_ITEM::m_StructType.
Definition: typeinfo.h:78
const std::vector< RN_DYNAMIC_LINE > & GetDynamicRatsnest() const
VECTOR2I anchorA
Class SHAPE_POLY_SET.
CN_ZONE_ISOLATED_ISLAND_LIST(ZONE_CONTAINER *aZone)
std::unique_ptr< CONNECTIVITY_DATA > m_dynamicConnectivity
std::vector< RN_NET * > m_nets
BOARD_CONNECTED_ITEM * a
Class BOARD holds information pertinent to a Pcbnew printed circuit board.
Definition: class_board.h:170
int net
Class RN_NET Describes ratsnest for a single net.
Definition: ratsnest_data.h:59