From fb1f3589edf1002de8f2f2d99ca3f225a9892c66 Mon Sep 17 00:00:00 2001 From: tamasmeszaros Date: Fri, 9 Oct 2020 17:21:48 +0200 Subject: [PATCH] Use rotated bounding box to calculate eccentricity --- src/libslic3r/SLA/SupportPointGenerator.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/libslic3r/SLA/SupportPointGenerator.cpp b/src/libslic3r/SLA/SupportPointGenerator.cpp index 2d36375a41..9462f0be66 100644 --- a/src/libslic3r/SLA/SupportPointGenerator.cpp +++ b/src/libslic3r/SLA/SupportPointGenerator.cpp @@ -11,8 +11,12 @@ #include "Point.hpp" #include "ClipperUtils.hpp" #include "Tesselate.hpp" +#include "ExPolygonCollection.hpp" #include "libslic3r.h" +#include "libnest2d/backends/clipper/geometries.hpp" +#include "libnest2d/utils/rotcalipers.hpp" + #include #include @@ -545,10 +549,14 @@ void SupportPointGenerator::uniformly_cover(const ExPolygons& islands, Structure //int num_of_points = std::max(1, (int)((island.area()*pow(SCALING_FACTOR, 2) * m_config.tear_pressure)/m_config.support_force)); float support_force_deficit = deficit; - auto bb = get_extents(islands); +// auto bb = get_extents(islands); if (flags & icfIsNew) { - Vec2d bbdim = unscaled(Vec2crd{bb.max - bb.min}); + auto chull_ex = ExPolygonCollection{islands}.convex_hull(); + auto chull = Slic3rMultiPoint_to_ClipperPath(chull_ex); + auto rotbox = libnest2d::minAreaBoundingBox(chull); + Vec2d bbdim = {unscaled(rotbox.width()), unscaled(rotbox.height())}; + if (bbdim.x() > bbdim.y()) std::swap(bbdim.x(), bbdim.y()); double aspectr = bbdim.y() / bbdim.x();