SHAPE_POLY_SET: add BooleanXor()

This commit is contained in:
Alex Shvartzkop 2023-07-29 10:12:54 +05:00
parent 6d624ac1ff
commit 040fd327ab
2 changed files with 28 additions and 0 deletions

View File

@ -978,6 +978,10 @@ public:
/// For \a aFastMode meaning, see function booleanOp
void BooleanIntersection( const SHAPE_POLY_SET& b, POLYGON_MODE aFastMode );
/// Perform boolean polyset exclusive or
/// For \a aFastMode meaning, see function booleanOp
void BooleanXor( const SHAPE_POLY_SET& b, POLYGON_MODE aFastMode );
/// Perform boolean polyset union between a and b, store the result in it self
/// For \a aFastMode meaning, see function booleanOp
void BooleanAdd( const SHAPE_POLY_SET& a, const SHAPE_POLY_SET& b,
@ -993,6 +997,11 @@ public:
void BooleanIntersection( const SHAPE_POLY_SET& a, const SHAPE_POLY_SET& b,
POLYGON_MODE aFastMode );
/// Perform boolean polyset exclusive or between a and b, store the result in it self
/// For \a aFastMode meaning, see function booleanOp
void BooleanXor( const SHAPE_POLY_SET& a, const SHAPE_POLY_SET& b,
POLYGON_MODE aFastMode );
/// define how inflate transform build inflated polygon
enum CORNER_STRATEGY
{

View File

@ -877,6 +877,15 @@ void SHAPE_POLY_SET::BooleanIntersection( const SHAPE_POLY_SET& b, POLYGON_MODE
}
void SHAPE_POLY_SET::BooleanXor( const SHAPE_POLY_SET& b, POLYGON_MODE aFastMode )
{
if( ADVANCED_CFG::GetCfg().m_UseClipper2 )
booleanOp( Clipper2Lib::ClipType::Xor, b );
else
booleanOp( ClipperLib::ctXor, b, aFastMode );
}
void SHAPE_POLY_SET::BooleanAdd( const SHAPE_POLY_SET& a, const SHAPE_POLY_SET& b,
POLYGON_MODE aFastMode )
{
@ -907,6 +916,16 @@ void SHAPE_POLY_SET::BooleanIntersection( const SHAPE_POLY_SET& a, const SHAPE_P
}
void SHAPE_POLY_SET::BooleanXor( const SHAPE_POLY_SET& a, const SHAPE_POLY_SET& b,
POLYGON_MODE aFastMode )
{
if( ADVANCED_CFG::GetCfg().m_UseClipper2 )
booleanOp( Clipper2Lib::ClipType::Xor, a, b );
else
booleanOp( ClipperLib::ctXor, a, b, aFastMode );
}
void SHAPE_POLY_SET::InflateWithLinkedHoles( int aFactor,
SHAPE_POLY_SET::CORNER_STRATEGY aCornerStrategy,
int aMaxError, POLYGON_MODE aFastMode )