Solved issue with virtual bed management.

libnest2d: Fix for unclosed polygons after merge.
This commit is contained in:
tamasmeszaros 2019-07-17 13:32:31 +02:00
parent 44801f4429
commit 2728f41123
5 changed files with 64 additions and 67 deletions

View file

@ -259,10 +259,12 @@ inline TMultiShape<PolygonImpl> clipper_execute(
poly.Contour.swap(pptr->Contour);
assert(!pptr->IsHole());
if(pptr->IsOpen()) {
if(!poly.Contour.empty() ) {
auto front_p = poly.Contour.front();
poly.Contour.emplace_back(front_p);
auto &back_p = poly.Contour.back();
if(front_p.X != back_p.X || front_p.Y != back_p.X)
poly.Contour.emplace_back(front_p);
}
for(auto h : pptr->Childs) { processHole(h, poly); }
@ -274,10 +276,12 @@ inline TMultiShape<PolygonImpl> clipper_execute(
poly.Holes.emplace_back(std::move(pptr->Contour));
assert(pptr->IsHole());
if(pptr->IsOpen()) {
auto front_p = poly.Holes.back().front();
poly.Holes.back().emplace_back(front_p);
if(!poly.Contour.empty() ) {
auto front_p = poly.Contour.front();
auto &back_p = poly.Contour.back();
if(front_p.X != back_p.X || front_p.Y != back_p.X)
poly.Contour.emplace_back(front_p);
}
for(auto c : pptr->Childs) processPoly(c);