diff --git a/resources/images/param_quartercubic.svg b/resources/images/param_quartercubic.svg new file mode 100644 index 0000000000..21008d7b11 --- /dev/null +++ b/resources/images/param_quartercubic.svg @@ -0,0 +1,108 @@ + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + diff --git a/src/libslic3r/Fill/FillBase.cpp b/src/libslic3r/Fill/FillBase.cpp index 6225987486..d5ce03d3b4 100644 --- a/src/libslic3r/Fill/FillBase.cpp +++ b/src/libslic3r/Fill/FillBase.cpp @@ -50,6 +50,7 @@ Fill* Fill::new_from_type(const InfillPattern type) case ipTriangles: return new FillTriangles(); case ipStars: return new FillStars(); case ipCubic: return new FillCubic(); + case ipQuarterCubic: return new FillQuarterCubic(); case ipArchimedeanChords: return new FillArchimedeanChords(); case ipHilbertCurve: return new FillHilbertCurve(); case ipOctagramSpiral: return new FillOctagramSpiral(); diff --git a/src/libslic3r/Fill/FillRectilinear.cpp b/src/libslic3r/Fill/FillRectilinear.cpp index dc9595eac4..6b1ba2f924 100644 --- a/src/libslic3r/Fill/FillRectilinear.cpp +++ b/src/libslic3r/Fill/FillRectilinear.cpp @@ -9,6 +9,7 @@ #include #include #include +#include #include "../ClipperUtils.hpp" #include "../ExPolygon.hpp" @@ -3035,6 +3036,39 @@ Polylines FillCubic::fill_surface(const Surface *surface, const FillParams ¶ return polylines_out; } +Polylines FillQuarterCubic::fill_surface(const Surface* surface, const FillParams& params) +{ + using namespace boost::math::float_constants; + + Polylines polylines_out; + + coord_t line_width = coord_t(scale_(this->spacing)); + coord_t period = coord_t(scale_(this->spacing) / params.density) * 4; + + // First half tetrahedral fill + double pattern_z_shift = 0.0; + coord_t shift = coord_t(one_div_root_two * (scale_(z) + pattern_z_shift * period * 2)) % period; + shift = std::min(shift, period - shift); // symmetry due to the fact that we are applying the shift in both directions + shift = std::min(shift, period / 2 - line_width / 2); // don't put lines too close to each other + shift = std::max(shift, line_width / 2); // don't put lines too close to each other + float dx1 = unscale_(shift); + + // Second half tetrahedral fill + pattern_z_shift = 0.5; + shift = coord_t(one_div_root_two * (scale_(z) + pattern_z_shift * period * 2)) % period; + shift = std::min(shift, period - shift); // symmetry due to the fact that we are applying the shift in both directions + shift = std::min(shift, period / 2 - line_width / 2); // don't put lines too close to each other + shift = std::max(shift, line_width / 2); // don't put lines too close to each other + float dx2 = unscale_(shift); + if (!this->fill_surface_by_multilines( + surface, params, + {{0.f, dx1}, {0.f, -dx1}, {float(M_PI / 2.), dx2}, {float(M_PI / 2.), -dx2}}, + polylines_out)) + BOOST_LOG_TRIVIAL(error) << "FillQuarterCubic::fill_surface() failed to fill a region."; + + return polylines_out; +} + Polylines FillSupportBase::fill_surface(const Surface *surface, const FillParams ¶ms) { assert(! params.full_infill()); diff --git a/src/libslic3r/Fill/FillRectilinear.hpp b/src/libslic3r/Fill/FillRectilinear.hpp index f85dce07e8..c835607ce7 100644 --- a/src/libslic3r/Fill/FillRectilinear.hpp +++ b/src/libslic3r/Fill/FillRectilinear.hpp @@ -107,6 +107,20 @@ protected: float _layer_angle(size_t idx) const override { return 0.f; } }; +// Added QuarterCubic pattern from Cura +class FillQuarterCubic : public FillRectilinear +{ +public: + Fill* clone() const override { return new FillQuarterCubic(*this); } + ~FillQuarterCubic() override = default; + Polylines fill_surface(const Surface *surface, const FillParams ¶ms) override; + +protected: + // The grid fill will keep the angle constant between the layers, see the implementation of Slic3r::Fill. + float _layer_angle(size_t idx) const override { return 0.f; } +}; + + class FillSupportBase : public FillRectilinear { public: diff --git a/src/libslic3r/PrintConfig.cpp b/src/libslic3r/PrintConfig.cpp index afcdfc0d22..0fd8c91b78 100644 --- a/src/libslic3r/PrintConfig.cpp +++ b/src/libslic3r/PrintConfig.cpp @@ -143,7 +143,8 @@ static t_config_enum_values s_keys_map_InfillPattern { { "octagramspiral", ipOctagramSpiral }, { "supportcubic", ipSupportCubic }, { "lightning", ipLightning }, - { "crosshatch", ipCrossHatch} + { "crosshatch", ipCrossHatch}, + { "quartercubic", ipQuarterCubic} }; CONFIG_OPTION_ENUM_DEFINE_STATIC_MAPS(InfillPattern) @@ -2272,6 +2273,7 @@ void PrintConfigDef::init_fff_params() def->enum_values.push_back("supportcubic"); def->enum_values.push_back("lightning"); def->enum_values.push_back("crosshatch"); + def->enum_values.push_back("quartercubic"); def->enum_labels.push_back(L("Concentric")); def->enum_labels.push_back(L("Rectilinear")); def->enum_labels.push_back(L("Grid")); @@ -2290,6 +2292,7 @@ void PrintConfigDef::init_fff_params() def->enum_labels.push_back(L("Support Cubic")); def->enum_labels.push_back(L("Lightning")); def->enum_labels.push_back(L("Cross Hatch")); + def->enum_labels.push_back(L("Quarter Cubic")); def->set_default_value(new ConfigOptionEnum(ipCrossHatch)); auto def_infill_anchor_min = def = this->add("infill_anchor", coFloatOrPercent); diff --git a/src/libslic3r/PrintConfig.hpp b/src/libslic3r/PrintConfig.hpp index 0d68906cb3..dc222603b8 100644 --- a/src/libslic3r/PrintConfig.hpp +++ b/src/libslic3r/PrintConfig.hpp @@ -52,7 +52,7 @@ enum AuthorizationType { enum InfillPattern : int { ipConcentric, ipRectilinear, ipGrid, ipLine, ipCubic, ipTriangles, ipStars, ipGyroid, ipHoneycomb, ipAdaptiveCubic, ipMonotonic, ipMonotonicLine, ipAlignedRectilinear, ip3DHoneycomb, ipHilbertCurve, ipArchimedeanChords, ipOctagramSpiral, ipSupportCubic, ipSupportBase, ipConcentricInternal, - ipLightning, ipCrossHatch, + ipLightning, ipCrossHatch, ipQuarterCubic, ipCount, };