Cubic infill.
This commit is contained in:
parent
1fb57e439e
commit
20cd34a3a5
@ -25,6 +25,7 @@ Fill* Fill::new_from_type(const InfillPattern type)
|
||||
case ipLine: return new FillLine();
|
||||
case ipGrid: return new FillGrid2();
|
||||
case ipTriangles: return new FillTriangles();
|
||||
case ipCubic: return new FillCubic();
|
||||
// case ipGrid: return new FillGrid();
|
||||
case ipArchimedeanChords: return new FillArchimedeanChords();
|
||||
case ipHilbertCurve: return new FillHilbertCurve();
|
||||
|
@ -39,7 +39,7 @@ class Fill
|
||||
public:
|
||||
// Index of the layer.
|
||||
size_t layer_id;
|
||||
// Height of the layer, in unscaled coordinates
|
||||
// Z coordinate of the top print surface, in unscaled coordinates
|
||||
coordf_t z;
|
||||
// in unscaled coordinates
|
||||
coordf_t spacing;
|
||||
|
@ -751,7 +751,7 @@ enum DirectionMask
|
||||
DIR_BACKWARD = 2
|
||||
};
|
||||
|
||||
bool FillRectilinear2::fill_surface_by_lines(const Surface *surface, const FillParams ¶ms, float angleBase, Polylines &polylines_out)
|
||||
bool FillRectilinear2::fill_surface_by_lines(const Surface *surface, const FillParams ¶ms, float angleBase, float pattern_shift, Polylines &polylines_out)
|
||||
{
|
||||
// At the end, only the new polylines will be rotated back.
|
||||
size_t n_polylines_out_initial = polylines_out.size();
|
||||
@ -791,10 +791,14 @@ bool FillRectilinear2::fill_surface_by_lines(const Surface *surface, const FillP
|
||||
} else {
|
||||
// extend bounding box so that our pattern will be aligned with other layers
|
||||
// Transform the reference point to the rotated coordinate system.
|
||||
Point refpt = rotate_vector.second.rotated(- rotate_vector.first);
|
||||
// _align_to_grid will not work correctly with positive pattern_shift.
|
||||
coord_t pattern_shift_scaled = coord_t(scale_(pattern_shift)) % this->_line_spacing;
|
||||
refpt.x -= (pattern_shift_scaled > 0) ? pattern_shift_scaled : (this->_line_spacing + pattern_shift_scaled);
|
||||
bounding_box.merge(_align_to_grid(
|
||||
bounding_box.min,
|
||||
Point(this->_line_spacing, this->_line_spacing),
|
||||
rotate_vector.second.rotated(- rotate_vector.first)));
|
||||
refpt));
|
||||
}
|
||||
|
||||
// Intersect a set of euqally spaced vertical lines wiht expolygon.
|
||||
@ -1438,7 +1442,7 @@ bool FillRectilinear2::fill_surface_by_lines(const Surface *surface, const FillP
|
||||
Polylines FillRectilinear2::fill_surface(const Surface *surface, const FillParams ¶ms)
|
||||
{
|
||||
Polylines polylines_out;
|
||||
if (! fill_surface_by_lines(surface, params, 0.f, polylines_out)) {
|
||||
if (! fill_surface_by_lines(surface, params, 0.f, 0.f, polylines_out)) {
|
||||
printf("FillRectilinear2::fill_surface() failed to fill a region.\n");
|
||||
}
|
||||
return polylines_out;
|
||||
@ -1447,8 +1451,8 @@ Polylines FillRectilinear2::fill_surface(const Surface *surface, const FillParam
|
||||
Polylines FillGrid2::fill_surface(const Surface *surface, const FillParams ¶ms)
|
||||
{
|
||||
Polylines polylines_out;
|
||||
if (! fill_surface_by_lines(surface, params, 0.f, polylines_out) ||
|
||||
! fill_surface_by_lines(surface, params, float(M_PI / 2.), polylines_out)) {
|
||||
if (! fill_surface_by_lines(surface, params, 0.f, 0.f, polylines_out) ||
|
||||
! fill_surface_by_lines(surface, params, float(M_PI / 2.), 0.f, polylines_out)) {
|
||||
printf("FillGrid2::fill_surface() failed to fill a region.\n");
|
||||
}
|
||||
return polylines_out;
|
||||
@ -1457,12 +1461,24 @@ Polylines FillGrid2::fill_surface(const Surface *surface, const FillParams ¶
|
||||
Polylines FillTriangles::fill_surface(const Surface *surface, const FillParams ¶ms)
|
||||
{
|
||||
Polylines polylines_out;
|
||||
if (! fill_surface_by_lines(surface, params, 0.f, polylines_out) ||
|
||||
! fill_surface_by_lines(surface, params, float(M_PI / 3.), polylines_out) ||
|
||||
! fill_surface_by_lines(surface, params, float(2. * M_PI / 3.), polylines_out)) {
|
||||
if (! fill_surface_by_lines(surface, params, 0.f, 0., polylines_out) ||
|
||||
! fill_surface_by_lines(surface, params, float(M_PI / 3.), 0., polylines_out) ||
|
||||
! fill_surface_by_lines(surface, params, float(2. * M_PI / 3.), 0., polylines_out)) {
|
||||
printf("FillTriangles::fill_surface() failed to fill a region.\n");
|
||||
}
|
||||
return polylines_out;
|
||||
}
|
||||
|
||||
Polylines FillCubic::fill_surface(const Surface *surface, const FillParams ¶ms)
|
||||
{
|
||||
Polylines polylines_out;
|
||||
if (! fill_surface_by_lines(surface, params, 0.f, z, polylines_out) ||
|
||||
! fill_surface_by_lines(surface, params, float(M_PI / 3.), -z, polylines_out) ||
|
||||
// Rotated by PI*2/3 + PI to achieve reverse sloping wall.
|
||||
! fill_surface_by_lines(surface, params, float(M_PI * 2. / 3.), z, polylines_out)) {
|
||||
printf("FillCubic::fill_surface() failed to fill a region.\n");
|
||||
}
|
||||
return polylines_out;
|
||||
}
|
||||
|
||||
} // namespace Slic3r
|
||||
|
@ -16,7 +16,7 @@ public:
|
||||
virtual Polylines fill_surface(const Surface *surface, const FillParams ¶ms);
|
||||
|
||||
protected:
|
||||
bool fill_surface_by_lines(const Surface *surface, const FillParams ¶ms, float angleBase, Polylines &polylines_out);
|
||||
bool fill_surface_by_lines(const Surface *surface, const FillParams ¶ms, float angleBase, float pattern_shift, Polylines &polylines_out);
|
||||
|
||||
coord_t _min_spacing;
|
||||
coord_t _line_spacing;
|
||||
@ -46,6 +46,18 @@ protected:
|
||||
virtual float _layer_angle(size_t idx) const { return 0.f; }
|
||||
};
|
||||
|
||||
class FillCubic : public FillRectilinear2
|
||||
{
|
||||
public:
|
||||
virtual ~FillCubic() {}
|
||||
virtual Polylines fill_surface(const Surface *surface, const FillParams ¶ms);
|
||||
|
||||
protected:
|
||||
// The grid fill will keep the angle constant between the layers, see the implementation of Slic3r::Fill::Base.
|
||||
virtual float _layer_angle(size_t idx) const { return 0.f; }
|
||||
};
|
||||
|
||||
|
||||
}; // namespace Slic3r
|
||||
|
||||
#endif // slic3r_FillRectilinear2_hpp_
|
||||
|
@ -372,6 +372,7 @@ PrintConfigDef::PrintConfigDef()
|
||||
def->enum_values.push_back("rectilinear");
|
||||
def->enum_values.push_back("grid");
|
||||
def->enum_values.push_back("triangles");
|
||||
def->enum_values.push_back("cubic");
|
||||
def->enum_values.push_back("line");
|
||||
def->enum_values.push_back("concentric");
|
||||
def->enum_values.push_back("honeycomb");
|
||||
@ -382,6 +383,7 @@ PrintConfigDef::PrintConfigDef()
|
||||
def->enum_labels.push_back("Rectilinear");
|
||||
def->enum_labels.push_back("Grid");
|
||||
def->enum_labels.push_back("Triangles");
|
||||
def->enum_labels.push_back("Cubic");
|
||||
def->enum_labels.push_back("Line");
|
||||
def->enum_labels.push_back("Concentric");
|
||||
def->enum_labels.push_back("Honeycomb");
|
||||
|
@ -30,7 +30,7 @@ enum GCodeFlavor {
|
||||
};
|
||||
|
||||
enum InfillPattern {
|
||||
ipRectilinear, ipGrid, ipTriangles, ipLine, ipConcentric, ipHoneycomb, ip3DHoneycomb,
|
||||
ipRectilinear, ipGrid, ipTriangles, ipCubic, ipLine, ipConcentric, ipHoneycomb, ip3DHoneycomb,
|
||||
ipHilbertCurve, ipArchimedeanChords, ipOctagramSpiral,
|
||||
};
|
||||
|
||||
@ -59,6 +59,7 @@ template<> inline t_config_enum_values ConfigOptionEnum<InfillPattern>::get_enum
|
||||
keys_map["rectilinear"] = ipRectilinear;
|
||||
keys_map["grid"] = ipGrid;
|
||||
keys_map["triangles"] = ipTriangles;
|
||||
keys_map["cubic"] = ipCubic;
|
||||
keys_map["line"] = ipLine;
|
||||
keys_map["concentric"] = ipConcentric;
|
||||
keys_map["honeycomb"] = ipHoneycomb;
|
||||
|
Loading…
Reference in New Issue
Block a user