Clipper2: Handle nested poly/hole/poly returns
In Clipper1, we had a flat tree structure on returns. Clipper2 nests these, so we need to properly handle the nesting structure when importing the polygons
This commit is contained in:
parent
34742b386d
commit
4cdf0bd6c9
|
@ -1394,6 +1394,9 @@ private:
|
|||
void importTree( Clipper2Lib::Paths64& paths,
|
||||
const std::vector<CLIPPER_Z_VALUE>& aZValueBuffer,
|
||||
const std::vector<SHAPE_ARC>& aArcBuffe );
|
||||
void importPolyPath( Clipper2Lib::PolyPath64* aPolyPath,
|
||||
const std::vector<CLIPPER_Z_VALUE>& aZValueBuffer,
|
||||
const std::vector<SHAPE_ARC>& aArcBuffer );
|
||||
|
||||
void inflate1( int aAmount, int aCircleSegCount, CORNER_STRATEGY aCornerStrategy );
|
||||
void inflate2( int aAmount, int aCircleSegCount, CORNER_STRATEGY aCornerStrategy );
|
||||
|
|
|
@ -1082,6 +1082,29 @@ void SHAPE_POLY_SET::importTree( ClipperLib::PolyTree* tree,
|
|||
}
|
||||
|
||||
|
||||
void SHAPE_POLY_SET::importPolyPath( Clipper2Lib::PolyPath64* aPolyPath,
|
||||
const std::vector<CLIPPER_Z_VALUE>& aZValueBuffer,
|
||||
const std::vector<SHAPE_ARC>& aArcBuffer )
|
||||
{
|
||||
if( !aPolyPath->IsHole() )
|
||||
{
|
||||
POLYGON paths;
|
||||
paths.reserve( aPolyPath->Count() + 1 );
|
||||
paths.emplace_back( aPolyPath->Polygon(), aZValueBuffer, aArcBuffer );
|
||||
|
||||
for( Clipper2Lib::PolyPath64* child : *aPolyPath )
|
||||
{
|
||||
paths.emplace_back( child->Polygon(), aZValueBuffer, aArcBuffer );
|
||||
|
||||
for( Clipper2Lib::PolyPath64* grandchild : *child )
|
||||
importPolyPath( grandchild, aZValueBuffer, aArcBuffer );
|
||||
}
|
||||
|
||||
m_polys.push_back( paths );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void SHAPE_POLY_SET::importTree( Clipper2Lib::PolyTree64& tree,
|
||||
const std::vector<CLIPPER_Z_VALUE>& aZValueBuffer,
|
||||
const std::vector<SHAPE_ARC>& aArcBuffer )
|
||||
|
@ -1089,20 +1112,7 @@ void SHAPE_POLY_SET::importTree( Clipper2Lib::PolyTree64& tree,
|
|||
m_polys.clear();
|
||||
|
||||
for( Clipper2Lib::PolyPath64* n : tree )
|
||||
{
|
||||
if( !n->IsHole() )
|
||||
{
|
||||
POLYGON paths;
|
||||
paths.reserve( n->Count() + 1 );
|
||||
|
||||
paths.emplace_back( n->Polygon(), aZValueBuffer, aArcBuffer );
|
||||
|
||||
for( Clipper2Lib::PolyPath64* child : *n)
|
||||
paths.emplace_back( child->Polygon(), aZValueBuffer, aArcBuffer );
|
||||
|
||||
m_polys.push_back( paths );
|
||||
}
|
||||
}
|
||||
importPolyPath( n, aZValueBuffer, aArcBuffer );
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue