mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-10-19 14:51:11 -06:00
Multithreaded infill. #154
This commit is contained in:
parent
8cdf9debfb
commit
8b777e9d70
6 changed files with 37 additions and 5 deletions
|
@ -36,6 +36,8 @@ use Slic3r::Surface;
|
|||
use Slic3r::TriangleMesh;
|
||||
use Slic3r::TriangleMesh::IntersectionLine;
|
||||
|
||||
our $threads = 4;
|
||||
|
||||
# output options
|
||||
our $output_filename_format = '[input_filename_base].gcode';
|
||||
|
||||
|
|
|
@ -121,6 +121,7 @@ sub make_fill {
|
|||
map [ $_->contour->[0], $_ ], @surfaces,
|
||||
])};
|
||||
|
||||
my @fills = ();
|
||||
SURFACE: foreach my $surface (@surfaces) {
|
||||
my $filler = $Slic3r::fill_pattern;
|
||||
my $density = $Slic3r::fill_density;
|
||||
|
@ -150,7 +151,7 @@ sub make_fill {
|
|||
my $params = shift @paths;
|
||||
|
||||
# save into layer
|
||||
push @{ $layer->fills }, Slic3r::ExtrusionPath::Collection->new(
|
||||
push @fills, Slic3r::ExtrusionPath::Collection->new(
|
||||
paths => [
|
||||
map Slic3r::ExtrusionPath->new(
|
||||
polyline => Slic3r::Polyline->new(@$_),
|
||||
|
@ -163,7 +164,7 @@ sub make_fill {
|
|||
}
|
||||
|
||||
# add thin fill regions
|
||||
push @{ $layer->fills }, Slic3r::ExtrusionPath::Collection->new(
|
||||
push @fills, Slic3r::ExtrusionPath::Collection->new(
|
||||
paths => [
|
||||
map {
|
||||
$_->isa('Slic3r::Polygon')
|
||||
|
@ -172,6 +173,8 @@ sub make_fill {
|
|||
} @{$layer->thin_fills},
|
||||
],
|
||||
) if @{$layer->thin_fills};
|
||||
|
||||
return @fills;
|
||||
}
|
||||
|
||||
1;
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package Slic3r::Skein;
|
||||
use Moo;
|
||||
|
||||
use Config;
|
||||
use File::Basename qw(basename fileparse);
|
||||
use Slic3r::Geometry qw(PI);
|
||||
use Time::HiRes qw(gettimeofday tv_interval);
|
||||
|
@ -84,7 +85,31 @@ sub go {
|
|||
$self->status_cb->(80, "Infilling layers...");
|
||||
{
|
||||
my $fill_maker = Slic3r::Fill->new('print' => $print);
|
||||
$fill_maker->make_fill($_) for @{$print->layers};
|
||||
|
||||
if ($Config{useithreads} && $Slic3r::threads > 1 && eval "use threads; use Thread::Queue; 1") {
|
||||
my $q = Thread::Queue->new;
|
||||
$q->enqueue(0..($print->layer_count-1), (map undef, 1..$Slic3r::threads));
|
||||
|
||||
my $thread_cb = sub {
|
||||
$Slic3r::Geometry::Clipper::clipper = Math::Clipper->new;
|
||||
my $fills = {};
|
||||
while (defined (my $layer_id = $q->dequeue)) {
|
||||
$fills->{$layer_id} = [ $fill_maker->make_fill($print->layers->[$layer_id]) ];
|
||||
}
|
||||
return $fills;
|
||||
};
|
||||
|
||||
foreach my $th (map threads->create($thread_cb), 1..$Slic3r::threads) {
|
||||
my $fills = $th->join;
|
||||
foreach my $layer_id (keys %$fills) {
|
||||
@{$print->layers->[$layer_id]->fills} = @{$fills->{$layer_id}};
|
||||
}
|
||||
}
|
||||
} else {
|
||||
foreach my $layer (@{$print->layers}) {
|
||||
@{$layer->fills} = $fill_maker->make_fill($layer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# output everything to a GCODE file
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue