KiCad PCB EDA Suite
zones_polygons_insulated_copper_islands.cpp
Go to the documentation of this file.
1 
4 /*
5  * This program source code file is part of KiCad, a free EDA CAD application.
6  *
7  * Copyright (C) 2012 Jean-Pierre Charras, jean-pierre.charras@ujf-grenoble.fr
8  * Copyright (C) 1992-2012 KiCad Developers, see AUTHORS.txt for contributors.
9  *
10  * This program is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU General Public License
12  * as published by the Free Software Foundation; either version 2
13  * of the License, or (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program; if not, you may find one here:
22  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
23  * or you may search the http://www.gnu.org website for the version 2 license,
24  * or you may write to the Free Software Foundation, Inc.,
25  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
26  */
27 
28 #include <fctsys.h>
29 #include <common.h>
30 
31 #include <class_board.h>
32 #include <class_module.h>
33 #include <class_track.h>
34 #include <class_zone.h>
35 
36 #include <pcbnew.h>
37 #include <zones.h>
39 
40 
42 {
44  return;
45 
46  // Build a list of points connected to the net:
47  // list of coordinates of pads and vias on this layer and on this net.
48  std::vector <wxPoint> listPointsCandidates;
49 
50  for( MODULE* module = aPcb->m_Modules; module; module = module->Next() )
51  {
52  for( D_PAD* pad = module->Pads(); pad != NULL; pad = pad->Next() )
53  {
54  if( !pad->IsOnLayer( GetLayer() ) )
55  continue;
56 
57  if( pad->GetNetCode() != GetNetCode() )
58  continue;
59 
60  listPointsCandidates.push_back( pad->GetPosition() );
61  }
62  }
63 
64  for( TRACK* track = aPcb->m_Track; track; track = track->Next() )
65  {
66  if( !track->IsOnLayer( GetLayer() ) )
67  continue;
68 
69  if( track->GetNetCode() != GetNetCode() )
70  continue;
71 
72  listPointsCandidates.push_back( track->GetStart() );
73 
74  if( track->Type() != PCB_VIA_T )
75  listPointsCandidates.push_back( track->GetEnd() );
76  }
77 
78  // test if a point is inside
79 
80  for( int outline = 0; outline < m_FilledPolysList.OutlineCount(); outline++ )
81  {
82  bool connected = false;
83 
84  for( unsigned ic = 0; ic < listPointsCandidates.size(); ic++ )
85  {
86  // test if this area is connected to a board item:
87  wxPoint pos = listPointsCandidates[ic];
88 
89  if( m_FilledPolysList.Contains( VECTOR2I( pos.x, pos.y ), outline ) )
90  {
91  connected = true;
92  break;
93  }
94  }
95 
96  if( !connected ) // this polygon is connected: analyse next polygon
97  {
99  outline--;
100  }
101  }
102 }
Class BOARD to handle a board.
MODULE * Next() const
Definition: class_module.h:100
Classes to handle copper zones.
int OutlineCount() const
Returns the number of outlines in the set
Functions relatives to tracks, vias and segments used to fill zones.
void DeletePolygon(int aIdx)
Deletes aIdx-th polygon from the set
void TestForCopperIslandAndRemoveInsulatedIslands(BOARD *aPcb)
Function TestForCopperIslandAndRemoveInsulatedIslands Remove insulated copper islands found in m_Fill...
D_PAD * Next() const
Definition: class_pad.h:106
SHAPE_POLY_SET m_FilledPolysList
Definition: class_zone.h:788
int GetNetCode() const
Function GetNetCode.
PCB_LAYER_ID GetLayer() const
Function GetLayer returns the primary layer this item is on.
TRACK * Next() const
Definition: class_track.h:98
Class BOARD holds information pertinent to a Pcbnew printed circuit board.
Definition: class_board.h:166
DLIST< MODULE > m_Modules
Definition: class_board.h:243
The common library.
class VIA, a via (like a track segment on a copper layer)
Definition: typeinfo.h:108
DLIST< TRACK > m_Track
Definition: class_board.h:244
Module description (excepted pads)
bool IsEmpty() const
Returns true if the set is empty (no polygons at all)
bool Contains(const VECTOR2I &aP, int aSubpolyIndex=-1) const
Returns true if a given subpolygon contains the point aP.