Fix polygon self intersection check

Fixes https://gitlab.com/kicad/code/kicad/issues/13628
This commit is contained in:
Vincenzo Fortunato 2023-01-26 22:56:47 +00:00 committed by Seth Hillbrand
parent 39e85015c2
commit 42b4f49e7f
2 changed files with 4 additions and 8 deletions

View File

@ -358,13 +358,6 @@ public:
return SEG( B, A );
}
bool IsAdjacent( SEG& aOther ) const
{
int diff = m_index - aOther.m_index;
return diff == 1 || diff == -1;
}
///< Returns the center point of the line
VECTOR2I Center() const
{

View File

@ -498,8 +498,11 @@ bool SHAPE_POLY_SET::IsPolygonSelfIntersecting( int aPolygonIndex ) const
if( max_x < min_x || ( max_x == min_x && max_y < min_y ) )
break;
int index_diff = std::abs( firstSegment.Index() - secondSegment.Index() );
bool adjacent = ( index_diff == 1) || (index_diff == (segments.size() - 1) );
// Check whether the two segments built collide, only when they are not adjacent.
if( !firstSegment.IsAdjacent( secondSegment ) && !firstSegment.Collide( secondSegment, 0 ) )
if( !adjacent && firstSegment.Collide( secondSegment, 0 ) )
return true;
}
}