From ce71144c7cdd93e7b83c12a11cd829d97bbbcb5f Mon Sep 17 00:00:00 2001 From: Filip Sykala - NTB T15p Date: Thu, 13 Oct 2022 13:30:22 +0200 Subject: [PATCH] Add minimal value for glyph flatness to not create huge amount of points on curve Fix for font: TREFOIL.TTF issue 74 --- src/libslic3r/Emboss.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/libslic3r/Emboss.cpp b/src/libslic3r/Emboss.cpp index 16b174517..ac886a151 100644 --- a/src/libslic3r/Emboss.cpp +++ b/src/libslic3r/Emboss.cpp @@ -280,10 +280,12 @@ ExPolygons Emboss::heal_shape(const Polygons &shape) { // fix of self intersections // http://www.angusj.com/delphi/clipper/documentation/Docs/Units/ClipperLib/Functions/SimplifyPolygon.htm ClipperLib::Paths paths = ClipperLib::SimplifyPolygons(ClipperUtils::PolygonsProvider(shape), ClipperLib::pftNonZero); - ClipperLib::CleanPolygons(paths); + const double clean_distance = 1.415; // little grater than sqrt(2) + ClipperLib::CleanPolygons(paths, clean_distance); Polygons polygons = to_polygons(paths); - // do not remove all duplicits but do it better way + // Do not remove all duplicits but do it better way + // Overlap all duplicit points by rectangle 3x3 Points duplicits = collect_duplications(to_points(polygons)); if (!duplicits.empty()) { polygons.reserve(polygons.size() + duplicits.size()); @@ -302,7 +304,6 @@ ExPolygons Emboss::heal_shape(const Polygons &shape) { return res; } -#define HEAL_CLOSE_POINTS bool Emboss::heal_shape(ExPolygons &shape, unsigned max_iteration) { if (shape.empty()) return true; @@ -478,6 +479,10 @@ const Emboss::Glyph* priv::get_glyph( } float flatness = static_cast(font.infos[font_index].ascent * RESOLUTION / font_prop.size_in_mm); + + // Fix for very small flatness because it create huge amount of points from curve + if (flatness < RESOLUTION) flatness = RESOLUTION; + std::optional glyph_opt = priv::get_glyph(*font_info_opt, unicode, flatness);