mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-18 04:08:02 -06:00
Updates in the C++ infill code.
This commit is contained in:
parent
b2a6f43923
commit
a5b7f14dfa
14 changed files with 645 additions and 305 deletions
|
@ -1,7 +1,9 @@
|
|||
#ifndef slic3r_FillBase_hpp_
|
||||
#define slic3r_FillBase_hpp_
|
||||
|
||||
#include <memory.h>
|
||||
#include <float.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "../libslic3r.h"
|
||||
#include "../BoundingBox.hpp"
|
||||
|
@ -61,7 +63,7 @@ public:
|
|||
virtual bool no_sort() const { return false; }
|
||||
|
||||
// Perform the fill.
|
||||
virtual Polylines fill_surface(const Surface *surface, const FillParams ¶ms) = 0;
|
||||
virtual Polylines fill_surface(const Surface *surface, const FillParams ¶ms);
|
||||
|
||||
protected:
|
||||
Fill() :
|
||||
|
@ -75,7 +77,41 @@ protected:
|
|||
bounding_box(Point(0, 0), Point(-1, -1))
|
||||
{}
|
||||
|
||||
static coord_t adjust_solid_spacing(const coord_t width, const coord_t distance);
|
||||
// The expolygon may be modified by the method to avoid a copy.
|
||||
virtual void _fill_surface_single(
|
||||
const FillParams ¶ms,
|
||||
unsigned int thickness_layers,
|
||||
const std::pair<float, Point> &direction,
|
||||
ExPolygon &expolygon,
|
||||
Polylines &polylines_out) {}
|
||||
|
||||
static coord_t _adjust_solid_spacing(const coord_t width, const coord_t distance);
|
||||
|
||||
virtual float _layer_angle(size_t idx) const {
|
||||
bool odd = idx & 1;
|
||||
return (idx & 1) ? float(M_PI/2.) : 0;
|
||||
}
|
||||
|
||||
virtual std::pair<float, Point> _infill_direction(const Surface *surface) const;
|
||||
|
||||
// Align a coordinate to a grid. The coordinate may be negative,
|
||||
// the aligned value will never be bigger than the original one.
|
||||
static coord_t _align_to_grid(const coord_t coord, const coord_t spacing) {
|
||||
// Current C++ standard defines the result of integer division to be rounded to zero,
|
||||
// for both positive and negative numbers. Here we want to round down for negative
|
||||
// numbers as well.
|
||||
coord_t aligned = (coord < 0) ?
|
||||
((coord - spacing + 1) / spacing) * spacing :
|
||||
(coord / spacing) * spacing;
|
||||
assert(aligned <= coord);
|
||||
return aligned;
|
||||
}
|
||||
static Point _align_to_grid(Point coord, Point spacing)
|
||||
{ return Point(_align_to_grid(coord.x, spacing.x), _align_to_grid(coord.y, spacing.y)); }
|
||||
static coord_t _align_to_grid(coord_t coord, coord_t spacing, coord_t base)
|
||||
{ return base + _align_to_grid(coord - base, spacing); }
|
||||
static Point _align_to_grid(Point coord, Point spacing, Point base)
|
||||
{ return Point(_align_to_grid(coord.x, spacing.x, base.x), _align_to_grid(coord.y, spacing.y, base.y)); }
|
||||
};
|
||||
|
||||
// An interface class to Perl, aggregating an instance of a Fill and a FillData.
|
||||
|
@ -83,21 +119,14 @@ class Filler
|
|||
{
|
||||
public:
|
||||
Filler() : fill(NULL) {}
|
||||
~Filler() { delete fill; fill = NULL; }
|
||||
~Filler() {
|
||||
delete fill;
|
||||
fill = NULL;
|
||||
}
|
||||
Fill *fill;
|
||||
FillParams params;
|
||||
};
|
||||
|
||||
class FillWithDirection : public Fill
|
||||
{
|
||||
public:
|
||||
virtual float _layer_angle(size_t idx) const {
|
||||
bool odd = idx & 1;
|
||||
return (idx & 1) ? float(M_PI/2.) : 0;
|
||||
}
|
||||
virtual std::pair<float, Point> infill_direction(const Surface *surface) const ;
|
||||
};
|
||||
|
||||
} // namespace Slic3r
|
||||
|
||||
#endif // slic3r_FillBase_hpp_
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue