Browse Source

Merge branch 'master' into avoid-crossing-perimeters

Conflicts:
	lib/Slic3r/GCode.pm
Alessandro Ranellucci 12 years ago
parent
commit
1627268fd4

+ 1 - 1
Build.PL

@@ -12,7 +12,7 @@ my $build = Module::Build->new(
         'File::Spec'                => '0',
         'Getopt::Long'              => '0',
         'Math::Clipper'             => '1.09',
-        'Math::ConvexHull'          => '1.0.4',
+        'Math::ConvexHull::MonotoneChain' => '0.01',
         'Math::Geometry::Voronoi'   => '1.3',
         'Math::PlanePath'           => '53',
         'Moo'                       => '0.091009',

+ 2 - 0
MANIFEST

@@ -35,12 +35,14 @@ lib/Slic3r/GUI/Plater.pm
 lib/Slic3r/GUI/SkeinPanel.pm
 lib/Slic3r/GUI/Tab.pm
 lib/Slic3r/Layer.pm
+lib/Slic3r/Layer/Region.pm
 lib/Slic3r/Line.pm
 lib/Slic3r/Model.pm
 lib/Slic3r/Point.pm
 lib/Slic3r/Polygon.pm
 lib/Slic3r/Polyline.pm
 lib/Slic3r/Print.pm
+lib/Slic3r/Print/Region.pm
 lib/Slic3r/Print/Object.pm
 lib/Slic3r/Surface.pm
 lib/Slic3r/SVG.pm

+ 3 - 1
README.markdown

@@ -153,7 +153,9 @@ The author of the Silk icon set is Mark James.
         --first-layer-height Layer height for first layer (mm or %, default: 100%)
         --infill-every-layers
                             Infill every N layers (default: 1)
-      
+        --solid-infill-every-layers
+                            Force a solid layer every N layers (default: 0)
+    
       Print options:
         --perimeters        Number of perimeters/horizontal skins (range: 0+, default: 3)
         --solid-layers      Number of solid layers to do for top/bottom surfaces

+ 7 - 4
lib/Slic3r.pm

@@ -7,7 +7,7 @@ use strict;
 use warnings;
 require v5.10;
 
-our $VERSION = "0.9.3-dev";
+our $VERSION = "0.9.4-dev";
 
 our $debug = 0;
 sub debugf {
@@ -44,6 +44,7 @@ use Slic3r::GCode;
 use Slic3r::GCode::MotionPlanner;
 use Slic3r::Geometry qw(PI);
 use Slic3r::Layer;
+use Slic3r::Layer::Region;
 use Slic3r::Line;
 use Slic3r::Model;
 use Slic3r::Point;
@@ -51,6 +52,7 @@ use Slic3r::Polygon;
 use Slic3r::Polyline;
 use Slic3r::Print;
 use Slic3r::Print::Object;
+use Slic3r::Print::Region;
 use Slic3r::Surface;
 use Slic3r::TriangleMesh;
 eval "use Slic3r::Build";
@@ -64,15 +66,16 @@ use constant SMALL_PERIMETER_LENGTH => (6.5 / SCALING_FACTOR) * 2 * PI;
 # process.  They should belong to the Print object, but we are keeping 
 # them here because it makes accessing them slightly faster.
 our $Config;
-our $extruders;
-our ($flow, $first_layer_flow, $perimeter_flow, $infill_flow, $support_material_flow);
+our $flow;
+our $first_layer_flow;
 
 sub parallelize {
     my %params = @_;
     
     if (!$params{disable} && $Slic3r::have_threads && $Config->threads > 1) {
+        my @items = (ref $params{items} eq 'CODE') ? $params{items}->() : @{$params{items}};
         my $q = Thread::Queue->new;
-        $q->enqueue(@{ $params{items} }, (map undef, 1..$Config->threads));
+        $q->enqueue(@items, (map undef, 1..$Config->threads));
         
         my $thread_cb = sub { $params{thread_cb}->($q) };
         foreach my $th (map threads->create($thread_cb), 1..$Config->threads) {

+ 19 - 2
lib/Slic3r/Config.pm

@@ -3,6 +3,8 @@ use strict;
 use warnings;
 use utf8;
 
+use List::Util qw(first);
+
 use constant PI => 4 * atan2(1, 1);
 
 # cemetery of old config settings
@@ -351,6 +353,15 @@ our $Options = {
         min     => 1,
         default => 1,
     },
+    'solid_infill_every_layers' => {
+        label   => 'Solid infill every',
+        tooltip => 'This feature allows to force a solid layer every given number of layers. Zero to disable.',
+        sidetext => 'layers',
+        cli     => 'solid-infill-every-layers=i',
+        type    => 'i',
+        min     => 0,
+        default => 0,
+    },
     
     # flow options
     'extrusion_width' => {
@@ -951,6 +962,9 @@ sub set {
         $opt_key =~ s/^bottom_layer_speed$/first_layer_speed/;
         $value = $value =~ /^\d+(?:\.\d+)?$/ && $value != 0 ? ($value*100) . "%" : 0;
     }
+    if ($opt_key eq 'threads' && !$Slic3r::have_threads) {
+        $value = 1;
+    }
     
     if (!exists $Options->{$opt_key}) {
         $opt_key = +(grep { $Options->{$_}{aliases} && grep $_ eq $opt_key, @{$Options->{$_}{aliases}} } keys %$Options)[0]
@@ -1058,15 +1072,18 @@ sub validate {
     
     # --fill-pattern
     die "Invalid value for --fill-pattern\n"
-        if !exists $Slic3r::Fill::FillTypes{$self->fill_pattern};
+        if !first { $_ eq $self->fill_pattern } @{$Options->{fill_pattern}{values}};
     
     # --solid-fill-pattern
     die "Invalid value for --solid-fill-pattern\n"
-        if !exists $Slic3r::Fill::FillTypes{$self->solid_fill_pattern};
+        if !first { $_ eq $self->solid_fill_pattern } @{$Options->{solid_fill_pattern}{values}};
     
     # --fill-density
     die "Invalid value for --fill-density\n"
         if $self->fill_density < 0 || $self->fill_density > 1;
+    die "The selected fill pattern is not supposed to work at 100% density\n"
+        if $self->fill_density == 1
+            && !first { $_ eq $self->fill_pattern } @{$Options->{solid_fill_pattern}{values}};
     
     # --infill-every-layers
     die "Invalid value for --infill-every-layers\n"

+ 3 - 1
lib/Slic3r/Extruder.pm

@@ -9,7 +9,9 @@ use constant OPTIONS => [qw(
     retract_length retract_lift retract_speed retract_restart_extra retract_before_travel
     retract_length_toolchange retract_restart_extra_toolchange
 )];
-has $_ => (is => 'ro', required => 1) for @{&OPTIONS};
+
+has 'id'    => (is => 'rw', required => 1);
+has $_      => (is => 'ro', required => 1) for @{&OPTIONS};
 
 has 'retracted'                 => (is => 'rw', default => sub {0} );
 has 'e_per_mm3'                 => (is => 'lazy');

+ 4 - 3
lib/Slic3r/ExtrusionPath.pm

@@ -160,6 +160,7 @@ sub detect_arcs {
     
     $max_angle = deg2rad($max_angle || 15);
     $len_epsilon ||= 10 / &Slic3r::SCALING_FACTOR;
+    my $parallel_degrees_limit = abs(Slic3r::Geometry::deg2rad(3));
     
     my @points = @{$self->points};
     my @paths = ();
@@ -191,8 +192,8 @@ sub detect_arcs {
             $s3_angle += 2*PI if $s3_angle < 0;
             my $s1s2_angle = $s2_angle - $s1_angle;
             my $s2s3_angle = $s3_angle - $s2_angle;
-            next if abs($s1s2_angle - $s2s3_angle) > $Slic3r::Geometry::parallel_degrees_limit;
-            next if abs($s1s2_angle) < $Slic3r::Geometry::parallel_degrees_limit;     # ignore parallel lines
+            next if abs($s1s2_angle - $s2s3_angle) > $parallel_degrees_limit;
+            next if abs($s1s2_angle) < $parallel_degrees_limit;     # ignore parallel lines
             next if $s1s2_angle > $max_angle;  # ignore too sharp vertices
             my @arc_points = ($points[$i], $points[$i+3]),  # first and last points
             
@@ -205,7 +206,7 @@ sub detect_arcs {
                 my $line_angle = $line->atan;
                 $line_angle += 2*PI if $line_angle < 0;
                 my $anglediff = $line_angle - $last_line_angle;
-                last if abs($s1s2_angle - $anglediff) > $Slic3r::Geometry::parallel_degrees_limit;
+                last if abs($s1s2_angle - $anglediff) > $parallel_degrees_limit;
                 
                 # point $j+1 belongs to the arc
                 $arc_points[-1] = $points[$j+1];

+ 1 - 1
lib/Slic3r/Fill.pm

@@ -99,7 +99,7 @@ sub make_fill {
     
     # add spacing between adjacent surfaces
     {
-        my $distance = scale $layer->infill_flow->spacing / 2;
+        my $distance = $layer->infill_flow->scaled_spacing / 2;
         my @offsets = ();
         foreach my $surface (@surfaces) {
             my $expolygon = $surface->expolygon;

+ 1 - 1
lib/Slic3r/Fill/Concentric.pm

@@ -63,7 +63,7 @@ sub fill_surface {
         my $path = $loop->split_at_index($index);
         
         # clip the path to avoid the extruder to get exactly on the first point of the loop
-        $path->clip_end(scale($self->layer ? $self->layer->flow->width : $Slic3r::flow->width) * 0.15);
+        $path->clip_end(($self->layer ? $self->layer->flow->scaled_width : $Slic3r::flow->scaled_width) * 0.15);
         
         push @paths, $path->points if @{$path->points};
     }

+ 1 - 1
lib/Slic3r/Fill/Honeycomb.pm

@@ -21,7 +21,7 @@ sub fill_surface {
     # infill math
     my $min_spacing = scale $params{flow_spacing};
     my $distance = $min_spacing / $params{density};
-    my $overlap_distance = scale($self->layer ? $self->layer->flow->width : $Slic3r::flow->width) * 0.4;
+    my $overlap_distance = ($self->layer ? $self->layer->flow->scaled_width : $Slic3r::flow->scaled_width) * 0.4;
     
     my $cache_id = sprintf "d%s_s%s_a%s",
         $params{density}, $params{flow_spacing}, $rotate_vector->[0][0];

Some files were not shown because too many files changed in this diff