KiCad PCB EDA Suite
tracks_cleaner.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) 2019 KiCad Developers, see AUTHORS.txt for contributors.
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2
9  * of the License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, you may find one here:
18  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
19  * or you may search the http://www.gnu.org website for the version 2 license,
20  * or you may write to the Free Software Foundation, Inc.,
21  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22  */
23 
24 #ifndef KICAD_TRACKS_CLEANER_H
25 #define KICAD_TRACKS_CLEANER_H
26 
27 #include <class_track.h>
28 
29 class BOARD;
30 class BOARD_COMMIT;
31 
32 
33 // Helper class used to clean tracks and vias
35 {
36 public:
37  TRACKS_CLEANER( EDA_UNITS aUnits, BOARD* aPcb, BOARD_COMMIT& aCommit );
38 
49  bool CleanupBoard( bool aDryRun, DRC_LIST* aItemsList, bool aCleanVias,
50  bool aRemoveMisConnected, bool aMergeSegments, bool aDeleteUnconnected,
51  bool aDeleteTracksinPad );
52 
53 private:
54  /* finds and remove all track segments which are connected to more than one net.
55  * (short circuits)
56  */
58 
63  bool cleanupVias();
64 
68  bool deleteDanglingTracks();
69 
73  bool deleteTracksInPads();
74 
76  bool deleteNullSegments( TRACKS& aTracks );
77 
81  bool cleanupSegments();
82 
89 
98  bool mergeCollinearSegments( TRACK* aSeg1, TRACK* aSeg2 );
99 
107  bool testTrackEndpointDangling( TRACK* aTrack );
108 
116  bool testTrackEndpointIsNode( TRACK* aTrack, bool aTstStart );
117 
121  bool m_dryRun;
123 
124  bool removeItems( std::set<BOARD_ITEM*>& aItems );
125 };
126 
127 
128 #endif //KICAD_TRACKS_CLEANER_H
EDA_UNITS
Definition: common.h:72
bool deleteDanglingTracks()
Removes dangling tracks.
bool deleteNullSegments(TRACKS &aTracks)
Delete null length track segments.
Definitions for tracks, vias and zones.
BOARD_COMMIT & m_commit
bool removeBadTrackSegments()
bool mergeCollinearSegments(TRACK *aSeg1, TRACK *aSeg2)
helper function merge aTrackRef and aCandidate, when possible, i.e.
EDA_UNITS m_units
TRACKS_CLEANER(EDA_UNITS aUnits, BOARD *aPcb, BOARD_COMMIT &aCommit)
std::vector< DRC_ITEM * > DRC_LIST
Definition: drc.h:175
BOARD holds information pertinent to a Pcbnew printed circuit board.
Definition: class_board.h:160
bool deleteTracksInPads()
Removes tracks that are fully inside pads.
bool CleanupBoard(bool aDryRun, DRC_LIST *aItemsList, bool aCleanVias, bool aRemoveMisConnected, bool aMergeSegments, bool aDeleteUnconnected, bool aDeleteTracksinPad)
the cleanup function.
DRC_LIST * m_itemsList
bool testTrackEndpointDangling(TRACK *aTrack)
bool cleanupSegments()
Merge collinear segments and remove duplicated and null len segments.
void buildTrackConnectionInfo()
helper function Rebuild list of tracks, and connected tracks this info must be rebuilt when tracks ar...
bool removeItems(std::set< BOARD_ITEM * > &aItems)
bool testTrackEndpointIsNode(TRACK *aTrack, bool aTstStart)
bool cleanupVias()
Removes redundant vias like vias at same location or on pad through.