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 #include <class_board.h>
29 
30 class BOARD_COMMIT;
31 class CLEANUP_ITEM;
32 
33 
34 // Helper class used to clean tracks and vias
36 {
37 public:
38  TRACKS_CLEANER( BOARD* aPcb, BOARD_COMMIT& aCommit );
39 
49  void CleanupBoard( bool aDryRun, std::vector<CLEANUP_ITEM*>* aItemsList, bool aCleanVias,
50  bool aRemoveMisConnected, bool aMergeSegments, bool aDeleteUnconnected,
51  bool aDeleteTracksinPad );
52 
53 private:
54  /*
55  * Removes track segments which are connected to more than one net (short circuits).
56  */
58 
62  void cleanupVias();
63 
64  bool deleteDanglingTracks();
65 
66  void deleteTracksInPads();
67 
68  void deleteNullSegments( TRACKS& aTracks );
69 
73  void cleanupSegments();
74 
83  void mergeCollinearSegments( TRACK* aSeg1, TRACK* aSeg2 );
84 
91  bool testTrackEndpointIsNode( TRACK* aTrack, bool aTstStart );
92 
93  void removeItems( std::set<BOARD_ITEM*>& aItems );
94 
95 private:
98  bool m_dryRun;
99  std::vector<CLEANUP_ITEM*>* m_itemsList;
100 };
101 
102 
103 #endif //KICAD_TRACKS_CLEANER_H
void deleteNullSegments(TRACKS &aTracks)
std::vector< CLEANUP_ITEM * > * m_itemsList
bool deleteDanglingTracks()
void cleanupVias()
Removes redundant vias like vias at same location or on pad through.
TRACKS_CLEANER(BOARD *aPcb, BOARD_COMMIT &aCommit)
A single base class (TRACK) represents both tracks and vias, with subclasses for curved tracks (ARC) ...
BOARD_COMMIT & m_commit
void cleanupSegments()
Merge collinear segments and remove duplicated and null length segments.
void mergeCollinearSegments(TRACK *aSeg1, TRACK *aSeg2)
helper function merge aTrackRef and aCandidate, when possible, i.e.
void removeItems(std::set< BOARD_ITEM * > &aItems)
void CleanupBoard(bool aDryRun, std::vector< CLEANUP_ITEM * > *aItemsList, bool aCleanVias, bool aRemoveMisConnected, bool aMergeSegments, bool aDeleteUnconnected, bool aDeleteTracksinPad)
the cleanup function.
BOARD holds information pertinent to a Pcbnew printed circuit board.
Definition: class_board.h:180
void removeBadTrackSegments()
bool testTrackEndpointIsNode(TRACK *aTrack, bool aTstStart)