fix for hole disappearance
This commit is contained in:
parent
d31590f438
commit
08b9d9a519
1 changed files with 18 additions and 19 deletions
|
@ -1041,37 +1041,31 @@ void SLAPrint::process()
|
||||||
{
|
{
|
||||||
ClipperPolygon poly;
|
ClipperPolygon poly;
|
||||||
|
|
||||||
// We need to reverse if flpXY OR is_lefthanded is true but
|
|
||||||
// not if both are true which is a logical inequality (XOR)
|
|
||||||
bool needreverse = flpXY != is_lefthanded;
|
|
||||||
|
|
||||||
// should be a move
|
// should be a move
|
||||||
poly.Contour.reserve(polygon.contour.size() + 1);
|
poly.Contour.reserve(polygon.contour.size() + 1);
|
||||||
|
|
||||||
auto& cntr = polygon.contour.points;
|
for(auto& p : polygon.contour.points)
|
||||||
if(needreverse)
|
|
||||||
for(auto it = cntr.rbegin(); it != cntr.rend(); ++it)
|
|
||||||
poly.Contour.emplace_back(it->x(), it->y());
|
|
||||||
else
|
|
||||||
for(auto& p : cntr)
|
|
||||||
poly.Contour.emplace_back(p.x(), p.y());
|
poly.Contour.emplace_back(p.x(), p.y());
|
||||||
|
|
||||||
|
auto pfirst = poly.Contour.front();
|
||||||
|
poly.Contour.emplace_back(pfirst);
|
||||||
|
|
||||||
for(auto& h : polygon.holes) {
|
for(auto& h : polygon.holes) {
|
||||||
poly.Holes.emplace_back();
|
poly.Holes.emplace_back();
|
||||||
auto& hole = poly.Holes.back();
|
auto& hole = poly.Holes.back();
|
||||||
hole.reserve(h.points.size() + 1);
|
hole.reserve(h.points.size() + 1);
|
||||||
|
|
||||||
if(needreverse)
|
for(auto& p : h.points) hole.emplace_back(p.x(), p.y());
|
||||||
for(auto& p : h.points)
|
auto pfirst = hole.front(); hole.emplace_back(pfirst);
|
||||||
hole.emplace_back(p.x(), p.y());
|
|
||||||
else
|
|
||||||
for(auto it = h.points.rbegin(); it != h.points.rend(); ++it)
|
|
||||||
hole.emplace_back(it->x(), it->y());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(is_lefthanded) {
|
if(is_lefthanded) {
|
||||||
for(auto& p : poly.Contour) p.X = -p.X;
|
for(auto& p : poly.Contour) p.X = -p.X;
|
||||||
for(auto& h : poly.Holes) for(auto& p : h) p.X = -p.X;
|
std::reverse(poly.Contour.begin(), poly.Contour.end());
|
||||||
|
for(auto& h : poly.Holes) {
|
||||||
|
for(auto& p : h) p.X = -p.X;
|
||||||
|
std::reverse(h.begin(), h.end());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sl::rotate(poly, double(instances[i].rotation));
|
sl::rotate(poly, double(instances[i].rotation));
|
||||||
|
@ -1080,7 +1074,12 @@ void SLAPrint::process()
|
||||||
|
|
||||||
if (flpXY) {
|
if (flpXY) {
|
||||||
for(auto& p : poly.Contour) std::swap(p.X, p.Y);
|
for(auto& p : poly.Contour) std::swap(p.X, p.Y);
|
||||||
for(auto& h : poly.Holes) for(auto& p : h) std::swap(p.X, p.Y);
|
std::reverse(poly.Contour.begin(), poly.Contour.end());
|
||||||
|
|
||||||
|
for(auto& h : poly.Holes) {
|
||||||
|
for(auto& p : h) std::swap(p.X, p.Y);
|
||||||
|
std::reverse(h.begin(), h.end());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
polygons.emplace_back(std::move(poly));
|
polygons.emplace_back(std::move(poly));
|
||||||
|
|
Loading…
Reference in a new issue