Add aExact to SHAPE_LINE_CHAIN::Split.

This commit is contained in:
Alex Shvartzkop 2023-10-05 11:39:46 +03:00
parent d7863b09c5
commit 8a22a8fa69
2 changed files with 6 additions and 2 deletions

View File

@ -586,10 +586,11 @@ public:
* Insert the point aP belonging to one of the our segments, splitting the adjacent segment
* in two.
* @param aP is the point to be inserted.
* @param aExact set to skip the split logic when an exact point match exists.
* @return index of the newly inserted point (or a negative value if aP does not lie on
* our line).
*/
int Split( const VECTOR2I& aP );
int Split( const VECTOR2I& aP, bool aExact = false );
/**
* Search for point \a aP.

View File

@ -890,13 +890,16 @@ SEG::ecoord SHAPE_LINE_CHAIN_BASE::SquaredDistance( const VECTOR2I& aP, bool aOu
}
int SHAPE_LINE_CHAIN::Split( const VECTOR2I& aP )
int SHAPE_LINE_CHAIN::Split( const VECTOR2I& aP, bool aExact )
{
int ii = -1;
int min_dist = 2;
int found_index = Find( aP );
if( found_index >= 0 && aExact )
return found_index;
for( int s = 0; s < SegmentCount(); s++ )
{
const SEG seg = CSegment( s );