mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-10-30 04:02:52 -06:00
Merge new-support2
This commit is contained in:
parent
a2cc230bb5
commit
913f401280
13 changed files with 578 additions and 309 deletions
|
|
@ -3,7 +3,7 @@ use Moo;
|
|||
|
||||
use File::Basename qw(basename fileparse);
|
||||
use File::Spec;
|
||||
use List::Util qw(max first);
|
||||
use List::Util qw(min max first);
|
||||
use Math::ConvexHull::MonotoneChain qw(convex_hull);
|
||||
use Slic3r::ExtrusionPath ':roles';
|
||||
use Slic3r::Geometry qw(X Y Z X1 Y1 X2 Y2 MIN MAX PI scale unscale move_points
|
||||
|
|
@ -263,6 +263,7 @@ sub init_extruders {
|
|||
}
|
||||
|
||||
# calculate support material flow
|
||||
# Note: we should calculate a different flow for support material interface
|
||||
if ($self->has_support_material) {
|
||||
my $extruder = $self->extruders->[$self->config->support_material_extruder-1];
|
||||
$self->support_material_flow($extruder->make_flow(
|
||||
|
|
@ -581,15 +582,18 @@ sub make_skirt {
|
|||
# collect points from all layers contained in skirt height
|
||||
my @points = ();
|
||||
foreach my $obj_idx (0 .. $#{$self->objects}) {
|
||||
my $skirt_height = $Slic3r::Config->skirt_height;
|
||||
$skirt_height = $self->objects->[$obj_idx]->layer_count if $skirt_height > $self->objects->[$obj_idx]->layer_count;
|
||||
my @layers = map $self->objects->[$obj_idx]->layers->[$_], 0..($skirt_height-1);
|
||||
my $object = $self->objects->[$obj_idx];
|
||||
my @layers = map $object->layers->[$_], 0..min($Slic3r::Config->skirt_height-1, $#{$object->layers});
|
||||
my @layer_points = (
|
||||
(map @$_, map @$_, map @{$_->slices}, @layers),
|
||||
(map @$_, map @{$_->thin_walls}, map @{$_->regions}, @layers),
|
||||
(map @{$_->unpack->polyline}, map @{$_->support_fills->paths}, grep $_->support_fills, @layers),
|
||||
);
|
||||
push @points, map move_points($_, @layer_points), @{$self->objects->[$obj_idx]->copies};
|
||||
if (@{ $object->support_layers }) {
|
||||
my @support_layers = map $object->support_layers->[$_], 0..min($Slic3r::Config->skirt_height-1, $#{$object->support_layers});
|
||||
push @layer_points,
|
||||
(map @{$_->unpack->polyline}, map @{$_->support_fills->paths}, grep $_->support_fills, @support_layers);
|
||||
}
|
||||
push @points, map move_points($_, @layer_points), @{$object->copies};
|
||||
}
|
||||
return if @points < 3; # at least three points required for a convex hull
|
||||
|
||||
|
|
@ -644,13 +648,19 @@ sub make_brim {
|
|||
my $grow_distance = $flow->scaled_width / 2;
|
||||
my @islands = (); # array of polygons
|
||||
foreach my $obj_idx (0 .. $#{$self->objects}) {
|
||||
my $layer0 = $self->objects->[$obj_idx]->layers->[0];
|
||||
my $object = $self->objects->[$obj_idx];
|
||||
my $layer0 = $object->layers->[0];
|
||||
my @object_islands = (
|
||||
(map $_->contour, @{$layer0->slices}),
|
||||
(map { $_->isa('Slic3r::Polygon') ? $_ : $_->grow($grow_distance) } map @{$_->thin_walls}, @{$layer0->regions}),
|
||||
(map $_->unpack->polyline->grow($grow_distance), map @{$_->support_fills->paths}, grep $_->support_fills, $layer0),
|
||||
);
|
||||
foreach my $copy (@{$self->objects->[$obj_idx]->copies}) {
|
||||
if (@{ $object->support_layers }) {
|
||||
my $support_layer0 = $object->support_layers->[0];
|
||||
push @object_islands,
|
||||
(map $_->unpack->polyline->grow($grow_distance), @{$support_layer0->support_fills->paths})
|
||||
if $support_layer0->support_fills;
|
||||
}
|
||||
foreach my $copy (@{$object->copies}) {
|
||||
push @islands, map $_->clone->translate(@$copy), @object_islands;
|
||||
}
|
||||
}
|
||||
|
|
@ -812,7 +822,9 @@ sub write_gcode {
|
|||
gcodegen => $gcodegen,
|
||||
);
|
||||
|
||||
for my $layer (@{$self->objects->[$obj_idx]->layers}) {
|
||||
my $object = $self->objects->[$obj_idx];
|
||||
my @layers = sort { $a->print_z <=> $b->print_z } @{$object->layers}, @{$object->support_layers};
|
||||
for my $layer (@layers) {
|
||||
# if we are printing the bottom layer of an object, and we have already finished
|
||||
# another one, set first layer temperatures. this happens before the Z move
|
||||
# is triggered, so machine has more time to reach such temperatures
|
||||
|
|
@ -837,11 +849,13 @@ sub write_gcode {
|
|||
my @obj_idx = chained_path([ map $_->copies->[0], @{$self->objects} ]);
|
||||
|
||||
# sort layers by Z
|
||||
my %layers = (); # print_z => [ layer, layer, layer ] by obj_idx
|
||||
my %layers = (); # print_z => [ [layers], [layers], [layers] ] by obj_idx
|
||||
foreach my $obj_idx (0 .. $#{$self->objects}) {
|
||||
foreach my $layer (@{$self->objects->[$obj_idx]->layers}) {
|
||||
my $object = $self->objects->[$obj_idx];
|
||||
foreach my $layer (@{$object->layers}, @{$object->support_layers}) {
|
||||
$layers{ $layer->print_z } ||= [];
|
||||
$layers{ $layer->print_z }[$obj_idx] = $layer; # turn this into [$layer] when merging support layers
|
||||
$layers{ $layer->print_z }[$obj_idx] ||= [];
|
||||
push @{$layers{ $layer->print_z }[$obj_idx]}, $layer;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -851,13 +865,14 @@ sub write_gcode {
|
|||
);
|
||||
foreach my $print_z (sort { $a <=> $b } keys %layers) {
|
||||
foreach my $obj_idx (@obj_idx) {
|
||||
next unless my $layer = $layers{$print_z}[$obj_idx];
|
||||
print $fh $buffer->append(
|
||||
$layer_gcode->process_layer($layer, $layer->object->copies),
|
||||
$layer->object."",
|
||||
$layer->id,
|
||||
$layer->print_z,
|
||||
);
|
||||
foreach my $layer (@{ $layers{$print_z}[$obj_idx] // [] }) {
|
||||
print $fh $buffer->append(
|
||||
$layer_gcode->process_layer($layer, $layer->object->copies),
|
||||
$layer->object . ref($layer), # differentiate $obj_id between normal layers and support layers
|
||||
$layer->id,
|
||||
$layer->print_z,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
print $fh $buffer->flush;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue