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 663 of file clean.cpp.

Referenced by TRACKS_CLEANER::mergeCollinearSegmentIfPossible().

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