KiCad PCB EDA Suite
tracks_cleaner.cpp
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) 2004-2018 Jean-Pierre Charras, jp.charras at wanadoo.fr
5  * Copyright (C) 2011 Wayne Stambaugh <stambaughw@verizon.net>
6  * Copyright (C) 1992-2018 KiCad Developers, see AUTHORS.txt for contributors.
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 
32 #include <fctsys.h>
33 #include <class_drawpanel.h>
34 #include <pcb_edit_frame.h>
35 #include <pcbnew.h>
36 #include <class_board.h>
37 #include <class_track.h>
39 #include <board_commit.h>
42 
43 #include <tool/tool_manager.h>
44 #include <tools/pcb_actions.h>
45 
46 // Helper class used to clean tracks and vias
48 {
49 public:
50  TRACKS_CLEANER( BOARD* aPcb, BOARD_COMMIT& aCommit );
51 
61  bool CleanupBoard( bool aCleanVias, bool aRemoveMisConnected,
62  bool aMergeSegments, bool aDeleteUnconnected );
63 
64 private:
65  /* finds and remove all track segments which are connected to more than one net.
66  * (short circuits)
67  */
69 
74  bool cleanupVias();
75 
80  void removeDuplicatesOfVia( const VIA *aVia, std::set<BOARD_ITEM *>& aToRemove );
81 
85  void removeDuplicatesOfTrack( const TRACK* aTrack, std::set<BOARD_ITEM*>& aToRemove );
86 
90  bool deleteDanglingTracks();
91 
93  bool deleteNullSegments();
94 
96  bool MergeCollinearTracks( TRACK* aSegment );
97 
101  bool cleanupSegments();
102 
109 
116  TRACK* aCandidate, ENDPOINT_T aEndType );
117 
118  const ZONE_CONTAINER* zoneForTrackEndpoint( const TRACK* aTrack,
119  ENDPOINT_T aEndPoint );
120 
121  bool testTrackEndpointDangling( TRACK* aTrack, ENDPOINT_T aEndPoint );
122 
125 
126  bool removeItems( std::set<BOARD_ITEM*>& aItems )
127  {
128  bool isModified = false;
129 
130 
131  for( auto item : aItems )
132  {
133  isModified = true;
134  m_brd->Remove( item );
135  m_commit.Removed( item );
136  }
137 
138  return isModified;
139  }
140 };
141 
142 
143 /* Install the cleanup dialog frame to know what should be cleaned
144 */
146 {
147  DIALOG_CLEANING_OPTIONS dlg( this );
148 
149  if( dlg.ShowModal() != wxID_OK )
150  return;
151 
152  // Old model has to be refreshed, GAL normally does not keep updating it
153  Compile_Ratsnest( NULL, false );
154 
155  wxBusyCursor dummy;
156  BOARD_COMMIT commit( this );
157  TRACKS_CLEANER cleaner( GetBoard(), commit );
158 
159  // Clear current selection list to avoid selection of deleted items
160  GetToolManager()->RunAction( PCB_ACTIONS::selectionClear, true );
161 
162  bool modified = cleaner.CleanupBoard( dlg.m_deleteShortCircuits, dlg.m_cleanVias,
164 
165  if( modified )
166  {
167  // Clear undo and redo lists to avoid inconsistencies between lists
168  SetCurItem( NULL );
169  commit.Push( _( "Board cleanup" ) );
170  }
171 
172  m_canvas->Refresh( true );
173 }
174 
175 
177 {
178  auto connectivity = m_brd->GetConnectivity();
179 
180  connectivity->Build(m_brd);
181 
182  // clear flags and variables used in cleanup
183  for( auto track : m_brd->Tracks() )
184  {
185  track->SetState( START_ON_PAD | END_ON_PAD | BUSY, false );
186  }
187 
188  for( auto track : m_brd->Tracks() )
189  {
190  // Mark track if connected to pads
191  for( auto pad : connectivity->GetConnectedPads( track ) )
192  {
193  if( pad->HitTest( track->GetStart() ) )
194  {
195  track->SetState( START_ON_PAD, true );
196  }
197 
198  if( pad->HitTest( track->GetEnd() ) )
199  {
200  track->SetState( END_ON_PAD, true );
201  }
202  }
203  }
204 }
205 
206 
207 /* Main cleaning function.
208  * Delete
209  * - Redundant points on tracks (merge aligned segments)
210  * - vias on pad
211  * - null length segments
212  */
213 bool TRACKS_CLEANER::CleanupBoard( bool aRemoveMisConnected,
214  bool aCleanVias,
215  bool aMergeSegments,
216  bool aDeleteUnconnected )
217 {
218 
219  bool modified = false;
220 
221  // delete redundant vias
222  if( aCleanVias )
223  modified |= cleanupVias();
224 
225  // Remove null segments and intermediate points on aligned segments
226  // If not asked, remove null segments only if remove misconnected is asked
227  if( aMergeSegments )
228  modified |= cleanupSegments();
229  else if( aRemoveMisConnected )
230  modified |= deleteNullSegments();
231 
233 
234  if( aRemoveMisConnected )
235  modified |= removeBadTrackSegments();
236 
237  // Delete dangling tracks
238  if( aDeleteUnconnected )
239  {
241 
242  if( deleteDanglingTracks() )
243  {
244  modified = true;
245 
246  // Removed tracks can leave aligned segments
247  // (when a T was formed by tracks and the "vertical" segment
248  // is removed)
249  if( aMergeSegments )
250  cleanupSegments();
251  }
252  }
253 
254  return modified;
255 }
256 
257 
259  : m_brd( aPcb ), m_commit( aCommit )
260 {
261 }
262 
263 
265 {
266  auto connectivity = m_brd->GetConnectivity();
267 
268  std::set<BOARD_ITEM *> toRemove;
269 
270  for( auto segment : m_brd->Tracks() )
271  {
272  segment->SetState( FLAG0, false );
273 
274  for( auto testedPad : connectivity->GetConnectedPads( segment ) )
275  {
276  if( segment->GetNetCode() != testedPad->GetNetCode() )
277  toRemove.insert( segment );
278  }
279 
280  for( auto testedTrack : connectivity->GetConnectedTracks( segment ) )
281  {
282  if( segment->GetNetCode() != testedTrack->GetNetCode() && !testedTrack->GetState( FLAG0 ) )
283  toRemove.insert( segment );
284  }
285  }
286 
287  return removeItems( toRemove );
288 }
289 
290 
291 void TRACKS_CLEANER::removeDuplicatesOfVia( const VIA *aVia, std::set<BOARD_ITEM *>& aToRemove )
292 {
293  VIA* next_via;
294 
295  for( VIA* alt_via = GetFirstVia( aVia->Next() ); alt_via != NULL; alt_via = next_via )
296  {
297  next_via = GetFirstVia( alt_via->Next() );
298 
299  if( ( alt_via->GetViaType() == VIA_THROUGH ) &&
300  ( alt_via->GetStart() == aVia->GetStart() ) )
301  aToRemove.insert ( alt_via );
302  }
303 }
304 
305 
307 {
308  std::set<BOARD_ITEM*> toRemove;
309 
310  for( VIA* via = GetFirstVia( m_brd->m_Track ); via != NULL;
311  via = GetFirstVia( via->Next() ) )
312  {
313  if( via->GetFlags() & TRACK_LOCKED )
314  continue;
315 
316  // Correct via m_End defects (if any), should never happen
317  if( via->GetStart() != via->GetEnd() )
318  {
319  wxFAIL_MSG( "Malformed via with mismatching ends" );
320  via->SetEnd( via->GetStart() );
321  }
322 
323  /* Important: these cleanups only do thru hole vias, they don't
324  * (yet) handle high density interconnects */
325  if( via->GetViaType() == VIA_THROUGH )
326  {
327  removeDuplicatesOfVia( via, toRemove );
328 
329  /* To delete through Via on THT pads at same location
330  * Examine the list of connected pads:
331  * if one through pad is found, the via can be removed */
332 
333  const auto pads = m_brd->GetConnectivity()->GetConnectedPads( via );
334  for( const auto pad : pads )
335  {
336  const LSET all_cu = LSET::AllCuMask();
337 
338  if( ( pad->GetLayerSet() & all_cu ) == all_cu )
339  {
340  // redundant: delete the via
341  toRemove.insert( via );
342  break;
343  }
344  }
345  }
346  }
347 
348  return removeItems( toRemove );
349 }
350 
351 
355 {
356  auto connectivity = m_brd->GetConnectivity();
357  VECTOR2I endpoint ;
358 
359  if( aTrack->Type() == PCB_TRACE_T )
360  endpoint = aTrack->GetEndPoint( aEndPoint );
361  else
362  endpoint = aTrack->GetStart( );
363 
364  //wxASSERT ( connectivity->GetConnectivityAlgo()->ItemEntry( aTrack ) != nullptr );
365  wxASSERT ( connectivity->GetConnectivityAlgo()->ItemEntry( aTrack ).GetItems().size() != 0 );
366  auto citem = connectivity->GetConnectivityAlgo()->ItemEntry( aTrack ).GetItems().front();
367 
368  if( !citem->Valid() )
369  return false;
370 
371  auto anchors = citem->Anchors();
372 
373  for( const auto& anchor : anchors )
374  {
375  if( anchor->Pos() == endpoint && anchor->IsDangling() )
376  return true;
377  }
378 
379  return false;
380 }
381 
382 
383 /* Delete dangling tracks
384  * Vias:
385  * If a via is only connected to a dangling track, it also will be removed
386  */
388 {
389  bool item_erased = false;
390  bool modified = false;
391 
392  do // Iterate when at least one track is deleted
393  {
394  item_erased = false;
395 
396  TRACK* next_track;
397 
398  for( TRACK *track = m_brd->m_Track; track != NULL; track = next_track )
399  {
400  next_track = track->Next();
401  bool flag_erase = false; // Start without a good reason to erase it
402 
403  /* if a track endpoint is not connected to a pad, test if
404  * the endpoint is connected to another track or to a zone.
405  * For via test, an enhancement could be to test if
406  * connected to 2 items on different layers. Currently
407  * a via must be connected to 2 items, that can be on the
408  * same layer */
409 
410  // Check if there is nothing attached on the start
411  if( !( track->GetState( START_ON_PAD ) ) )
412  flag_erase |= testTrackEndpointDangling( track, ENDPOINT_START );
413 
414  // If not sure about removal, then check if there is nothing attached on the end
415  if( !flag_erase && !track->GetState( END_ON_PAD ) )
416  flag_erase |= testTrackEndpointDangling( track, ENDPOINT_END );
417 
418  if( flag_erase )
419  {
420  m_brd->Remove( track );
421  m_commit.Removed( track );
422 
423  /* keep iterating, because a track connected to the deleted track
424  * now perhaps is not connected and should be deleted */
425  item_erased = true;
426  modified = true;
427  }
428  }
429  } while( item_erased );
430 
431 
432  return modified;
433 }
434 
435 
436 // Delete null length track segments
438 {
439  std::set<BOARD_ITEM *> toRemove;
440 
441  for( auto segment : m_brd->Tracks() )
442  {
443  if( segment->IsNull() ) // Length segment = 0; delete it
444  toRemove.insert( segment );
445  }
446 
447  return removeItems( toRemove );
448 }
449 
450 void TRACKS_CLEANER::removeDuplicatesOfTrack( const TRACK *aTrack, std::set<BOARD_ITEM*>& aToRemove )
451 {
452  if( aTrack->GetFlags() & STRUCT_DELETED )
453  return;
454 
455  for( auto other : m_brd->Tracks() )
456  {
457  // New netcode, break out (can't be there any other)
458  if( aTrack->GetNetCode() != other->GetNetCode() )
459  continue;
460 
461  if( aTrack == other )
462  continue;
463 
464  if( other->GetFlags() & STRUCT_DELETED )
465  continue;
466 
467  // Must be of the same type, on the same layer and the endpoints
468  // must be the same (maybe swapped)
469  if( ( aTrack->Type() == other->Type() ) &&
470  ( aTrack->GetLayer() == other->GetLayer() ) )
471  {
472  if( ( ( aTrack->GetStart() == other->GetStart() ) &&
473  ( aTrack->GetEnd() == other->GetEnd() ) ) ||
474  ( ( aTrack->GetStart() == other->GetEnd() ) &&
475  ( aTrack->GetEnd() == other->GetStart() ) ) )
476  {
477  other->SetFlags( STRUCT_DELETED );
478  aToRemove.insert( other );
479  }
480  }
481  }
482 }
483 
484 
486 {
487  bool merged_this = false;
488 
489 
490  for( ENDPOINT_T endpoint = ENDPOINT_START; endpoint <= ENDPOINT_END;
491  endpoint = ENDPOINT_T( endpoint + 1 ) )
492  {
493  // search for a possible segment connected to the current endpoint of the current one
494  TRACK* other = aSegment->Next();
495 
496  if( other )
497  {
498  other = aSegment->GetTrack( other, NULL, endpoint, true, false );
499 
500  if( other )
501  {
502  // the two segments must have the same width and the other
503  // cannot be a via
504  if( ( aSegment->GetWidth() == other->GetWidth() ) &&
505  ( other->Type() == PCB_TRACE_T ) )
506  {
507  // There can be only one segment connected
508  other->SetState( BUSY, true );
509  TRACK* yet_another = aSegment->GetTrack( m_brd->m_Track, NULL,
510  endpoint, true, false );
511  other->SetState( BUSY, false );
512 
513  if( !yet_another )
514  {
515  // Try to merge them
516  TRACK* segDelete = mergeCollinearSegmentIfPossible( aSegment,
517  other, endpoint );
518 
519  // Merge succesful, the other one has to go away
520  if( segDelete )
521  {
522  m_brd->Remove( segDelete );
523  m_commit.Removed( segDelete );
524  merged_this = true;
525  }
526  }
527  }
528  }
529  }
530  }
531 
532 
533 
534  return merged_this;
535 }
536 
537 
538 // Delete null length segments, and intermediate points ..
540 {
541  bool modified = false;
542 
543  // Easy things first
544  modified |= deleteNullSegments();
545 
547 
548  std::set<BOARD_ITEM*> toRemove;
549 
550  // Delete redundant segments, i.e. segments having the same end points and layers
551  // (can happens when blocks are copied on themselve)
552  for( auto segment : m_brd->Tracks() )
553  removeDuplicatesOfTrack( segment, toRemove );
554 
555  modified |= removeItems( toRemove );
556 
557  if( modified )
559 
560  // merge collinear segments:
561  TRACK* nextsegment;
562 
563  for( TRACK* segment = m_brd->m_Track; segment; segment = nextsegment )
564  {
565  nextsegment = segment->Next();
566 
567  if( segment->Type() == PCB_TRACE_T )
568  {
569  bool merged_this = MergeCollinearTracks( segment );
570 
571  if( merged_this ) // The current segment was modified, retry to merge it again
572  {
573  nextsegment = segment->Next();
574  modified = true;
575  }
576  }
577  }
578 
579  return modified;
580 }
581 
582 
583 /* Utility: check for parallelism between two segments */
584 static bool parallelismTest( int dx1, int dy1, int dx2, int dy2 )
585 {
586  /* The following condition list is ugly and repetitive, but I have
587  * not a better way to express clearly the trivial cases. Hope the
588  * compiler optimize it better than always doing the product
589  * below... */
590 
591  // test for vertical alignment (easy to handle)
592  if( dx1 == 0 )
593  return dx2 == 0;
594 
595  if( dx2 == 0 )
596  return dx1 == 0;
597 
598  // test for horizontal alignment (easy to handle)
599  if( dy1 == 0 )
600  return dy2 == 0;
601 
602  if( dy2 == 0 )
603  return dy1 == 0;
604 
605  /* test for alignment in other cases: Do the usual cross product test
606  * (the same as testing the slope, but without a division) */
607  return ((double)dy1 * dx2 == (double)dx1 * dy2);
608 }
609 
610 
624 static void updateConn( TRACK *track, const std::shared_ptr<CONNECTIVITY_DATA>& connectivity )
625 {
626  for( auto pad : connectivity->GetConnectedPads( track ) )
627  {
628  if( pad->HitTest( track->GetStart() ) )
629  {
630  track->SetState( START_ON_PAD, true );
631  }
632 
633  if( pad->HitTest( track->GetEnd() ) )
634  {
635  track->SetState( END_ON_PAD, true );
636  }
637  }
638 }
639 
640 
642  ENDPOINT_T aEndType )
643 {
644  // First of all, they must be of the same width and must be both actual tracks
645  if( ( aTrackRef->GetWidth() != aCandidate->GetWidth() ) ||
646  ( aTrackRef->Type() != PCB_TRACE_T ) ||
647  ( aCandidate->Type() != PCB_TRACE_T ) )
648  return NULL;
649 
650  // Trivial case: exactly the same track
651  if( ( aTrackRef->GetStart() == aCandidate->GetStart() ) &&
652  ( aTrackRef->GetEnd() == aCandidate->GetEnd() ) )
653  return aCandidate;
654 
655  if( ( aTrackRef->GetStart() == aCandidate->GetEnd() ) &&
656  ( aTrackRef->GetEnd() == aCandidate->GetStart() ) )
657  return aCandidate;
658 
659  // Weed out non-parallel tracks
660  if( !parallelismTest( aTrackRef->GetEnd().x - aTrackRef->GetStart().x,
661  aTrackRef->GetEnd().y - aTrackRef->GetStart().y,
662  aCandidate->GetEnd().x - aCandidate->GetStart().x,
663  aCandidate->GetEnd().y - aCandidate->GetStart().y ) )
664  return NULL;
665 
666  auto connectivity = m_brd->GetConnectivity();
667 
668  updateConn( aTrackRef, connectivity );
669  updateConn( aCandidate, connectivity );
670 
671  if( aEndType == ENDPOINT_START )
672  {
673  // We do not have a pad, which is a always terminal point for a track
674  if( aTrackRef->GetState( START_ON_PAD ) )
675  return NULL;
676 
677  /* change the common point coordinate of pt_segm to use the other point
678  * of pt_segm (pt_segm will be removed later) */
679  if( aTrackRef->GetStart() == aCandidate->GetStart() )
680  {
681  m_commit.Modify( aTrackRef );
682  aTrackRef->SetStart( aCandidate->GetEnd() );
683  aTrackRef->SetState( START_ON_PAD, aCandidate->GetState( END_ON_PAD ) );
684  connectivity->Update( aTrackRef );
685  return aCandidate;
686  }
687  else
688  {
689  m_commit.Modify( aTrackRef );
690  aTrackRef->SetStart( aCandidate->GetStart() );
691  aTrackRef->SetState( START_ON_PAD, aCandidate->GetState( START_ON_PAD ) );
692  connectivity->Update( aTrackRef );
693  return aCandidate;
694  }
695  }
696  else // aEndType == END
697  {
698  // We do not have a pad, which is a always terminal point for a track
699  if( aTrackRef->GetState( END_ON_PAD ) )
700  return NULL;
701 
702  /* change the common point coordinate of pt_segm to use the other point
703  * of pt_segm (pt_segm will be removed later) */
704  if( aTrackRef->GetEnd() == aCandidate->GetStart() )
705  {
706  m_commit.Modify( aTrackRef );
707  aTrackRef->SetEnd( aCandidate->GetEnd() );
708  aTrackRef->SetState( END_ON_PAD, aCandidate->GetState( END_ON_PAD ) );
709  connectivity->Update( aTrackRef );
710 
711  return aCandidate;
712  }
713  else
714  {
715  m_commit.Modify( aTrackRef );
716  aTrackRef->SetEnd( aCandidate->GetStart() );
717  aTrackRef->SetState( END_ON_PAD, aCandidate->GetState( START_ON_PAD ) );
718  connectivity->Update( aTrackRef );
719  return aCandidate;
720  }
721  }
722 
723  return NULL;
724 }
725 
726 
728 {
729  // Old model has to be refreshed, GAL normally does not keep updating it
730  Compile_Ratsnest( NULL, false );
731  BOARD_COMMIT commit( this );
732 
733  TRACKS_CLEANER cleaner( GetBoard(), commit );
734  bool isModified = cleaner.CleanupBoard( true, false, false, false );
735 
736  if( isModified )
737  {
738  // Clear undo and redo lists to avoid inconsistencies between lists
739  SetCurItem( NULL );
740  commit.Push( _( "Board cleanup" ) );
741  Compile_Ratsnest( NULL, true );
742  }
743 
744  m_canvas->Refresh( true );
745 
746  return isModified;
747 }
static TOOL_ACTION selectionClear
Clears the current selection.
Definition: pcb_actions.h:53
static LSET AllCuMask(int aCuLayerCount=MAX_CU_LAYERS)
Function AllCuMask returns a mask holding the requested number of Cu PCB_LAYER_IDs.
Definition: lset.cpp:676
KICAD_T Type() const
Function Type()
Definition: base_struct.h:201
Class ZONE_CONTAINER handles a list of polygons defining a copper zone.
Definition: class_zone.h:59
STATUS_FLAGS GetFlags() const
Definition: base_struct.h:258
TRACK * GetTrack(TRACK *aStartTrace, TRACK *aEndTrace, ENDPOINT_T aEndPoint, bool aSameNetOnly, bool aSequential)
Function GetTrack returns the trace segment connected to the segment at aEndPoint from aStartTrace to...
COMMIT & Modify(EDA_ITEM *aItem)
Modifies a given item in the model.
Definition: commit.h:103
bool MergeCollinearTracks(TRACK *aSegment)
Try to merge the segment to a following collinear one.
void SetEnd(const wxPoint &aEnd)
Definition: class_track.h:122
virtual PCB_LAYER_ID GetLayer() const
Function GetLayer returns the primary layer this item is on.
bool CleanupBoard(bool aCleanVias, bool aRemoveMisConnected, bool aMergeSegments, bool aDeleteUnconnected)
the cleanup function.
Class BOARD to handle a board.
bool deleteDanglingTracks()
Removes dangling tracks.
#define BUSY
Pcbnew: flag indicating that the structure has.
Definition: base_struct.h:135
TRACKS_CLEANER(BOARD *aPcb, BOARD_COMMIT &aCommit)
bool testTrackEndpointDangling(TRACK *aTrack, ENDPOINT_T aEndPoint)
Utility: does the endpoint unconnected processed for one endpoint of one track Returns true if the tr...
int GetState(int type) const
Definition: base_struct.h:240
const wxPoint & GetEnd() const
Definition: class_track.h:123
Functions relatives to tracks, vias and segments used to fill zones.
class TRACK, a track segment (segment on a copper layer)
Definition: typeinfo.h:95
BOARD_COMMIT & m_commit
ENDPOINT_T
Flag used in locate routines (from which endpoint work)
Definition: pcbnew.h:58
void removeDuplicatesOfTrack(const TRACK *aTrack, std::set< BOARD_ITEM * > &aToRemove)
Removes all the following duplicates tracks of the specified one.
#define START_ON_PAD
Definition: netinfo.h:590
COMMIT & Removed(EDA_ITEM *aItem)
Notifies observers that aItem has been removed
Definition: commit.h:96
Class LSET is a set of PCB_LAYER_IDs.
bool RemoveMisConnectedTracks()
Function RemoveMisConnectedTracks finds all track segments which are mis-connected (to more than one ...
const wxPoint & GetStart() const
Definition: class_track.h:126
const wxPoint & GetEndPoint(ENDPOINT_T aEndPoint) const
Return the selected endpoint (start or end)
Definition: class_track.h:130
bool removeBadTrackSegments()
#define STRUCT_DELETED
flag indication structures to be erased
Definition: base_struct.h:123
#define TRACK_LOCKED
Pcbnew: track locked: protected from global deletion.
Definition: base_struct.h:129
const ZONE_CONTAINER * zoneForTrackEndpoint(const TRACK *aTrack, ENDPOINT_T aEndPoint)
#define FLAG0
Pcbnew: flag used in local computations.
Definition: base_struct.h:132
#define END_ON_PAD
Definition: netinfo.h:591
BOARD * GetBoard()
static void updateConn(TRACK *track, const std::shared_ptr< CONNECTIVITY_DATA > &connectivity)
Function used by cleanupSegments.
int GetNetCode() const
Function GetNetCode.
TRACK * Next() const
Definition: class_track.h:103
TRACK * mergeCollinearSegmentIfPossible(TRACK *aTrackRef, TRACK *aCandidate, ENDPOINT_T aEndType)
helper function merge aTrackRef and aCandidate, when possible, i.e.
void SetState(int type, int state)
Definition: base_struct.h:245
static LIB_PART * dummy()
Used when a LIB_PART is not found in library to draw a dummy shape This component is a 400 mils squar...
Class BOARD holds information pertinent to a Pcbnew printed circuit board.
Definition: class_board.h:171
int GetWidth() const
Definition: class_track.h:120
static bool parallelismTest(int dx1, int dy1, int dx2, int dy2)
virtual void Push(const wxString &aMessage=wxT("A commit"), bool aCreateUndoEntry=true, bool aSetDirtyBit=true) override
Executes the changes.
void SetStart(const wxPoint &aStart)
Definition: class_track.h:125
DLIST_ITERATOR_WRAPPER< TRACK > Tracks()
Definition: class_board.h:254
DLIST< TRACK > m_Track
Definition: class_board.h:250
bool cleanupSegments()
Merge collinear segments and remove duplicated and null len segments.
void removeDuplicatesOfVia(const VIA *aVia, std::set< BOARD_ITEM * > &aToRemove)
Removes all the following THT vias on the same position of the specified one.
std::shared_ptr< CONNECTIVITY_DATA > GetConnectivity() const
Function GetConnectivity() returns list of missing connections between components/tracks.
Definition: class_board.h:297
bool deleteNullSegments()
Delete null length track segments.
void Clean_Pcb()
Function Clean_Pcb Clean up the board (remove redundant vias, not connected tracks and merges colline...
void Remove(BOARD_ITEM *aBoardItem) override
Removes an item from the container.
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 cleanupVias()
Removes redundant vias like vias at same location or on pad through.
VIA * GetFirstVia(TRACK *aTrk, const TRACK *aStopPoint=NULL)
Scan a track list for the first VIA o NULL if not found (or NULL passed)
Definition: class_track.h:514