Fillers: Removal of old FillRectilinear, using of "override" instead

of "virtual" where applicable.
This commit is contained in:
Vojtech Bubnik 2020-11-16 11:16:44 +01:00
parent e77fc43159
commit e9fa36ea7d
13 changed files with 78 additions and 131 deletions

View file

@ -19,10 +19,10 @@ class LayerRegion;
class Filler class Filler
{ {
public: public:
Filler() : fill(NULL) {} Filler() : fill(nullptr) {}
~Filler() { ~Filler() {
delete fill; delete fill;
fill = NULL; fill = nullptr;
} }
Fill *fill; Fill *fill;
FillParams params; FillParams params;

View file

@ -12,19 +12,19 @@ namespace Slic3r {
class Fill3DHoneycomb : public Fill class Fill3DHoneycomb : public Fill
{ {
public: public:
virtual Fill* clone() const { return new Fill3DHoneycomb(*this); }; Fill* clone() const override { return new Fill3DHoneycomb(*this); };
virtual ~Fill3DHoneycomb() {} ~Fill3DHoneycomb() override {}
// require bridge flow since most of this pattern hangs in air // require bridge flow since most of this pattern hangs in air
virtual bool use_bridge_flow() const { return true; } bool use_bridge_flow() const override { return true; }
protected: protected:
virtual void _fill_surface_single( void _fill_surface_single(
const FillParams &params, const FillParams &params,
unsigned int thickness_layers, unsigned int thickness_layers,
const std::pair<float, Point> &direction, const std::pair<float, Point> &direction,
ExPolygon &expolygon, ExPolygon &expolygon,
Polylines &polylines_out); Polylines &polylines_out) override;
}; };
} // namespace Slic3r } // namespace Slic3r

View file

@ -56,17 +56,17 @@ FillAdaptive::OctreePtr build_octree(
class Filler : public Slic3r::Fill class Filler : public Slic3r::Fill
{ {
public: public:
virtual ~Filler() {} ~Filler() override {}
protected: protected:
virtual Fill* clone() const { return new Filler(*this); }; Fill* clone() const override { return new Filler(*this); };
virtual void _fill_surface_single( void _fill_surface_single(
const FillParams &params, const FillParams &params,
unsigned int thickness_layers, unsigned int thickness_layers,
const std::pair<float, Point> &direction, const std::pair<float, Point> &direction,
ExPolygon &expolygon, ExPolygon &expolygon,
Polylines &polylines_out); Polylines &polylines_out) override;
virtual bool no_sort() const { return true; } bool no_sort() const override { return true; }
}; };
}; // namespace FillAdaptive }; // namespace FillAdaptive

View file

@ -34,7 +34,6 @@ Fill* Fill::new_from_type(const InfillPattern type)
case ipTriangles: return new FillTriangles(); case ipTriangles: return new FillTriangles();
case ipStars: return new FillStars(); case ipStars: return new FillStars();
case ipCubic: return new FillCubic(); case ipCubic: return new FillCubic();
// case ipGrid: return new FillGrid();
case ipArchimedeanChords: return new FillArchimedeanChords(); case ipArchimedeanChords: return new FillArchimedeanChords();
case ipHilbertCurve: return new FillHilbertCurve(); case ipHilbertCurve: return new FillHilbertCurve();
case ipOctagramSpiral: return new FillOctagramSpiral(); case ipOctagramSpiral: return new FillOctagramSpiral();

View file

@ -83,6 +83,7 @@ public:
public: public:
virtual ~Fill() {} virtual ~Fill() {}
virtual Fill* clone() const = 0;
static Fill* new_from_type(const InfillPattern type); static Fill* new_from_type(const InfillPattern type);
static Fill* new_from_type(const std::string &type); static Fill* new_from_type(const std::string &type);

View file

@ -8,18 +8,18 @@ namespace Slic3r {
class FillConcentric : public Fill class FillConcentric : public Fill
{ {
public: public:
virtual ~FillConcentric() {} ~FillConcentric() override {}
protected: protected:
virtual Fill* clone() const { return new FillConcentric(*this); }; Fill* clone() const override { return new FillConcentric(*this); };
virtual void _fill_surface_single( void _fill_surface_single(
const FillParams &params, const FillParams &params,
unsigned int thickness_layers, unsigned int thickness_layers,
const std::pair<float, Point> &direction, const std::pair<float, Point> &direction,
ExPolygon &expolygon, ExPolygon &expolygon,
Polylines &polylines_out); Polylines &polylines_out) override;
virtual bool no_sort() const { return true; } bool no_sort() const override { return true; }
}; };
} // namespace Slic3r } // namespace Slic3r

View file

@ -11,10 +11,10 @@ class FillGyroid : public Fill
{ {
public: public:
FillGyroid() {} FillGyroid() {}
virtual Fill* clone() const { return new FillGyroid(*this); } Fill* clone() const override { return new FillGyroid(*this); }
// require bridge flow since most of this pattern hangs in air // require bridge flow since most of this pattern hangs in air
virtual bool use_bridge_flow() const { return false; } bool use_bridge_flow() const override { return false; }
// Correction applied to regular infill angle to maximize printing // Correction applied to regular infill angle to maximize printing
// speed in default configuration (degrees) // speed in default configuration (degrees)
@ -28,12 +28,12 @@ public:
protected: protected:
virtual void _fill_surface_single( void _fill_surface_single(
const FillParams &params, const FillParams &params,
unsigned int thickness_layers, unsigned int thickness_layers,
const std::pair<float, Point> &direction, const std::pair<float, Point> &direction,
ExPolygon &expolygon, ExPolygon &expolygon,
Polylines &polylines_out); Polylines &polylines_out) override;
}; };
} // namespace Slic3r } // namespace Slic3r

View file

@ -12,16 +12,16 @@ namespace Slic3r {
class FillHoneycomb : public Fill class FillHoneycomb : public Fill
{ {
public: public:
virtual ~FillHoneycomb() {} ~FillHoneycomb() override {}
protected: protected:
virtual Fill* clone() const { return new FillHoneycomb(*this); }; Fill* clone() const override { return new FillHoneycomb(*this); };
virtual void _fill_surface_single( void _fill_surface_single(
const FillParams &params, const FillParams &params,
unsigned int thickness_layers, unsigned int thickness_layers,
const std::pair<float, Point> &direction, const std::pair<float, Point> &direction,
ExPolygon &expolygon, ExPolygon &expolygon,
Polylines &polylines_out); Polylines &polylines_out) override;
// Caching the // Caching the
struct CacheID struct CacheID
@ -49,7 +49,7 @@ protected:
typedef std::map<CacheID, CacheData> Cache; typedef std::map<CacheID, CacheData> Cache;
Cache cache; Cache cache;
virtual float _layer_angle(size_t idx) const { return float(M_PI/3.) * (idx % 3); } float _layer_angle(size_t idx) const override { return float(M_PI/3.) * (idx % 3); }
}; };
} // namespace Slic3r } // namespace Slic3r

View file

@ -16,17 +16,17 @@ namespace Slic3r {
class FillPlanePath : public Fill class FillPlanePath : public Fill
{ {
public: public:
virtual ~FillPlanePath() {} ~FillPlanePath() override = default;
protected: protected:
virtual void _fill_surface_single( void _fill_surface_single(
const FillParams &params, const FillParams &params,
unsigned int thickness_layers, unsigned int thickness_layers,
const std::pair<float, Point> &direction, const std::pair<float, Point> &direction,
ExPolygon &expolygon, ExPolygon &expolygon,
Polylines &polylines_out); Polylines &polylines_out) override;
virtual float _layer_angle(size_t idx) const { return 0.f; } float _layer_angle(size_t idx) const override { return 0.f; }
virtual bool _centered() const = 0; virtual bool _centered() const = 0;
virtual Pointfs _generate(coord_t min_x, coord_t min_y, coord_t max_x, coord_t max_y) = 0; virtual Pointfs _generate(coord_t min_x, coord_t min_y, coord_t max_x, coord_t max_y) = 0;
}; };
@ -34,34 +34,34 @@ protected:
class FillArchimedeanChords : public FillPlanePath class FillArchimedeanChords : public FillPlanePath
{ {
public: public:
virtual Fill* clone() const { return new FillArchimedeanChords(*this); }; Fill* clone() const override { return new FillArchimedeanChords(*this); };
virtual ~FillArchimedeanChords() {} ~FillArchimedeanChords() override = default;
protected: protected:
virtual bool _centered() const { return true; } bool _centered() const override { return true; }
virtual Pointfs _generate(coord_t min_x, coord_t min_y, coord_t max_x, coord_t max_y); Pointfs _generate(coord_t min_x, coord_t min_y, coord_t max_x, coord_t max_y) override;
}; };
class FillHilbertCurve : public FillPlanePath class FillHilbertCurve : public FillPlanePath
{ {
public: public:
virtual Fill* clone() const { return new FillHilbertCurve(*this); }; Fill* clone() const override { return new FillHilbertCurve(*this); };
virtual ~FillHilbertCurve() {} ~FillHilbertCurve() override = default;
protected: protected:
virtual bool _centered() const { return false; } bool _centered() const override { return false; }
virtual Pointfs _generate(coord_t min_x, coord_t min_y, coord_t max_x, coord_t max_y); Pointfs _generate(coord_t min_x, coord_t min_y, coord_t max_x, coord_t max_y) override;
}; };
class FillOctagramSpiral : public FillPlanePath class FillOctagramSpiral : public FillPlanePath
{ {
public: public:
virtual Fill* clone() const { return new FillOctagramSpiral(*this); }; Fill* clone() const override { return new FillOctagramSpiral(*this); };
virtual ~FillOctagramSpiral() {} ~FillOctagramSpiral() override = default;
protected: protected:
virtual bool _centered() const { return true; } bool _centered() const override { return true; }
virtual Pointfs _generate(coord_t min_x, coord_t min_y, coord_t max_x, coord_t max_y); Pointfs _generate(coord_t min_x, coord_t min_y, coord_t max_x, coord_t max_y) override;
}; };
} // namespace Slic3r } // namespace Slic3r

View file

@ -7,7 +7,7 @@
namespace Slic3r { namespace Slic3r {
void FillRectilinear::_fill_surface_single( void FillLine::_fill_surface_single(
const FillParams &params, const FillParams &params,
unsigned int thickness_layers, unsigned int thickness_layers,
const std::pair<float, Point> &direction, const std::pair<float, Point> &direction,
@ -42,11 +42,6 @@ void FillRectilinear::_fill_surface_single(
Lines lines; Lines lines;
for (coord_t x = bounding_box.min(0); x <= x_max; x += this->_line_spacing) for (coord_t x = bounding_box.min(0); x <= x_max; x += this->_line_spacing)
lines.push_back(this->_line(lines.size(), x, bounding_box.min(1), bounding_box.max(1))); lines.push_back(this->_line(lines.size(), x, bounding_box.min(1), bounding_box.max(1)));
if (this->_horizontal_lines()) {
coord_t y_max = bounding_box.max(1) + SCALED_EPSILON;
for (coord_t y = bounding_box.min(1); y <= y_max; y += this->_line_spacing)
lines.push_back(Line(Point(bounding_box.min(0), y), Point(bounding_box.max(0), y)));
}
// clip paths against a slightly larger expolygon, so that the first and last paths // clip paths against a slightly larger expolygon, so that the first and last paths
// are kept even if the expolygon has vertical sides // are kept even if the expolygon has vertical sides

View file

@ -9,19 +9,19 @@ namespace Slic3r {
class Surface; class Surface;
class FillRectilinear : public Fill class FillLine : public Fill
{ {
public: public:
virtual Fill* clone() const { return new FillRectilinear(*this); }; Fill* clone() const override { return new FillLine(*this); };
virtual ~FillRectilinear() {} ~FillLine() override = default;
protected: protected:
virtual void _fill_surface_single( void _fill_surface_single(
const FillParams &params, const FillParams &params,
unsigned int thickness_layers, unsigned int thickness_layers,
const std::pair<float, Point> &direction, const std::pair<float, Point> &direction,
ExPolygon &expolygon, ExPolygon &expolygon,
Polylines &polylines_out); Polylines &polylines_out) override;
coord_t _min_spacing; coord_t _min_spacing;
coord_t _line_spacing; coord_t _line_spacing;
@ -30,30 +30,12 @@ protected:
// only for line infill // only for line infill
coord_t _line_oscillation; coord_t _line_oscillation;
// Enabled for the grid infill, disabled for the rectilinear and line infill. Line _line(int i, coord_t x, coord_t y_min, coord_t y_max) const {
virtual bool _horizontal_lines() const { return false; }
virtual Line _line(int i, coord_t x, coord_t y_min, coord_t y_max) const
{ return Line(Point(x, y_min), Point(x, y_max)); }
virtual bool _can_connect(coord_t dist_X, coord_t dist_Y) {
return dist_X <= this->_diagonal_distance
&& dist_Y <= this->_diagonal_distance;
}
};
class FillLine : public FillRectilinear
{
public:
virtual ~FillLine() {}
protected:
virtual Line _line(int i, coord_t x, coord_t y_min, coord_t y_max) const {
coord_t osc = (i & 1) ? this->_line_oscillation : 0; coord_t osc = (i & 1) ? this->_line_oscillation : 0;
return Line(Point(x - osc, y_min), Point(x + osc, y_max)); return Line(Point(x - osc, y_min), Point(x + osc, y_max));
} }
virtual bool _can_connect(coord_t dist_X, coord_t dist_Y) bool _can_connect(coord_t dist_X, coord_t dist_Y)
{ {
coord_t TOLERANCE = 10 * SCALED_EPSILON; coord_t TOLERANCE = 10 * SCALED_EPSILON;
return (dist_X >= (this->_line_spacing - this->_line_oscillation) - TOLERANCE) return (dist_X >= (this->_line_spacing - this->_line_oscillation) - TOLERANCE)
@ -62,18 +44,6 @@ protected:
} }
}; };
class FillGrid : public FillRectilinear
{
public:
virtual ~FillGrid() {}
protected:
// The grid fill will keep the angle constant between the layers, see the implementation of Slic3r::Fill.
virtual float _layer_angle(size_t idx) const { return 0.f; }
// Flag for Slic3r::Fill::Rectilinear to fill both directions.
virtual bool _horizontal_lines() const { return true; }
};
}; // namespace Slic3r }; // namespace Slic3r
#endif // slic3r_FillRectilinear_hpp_ #endif // slic3r_FillRectilinear_hpp_

View file

@ -2762,9 +2762,6 @@ bool FillRectilinear2::fill_surface_by_lines(const Surface *surface, const FillP
return true; return true;
} }
#define FILL_MULTIPLE_SWEEPS_NEW
#ifdef FILL_MULTIPLE_SWEEPS_NEW
bool FillRectilinear2::fill_surface_by_multilines(const Surface *surface, FillParams params, const std::initializer_list<SweepParams> &sweep_params, Polylines &polylines_out) bool FillRectilinear2::fill_surface_by_multilines(const Surface *surface, FillParams params, const std::initializer_list<SweepParams> &sweep_params, Polylines &polylines_out)
{ {
assert(sweep_params.size() > 1); assert(sweep_params.size() > 1);
@ -2823,30 +2820,15 @@ bool FillRectilinear2::fill_surface_by_multilines(const Surface *surface, FillPa
} }
} }
if (fill_lines.size() > 1) if (params.dont_connect || fill_lines.size() <= 1) {
fill_lines = chain_polylines(std::move(fill_lines)); if (fill_lines.size() > 1)
fill_lines = chain_polylines(std::move(fill_lines));
if (params.dont_connect || fill_lines.size() <= 1)
append(polylines_out, std::move(fill_lines)); append(polylines_out, std::move(fill_lines));
else } else
connect_infill(std::move(fill_lines), poly_with_offset_base.polygons_outer, get_extents(surface->expolygon.contour), polylines_out, this->spacing, params); connect_infill(std::move(fill_lines), poly_with_offset_base.polygons_outer, get_extents(surface->expolygon.contour), polylines_out, this->spacing, params);
return true; return true;
} }
#else
bool FillRectilinear2::fill_surface_by_multilines(const Surface *surface, FillParams params, const std::initializer_list<SweepParams> &sweep_params, Polylines &polylines_out)
{
params.density /= double(sweep_params.size());
bool success = true;
int idx = 0;
for (const SweepParams &sweep_param : sweep_params) {
if (++ idx == 3)
params.dont_connect = true;
success &= this->fill_surface_by_lines(surface, params, sweep_param.angle_base, sweep_param.pattern_shift, polylines_out);
}
return success;
}
#endif
Polylines FillRectilinear2::fill_surface(const Surface *surface, const FillParams &params) Polylines FillRectilinear2::fill_surface(const Surface *surface, const FillParams &params)
{ {

View file

@ -12,9 +12,9 @@ class Surface;
class FillRectilinear2 : public Fill class FillRectilinear2 : public Fill
{ {
public: public:
virtual Fill* clone() const { return new FillRectilinear2(*this); }; Fill* clone() const override { return new FillRectilinear2(*this); };
virtual ~FillRectilinear2() = default; ~FillRectilinear2() override = default;
virtual Polylines fill_surface(const Surface *surface, const FillParams &params); Polylines fill_surface(const Surface *surface, const FillParams &params) override;
protected: protected:
// Fill by single directional lines, interconnect the lines along perimeters. // Fill by single directional lines, interconnect the lines along perimeters.
@ -32,58 +32,58 @@ protected:
class FillMonotonic : public FillRectilinear2 class FillMonotonic : public FillRectilinear2
{ {
public: public:
virtual Fill* clone() const { return new FillMonotonic(*this); }; Fill* clone() const override { return new FillMonotonic(*this); };
virtual ~FillMonotonic() = default; ~FillMonotonic() override = default;
virtual Polylines fill_surface(const Surface *surface, const FillParams &params); Polylines fill_surface(const Surface *surface, const FillParams &params) override;
virtual bool no_sort() const { return true; } bool no_sort() const override { return true; }
}; };
class FillGrid2 : public FillRectilinear2 class FillGrid2 : public FillRectilinear2
{ {
public: public:
virtual Fill* clone() const { return new FillGrid2(*this); }; Fill* clone() const override { return new FillGrid2(*this); };
virtual ~FillGrid2() = default; ~FillGrid2() override = default;
virtual Polylines fill_surface(const Surface *surface, const FillParams &params); Polylines fill_surface(const Surface *surface, const FillParams &params) override;
protected: protected:
// The grid fill will keep the angle constant between the layers, see the implementation of Slic3r::Fill. // The grid fill will keep the angle constant between the layers, see the implementation of Slic3r::Fill.
virtual float _layer_angle(size_t idx) const { return 0.f; } float _layer_angle(size_t idx) const override { return 0.f; }
}; };
class FillTriangles : public FillRectilinear2 class FillTriangles : public FillRectilinear2
{ {
public: public:
virtual Fill* clone() const { return new FillTriangles(*this); }; Fill* clone() const override { return new FillTriangles(*this); };
virtual ~FillTriangles() = default; ~FillTriangles() override = default;
virtual Polylines fill_surface(const Surface *surface, const FillParams &params); Polylines fill_surface(const Surface *surface, const FillParams &params) override;
protected: protected:
// The grid fill will keep the angle constant between the layers, see the implementation of Slic3r::Fill. // The grid fill will keep the angle constant between the layers, see the implementation of Slic3r::Fill.
virtual float _layer_angle(size_t idx) const { return 0.f; } float _layer_angle(size_t idx) const override { return 0.f; }
}; };
class FillStars : public FillRectilinear2 class FillStars : public FillRectilinear2
{ {
public: public:
virtual Fill* clone() const { return new FillStars(*this); }; Fill* clone() const override { return new FillStars(*this); };
virtual ~FillStars() = default; ~FillStars() override = default;
virtual Polylines fill_surface(const Surface *surface, const FillParams &params); Polylines fill_surface(const Surface *surface, const FillParams &params) override;
protected: protected:
// The grid fill will keep the angle constant between the layers, see the implementation of Slic3r::Fill. // The grid fill will keep the angle constant between the layers, see the implementation of Slic3r::Fill.
virtual float _layer_angle(size_t idx) const { return 0.f; } float _layer_angle(size_t idx) const override { return 0.f; }
}; };
class FillCubic : public FillRectilinear2 class FillCubic : public FillRectilinear2
{ {
public: public:
virtual Fill* clone() const { return new FillCubic(*this); }; Fill* clone() const override { return new FillCubic(*this); };
virtual ~FillCubic() = default; ~FillCubic() override = default;
virtual Polylines fill_surface(const Surface *surface, const FillParams &params); Polylines fill_surface(const Surface *surface, const FillParams &params) override;
protected: protected:
// The grid fill will keep the angle constant between the layers, see the implementation of Slic3r::Fill. // The grid fill will keep the angle constant between the layers, see the implementation of Slic3r::Fill.
virtual float _layer_angle(size_t idx) const { return 0.f; } float _layer_angle(size_t idx) const override { return 0.f; }
}; };