Added a new grid infill pattern
This commit is contained in:
parent
889a54e946
commit
2811af349a
5 changed files with 29 additions and 6 deletions
|
@ -21,6 +21,7 @@ has 'fillers' => (is => 'rw', default => sub { {} });
|
|||
our %FillTypes = (
|
||||
archimedeanchords => 'Slic3r::Fill::ArchimedeanChords',
|
||||
rectilinear => 'Slic3r::Fill::Rectilinear',
|
||||
grid => 'Slic3r::Fill::Grid',
|
||||
flowsnake => 'Slic3r::Fill::Flowsnake',
|
||||
octagramspiral => 'Slic3r::Fill::OctagramSpiral',
|
||||
hilbertcurve => 'Slic3r::Fill::HilbertCurve',
|
||||
|
|
|
@ -12,6 +12,8 @@ has '_line_oscillation' => (is => 'rw');
|
|||
use Slic3r::Geometry qw(scale unscale scaled_epsilon);
|
||||
use Slic3r::Geometry::Clipper qw(intersection_pl);
|
||||
|
||||
sub horizontal_lines { 0 }
|
||||
|
||||
sub fill_surface {
|
||||
my $self = shift;
|
||||
my ($surface, %params) = @_;
|
||||
|
@ -44,9 +46,18 @@ sub fill_surface {
|
|||
|
||||
# generate the basic pattern
|
||||
my $x_max = $bounding_box->x_max + scaled_epsilon;
|
||||
my @vertical_lines = ();
|
||||
my @lines = ();
|
||||
for (my $x = $bounding_box->x_min; $x <= $x_max; $x += $self->_line_spacing) {
|
||||
push @vertical_lines, $self->_line($#vertical_lines, $x, $bounding_box->y_min, $bounding_box->y_max);
|
||||
push @lines, $self->_line($#lines, $x, $bounding_box->y_min, $bounding_box->y_max);
|
||||
}
|
||||
if ($self->horizontal_lines) {
|
||||
my $y_max = $bounding_box->y_max + scaled_epsilon;
|
||||
for (my $y = $bounding_box->y_min; $y <= $y_max; $y += $self->_line_spacing) {
|
||||
push @lines, Slic3r::Polyline->new(
|
||||
[$bounding_box->x_min, $y],
|
||||
[$bounding_box->x_max, $y],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
# clip paths against a slightly larger expolygon, so that the first and last paths
|
||||
|
@ -54,7 +65,7 @@ sub fill_surface {
|
|||
# the minimum offset for preventing edge lines from being clipped is scaled_epsilon;
|
||||
# however we use a larger offset to support expolygons with slightly skewed sides and
|
||||
# not perfectly straight
|
||||
my @polylines = @{intersection_pl(\@vertical_lines, $expolygon->offset(+scale 0.02))};
|
||||
my @polylines = @{intersection_pl(\@lines, $expolygon->offset(+scale 0.02))};
|
||||
|
||||
my $extra = $self->_min_spacing * &Slic3r::INFILL_OVERLAP_OVER_SPACING;
|
||||
foreach my $polyline (@polylines) {
|
||||
|
@ -146,4 +157,12 @@ sub _can_connect {
|
|||
&& $dist_Y <= $self->_diagonal_distance;
|
||||
}
|
||||
|
||||
|
||||
package Slic3r::Fill::Grid;
|
||||
use Moo;
|
||||
extends 'Slic3r::Fill::Rectilinear';
|
||||
|
||||
sub angles () { [0] }
|
||||
sub horizontal_lines { 1 }
|
||||
|
||||
1;
|
||||
|
|
|
@ -437,7 +437,7 @@ sub make_perimeters {
|
|||
$slice->extra_perimeters($slice->extra_perimeters + 1);
|
||||
}
|
||||
Slic3r::debugf " adding %d more perimeter(s) at layer %d\n",
|
||||
$slice->extra_perimeters, $layerm->id
|
||||
$slice->extra_perimeters, $layerm->layer->id
|
||||
if $slice->extra_perimeters > 0;
|
||||
}
|
||||
}
|
||||
|
@ -1072,7 +1072,7 @@ sub combine_infill {
|
|||
+ $layerms[-1]->flow(FLOW_ROLE_PERIMETER)->scaled_width / 2
|
||||
# Because fill areas for rectilinear and honeycomb are grown
|
||||
# later to overlap perimeters, we need to counteract that too.
|
||||
+ (($type == S_TYPE_INTERNALSOLID || $region->config->fill_pattern =~ /(rectilinear|honeycomb)/)
|
||||
+ (($type == S_TYPE_INTERNALSOLID || $region->config->fill_pattern =~ /(rectilinear|grid|line|honeycomb)/)
|
||||
? $layerms[-1]->flow(FLOW_ROLE_SOLID_INFILL)->scaled_width
|
||||
: 0)
|
||||
)}, @$intersection;
|
||||
|
|
|
@ -301,6 +301,7 @@ PrintConfigDef::build_def() {
|
|||
Options["fill_pattern"].cli = "fill-pattern=s";
|
||||
Options["fill_pattern"].enum_keys_map = ConfigOptionEnum<InfillPattern>::get_enum_values();
|
||||
Options["fill_pattern"].enum_values.push_back("rectilinear");
|
||||
Options["fill_pattern"].enum_values.push_back("grid");
|
||||
Options["fill_pattern"].enum_values.push_back("line");
|
||||
Options["fill_pattern"].enum_values.push_back("concentric");
|
||||
Options["fill_pattern"].enum_values.push_back("honeycomb");
|
||||
|
@ -309,6 +310,7 @@ PrintConfigDef::build_def() {
|
|||
Options["fill_pattern"].enum_values.push_back("archimedeanchords");
|
||||
Options["fill_pattern"].enum_values.push_back("octagramspiral");
|
||||
Options["fill_pattern"].enum_labels.push_back("Rectilinear");
|
||||
Options["fill_pattern"].enum_labels.push_back("Grid");
|
||||
Options["fill_pattern"].enum_labels.push_back("Line");
|
||||
Options["fill_pattern"].enum_labels.push_back("Concentric");
|
||||
Options["fill_pattern"].enum_labels.push_back("Honeycomb");
|
||||
|
|
|
@ -12,7 +12,7 @@ enum GCodeFlavor {
|
|||
};
|
||||
|
||||
enum InfillPattern {
|
||||
ipRectilinear, ipLine, ipConcentric, ipHoneycomb, ip3DHoneycomb,
|
||||
ipRectilinear, ipGrid, ipLine, ipConcentric, ipHoneycomb, ip3DHoneycomb,
|
||||
ipHilbertCurve, ipArchimedeanChords, ipOctagramSpiral,
|
||||
};
|
||||
|
||||
|
@ -39,6 +39,7 @@ template<> inline t_config_enum_values ConfigOptionEnum<GCodeFlavor>::get_enum_v
|
|||
template<> inline t_config_enum_values ConfigOptionEnum<InfillPattern>::get_enum_values() {
|
||||
t_config_enum_values keys_map;
|
||||
keys_map["rectilinear"] = ipRectilinear;
|
||||
keys_map["grid"] = ipGrid;
|
||||
keys_map["line"] = ipLine;
|
||||
keys_map["concentric"] = ipConcentric;
|
||||
keys_map["honeycomb"] = ipHoneycomb;
|
||||
|
|
Loading…
Reference in a new issue