Browse Source

Better handling of vertex sorting

Nominally, the zcode of a vertex is unique.  This is not 100% true,
however, as we must interlace two 32-bit numbers into a single 32-bit
number.  Sorting needs to account for the possibility that the zcode
will be the same while other elements of the vertex are different.  This
commit fixes the broken boolean logic to more clearly handle these cases

Fixes https://gitlab.com/kicad/code/kicad/issues/13867
newinvert
Seth Hillbrand 3 years ago
parent
commit
e7fe69b97f
  1. 11
      libs/kimath/include/geometry/polygon_triangulation.h
  2. 14
      pcbnew/drc/drc_test_provider_connection_width.cpp

11
libs/kimath/include/geometry/polygon_triangulation.h

@ -210,7 +210,16 @@ private:
std::sort( queue.begin(), queue.end(), []( const Vertex* a, const Vertex* b )
{
return a->z < b->z;
if( a->z != b->z )
return a->z < b->z;
if( a->x != b->x )
return a->x < b->x;
if( a->y != b->y )
return a->y < b->y;
return a->i < b->i;
} );
Vertex* prev_elem = nullptr;

14
pcbnew/drc/drc_test_provider_connection_width.cpp

@ -252,10 +252,16 @@ private:
std::sort( queue.begin(), queue.end(), []( const Vertex* a, const Vertex* b )
{
return a->z < b->z || ( a->z == b->z
&& ( ( a->x < b->x )
|| ( a->y < b->y )
|| ( a->i < b->i ) ) );
if( a->z != b->z )
return a->z < b->z;
if( a->x != b->x )
return a->x < b->x;
if( a->y != b->y )
return a->y < b->y;
return a->i < b->i;
} );
Vertex* prev_elem = nullptr;

Loading…
Cancel
Save