From cf52f9c531dae3efdd3253c13b2eed2617510b20 Mon Sep 17 00:00:00 2001 From: Scott Mudge Date: Mon, 19 Jun 2023 04:26:15 -0400 Subject: [PATCH] Merge PR "Aligned Monotonic infill for improving surface finish and clarity of clear parts" https://github.com/prusa3d/PrusaSlicer/pull/10847 --- src/libslic3r/Fill/FillBase.cpp | 1 + src/libslic3r/Fill/FillRectilinear.cpp | 10 ++++++++++ src/libslic3r/Fill/FillRectilinear.hpp | 13 +++++++++++++ src/libslic3r/PrintConfig.cpp | 4 ++++ src/libslic3r/PrintConfig.hpp | 6 +++--- 5 files changed, 31 insertions(+), 3 deletions(-) diff --git a/src/libslic3r/Fill/FillBase.cpp b/src/libslic3r/Fill/FillBase.cpp index fa9b0429d7e..02a8c891bc8 100644 --- a/src/libslic3r/Fill/FillBase.cpp +++ b/src/libslic3r/Fill/FillBase.cpp @@ -48,6 +48,7 @@ Fill* Fill::new_from_type(const InfillPattern type) case ipAlignedRectilinear: return new FillAlignedRectilinear(); case ipMonotonic: return new FillMonotonic(); case ipMonotonicLines: return new FillMonotonicLines(); + case ipAlignedMonotonic: return new FillAlignedMonotonic(); case ipLine: return new FillLine(); case ipGrid: return new FillGrid(); case ipTriangles: return new FillTriangles(); diff --git a/src/libslic3r/Fill/FillRectilinear.cpp b/src/libslic3r/Fill/FillRectilinear.cpp index 8802d371c0e..4a60612a6d6 100644 --- a/src/libslic3r/Fill/FillRectilinear.cpp +++ b/src/libslic3r/Fill/FillRectilinear.cpp @@ -2983,6 +2983,16 @@ Polylines FillMonotonic::fill_surface(const Surface *surface, const FillParams & return polylines_out; } +Polylines FillAlignedMonotonic::fill_surface(const Surface *surface, const FillParams ¶ms) +{ + FillParams params2 = params; + params2.monotonic = true; + Polylines polylines_out; + if (! fill_surface_by_lines(surface, params2, 0.f, 0.f, polylines_out)) + BOOST_LOG_TRIVIAL(error) << "FillAlignedMonotonic::fill_surface() failed to fill a region."; + return polylines_out; +} + Polylines FillMonotonicLines::fill_surface(const Surface *surface, const FillParams ¶ms) { FillParams params2 = params; diff --git a/src/libslic3r/Fill/FillRectilinear.hpp b/src/libslic3r/Fill/FillRectilinear.hpp index e009d686fd1..e6d2675755f 100644 --- a/src/libslic3r/Fill/FillRectilinear.hpp +++ b/src/libslic3r/Fill/FillRectilinear.hpp @@ -69,6 +69,19 @@ class FillMonotonicLines : public FillRectilinear bool no_sort() const override { return true; } }; +class FillAlignedMonotonic : public FillRectilinear +{ +public: + Fill* clone() const override { return new FillAlignedMonotonic(*this); } + ~FillAlignedMonotonic() override = default; + Polylines fill_surface(const Surface *surface, const FillParams ¶ms) override; + bool no_sort() const override { return true; } + +protected: + // Always generate infill at the same angle. + virtual float _layer_angle(size_t idx) const override { return 0.f; } +}; + class FillGrid : public FillRectilinear { public: diff --git a/src/libslic3r/PrintConfig.cpp b/src/libslic3r/PrintConfig.cpp index 2607e4f9eb8..6dbddd39deb 100644 --- a/src/libslic3r/PrintConfig.cpp +++ b/src/libslic3r/PrintConfig.cpp @@ -124,6 +124,7 @@ static const t_config_enum_values s_keys_map_InfillPattern { { "monotonic", ipMonotonic }, { "monotoniclines", ipMonotonicLines }, { "alignedrectilinear", ipAlignedRectilinear }, + { "alignedmonotonic", ipAlignedMonotonic }, { "grid", ipGrid }, { "triangles", ipTriangles }, { "stars", ipStars }, @@ -944,6 +945,7 @@ void PrintConfigDef::init_fff_params() { "monotonic", L("Monotonic") }, { "monotoniclines", L("Monotonic Lines") }, { "alignedrectilinear", L("Aligned Rectilinear") }, + { "alignedmonotonic", L("Aligned Monotonic") }, { "concentric", L("Concentric") }, { "hilbertcurve", L("Hilbert Curve") }, { "archimedeanchords", L("Archimedean Chords") }, @@ -1476,6 +1478,8 @@ void PrintConfigDef::init_fff_params() def->set_enum({ { "rectilinear", L("Rectilinear") }, { "alignedrectilinear", L("Aligned Rectilinear") }, + { "monotonic", L("Monotonic") }, + { "alignedmonotonic", L("Aligned Monotonic") }, { "grid", L("Grid") }, { "triangles", L("Triangles")}, { "stars", L("Stars")}, diff --git a/src/libslic3r/PrintConfig.hpp b/src/libslic3r/PrintConfig.hpp index 5faa235d839..da2a91239fc 100644 --- a/src/libslic3r/PrintConfig.hpp +++ b/src/libslic3r/PrintConfig.hpp @@ -79,9 +79,9 @@ enum class FuzzySkinType { }; enum InfillPattern : int { - ipRectilinear, ipMonotonic, ipMonotonicLines, ipAlignedRectilinear, ipGrid, ipTriangles, ipStars, ipCubic, ipLine, ipConcentric, ipHoneycomb, ip3DHoneycomb, - ipGyroid, ipHilbertCurve, ipArchimedeanChords, ipOctagramSpiral, ipAdaptiveCubic, ipSupportCubic, ipSupportBase, - ipLightning, + ipRectilinear, ipMonotonic, ipMonotonicLines, ipAlignedRectilinear, ipAlignedMonotonic, ipGrid, ipTriangles, ipStars, ipCubic, ipLine, + ipConcentric, ipHoneycomb, ip3DHoneycomb, ipGyroid, ipHilbertCurve, ipArchimedeanChords, ipOctagramSpiral, ipAdaptiveCubic, ipSupportCubic, + ipSupportBase,ipLightning, ipEnsuring, ipCount, ipAlterCentric