KiCad PCB EDA Suite
clean.cpp File Reference

functions to clean tracks: remove null length and redundant segments More...

#include <fctsys.h>
#include <class_drawpanel.h>
#include <wxPcbStruct.h>
#include <pcbnew.h>
#include <class_board.h>
#include <class_track.h>
#include <connect.h>
#include <dialog_cleaning_options.h>
#include <board_commit.h>
#include <tuple>

Go to the source code of this file.

Classes

class  TRACKS_CLEANER
 

Functions

static bool parallelism_test (int dx1, int dy1, int dx2, int dy2)
 

Detailed Description

functions to clean tracks: remove null length and redundant segments

Definition in file clean.cpp.

Function Documentation

static bool parallelism_test ( int  dx1,
int  dy1,
int  dx2,
int  dy2 
)
static

Definition at line 662 of file clean.cpp.

Referenced by TRACKS_CLEANER::mergeCollinearSegmentIfPossible().

663 {
664  /* The following condition list is ugly and repetitive, but I have
665  * not a better way to express clearly the trivial cases. Hope the
666  * compiler optimize it better than always doing the product
667  * below... */
668 
669  // test for vertical alignment (easy to handle)
670  if( dx1 == 0 )
671  return dx2 == 0;
672 
673  if( dx2 == 0 )
674  return dx1 == 0;
675 
676  // test for horizontal alignment (easy to handle)
677  if( dy1 == 0 )
678  return dy2 == 0;
679 
680  if( dy2 == 0 )
681  return dy1 == 0;
682 
683  /* test for alignment in other cases: Do the usual cross product test
684  * (the same as testing the slope, but without a division) */
685  return ((double)dy1 * dx2 == (double)dx1 * dy2);
686 }