mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-08-14 05:05:56 +08:00
Fix broken arrange
This commit is contained in:
parent
440e54181b
commit
50c351e0f4
@ -150,9 +150,10 @@ template<> inline void offset(PolygonImpl& sh, TCoord<PointImpl> distance)
|
|||||||
// but throwing would be an overkill. Instead, we should warn the
|
// but throwing would be an overkill. Instead, we should warn the
|
||||||
// caller about the inability to create correct geometries
|
// caller about the inability to create correct geometries
|
||||||
if(!found_the_contour) {
|
if(!found_the_contour) {
|
||||||
sh.Contour = r;
|
sh.Contour = std::move(r);
|
||||||
ClipperLib::ReversePath(sh.Contour);
|
ClipperLib::ReversePath(sh.Contour);
|
||||||
sh.Contour.push_back(sh.Contour.front());
|
auto front_p = sh.Contour.front();
|
||||||
|
sh.Contour.emplace_back(std::move(front_p));
|
||||||
found_the_contour = true;
|
found_the_contour = true;
|
||||||
} else {
|
} else {
|
||||||
dout() << "Warning: offsetting result is invalid!";
|
dout() << "Warning: offsetting result is invalid!";
|
||||||
@ -162,9 +163,10 @@ template<> inline void offset(PolygonImpl& sh, TCoord<PointImpl> distance)
|
|||||||
// TODO If there are multiple contours we can't be sure which hole
|
// TODO If there are multiple contours we can't be sure which hole
|
||||||
// belongs to the first contour. (But in this case the situation is
|
// belongs to the first contour. (But in this case the situation is
|
||||||
// bad enough to let it go...)
|
// bad enough to let it go...)
|
||||||
sh.Holes.push_back(r);
|
sh.Holes.emplace_back(std::move(r));
|
||||||
ClipperLib::ReversePath(sh.Holes.back());
|
ClipperLib::ReversePath(sh.Holes.back());
|
||||||
sh.Holes.back().push_back(sh.Holes.back().front());
|
auto front_p = sh.Holes.back().front();
|
||||||
|
sh.Holes.back().emplace_back(std::move(front_p));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -328,16 +330,18 @@ inline std::vector<PolygonImpl> clipper_execute(
|
|||||||
std::function<void(ClipperLib::PolyNode*, PolygonImpl&)> processHole;
|
std::function<void(ClipperLib::PolyNode*, PolygonImpl&)> processHole;
|
||||||
|
|
||||||
auto processPoly = [&retv, &processHole](ClipperLib::PolyNode *pptr) {
|
auto processPoly = [&retv, &processHole](ClipperLib::PolyNode *pptr) {
|
||||||
PolygonImpl poly(pptr->Contour);
|
PolygonImpl poly;
|
||||||
poly.Contour.push_back(poly.Contour.front());
|
poly.Contour.swap(pptr->Contour); auto front_p = poly.Contour.front();
|
||||||
|
poly.Contour.emplace_back(std::move(front_p));
|
||||||
for(auto h : pptr->Childs) { processHole(h, poly); }
|
for(auto h : pptr->Childs) { processHole(h, poly); }
|
||||||
retv.push_back(poly);
|
retv.push_back(poly);
|
||||||
};
|
};
|
||||||
|
|
||||||
processHole = [&processPoly](ClipperLib::PolyNode *pptr, PolygonImpl& poly)
|
processHole = [&processPoly](ClipperLib::PolyNode *pptr, PolygonImpl& poly)
|
||||||
{
|
{
|
||||||
poly.Holes.push_back(pptr->Contour);
|
poly.Holes.emplace_back(std::move(pptr->Contour));
|
||||||
poly.Holes.back().push_back(poly.Holes.back().front());
|
auto front_p = poly.Holes.back().front();
|
||||||
|
poly.Holes.back().emplace_back(std::move(front_p));
|
||||||
for(auto c : pptr->Childs) processPoly(c);
|
for(auto c : pptr->Childs) processPoly(c);
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -365,7 +369,9 @@ merge(const std::vector<PolygonImpl>& shapes)
|
|||||||
|
|
||||||
for(auto& path : shapes) {
|
for(auto& path : shapes) {
|
||||||
valid &= clipper.AddPath(path.Contour, ClipperLib::ptSubject, closed);
|
valid &= clipper.AddPath(path.Contour, ClipperLib::ptSubject, closed);
|
||||||
valid &= clipper.AddPaths(path.Holes, ClipperLib::ptSubject, closed);
|
|
||||||
|
for(auto& h : path.Holes)
|
||||||
|
valid &= clipper.AddPath(h, ClipperLib::ptSubject, closed);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!valid) throw GeometryException(GeomErr::MERGE);
|
if(!valid) throw GeometryException(GeomErr::MERGE);
|
||||||
|
@ -966,7 +966,7 @@ private:
|
|||||||
|
|
||||||
for(size_t i = 0; i < pckgrp.size(); i++) {
|
for(size_t i = 0; i < pckgrp.size(); i++) {
|
||||||
auto items = pckgrp[i];
|
auto items = pckgrp[i];
|
||||||
pg.push_back({});
|
pg.emplace_back();
|
||||||
pg[i].reserve(items.size());
|
pg[i].reserve(items.size());
|
||||||
|
|
||||||
for(Item& itemA : items) {
|
for(Item& itemA : items) {
|
||||||
|
@ -261,7 +261,7 @@ template<class RawShape> class EdgeCache {
|
|||||||
while(next != endit) {
|
while(next != endit) {
|
||||||
contour_.emap.emplace_back(*(first++), *(next++));
|
contour_.emap.emplace_back(*(first++), *(next++));
|
||||||
contour_.full_distance += contour_.emap.back().length();
|
contour_.full_distance += contour_.emap.back().length();
|
||||||
contour_.distances.push_back(contour_.full_distance);
|
contour_.distances.emplace_back(contour_.full_distance);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -276,10 +276,10 @@ template<class RawShape> class EdgeCache {
|
|||||||
while(next != endit) {
|
while(next != endit) {
|
||||||
hc.emap.emplace_back(*(first++), *(next++));
|
hc.emap.emplace_back(*(first++), *(next++));
|
||||||
hc.full_distance += hc.emap.back().length();
|
hc.full_distance += hc.emap.back().length();
|
||||||
hc.distances.push_back(hc.full_distance);
|
hc.distances.emplace_back(hc.full_distance);
|
||||||
}
|
}
|
||||||
|
|
||||||
holes_.push_back(hc);
|
holes_.emplace_back(std::move(hc));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -63,7 +63,7 @@ public:
|
|||||||
bool pack(Item& item, const Range& rem = Range()) {
|
bool pack(Item& item, const Range& rem = Range()) {
|
||||||
auto&& r = static_cast<Subclass*>(this)->trypack(item, rem);
|
auto&& r = static_cast<Subclass*>(this)->trypack(item, rem);
|
||||||
if(r) {
|
if(r) {
|
||||||
items_.push_back(*(r.item_ptr_));
|
items_.emplace_back(*(r.item_ptr_));
|
||||||
farea_valid_ = false;
|
farea_valid_ = false;
|
||||||
}
|
}
|
||||||
return r;
|
return r;
|
||||||
@ -78,7 +78,7 @@ public:
|
|||||||
if(r) {
|
if(r) {
|
||||||
r.item_ptr_->translation(r.move_);
|
r.item_ptr_->translation(r.move_);
|
||||||
r.item_ptr_->rotation(r.rot_);
|
r.item_ptr_->rotation(r.rot_);
|
||||||
items_.push_back(*(r.item_ptr_));
|
items_.emplace_back(*(r.item_ptr_));
|
||||||
farea_valid_ = false;
|
farea_valid_ = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -667,7 +667,7 @@ public:
|
|||||||
addBin();
|
addBin();
|
||||||
ItemList& not_packed = not_packeds[b];
|
ItemList& not_packed = not_packeds[b];
|
||||||
for(unsigned idx = b; idx < store_.size(); idx+=bincount_guess) {
|
for(unsigned idx = b; idx < store_.size(); idx+=bincount_guess) {
|
||||||
not_packed.push_back(store_[idx]);
|
not_packed.emplace_back(store_[idx]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -463,7 +463,7 @@ template<> inline std::string serialize<libnest2d::Formats::SVG>(
|
|||||||
auto& v = *it;
|
auto& v = *it;
|
||||||
hf.emplace_back(getX(v)*scale, getY(v)*scale);
|
hf.emplace_back(getX(v)*scale, getY(v)*scale);
|
||||||
};
|
};
|
||||||
holes.push_back(hf);
|
holes.emplace_back(std::move(hf));
|
||||||
}
|
}
|
||||||
|
|
||||||
Polygonf poly;
|
Polygonf poly;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user