diff --git a/src/libnest2d/include/libnest2d/backends/clipper/geometries.hpp b/src/libnest2d/include/libnest2d/backends/clipper/geometries.hpp index 57da6ec12..dd80322bc 100644 --- a/src/libnest2d/include/libnest2d/backends/clipper/geometries.hpp +++ b/src/libnest2d/include/libnest2d/backends/clipper/geometries.hpp @@ -77,7 +77,7 @@ inline void offset(PolygonImpl& sh, TCoord distance, const PolygonTag #define DISABLE_BOOST_OFFSET using ClipperLib::ClipperOffset; - using ClipperLib::jtMiter; + using ClipperLib::jtSquare; using ClipperLib::etClosedPolygon; using ClipperLib::Paths; @@ -85,8 +85,8 @@ inline void offset(PolygonImpl& sh, TCoord distance, const PolygonTag try { ClipperOffset offs; - offs.AddPath(sh.Contour, jtMiter, etClosedPolygon); - offs.AddPaths(sh.Holes, jtMiter, etClosedPolygon); + offs.AddPath(sh.Contour, jtSquare, etClosedPolygon); + offs.AddPaths(sh.Holes, jtSquare, etClosedPolygon); offs.Execute(result, static_cast(distance)); } catch (ClipperLib::clipperException &) { throw GeometryException(GeomErr::OFFSET); diff --git a/src/libnest2d/include/libnest2d/placers/nfpplacer.hpp b/src/libnest2d/include/libnest2d/placers/nfpplacer.hpp index 91f04cb93..6cdaadd25 100644 --- a/src/libnest2d/include/libnest2d/placers/nfpplacer.hpp +++ b/src/libnest2d/include/libnest2d/placers/nfpplacer.hpp @@ -528,15 +528,12 @@ public: static inline double overfit(const Box& bb, const Box& bin) { - auto Bw = bin.width(); - auto Bh = bin.height(); - auto mBw = -Bw; - auto mBh = -Bh; - auto wdiff = double(bb.width()) + mBw; - auto hdiff = double(bb.height()) + mBh; - double diff = 0; - if(wdiff > 0) diff += wdiff; - if(hdiff > 0) diff += hdiff; + auto wdiff = TCompute(bb.width()) - bin.width(); + auto hdiff = TCompute(bb.height()) - bin.height(); + double diff = .0; + if(wdiff > 0) diff += double(wdiff); + if(hdiff > 0) diff += double(hdiff); + return diff; } diff --git a/src/libslic3r/Arrange.cpp b/src/libslic3r/Arrange.cpp index de6b34c1f..6ae7dd6a2 100644 --- a/src/libslic3r/Arrange.cpp +++ b/src/libslic3r/Arrange.cpp @@ -396,11 +396,14 @@ template<> std::function AutoArranger::get_objfn() double score = std::get<0>(result); auto& fullbb = std::get<1>(result); - double miss = Placer::overfit(fullbb, m_bin); + auto bin = m_bin; + sl::offset(bin, -EPSILON * (m_bin.width() + m_bin.height())); + + double miss = Placer::overfit(fullbb, bin); miss = miss > 0? miss : 0; score += miss*miss; - return score; + return score; }; }