Generate infill using each object's bounding_box instead of full print. #1177

This commit is contained in:
Alessandro Ranellucci 2013-05-19 11:35:41 +02:00
parent 627debf284
commit bbb190dc68
4 changed files with 21 additions and 14 deletions

View File

@ -17,7 +17,7 @@ use Slic3r::Geometry::Clipper qw(union_ex diff diff_ex intersection_ex offset);
use Slic3r::Surface ':types';
has 'print' => (is => 'ro', required => 1, weak_ref => 1);
has 'object' => (is => 'ro', required => 1, weak_ref => 1);
has 'fillers' => (is => 'rw', default => sub { {} });
our %FillTypes = (
@ -40,7 +40,7 @@ sub filler {
}
$self->fillers->{$filler} ||= $FillTypes{$filler}->new(
bounding_box => [ $self->print->bounding_box ],
bounding_box => [ $self->object->bounding_box ],
);
return $self->fillers->{$filler};
}

View File

@ -301,7 +301,7 @@ sub _fill_gaps {
return unless $Slic3r::Config->gap_fill_speed > 0 && $Slic3r::Config->fill_density > 0 && @$gaps;
my $filler = $self->layer->object->print->fill_maker->filler('rectilinear');
my $filler = $self->layer->object->fill_maker->filler('rectilinear');
$filler->layer_id($self->layer->id);
# we should probably use this code to handle thin walls and remove that logic from

View File

@ -21,7 +21,6 @@ has 'regions' => (is => 'rw', default => sub {[]});
has 'support_material_flow' => (is => 'rw');
has 'first_layer_support_material_flow' => (is => 'rw');
has 'has_support_material' => (is => 'lazy');
has 'fill_maker' => (is => 'lazy');
# ordered collection of extrusion paths to build skirt loops
has 'skirt' => (
@ -82,11 +81,6 @@ sub _build_has_support_material {
|| $self->config->support_material_enforce_layers > 0;
}
sub _build_fill_maker {
my $self = shift;
return Slic3r::Fill->new(print => $self);
}
# caller is responsible for supplying models whose objects don't collide
# and have explicit instance positions
sub add_model {
@ -362,7 +356,6 @@ sub export_gcode {
# this will generate extrusion paths for each layer
$status_cb->(80, "Infilling layers");
{
my $fill_maker = $self->fill_maker;
Slic3r::parallelize(
items => sub {
my @items = (); # [obj_idx, layer_id]
@ -379,10 +372,11 @@ sub export_gcode {
my $fills = {};
while (defined (my $obj_layer = $q->dequeue)) {
my ($obj_idx, $layer_id, $region_id) = @$obj_layer;
my $object = $self->objects->[$obj_idx];
$fills->{$obj_idx} ||= {};
$fills->{$obj_idx}{$layer_id} ||= {};
$fills->{$obj_idx}{$layer_id}{$region_id} = [
$fill_maker->make_fill($self->objects->[$obj_idx]->layers->[$layer_id]->regions->[$region_id]),
$object->fill_maker->make_fill($object->layers->[$layer_id]->regions->[$region_id]),
];
}
return $fills;
@ -401,7 +395,7 @@ sub export_gcode {
},
no_threads_cb => sub {
foreach my $layerm (map @{$_->regions}, map @{$_->layers}, @{$self->objects}) {
$layerm->fills([ $fill_maker->make_fill($layerm) ]);
$layerm->fills([ $layerm->layer->object->fill_maker->make_fill($layerm) ]);
}
},
);

View File

@ -14,6 +14,7 @@ has 'size' => (is => 'rw', required => 1);
has 'copies' => (is => 'rw', trigger => 1); # in scaled coordinates
has 'layers' => (is => 'rw', default => sub { [] });
has 'layer_height_ranges' => (is => 'rw', default => sub { [] }); # [ z_min, z_max, layer_height ]
has 'fill_maker' => (is => 'lazy');
sub BUILD {
my $self = shift;
@ -76,6 +77,11 @@ sub BUILD {
}
}
sub _build_fill_maker {
my $self = shift;
return Slic3r::Fill->new(object => $self);
}
# This should be probably moved in Print.pm at the point where we sort Layer objects
sub _trigger_copies {
my $self = shift;
@ -127,6 +133,13 @@ sub get_layer_range {
return ($min_layer, $max_layer);
}
sub bounding_box {
my $self = shift;
# since the object is aligned to origin, bounding box coincides with size
return Slic3r::Geometry::bounding_box([ [0,0], $self->size ]);
}
sub slice {
my $self = shift;
my %params = @_;
@ -931,7 +944,7 @@ sub generate_support_material {
push @angles, $angles[0] + 90;
}
my $filler = $self->print->fill_maker->filler($pattern);
my $filler = $self->fill_maker->filler($pattern);
my $make_pattern = sub {
my ($expolygon, $density) = @_;
@ -1016,7 +1029,7 @@ sub generate_support_material {
# make a solid base on bottom layer
if ($layer_id == 0) {
my $filler = $self->print->fill_maker->filler('rectilinear');
my $filler = $self->fill_maker->filler('rectilinear');
$filler->angle($Slic3r::Config->support_material_angle + 90);
foreach my $expolygon (@$islands) {
my @paths = $filler->fill_surface(