New implementation of support material
This commit is contained in:
parent
82a16ed8ee
commit
a8adff53ca
3 changed files with 33 additions and 41 deletions
|
@ -23,7 +23,7 @@ sub fill_surface {
|
||||||
my ($surface, %params) = @_;
|
my ($surface, %params) = @_;
|
||||||
|
|
||||||
# rotate polygons
|
# rotate polygons
|
||||||
my $expolygon = $surface->expolygon;
|
my $expolygon = $surface->expolygon->clone;
|
||||||
my $rotate_vector = $self->infill_direction($surface);
|
my $rotate_vector = $self->infill_direction($surface);
|
||||||
$self->rotate_points($expolygon, $rotate_vector);
|
$self->rotate_points($expolygon, $rotate_vector);
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@ sub fill_surface {
|
||||||
my ($surface, %params) = @_;
|
my ($surface, %params) = @_;
|
||||||
|
|
||||||
# rotate polygons so that we can work with vertical lines here
|
# rotate polygons so that we can work with vertical lines here
|
||||||
my $expolygon = $surface->expolygon;
|
my $expolygon = $surface->expolygon->clone;
|
||||||
my $rotate_vector = $self->infill_direction($surface);
|
my $rotate_vector = $self->infill_direction($surface);
|
||||||
$self->rotate_points($expolygon, $rotate_vector);
|
$self->rotate_points($expolygon, $rotate_vector);
|
||||||
|
|
||||||
|
|
|
@ -593,7 +593,7 @@ sub generate_support_material {
|
||||||
my @unsupported_expolygons = ();
|
my @unsupported_expolygons = ();
|
||||||
{
|
{
|
||||||
my (@a, @b) = ();
|
my (@a, @b) = ();
|
||||||
for (my $i = $#{$self->layers}; $i >=0; $i--) {
|
for my $i (reverse 0 .. $#{$self->layers}) {
|
||||||
my $layer = $self->layers->[$i];
|
my $layer = $self->layers->[$i];
|
||||||
my @c = ();
|
my @c = ();
|
||||||
if (@b) {
|
if (@b) {
|
||||||
|
@ -617,61 +617,53 @@ sub generate_support_material {
|
||||||
return if !@unsupported_expolygons;
|
return if !@unsupported_expolygons;
|
||||||
|
|
||||||
# generate paths for the pattern that we're going to use
|
# generate paths for the pattern that we're going to use
|
||||||
my $support_pattern = [];
|
my $support_patterns = [];
|
||||||
{
|
{
|
||||||
my @support_material_areas = @{union_ex([ map @$_, @unsupported_expolygons ])};
|
my @support_material_areas = map $_->offset_ex(scale 5),
|
||||||
|
@{union_ex([ map @$_, @unsupported_expolygons ])};
|
||||||
for (1..$Slic3r::perimeters+1) {
|
|
||||||
foreach my $expolygon (@support_material_areas) {
|
|
||||||
push @$support_pattern,
|
|
||||||
map Slic3r::ExtrusionLoop->new(
|
|
||||||
polygon => $_,
|
|
||||||
role => 'support-material',
|
|
||||||
)->split_at_first_point, @$expolygon;
|
|
||||||
}
|
|
||||||
@support_material_areas = map $_->offset_ex(- scale $Slic3r::flow_spacing),
|
|
||||||
@support_material_areas;
|
|
||||||
}
|
|
||||||
|
|
||||||
my $fill = Slic3r::Fill->new(print => $self);
|
my $fill = Slic3r::Fill->new(print => $self);
|
||||||
foreach my $expolygon (@support_material_areas) {
|
foreach my $angle (0, 90) {
|
||||||
my @paths = $fill->fillers->{rectilinear}->fill_surface(
|
my @patterns = ();
|
||||||
Slic3r::Surface->new(
|
foreach my $expolygon (@support_material_areas) {
|
||||||
expolygon => $expolygon,
|
my @paths = $fill->fillers->{rectilinear}->fill_surface(
|
||||||
bridge_angle => $Slic3r::fill_angle + 45,
|
Slic3r::Surface->new(
|
||||||
),
|
expolygon => $expolygon,
|
||||||
density => 0.15,
|
bridge_angle => $Slic3r::fill_angle + 45 + $angle,
|
||||||
flow_spacing => $Slic3r::flow_spacing,
|
),
|
||||||
);
|
density => 0.20,
|
||||||
my $params = shift @paths;
|
flow_spacing => $Slic3r::flow_spacing,
|
||||||
|
);
|
||||||
push @$support_pattern,
|
my $params = shift @paths;
|
||||||
map Slic3r::ExtrusionPath->new(
|
|
||||||
polyline => Slic3r::Polyline->new(@$_),
|
push @patterns,
|
||||||
role => 'support-material',
|
map Slic3r::ExtrusionPath->new(
|
||||||
depth_layers => 1,
|
polyline => Slic3r::Polyline->new(@$_),
|
||||||
flow_spacing => $params->{flow_spacing},
|
role => 'support-material',
|
||||||
), @paths;
|
depth_layers => 1,
|
||||||
|
flow_spacing => $params->{flow_spacing},
|
||||||
|
), @paths;
|
||||||
|
}
|
||||||
|
push @$support_patterns, [@patterns];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$_->polyline->simplify(scale $Slic3r::flow_spacing / 3) for @$support_pattern;
|
|
||||||
|
|
||||||
if (0) {
|
if (0) {
|
||||||
require "Slic3r/SVG.pm";
|
require "Slic3r/SVG.pm";
|
||||||
Slic3r::SVG::output(undef, "support.svg",
|
Slic3r::SVG::output(undef, "support.svg",
|
||||||
polylines => [ map $_->polyline, @$support_pattern ],
|
polylines => [ map $_->polyline, map @$_, @$support_patterns ],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
# apply the pattern to layers
|
# apply the pattern to layers
|
||||||
{
|
{
|
||||||
my $clip_pattern = sub {
|
my $clip_pattern = sub {
|
||||||
my ($expolygons) = @_;
|
my ($layer_id, $expolygons) = @_;
|
||||||
my @paths = ();
|
my @paths = ();
|
||||||
foreach my $expolygon (@$expolygons) {
|
foreach my $expolygon (@$expolygons) {
|
||||||
push @paths, map $_->clip_with_expolygon($expolygon),
|
push @paths, map $_->clip_with_expolygon($expolygon),
|
||||||
map $_->clip_with_polygon($expolygon->bounding_box_polygon),
|
map $_->clip_with_polygon($expolygon->bounding_box_polygon),
|
||||||
@$support_pattern;
|
@{$support_patterns->[ $layer_id % 2 ]};
|
||||||
};
|
};
|
||||||
return @paths;
|
return @paths;
|
||||||
};
|
};
|
||||||
|
@ -682,7 +674,7 @@ sub generate_support_material {
|
||||||
my $q = shift;
|
my $q = shift;
|
||||||
my $paths = {};
|
my $paths = {};
|
||||||
while (defined (my $layer_id = $q->dequeue)) {
|
while (defined (my $layer_id = $q->dequeue)) {
|
||||||
$paths->{$layer_id} = [ $clip_pattern->($layers{$layer_id}) ];
|
$paths->{$layer_id} = [ $clip_pattern->($layer_id, $layers{$layer_id}) ];
|
||||||
}
|
}
|
||||||
return $paths;
|
return $paths;
|
||||||
},
|
},
|
||||||
|
@ -691,7 +683,7 @@ sub generate_support_material {
|
||||||
$layer_paths{$_} = $paths->{$_} for keys %$paths;
|
$layer_paths{$_} = $paths->{$_} for keys %$paths;
|
||||||
},
|
},
|
||||||
no_threads_cb => sub {
|
no_threads_cb => sub {
|
||||||
$layer_paths{$_} = [ $clip_pattern->($layers{$_}) ] for keys %layers;
|
$layer_paths{$_} = [ $clip_pattern->($_, $layers{$_}) ] for keys %layers;
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue