mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-09-27 19:01:02 +00:00
Port Quartercubic infill pattern (#7243)
* Ported Quarter Cubic infill pattern from Cura * Code reformat
This commit is contained in:
@@ -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();
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include <boost/container/small_vector.hpp>
|
||||
#include <boost/log/trivial.hpp>
|
||||
#include <boost/static_assert.hpp>
|
||||
#include <boost/math/constants/constants.hpp>
|
||||
|
||||
#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());
|
||||
|
||||
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user