From 69ed69179b39747d8f51b9c68c39a39285ea4fb4 Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci Date: Tue, 17 Dec 2013 16:09:07 +0100 Subject: [PATCH 01/50] Handle read_from_file() exceptions in GUI. #1619 --- lib/Slic3r/GUI/Plater.pm | 5 ++++- lib/Slic3r/GUI/SkeinPanel.pm | 9 +++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/lib/Slic3r/GUI/Plater.pm b/lib/Slic3r/GUI/Plater.pm index 5eec5954..fef88daa 100644 --- a/lib/Slic3r/GUI/Plater.pm +++ b/lib/Slic3r/GUI/Plater.pm @@ -384,7 +384,10 @@ sub load_file { $process_dialog->Pulse; local $SIG{__WARN__} = Slic3r::GUI::warning_catcher($self); - my $model = Slic3r::Model->read_from_file($input_file); + + my $model = eval { Slic3r::Model->read_from_file($input_file) }; + Slic3r::GUI::show_error($self, $@) if $@; + for my $i (0 .. $#{$model->objects}) { my $object = Slic3r::GUI::Plater::Object->new( name => $basename, diff --git a/lib/Slic3r/GUI/SkeinPanel.pm b/lib/Slic3r/GUI/SkeinPanel.pm index 2ea3dd76..20e573d5 100644 --- a/lib/Slic3r/GUI/SkeinPanel.pm +++ b/lib/Slic3r/GUI/SkeinPanel.pm @@ -133,8 +133,11 @@ sub quick_slice { $Slic3r::GUI::Settings->{recent}{skein_directory} = dirname($input_file); Slic3r::GUI->save_settings; + my $model = eval { Slic3r::Model->read_from_file($input_file) }; + Slic3r::GUI::show_error($self, $@) if $@; + my $print = $self->init_print; - $print->add_model(Slic3r::Model->read_from_file($input_file)); + $print->add_model($model); $print->validate; # select output file @@ -364,7 +367,9 @@ sub combine_stls { $output_file = $dlg->GetPath; } - my @models = map Slic3r::Model->read_from_file($_), @input_files; + my @models = eval { map Slic3r::Model->read_from_file($_), @input_files }; + Slic3r::GUI::show_error($self, $@) if $@; + my $new_model = Slic3r::Model->new; my $new_object = $new_model->add_object; for my $m (0 .. $#models) { From 7e8841805caceb680d30a0d1147f3cc63c7c6f98 Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci Date: Tue, 17 Dec 2013 16:15:25 +0100 Subject: [PATCH 02/50] Fixed fatal error about missing method thin_walls(). #1607 #1615 --- lib/Slic3r/Print/Object.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Slic3r/Print/Object.pm b/lib/Slic3r/Print/Object.pm index 64c6b509..ed645bcd 100644 --- a/lib/Slic3r/Print/Object.pm +++ b/lib/Slic3r/Print/Object.pm @@ -199,7 +199,7 @@ sub slice { # remove empty layers from bottom my $first_object_layer_id = $self->config->raft_layers; - while (@{$self->layers} && !@{$self->layers->[$first_object_layer_id]->slices} && !map @{$_->thin_walls}, @{$self->layers->[$first_object_layer_id]->regions}) { + while (@{$self->layers} && !@{$self->layers->[$first_object_layer_id]->slices}, @{$self->layers->[$first_object_layer_id]->regions}) { splice @{$self->layers}, $first_object_layer_id, 1; for (my $i = $first_object_layer_id; $i <= $#{$self->layers}; $i++) { $self->layers->[$i]->id($i); From ca16567ba91c415ef1909b44fe033fa64f6a41d3 Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci Date: Wed, 18 Dec 2013 10:20:36 +0100 Subject: [PATCH 03/50] Fixed wrong commit f495136. Thanks pdbogen for the report. #1623 --- lib/Slic3r/Print/Object.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Slic3r/Print/Object.pm b/lib/Slic3r/Print/Object.pm index ed645bcd..35149667 100644 --- a/lib/Slic3r/Print/Object.pm +++ b/lib/Slic3r/Print/Object.pm @@ -199,7 +199,7 @@ sub slice { # remove empty layers from bottom my $first_object_layer_id = $self->config->raft_layers; - while (@{$self->layers} && !@{$self->layers->[$first_object_layer_id]->slices}, @{$self->layers->[$first_object_layer_id]->regions}) { + while (@{$self->layers} && !@{$self->layers->[$first_object_layer_id]->slices}) { splice @{$self->layers}, $first_object_layer_id, 1; for (my $i = $first_object_layer_id; $i <= $#{$self->layers}; $i++) { $self->layers->[$i]->id($i); From e403dc16ae6d2633637f3145757abca47e87282e Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci Date: Sun, 22 Dec 2013 18:47:39 +0100 Subject: [PATCH 04/50] Rewrite avoid_crossing_perimeters() to fix a regression and get better performance by choosing regular points along contours. #1531 --- lib/Slic3r/GCode.pm | 2 +- lib/Slic3r/GCode/MotionPlanner.pm | 467 ++++++++++++++++-------------- lib/Slic3r/Print.pm | 2 +- 3 files changed, 251 insertions(+), 220 deletions(-) diff --git a/lib/Slic3r/GCode.pm b/lib/Slic3r/GCode.pm index 26a9ba76..4faf45a0 100644 --- a/lib/Slic3r/GCode.pm +++ b/lib/Slic3r/GCode.pm @@ -456,7 +456,7 @@ sub _plan { # append the actual path and return $self->speed('travel'); # use G1 because we rely on paths being straight (G0 may make round paths) - $gcode .= join '', map $self->G1($_->[B], undef, 0, $comment || ""), @travel; + $gcode .= join '', map $self->G1($_->b, undef, 0, $comment || ""), @travel; return $gcode; } diff --git a/lib/Slic3r/GCode/MotionPlanner.pm b/lib/Slic3r/GCode/MotionPlanner.pm index 68c386aa..9caf59d6 100644 --- a/lib/Slic3r/GCode/MotionPlanner.pm +++ b/lib/Slic3r/GCode/MotionPlanner.pm @@ -1,23 +1,18 @@ package Slic3r::GCode::MotionPlanner; use Moo; -has 'islands' => (is => 'ro', required => 1); -has 'no_internal' => (is => 'ro'); -has 'last_crossings'=> (is => 'rw'); -has '_inner' => (is => 'rw', default => sub { [] }); # arrayref of arrayrefs of expolygons -has '_outer' => (is => 'rw', default => sub { [] }); # arrayref of arrayrefs of polygons -has '_contours_ex' => (is => 'rw', default => sub { [] }); # arrayref of arrayrefs of expolygons -has '_pointmap' => (is => 'rw', default => sub { {} }); # { id => $point } -has '_edges' => (is => 'rw', default => sub { {} }); # node_idx => { node_idx => distance, ... } -has '_crossing_edges' => (is => 'rw', default => sub { {} }); # edge_idx => bool -has '_tolerance' => (is => 'lazy'); +has 'islands' => (is => 'ro', required => 1); # arrayref of ExPolygons +has 'internal' => (is => 'ro', default => sub { 1 }); +has '_space' => (is => 'ro', default => sub { Slic3r::GCode::MotionPlanner::ConfigurationSpace->new }); +has '_inner' => (is => 'ro', default => sub { [] }); # arrayref of ExPolygons +has '_tolerance' => (is => 'lazy'); -use List::Util qw(first); +use List::Util qw(first max); use Slic3r::Geometry qw(A B scale epsilon); -use Slic3r::Geometry::Clipper qw(diff_ex offset); +use Slic3r::Geometry::Clipper qw(offset offset_ex diff_ex); # clearance (in mm) from the perimeters -has '_inner_margin' => (is => 'ro', default => sub { scale 0.5 }); +has '_inner_margin' => (is => 'ro', default => sub { scale 1 }); has '_outer_margin' => (is => 'ro', default => sub { scale 2 }); # this factor weigths the crossing of a perimeter @@ -27,9 +22,9 @@ has '_outer_margin' => (is => 'ro', default => sub { scale 2 }); # follow if we decided to cross the perimeter. # a nearly-infinite value for this will only permit # perimeter crossing when there's no alternative path. -use constant CROSSING_FACTOR => 20; +use constant CROSSING_PENALTY => 20; -use constant INFINITY => 'inf'; +use constant POINT_DISTANCE => 10; # unscaled sub _build__tolerance { scale epsilon } @@ -37,191 +32,101 @@ sub _build__tolerance { scale epsilon } sub BUILD { my $self = shift; - my $edges = $self->_edges; - my $crossing_edges = $self->_crossing_edges; - - # simplify islands - @{$self->islands} = map $_->simplify($self->_inner_margin), @{$self->islands}; + my $point_distance = scale POINT_DISTANCE; + my $nodes = $self->_space->nodes; + my $edges = $self->_space->edges; # process individual islands - for my $i (0 .. $#{$self->islands}) { - # offset the island inwards to make the boundaries for internal movements - # so that no motion along external perimeters happens - $self->_inner->[$i] = $self->no_internal - ? [] - : $self->islands->[$i]->offset_ex(-$self->_inner_margin); + for my $i (0 .. $#{$self->islands}) { + my $expolygon = $self->islands->[$i]; + + # find external margin + my $outer = offset([ @$expolygon ], +$self->_outer_margin); + my @outer_points = map @{$_->equally_spaced_points($point_distance)}, @$outer; - # offset the island outwards to make the boundaries for external movements - $self->_outer->[$i] = offset([ $self->islands->[$i]->contour ], $self->_outer_margin); + # add outer points to graph + my $o_outer = $self->_space->add_nodes(@outer_points); - # if internal motion is enabled, build a set of utility expolygons representing - # the outer boundaries (as contours) and the inner boundaries (as holes). whenever - # we jump from a hole to a contour or viceversa, we know we're crossing a perimeter - if (!$self->no_internal) { - $self->_contours_ex->[$i] = diff_ex( - $self->_outer->[$i], - [ map $_->contour, @{$self->_inner->[$i]} ], + # find pairs of visible outer points and add them to the graph + for my $i (0 .. $#outer_points) { + for my $j (($i+1) .. $#outer_points) { + my ($a, $b) = ($outer_points[$i], $outer_points[$j]); + my $line = Slic3r::Line->new($a, $b); + # outer points are visible when their line has empty intersection with islands + my $intersection = Boost::Geometry::Utils::multi_polygon_multi_linestring_intersection( + [ map $_->pp, @{$self->islands} ], + [ $line->pp ], + ); + if (!@$intersection) { + $self->_space->add_edge($i+$o_outer, $j+$o_outer, $line->length); + } + } + } + + if ($self->internal) { + # find internal margin + my $inner = offset_ex([ @$expolygon ], -$self->_inner_margin); + push @{ $self->_inner }, @$inner; + my @inner_points = map @{$_->equally_spaced_points($point_distance)}, map @$_, @$inner; + + # add points to graph and get their offset + my $o_inner = $self->_space->add_nodes(@inner_points); + + # find pairs of visible inner points and add them to the graph + for my $i (0 .. $#inner_points) { + for my $j (($i+1) .. $#inner_points) { + my ($a, $b) = ($inner_points[$i], $inner_points[$j]); + my $line = Slic3r::Line->new($a, $b); + # turn $inner into an ExPolygonCollection and use $inner->contains_line() + if (first { $_->encloses_line($line, $self->_tolerance) } @$inner) { + $self->_space->add_edge($i+$o_inner, $j+$o_inner, $line->length); + } + } + } + + # generate the stripe around slice contours + my $contour = diff_ex( + $outer, + [ map @$_, @$inner ], ); - # lines enclosed in inner expolygons are visible - $self->_add_expolygon($_) for @{ $self->_inner->[$i] }; - - # lines enclosed in expolygons covering perimeters are visible - # (but discouraged) - $self->_add_expolygon($_, 1) for @{ $self->_contours_ex->[$i] }; - } - } - - { - my @outer = (map @$_, @{$self->_outer}); - my @outer_ex = map Slic3r::ExPolygon->new($_), @outer; # build ExPolygons for Boost - - # lines of outer polygons connect visible points - for my $i (0 .. $#outer) { - foreach my $line (@{$outer[$i]->lines}) { - my $dist = $line->length; - $edges->{$line->a}{$line->b} = $dist; - $edges->{$line->b}{$line->a} = $dist; - } - } - - # lines connecting outer polygons are visible - for my $i (0 .. $#outer) { - for my $j (($i+1) .. $#outer) { - for my $m (0 .. $#{$outer[$i]}) { - for my $n (0 .. $#{$outer[$j]}) { - my $line = Slic3r::Line->new($outer[$i][$m], $outer[$j][$n]); - if (!@{Boost::Geometry::Utils::multi_polygon_multi_linestring_intersection([ map $_->pp, @outer_ex ], [$line->pp])}) { - # this line does not cross any polygon - my $dist = $line->length; - $edges->{$outer[$i][$m]}{$outer[$j][$n]} = $dist; - $edges->{$outer[$j][$n]}{$outer[$i][$m]} = $dist; - } + # find pairs of visible points in this area and add them to the graph + for my $i (0 .. $#inner_points) { + for my $j (0 .. $#outer_points) { + my ($a, $b) = ($inner_points[$i], $outer_points[$j]); + my $line = Slic3r::Line->new($a, $b); + # turn $contour into an ExPolygonCollection and use $contour->contains_line() + if (first { $_->encloses_line($line, $self->_tolerance) } @$contour) { + $self->_space->add_edge($i+$o_inner, $j+$o_outer, $line->length * CROSSING_PENALTY); } } } } } - # lines connecting inner polygons contours are visible but discouraged - if (!$self->no_internal) { - my @inner = (map $_->contour, map @$_, @{$self->_inner}); - my @inner_ex = map Slic3r::ExPolygon->new($_), @inner; # build ExPolygons for Boost - for my $i (0 .. $#inner) { - for my $j (($i+1) .. $#inner) { - for my $m (0 .. $#{$inner[$i]}) { - for my $n (0 .. $#{$inner[$j]}) { - my $line = Slic3r::Line->new($inner[$i][$m], $inner[$j][$n]); - if (!@{Boost::Geometry::Utils::multi_polygon_multi_linestring_intersection([ map $_->pp, @inner_ex ], [$line->pp])}) { - # this line does not cross any polygon - my $dist = $line->length * CROSSING_FACTOR; - $edges->{$inner[$i][$m]}{$inner[$j][$n]} = $dist; - $edges->{$inner[$j][$n]}{$inner[$i][$m]} = $dist; - $crossing_edges->{$inner[$i][$m]}{$inner[$j][$n]} = 1; - $crossing_edges->{$inner[$j][$n]}{$inner[$i][$m]} = 1; - } - } - } - } - } - } - - $self->_pointmap({ - map +("$_" => $_), - (map @$_, map @$_, map @$_, @{$self->_inner}), - (map @$_, map @$_, @{$self->_outer}), - (map @$_, map @$_, map @$_, @{$self->_contours_ex}), - }); + # since Perl has no infinity symbol and we don't want to overcomplicate + # the Dijkstra algorithm with string constants or -1 values + $self->_space->_infinity(10 * (max(map values %$_, values %{$self->_space->edges}) // 0)); if (0) { - my @lines = (); - my %lines = (); - for my $i (keys %{$self->_edges}) { - for my $j (keys %{$self->_edges->{$i}}) { - next if $lines{join '_', sort $i, $j}; - push @lines, [ map $self->_pointmap->{$_}, $i, $j ]; - $lines{join '_', sort $i, $j} = 1; - } - } - require "Slic3r/SVG.pm"; Slic3r::SVG::output("space.svg", - lines => \@lines, - points => [ values %{$self->_pointmap} ], no_arrows => 1, expolygons => $self->islands, - #red_polygons => [ map @{$_->holes}, map @$_, @{$self->_inner} ], - #white_polygons => [ map @$_, @{$self->_outer} ], + lines => $self->_space->get_lines, + points => $self->_space->nodes, ); printf "%d islands\n", scalar @{$self->islands}; eval "use Devel::Size"; print "MEMORY USAGE:\n"; printf " %-19s = %.1fMb\n", $_, Devel::Size::total_size($self->$_)/1024/1024 - for qw(_inner _outer _contours_ex _pointmap _edges _crossing_edges islands last_crossings); + for qw(_space islands); + printf " %-19s = %.1fMb\n", $_, Devel::Size::total_size($self->_space->$_)/1024/1024 + for qw(nodes edges); printf " %-19s = %.1fMb\n", 'self', Devel::Size::total_size($self)/1024/1024; - } -} - -# given an expolygon, this subroutine connects all its visible points -sub _add_expolygon { - my $self = shift; - my ($expolygon, $crosses_perimeter) = @_; - - my $edges = $self->_edges; - my $crossing_edges = $self->_crossing_edges; - - my @points = map @$_, @$expolygon; - for my $i (0 .. $#points) { - for my $j (($i+1) .. $#points) { - my $line = Slic3r::Line->new($points[$i], $points[$j]); - if ($expolygon->encloses_line($line, $self->_tolerance)) { - my $dist = $line->length * ($crosses_perimeter ? CROSSING_FACTOR : 1); - $edges->{$points[$i]}{$points[$j]} = $dist; - $edges->{$points[$j]}{$points[$i]} = $dist; - $crossing_edges->{$points[$i]}{$points[$j]} = 1; - $crossing_edges->{$points[$j]}{$points[$i]} = 1; - } - } - } -} - -sub find_node { - my $self = shift; - my ($point, $near_to) = @_; - - # for optimal pathing, we should check visibility from $point to all $candidates, and then - # choose the one that is nearest to $near_to among the visible ones; however this is probably too slow - - # if we're inside a hole, move to a point on hole; - { - my $polygon = first { $_->encloses_point($point) } (map @{$_->holes}, map @$_, @{$self->_inner}); - return $point->nearest_point([ @$polygon ]) if $polygon; - } - - # if we're inside an expolygon move to a point on contour or holes - { - my $expolygon = first { $_->encloses_point_quick($point) } (map @$_, @{$self->_inner}); - return $point->nearest_point([ map @$_, @$expolygon ]) if $expolygon; - } - - { - my $outer_polygon_idx; - if (!$self->no_internal) { - # look for an outer expolygon whose contour contains our point - $outer_polygon_idx = first { first { $_->contour->encloses_point($point) } @{$self->_contours_ex->[$_]} } - 0 .. $#{ $self->_contours_ex }; - } else { - # # look for an outer expolygon containing our point - $outer_polygon_idx = first { first { $_->encloses_point($point) } @{$self->_outer->[$_]} } - 0 .. $#{ $self->_outer }; - } - my $candidates = defined $outer_polygon_idx - ? [ map @{$_->contour}, @{$self->_inner->[$outer_polygon_idx]} ] - : [ map @$_, map @$_, @{$self->_outer} ]; - $candidates = [ map @$_, @{$self->_outer->[$outer_polygon_idx]} ] - if @$candidates == 0; - return $point->nearest_point($candidates); + + exit if $self->internal; } } @@ -229,62 +134,188 @@ sub shortest_path { my $self = shift; my ($from, $to) = @_; - return Slic3r::Polyline->new($from, $to) if !@{$self->islands}; + return Slic3r::Polyline->new($from, $to) + if !@{$self->_space->nodes}; - # find nearest nodes - my $new_from = $self->find_node($from, $to); - my $new_to = $self->find_node($to, $from); + # create a temporary configuration space + my $space = $self->_space->clone; - my $root = "$new_from"; - my $target = "$new_to"; - my $edges = $self->_edges; - my %dist = map { $_ => INFINITY } keys %$edges; - $dist{$root} = 0; - my %prev = map { $_ => undef } keys %$edges; - my @unsolved = keys %$edges; - my %crossings = (); # node_idx => bool + # add from/to points to the temporary configuration space + my $node_from = $self->_add_point_to_space($from, $space); + my $node_to = $self->_add_point_to_space($to, $space); - while (@unsolved) { - # sort unsolved by distance from root - # using a sorting option that accounts for infinity - @unsolved = sort { - $dist{$a} eq INFINITY ? +1 : - $dist{$b} eq INFINITY ? -1 : - $dist{$a} <=> $dist{$b}; - } @unsolved; + # compute shortest path + my $path = $space->shortest_path($node_from, $node_to); + + if (!$path->is_valid) { + Slic3r::debugf "Failed to compute shortest path.\n"; + return Slic3r::Polyline->new($from, $to); + } + + if (0) { + require "Slic3r/SVG.pm"; + Slic3r::SVG::output("path.svg", + no_arrows => 1, + expolygons => $self->islands, + lines => $space->get_lines, + red_points => [$from, $to], + red_polylines => [$path], + ); + exit; + } + + return $path; +} + +# returns the index of the new node +sub _add_point_to_space { + my ($self, $point, $space) = @_; + + my $n = $space->nodes_count; + $space->add_nodes($point); + + # check whether we are inside an island or outside + my $inside = defined first { $self->islands->[$_]->encloses_point($point) } 0..$#{$self->islands}; + + # find candidates by checking visibility from $from to them + foreach my $idx (0..$#{$space->nodes}) { + my $line = Slic3r::Line->new($point, $space->nodes->[$idx]); + # if $point is inside an island, it is visible from $idx when island contains their line + # if $point is outside an island, it is visible from $idx when their line does not cross any island + if ( + ($inside && defined first { $_->encloses_line($line) } @{$self->_inner}) + || (!$inside && !@{Boost::Geometry::Utils::multi_polygon_multi_linestring_intersection( + [ map $_->pp, @{$self->islands} ], + [ $line->pp ], + )}) + ) { + # $n ($point) and $idx are visible + $space->add_edge($n, $idx, $line->length); + } + } + + # if we found no visibility, retry with larger margins + if (!exists $space->edges->{$n} && $inside) { + foreach my $idx (0..$#{$space->nodes}) { + my $line = Slic3r::Line->new($point, $space->nodes->[$idx]); + if (defined first { $_->encloses_line($line) } @{$self->islands}) { + # $n ($point) and $idx are visible + $space->add_edge($n, $idx, $line->length); + } + } + } + + warn "Temporary node is not visible from any other node" + if !exists $space->edges->{$n}; + + return $n; +} + +package Slic3r::GCode::MotionPlanner::ConfigurationSpace; +use Moo; + +has 'nodes' => (is => 'rw', default => sub { [] }); # [ Point, ... ] +has 'edges' => (is => 'rw', default => sub { {} }); # node_idx => { node_idx => distance, ... } +has '_infinity' => (is => 'rw'); + +sub clone { + my $self = shift; + + return (ref $self)->new( + nodes => [ map $_->clone, @{$self->nodes} ], + edges => { map { $_ => { %{$self->edges->{$_}} } } keys %{$self->edges} }, + _infinity => $self->_infinity, + ); +} + +sub nodes_count { + my $self = shift; + return scalar(@{ $self->nodes }); +} + +sub add_nodes { + my ($self, @nodes) = @_; + + my $offset = $self->nodes_count; + push @{ $self->nodes }, @nodes; + return $offset; +} + +sub add_edge { + my ($self, $a, $b, $dist) = @_; + $self->edges->{$a}{$b} = $self->edges->{$b}{$a} = $dist; +} + +sub shortest_path { + my ($self, $node_from, $node_to) = @_; + + my $edges = $self->edges; + my (%dist, %visited, %prev); + $dist{$_} = $self->_infinity for keys %$edges; + $dist{$node_from} = 0; + + my @queue = ($node_from); + while (@queue) { + my $u = -1; + { + # find node in @queue with smallest distance in %dist and has not been visited + my $d = -1; + foreach my $n (@queue) { + next if $visited{$n}; + if ($u == -1 || $dist{$n} < $d) { + $u = $n; + $d = $dist{$n}; + } + } + } + last if $u == $node_to; - # we'll solve the closest node - last if $dist{$unsolved[0]} eq INFINITY; - my $n = shift @unsolved; + # remove $u from @queue + @queue = grep $_ != $u, @queue; + $visited{$u} = 1; - # stop search - last if $n eq $target; - - # now, look at all the nodes connected to n - foreach my $n2 (keys %{$edges->{$n}}) { - # .. and find out if any of their estimated distances - # can be improved if we go through n - if ( ($dist{$n2} eq INFINITY) || ($dist{$n2} > ($dist{$n} + $edges->{$n}{$n2})) ) { - $dist{$n2} = $dist{$n} + $edges->{$n}{$n2}; - $prev{$n2} = $n; - $crossings{$n} = 1 if $self->_crossing_edges->{$n}{$n2}; - } + # loop through neighbors of $u + foreach my $v (keys %{ $edges->{$u} }) { + my $alt = $dist{$u} + $edges->{$u}{$v}; + if ($alt < $dist{$v}) { + $dist{$v} = $alt; + $prev{$v} = $u; + if (!$visited{$v}) { + push @queue, $v; + } + } } } my @points = (); - my $crossings = 0; { - my $pointmap = $self->_pointmap; - my $u = $target; - while (defined $prev{$u}) { - unshift @points, $pointmap->{$u}; - $crossings++ if $crossings{$u}; + my $u = $node_to; + while (exists $prev{$u}) { + unshift @points, $self->nodes->[$u]; $u = $prev{$u}; } + unshift @points, $self->nodes->[$node_from]; } - $self->last_crossings($crossings); - return Slic3r::Polyline->new($from, $new_from, @points, $to); # @points already includes $new_to + + return Slic3r::Polyline->new(@points); +} + +# for debugging purposes +sub get_lines { + my $self = shift; + + my @lines = (); + my %lines = (); + for my $i (keys %{$self->edges}) { + for my $j (keys %{$self->edges->{$i}}) { + my $line_id = join '_', sort $i, $j; + next if $lines{$line_id}; + $lines{$line_id} = 1; + push @lines, Slic3r::Line->new(map $self->nodes->[$_], $i, $j); + } + } + + return [@lines]; } 1; diff --git a/lib/Slic3r/Print.pm b/lib/Slic3r/Print.pm index ed0d8068..94fcabb0 100644 --- a/lib/Slic3r/Print.pm +++ b/lib/Slic3r/Print.pm @@ -797,7 +797,7 @@ sub write_gcode { } $gcodegen->external_mp(Slic3r::GCode::MotionPlanner->new( islands => union_ex([ map @$_, @islands ]), - no_internal => 1, + internal => 0, )); } From c180a2de5701df17304f1acf6cfcf0b88a54b1b7 Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci Date: Mon, 23 Dec 2013 01:19:02 +0100 Subject: [PATCH 05/50] Bugfix: fan wasn't turned on for bridges when vibration limit or another internal post-processor was enabled. Includes regression test. #1533 --- lib/Slic3r/GCode/Reader.pm | 2 +- t/cooling.t | 38 +++++++++++++++++++++++++++++++++++++- 2 files changed, 38 insertions(+), 2 deletions(-) diff --git a/lib/Slic3r/GCode/Reader.pm b/lib/Slic3r/GCode/Reader.pm index 251f1f2b..d2a7c184 100644 --- a/lib/Slic3r/GCode/Reader.pm +++ b/lib/Slic3r/GCode/Reader.pm @@ -18,11 +18,11 @@ sub parse { print "$raw_line\n" if $Verbose || $ENV{SLIC3R_TESTS_GCODE}; my $line = $raw_line; $line =~ s/\s*;(.*)//; # strip comment - next if $line eq ''; my %info = (comment => $1, raw => $raw_line); # parse command my ($command, @args) = split /\s+/, $line; + $command //= ''; my %args = map { /([A-Z])(.*)/; ($1 => $2) } @args; # check motion diff --git a/t/cooling.t b/t/cooling.t index 5cd156e3..87d3dff3 100644 --- a/t/cooling.t +++ b/t/cooling.t @@ -2,7 +2,7 @@ use Test::More; use strict; use warnings; -plan tests => 8; +plan tests => 11; BEGIN { use FindBin; @@ -10,6 +10,7 @@ BEGIN { } use Slic3r; +use Slic3r::Test; sub buffer { my $config = shift || Slic3r::Config->new_from_defaults; @@ -86,4 +87,39 @@ $config->set('disable_fan_first_layers', 0); like $gcode, qr/M106/, 'fan activation is computed on all objects printing at different Z'; } +{ + my $config = Slic3r::Config->new_from_defaults; + $config->set('cooling', 1); + $config->set('bridge_fan_speed', 100); + $config->set('fan_below_layer_time', 0); + $config->set('slowdown_below_layer_time', 0); + $config->set('bridge_speed', 99); + $config->set('top_solid_layers', 1); # internal bridges use solid_infil speed + $config->set('bottom_solid_layers', 1); # internal bridges use solid_infil speed + $config->set('vibration_limit', 30); # test that fan is turned on even when vibration limit (or other G-code post-processor) is enabled + + my $print = Slic3r::Test::init_print('overhang', config => $config); + my $fan = 0; + my $fan_with_incorrect_speeds = my $fan_with_incorrect_print_speeds = 0; + my $bridge_with_no_fan = 0; + Slic3r::GCode::Reader->new->parse(Slic3r::Test::gcode($print), sub { + my ($self, $cmd, $args, $info) = @_; + + if ($cmd eq 'M106') { + $fan = $args->{S}; + $fan_with_incorrect_speeds++ if $fan != 255; + } elsif ($cmd eq 'M107') { + $fan = 0; + } elsif ($info->{extruding} && $info->{dist_XY} > 0) { + $fan_with_incorrect_print_speeds++ + if ($fan > 0) && ($args->{F} // $self->F) != 60*$config->bridge_speed; + $bridge_with_no_fan++ + if !$fan && ($args->{F} // $self->F) == 60*$config->bridge_speed; + } + }); + ok !$fan_with_incorrect_speeds, 'bridge fan speed is applied correctly'; + ok !$fan_with_incorrect_print_speeds, 'bridge fan is only turned on for bridges'; + ok !$bridge_with_no_fan, 'bridge fan is turned on for all bridges'; +} + __END__ From 74f2f455547f17e69d391aa291922e87be3062a5 Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci Date: Mon, 23 Dec 2013 20:12:39 +0100 Subject: [PATCH 06/50] Fix regression preventing raft from being generated for the entire object footprint. #1614 #1567 --- lib/Slic3r/Print/SupportMaterial.pm | 121 +++++++++++++++------------- lib/Slic3r/Test.pm | 1 + t/support.t | 39 ++++++++- 3 files changed, 104 insertions(+), 57 deletions(-) diff --git a/lib/Slic3r/Print/SupportMaterial.pm b/lib/Slic3r/Print/SupportMaterial.pm index 92ccb16e..07f8624b 100644 --- a/lib/Slic3r/Print/SupportMaterial.pm +++ b/lib/Slic3r/Print/SupportMaterial.pm @@ -81,6 +81,10 @@ sub contact_area { my %contact = (); # contact_z => [ polygons ] my %overhang = (); # contact_z => [ polygons ] - this stores the actual overhang supported by each contact layer for my $layer_id (0 .. $#{$object->layers}) { + # note $layer_id might != $layer->id when raft_layers > 0 + # so $layer_id == 0 means first object layer + # and $layer->id == 0 means first print layer (including raft) + if ($self->config->raft_layers == 0) { next if $layer_id == 0; } elsif (!$self->config->support_material) { @@ -89,69 +93,76 @@ sub contact_area { last if $layer_id > 0; } my $layer = $object->layers->[$layer_id]; - my $lower_layer = $object->layers->[$layer_id-1]; # detect overhangs and contact areas needed to support them my (@overhang, @contact) = (); - foreach my $layerm (@{$layer->regions}) { - my $fw = $layerm->perimeter_flow->scaled_width; - my $diff; + if ($layer_id == 0) { + # this is the first object layer, so we're here just to get the object + # footprint for the raft + push @overhang, map $_->clone, map @$_, @{$layer->slices}; + push @contact, @{offset(\@overhang, scale +MARGIN)}; + } else { + my $lower_layer = $object->layers->[$layer_id-1]; + foreach my $layerm (@{$layer->regions}) { + my $fw = $layerm->perimeter_flow->scaled_width; + my $diff; - # If a threshold angle was specified, use a different logic for detecting overhangs. - if (defined $threshold_rad - || $layer_id < $self->config->support_material_enforce_layers - || $self->config->raft_layers > 0) { - my $d = defined $threshold_rad - ? scale $lower_layer->height * ((cos $threshold_rad) / (sin $threshold_rad)) - : 0; + # If a threshold angle was specified, use a different logic for detecting overhangs. + if (defined $threshold_rad + || $layer_id < $self->config->support_material_enforce_layers + || $self->config->raft_layers > 0) { + my $d = defined $threshold_rad + ? scale $lower_layer->height * ((cos $threshold_rad) / (sin $threshold_rad)) + : 0; - $diff = diff( - offset([ map $_->p, @{$layerm->slices} ], -$d), - [ map @$_, @{$lower_layer->slices} ], - ); - - # only enforce spacing from the object ($fw/2) if the threshold angle - # is not too high: in that case, $d will be very small (as we need to catch - # very short overhangs), and such contact area would be eaten by the - # enforced spacing, resulting in high threshold angles to be almost ignored - $diff = diff( - offset($diff, $d - $fw/2), - [ map @$_, @{$lower_layer->slices} ], - ) if $d > $fw/2; - } else { - $diff = diff( - offset([ map $_->p, @{$layerm->slices} ], -$fw/2), - [ map @$_, @{$lower_layer->slices} ], - ); - - # collapse very tiny spots - $diff = offset2($diff, -$fw/10, +$fw/10); - - # $diff now contains the ring or stripe comprised between the boundary of - # lower slices and the centerline of the last perimeter in this overhanging layer. - # Void $diff means that there's no upper perimeter whose centerline is - # outside the lower slice boundary, thus no overhang - } - - # TODO: this is the place to remove bridged areas - - next if !@$diff; - push @overhang, @$diff; # NOTE: this is not the full overhang as it misses the outermost half of the perimeter width! - - # Let's define the required contact area by using a max gap of half the upper - # extrusion width and extending the area according to the configured margin. - # We increment the area in steps because we don't want our support to overflow - # on the other side of the object (if it's very thin). - { - my @slices_margin = @{offset([ map @$_, @{$lower_layer->slices} ], $fw/2)}; - for ($fw/2, map {scale MARGIN_STEP} 1..(MARGIN / MARGIN_STEP)) { $diff = diff( - offset($diff, $_), - \@slices_margin, + offset([ map $_->p, @{$layerm->slices} ], -$d), + [ map @$_, @{$lower_layer->slices} ], ); + + # only enforce spacing from the object ($fw/2) if the threshold angle + # is not too high: in that case, $d will be very small (as we need to catch + # very short overhangs), and such contact area would be eaten by the + # enforced spacing, resulting in high threshold angles to be almost ignored + $diff = diff( + offset($diff, $d - $fw/2), + [ map @$_, @{$lower_layer->slices} ], + ) if $d > $fw/2; + } else { + $diff = diff( + offset([ map $_->p, @{$layerm->slices} ], -$fw/2), + [ map @$_, @{$lower_layer->slices} ], + ); + + # collapse very tiny spots + $diff = offset2($diff, -$fw/10, +$fw/10); + + # $diff now contains the ring or stripe comprised between the boundary of + # lower slices and the centerline of the last perimeter in this overhanging layer. + # Void $diff means that there's no upper perimeter whose centerline is + # outside the lower slice boundary, thus no overhang } + + # TODO: this is the place to remove bridged areas + + next if !@$diff; + push @overhang, @$diff; # NOTE: this is not the full overhang as it misses the outermost half of the perimeter width! + + # Let's define the required contact area by using a max gap of half the upper + # extrusion width and extending the area according to the configured margin. + # We increment the area in steps because we don't want our support to overflow + # on the other side of the object (if it's very thin). + { + my @slices_margin = @{offset([ map @$_, @{$lower_layer->slices} ], $fw/2)}; + for ($fw/2, map {scale MARGIN_STEP} 1..(MARGIN / MARGIN_STEP)) { + $diff = diff( + offset($diff, $_), + \@slices_margin, + ); + } + } + push @contact, @$diff; } - push @contact, @$diff; } next if !@contact; @@ -176,7 +187,7 @@ sub contact_area { require "Slic3r/SVG.pm"; Slic3r::SVG::output("contact_" . $contact_z . ".svg", expolygons => union_ex(\@contact), - red_expolygons => \@overhang, + red_expolygons => union_ex(\@overhang), ); } } diff --git a/lib/Slic3r/Test.pm b/lib/Slic3r/Test.pm index 6f2b5d40..8c4a969e 100644 --- a/lib/Slic3r/Test.pm +++ b/lib/Slic3r/Test.pm @@ -107,6 +107,7 @@ sub init_print { $model_name = [$model_name] if ref($model_name) ne 'ARRAY'; for my $model (map model($_, %params), @$model_name) { + die "Unknown model in test" if !defined $model; $model->arrange_objects($config); $print->add_model($model); } diff --git a/t/support.t b/t/support.t index 768ddc09..b7d1810d 100644 --- a/t/support.t +++ b/t/support.t @@ -1,4 +1,4 @@ -use Test::More tests => 13; +use Test::More tests => 14; use strict; use warnings; @@ -9,7 +9,8 @@ BEGIN { use List::Util qw(first); use Slic3r; -use Slic3r::Geometry qw(epsilon); +use Slic3r::Geometry qw(epsilon scale); +use Slic3r::Geometry::Clipper qw(diff); use Slic3r::Test; { @@ -88,4 +89,38 @@ use Slic3r::Test; }); } +{ + my $config = Slic3r::Config->new_from_defaults; + $config->set('skirts', 0); + $config->set('raft_layers', 3); + $config->set('support_material_extrusion_width', 0.6); + $config->set('first_layer_extrusion_width', '100%'); + my $print = Slic3r::Test::init_print('20mm_cube', config => $config); + + my $layer_id = 0; + my @raft = my @first_object_layer = (); + Slic3r::GCode::Reader->new->parse(Slic3r::Test::gcode($print), sub { + my ($self, $cmd, $args, $info) = @_; + + if ($info->{extruding} && $info->{dist_XY} > 0) { + if ($layer_id <= $config->raft_layers) { + # this is a raft layer or the first object layer + my $line = Slic3r::Line->new_scale([ $self->X, $self->Y ], [ $info->{new_X}, $info->{new_Y} ]); + my @path = $line->grow(scale($config->support_material_extrusion_width/2)); + if ($layer_id < $config->raft_layers) { + # this is a raft layer + push @raft, @path; + } else { + push @first_object_layer, @path; + } + } + } elsif ($cmd eq 'G1' && $info->{dist_Z} > 0) { + $layer_id++; + } + }); + + ok !@{diff(\@first_object_layer, \@raft)}, + 'first object layer is completely supported by raft'; +} + __END__ From b5518523920629d9d315d789375b9b74867cc2a4 Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci Date: Mon, 23 Dec 2013 20:36:16 +0100 Subject: [PATCH 07/50] Fix regression causing thin walls to come out as zigzag paths. #1573 #1575 --- lib/Slic3r/ExPolygon.pm | 4 +++- lib/Slic3r/Layer/Region.pm | 3 +-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/Slic3r/ExPolygon.pm b/lib/Slic3r/ExPolygon.pm index b72b9354..b3c3be2e 100644 --- a/lib/Slic3r/ExPolygon.pm +++ b/lib/Slic3r/ExPolygon.pm @@ -249,9 +249,11 @@ sub _medial_axis_voronoi { } else { push @result, Slic3r::Polyline->new(@points); } - $result[-1]->simplify($width / 7); } + # apply Douglas-Peucker to straighten paths + @result = map $_->simplify($width / 7), @result; + return @result; } diff --git a/lib/Slic3r/Layer/Region.pm b/lib/Slic3r/Layer/Region.pm index b10b2dac..a375ef70 100644 --- a/lib/Slic3r/Layer/Region.pm +++ b/lib/Slic3r/Layer/Region.pm @@ -298,8 +298,7 @@ sub make_perimeters { # append perimeters $self->perimeters->append(@loops); - # detect thin walls by offsetting slices by half extrusion inwards - # and add them as perimeters + # process thin walls by collapsing slices to single passes if (@thin_walls) { my @p = map $_->medial_axis($pspacing), @thin_walls; my @paths = (); From eb5ca204497d614a76d256d549d4c80b15478f9b Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci Date: Mon, 23 Dec 2013 21:22:32 +0100 Subject: [PATCH 08/50] Fixed regression causing incomplete gap fill when all configured perimeters were successfully generated. #1589 --- lib/Slic3r/Layer/Region.pm | 73 ++++++++++++++++++++------------------ 1 file changed, 39 insertions(+), 34 deletions(-) diff --git a/lib/Slic3r/Layer/Region.pm b/lib/Slic3r/Layer/Region.pm index a375ef70..7f5be7f6 100644 --- a/lib/Slic3r/Layer/Region.pm +++ b/lib/Slic3r/Layer/Region.pm @@ -167,42 +167,47 @@ sub make_perimeters { my @last = @{$surface->expolygon}; my @last_gaps = (); - for my $i (1 .. $loop_number) { # outer loop is 1 - my @offsets = (); - if ($i == 1) { - # the minimum thickness of a single loop is: - # width/2 + spacing/2 + spacing/2 + width/2 - @offsets = @{offset2(\@last, -(0.5*$pwidth + 0.5*$pspacing - 1), +(0.5*$pspacing - 1))}; + if ($loop_number > 0) { + # we loop one time more than needed in order to find gaps after the last perimeter was applied + for my $i (1 .. ($loop_number+1)) { # outer loop is 1 + my @offsets = (); + if ($i == 1) { + # the minimum thickness of a single loop is: + # width/2 + spacing/2 + spacing/2 + width/2 + @offsets = @{offset2(\@last, -(0.5*$pwidth + 0.5*$pspacing - 1), +(0.5*$pspacing - 1))}; - # look for thin walls - if ($self->config->thin_walls) { - my $diff = diff_ex( - \@last, - offset(\@offsets, +0.5*$pwidth), - ); - push @thin_walls, grep abs($_->area) >= $gap_area_threshold, @$diff; - } - } else { - @offsets = @{offset2(\@last, -(1.5*$pspacing - 1), +(0.5*$pspacing - 1))}; - - # look for gaps - if ($Slic3r::Config->gap_fill_speed > 0 && $self->config->fill_density > 0) { - my $diff = diff_ex( - offset(\@last, -0.5*$pspacing), - offset(\@offsets, +0.5*$pspacing), - ); - push @gaps, @last_gaps = grep abs($_->area) >= $gap_area_threshold, @$diff; - } - } - - last if !@offsets; - # clone polygons because these ExPolygons will go out of scope very soon - @last = @offsets; - foreach my $polygon (@offsets) { - if ($polygon->is_counter_clockwise) { - push @contours, $polygon; + # look for thin walls + if ($self->config->thin_walls) { + my $diff = diff_ex( + \@last, + offset(\@offsets, +0.5*$pwidth), + ); + push @thin_walls, grep abs($_->area) >= $gap_area_threshold, @$diff; + } } else { - push @holes, $polygon; + @offsets = @{offset2(\@last, -(1.5*$pspacing - 1), +(0.5*$pspacing - 1))}; + + # look for gaps + if ($Slic3r::Config->gap_fill_speed > 0 && $self->config->fill_density > 0) { + my $diff = diff_ex( + offset(\@last, -0.5*$pspacing), + offset(\@offsets, +0.5*$pspacing), + ); + push @gaps, @last_gaps = grep abs($_->area) >= $gap_area_threshold, @$diff; + } + } + + last if !@offsets; + last if $i > $loop_number; # we were only looking for gaps this time + + # clone polygons because these ExPolygons will go out of scope very soon + @last = @offsets; + foreach my $polygon (@offsets) { + if ($polygon->is_counter_clockwise) { + push @contours, $polygon; + } else { + push @holes, $polygon; + } } } } From 6d8d166eff12f6401ca6ddefae7eb69ca5faebc2 Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci Date: Wed, 25 Dec 2013 12:37:03 +0100 Subject: [PATCH 09/50] Backport the GLUquadricObjPtr declaration to prevent errors during Quick Slice. #1636 --- lib/Slic3r.pm | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/Slic3r.pm b/lib/Slic3r.pm index d317f2e6..98972d7e 100644 --- a/lib/Slic3r.pm +++ b/lib/Slic3r.pm @@ -160,4 +160,8 @@ sub open { return CORE::open $$fh, $mode, encode_path($filename); } +# this package declaration prevents an ugly fatal warning to be emitted when +# spawning a new thread +package GLUquadricObjPtr; + 1; From 907e72830f61f014c145a060dbeb56d6af9634c3 Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci Date: Sat, 28 Dec 2013 15:32:43 +0100 Subject: [PATCH 10/50] Fix random crashes on 32-bit. Thank you Valgrind --- lib/Slic3r/Layer/Region.pm | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/Slic3r/Layer/Region.pm b/lib/Slic3r/Layer/Region.pm index 7f5be7f6..05713ba1 100644 --- a/lib/Slic3r/Layer/Region.pm +++ b/lib/Slic3r/Layer/Region.pm @@ -221,6 +221,7 @@ sub make_perimeters { # and then we offset back and forth by half the infill spacing to only consider the # non-collapsing regions $self->fill_surfaces->append( + map Slic3r::Surface->new(expolygon => $_, surface_type => S_TYPE_INTERNAL), # use a bogus surface type @{offset2_ex( [ map $_->simplify_as_polygons(&Slic3r::SCALED_RESOLUTION), @{union_ex(\@last)} ], -($pspacing/2 + $ispacing/2), From 354e4ce84127323564bd9a9b027c876968d39f88 Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci Date: Sat, 28 Dec 2013 16:01:27 +0100 Subject: [PATCH 11/50] Add Module::Build::WithXSpp to prerequisites. #1640 --- Build.PL | 1 + 1 file changed, 1 insertion(+) diff --git a/Build.PL b/Build.PL index 18bc772f..f7117e66 100644 --- a/Build.PL +++ b/Build.PL @@ -16,6 +16,7 @@ my %prereqs = qw( Math::ConvexHull::MonotoneChain 0.01 Math::Geometry::Voronoi 1.3 Math::PlanePath 53 + Module::Build::WithXSpp 0.14 Moo 1.003001 Scalar::Util 0 Storable 0 From 6afc01c3b9803c568dd7962bd82e6221707a978e Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci Date: Sat, 28 Dec 2013 17:55:45 +0100 Subject: [PATCH 12/50] Releasing 1.0.0RC2 --- lib/Slic3r.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Slic3r.pm b/lib/Slic3r.pm index 98972d7e..6f09c4fb 100644 --- a/lib/Slic3r.pm +++ b/lib/Slic3r.pm @@ -7,7 +7,7 @@ use strict; use warnings; require v5.10; -our $VERSION = "1.0.0RC1"; +our $VERSION = "1.0.0RC2"; our $debug = 0; sub debugf { From 713bdd8055cae6d9753f68531dbb1b51419a9f2d Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci Date: Thu, 2 Jan 2014 18:50:54 +0100 Subject: [PATCH 13/50] Bugfix: overflow causing full object facets reversal when STL file has large coordinates. #1666 --- xs/src/admesh/util.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/xs/src/admesh/util.c b/xs/src/admesh/util.c index 65a226ab..7b3fae80 100644 --- a/xs/src/admesh/util.c +++ b/xs/src/admesh/util.c @@ -376,19 +376,22 @@ void stl_calculate_volume(stl_file *stl) static float get_area(stl_facet *facet) { - float cross[3][3]; + double cross[3][3]; float sum[3]; float n[3]; float area; int i; + // cast to double before calculating cross product because large coordinates + // can result in overflowing product + // (bad area is responsible for bad volume and bad facets reversal) for(i = 0; i < 3; i++){ - cross[i][0]=((facet->vertex[i].y * facet->vertex[(i + 1) % 3].z) - - (facet->vertex[i].z * facet->vertex[(i + 1) % 3].y)); - cross[i][1]=((facet->vertex[i].z * facet->vertex[(i + 1) % 3].x) - - (facet->vertex[i].x * facet->vertex[(i + 1) % 3].z)); - cross[i][2]=((facet->vertex[i].x * facet->vertex[(i + 1) % 3].y) - - (facet->vertex[i].y * facet->vertex[(i + 1) % 3].x)); + cross[i][0]=(((double)facet->vertex[i].y * (double)facet->vertex[(i + 1) % 3].z) - + ((double)facet->vertex[i].z * (double)facet->vertex[(i + 1) % 3].y)); + cross[i][1]=(((double)facet->vertex[i].z * (double)facet->vertex[(i + 1) % 3].x) - + ((double)facet->vertex[i].x * (double)facet->vertex[(i + 1) % 3].z)); + cross[i][2]=(((double)facet->vertex[i].x * (double)facet->vertex[(i + 1) % 3].y) - + ((double)facet->vertex[i].y * (double)facet->vertex[(i + 1) % 3].x)); } sum[0] = cross[0][0] + cross[1][0] + cross[2][0]; From 468935c1770ee2f3de427ea3516a7786f02f53e8 Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci Date: Thu, 2 Jan 2014 19:22:27 +0100 Subject: [PATCH 14/50] Bump version number --- lib/Slic3r.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Slic3r.pm b/lib/Slic3r.pm index 6f09c4fb..da2de023 100644 --- a/lib/Slic3r.pm +++ b/lib/Slic3r.pm @@ -7,7 +7,7 @@ use strict; use warnings; require v5.10; -our $VERSION = "1.0.0RC2"; +our $VERSION = "1.0.0RC3-dev"; our $debug = 0; sub debugf { From bb50dfb9baa5b74894f9fbc2323cd31428226487 Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci Date: Sat, 11 Jan 2014 14:24:40 +0100 Subject: [PATCH 15/50] Test that absolute_E is positive at the end of print (and document that it accounts for the final retraction) --- t/gcode.t | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/t/gcode.t b/t/gcode.t index 17f4ed82..4d0ed149 100644 --- a/t/gcode.t +++ b/t/gcode.t @@ -1,4 +1,4 @@ -use Test::More tests => 6; +use Test::More tests => 7; use strict; use warnings; @@ -69,4 +69,18 @@ use Slic3r::Test; is_deeply [ @z_moves[0..($layer_count-1)] ], [ @z_moves[$layer_count..$#z_moves] ], 'complete_objects generates the correct Z moves'; } +{ + my $config = Slic3r::Config->new_from_defaults; + $config->set('retract_length', [1000000]); + $config->set('use_relative_e_distances', 1); + my $print = Slic3r::Test::init_print('20mm_cube', config => $config); + Slic3r::GCode::Reader->new->parse(Slic3r::Test::gcode($print), sub { + my ($self, $cmd, $args, $info) = @_; + + + }); + # account for one single retraction at the end of the print + ok $print->extruders->[0]->absolute_E + $config->retract_length->[0] > 0, 'total filament length is positive'; +} + __END__ From a32f548a23f3e90a4c44817aba80613ea9a980b3 Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci Date: Sat, 11 Jan 2014 14:30:34 +0100 Subject: [PATCH 16/50] Put a hard limit on manually configured extrusion widths (10 * the largest nozzle diameter configured) to prevent confusion when a bad value is entered. #1691 --- lib/Slic3r/Config.pm | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/Slic3r/Config.pm b/lib/Slic3r/Config.pm index adf83bec..d4096549 100644 --- a/lib/Slic3r/Config.pm +++ b/lib/Slic3r/Config.pm @@ -3,7 +3,7 @@ use strict; use warnings; use utf8; -use List::Util qw(first); +use List::Util qw(first max); # cemetery of old config settings our @Ignore = qw(duplicate_x duplicate_y multiply_x multiply_y support_material_tool acceleration @@ -1472,6 +1472,15 @@ sub validate { if ($self->perimeter_acceleration || $self->infill_acceleration || $self->bridge_acceleration || $self->first_layer_acceleration) && !$self->default_acceleration; + # extrusion widths + { + my $max_nozzle_diameter = max(@{ $self->nozzle_diameter }); + die "Invalid extrusion width (too large)\n" + if defined first { $_ > 10 * $max_nozzle_diameter } + map $self->get("${_}_extrusion_width"), + qw(perimeter infill solid_infill top_infill support_material first_layer); + } + # general validation, quick and dirty foreach my $opt_key (keys %$Options) { my $opt = $Options->{$opt_key}; From 5c02bfd31018e55519b838e51903c3f3764a925e Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci Date: Sat, 11 Jan 2014 17:24:56 +0100 Subject: [PATCH 17/50] Bugfix: ambiguous semantics of the layers_count() method caused M73 to go beyond 100%. #1670 --- lib/Slic3r/GCode.pm | 4 +++- lib/Slic3r/Print.pm | 49 +++++++++++++++++++++----------------- lib/Slic3r/Print/Object.pm | 35 ++++++++++++++------------- t/gcode.t | 17 +++++++++++++ 4 files changed, 66 insertions(+), 39 deletions(-) diff --git a/lib/Slic3r/GCode.pm b/lib/Slic3r/GCode.pm index 4faf45a0..5bace196 100644 --- a/lib/Slic3r/GCode.pm +++ b/lib/Slic3r/GCode.pm @@ -15,6 +15,7 @@ has 'standby_points' => (is => 'rw'); has 'enable_loop_clipping' => (is => 'rw', default => sub {1}); has 'enable_wipe' => (is => 'lazy'); # at least one extruder has wipe enabled has 'layer_count' => (is => 'ro', required => 1 ); +has '_layer_index' => (is => 'rw', default => sub {-1}); # just a counter has 'layer' => (is => 'rw'); has '_layer_islands' => (is => 'rw'); has '_upper_layer_islands' => (is => 'rw'); @@ -92,6 +93,7 @@ sub change_layer { my ($self, $layer) = @_; $self->layer($layer); + $self->_layer_index($self->_layer_index + 1); # avoid computing islands and overhangs if they're not needed $self->_layer_islands($layer->islands); @@ -111,7 +113,7 @@ sub change_layer { my $gcode = ""; if ($self->config->gcode_flavor =~ /^(?:makerware|sailfish)$/) { $gcode .= sprintf "M73 P%s%s\n", - int(99 * ($layer->id / ($self->layer_count - 1))), + int(99 * ($self->_layer_index / ($self->layer_count - 1))), ($self->config->gcode_comments ? ' ; update progress' : ''); } if ($self->config->first_layer_acceleration) { diff --git a/lib/Slic3r/Print.pm b/lib/Slic3r/Print.pm index 94fcabb0..2b413360 100644 --- a/lib/Slic3r/Print.pm +++ b/lib/Slic3r/Print.pm @@ -283,9 +283,11 @@ sub init_extruders { } } +# this value is not supposed to be compared with $layer->id +# since they have different semantics sub layer_count { my $self = shift; - return max(map { scalar @{$_->layers} } @{$self->objects}); + return max(map $_->layer_count, @{$self->objects}); } sub regions_count { @@ -398,8 +400,9 @@ sub export_gcode { items => sub { my @items = (); # [obj_idx, layer_id] for my $obj_idx (0 .. $#{$self->objects}) { - for my $region_id (0 .. ($self->regions_count-1)) { - push @items, map [$obj_idx, $_, $region_id], 0..($self->objects->[$obj_idx]->layer_count-1); + my $object = $self->objects->[$obj_idx]; + for my $region_id (0 .. $#{$self->regions}) { + push @items, map [$obj_idx, $_, $region_id], 0..$#{$object->layers}; } } @items; @@ -407,9 +410,9 @@ sub export_gcode { thread_cb => sub { my $q = shift; while (defined (my $obj_layer = $q->dequeue)) { - my ($obj_idx, $layer_id, $region_id) = @$obj_layer; + my ($obj_idx, $layer_i, $region_id) = @$obj_layer; my $object = $self->objects->[$obj_idx]; - my $layerm = $object->layers->[$layer_id]->regions->[$region_id]; + my $layerm = $object->layers->[$layer_i]->regions->[$region_id]; $layerm->fills->append( $object->fill_maker->make_fill($layerm) ); } }, @@ -517,29 +520,31 @@ EOF ($type eq 'contour' ? 'white' : 'black'); }; + my @layers = sort { $a->print_z <=> $b->print_z } + map { @{$_->layers}, @{$_->support_layers} } + @{$self->objects}; + + my $layer_id = -1; my @previous_layer_slices = (); - for my $layer_id (0..$self->layer_count-1) { - my @layers = map $_->layers->[$layer_id], @{$self->objects}; - printf $fh qq{ \n}, $layer_id, unscale +(grep defined $_, @layers)[0]->slice_z; + for my $layer (@layers) { + $layer_id++; + # TODO: remove slic3r:z for raft layers + printf $fh qq{ \n}, $layer_id, unscale($layer->slice_z); my @current_layer_slices = (); - for my $obj_idx (0 .. $#{$self->objects}) { - my $layer = $self->objects->[$obj_idx]->layers->[$layer_id] or next; - - # sort slices so that the outermost ones come first - my @slices = sort { $a->contour->encloses_point($b->contour->[0]) ? 0 : 1 } @{$layer->slices}; - foreach my $copy (@{$self->objects->[$obj_idx]->copies}) { - foreach my $slice (@slices) { - my $expolygon = $slice->clone; - $expolygon->translate(@$copy); - $print_polygon->($expolygon->contour, 'contour'); - $print_polygon->($_, 'hole') for @{$expolygon->holes}; - push @current_layer_slices, $expolygon; - } + # sort slices so that the outermost ones come first + my @slices = sort { $a->contour->encloses_point($b->contour->[0]) ? 0 : 1 } @{$layer->slices}; + foreach my $copy (@{$layer->object->copies}) { + foreach my $slice (@slices) { + my $expolygon = $slice->clone; + $expolygon->translate(@$copy); + $print_polygon->($expolygon->contour, 'contour'); + $print_polygon->($_, 'hole') for @{$expolygon->holes}; + push @current_layer_slices, $expolygon; } } # generate support material - if ($self->has_support_material && $layer_id > 0) { + if ($self->has_support_material && $layer->id > 0) { my (@supported_slices, @unsupported_slices) = (); foreach my $expolygon (@current_layer_slices) { my $intersection = intersection_ex( diff --git a/lib/Slic3r/Print/Object.pm b/lib/Slic3r/Print/Object.pm index 35149667..7c0f41f3 100644 --- a/lib/Slic3r/Print/Object.pm +++ b/lib/Slic3r/Print/Object.pm @@ -93,9 +93,12 @@ sub init_config { $self->config(Slic3r::Config->merge($self->print->config, $self->config_overrides)); } +# this is the *total* layer count +# this value is not supposed to be compared with $layer->id +# since they have different semantics sub layer_count { my $self = shift; - return scalar @{ $self->layers }; + return scalar @{ $self->layers } + scalar @{ $self->support_layers }; } sub bounding_box { @@ -219,9 +222,10 @@ sub make_perimeters { # hollow objects if ($self->config->extra_perimeters && $self->config->perimeters > 0 && $self->config->fill_density > 0) { for my $region_id (0 .. ($self->print->regions_count-1)) { - for my $layer_id (0 .. $self->layer_count-2) { - my $layerm = $self->layers->[$layer_id]->regions->[$region_id]; - my $upper_layerm = $self->layers->[$layer_id+1]->regions->[$region_id]; + for my $i (0 .. $#{$self->layers}-1) { + # remember that $i != $layer->id + my $layerm = $self->layers->[$i]->regions->[$region_id]; + my $upper_layerm = $self->layers->[$i+1]->regions->[$region_id]; my $perimeter_spacing = $layerm->perimeter_flow->scaled_spacing; my $overlap = $perimeter_spacing; # one perimeter @@ -258,7 +262,7 @@ sub make_perimeters { # only add the perimeter if there's an intersection with the collapsed area last CYCLE if !@{ intersection($diff, $hypothetical_perimeter) }; - Slic3r::debugf " adding one more perimeter at layer %d\n", $layer_id; + Slic3r::debugf " adding one more perimeter at layer %d\n", $layerm->id; $slice->extra_perimeters($extra_perimeters); } } @@ -267,11 +271,11 @@ sub make_perimeters { } Slic3r::parallelize( - items => sub { 0 .. ($self->layer_count-1) }, + items => sub { 0 .. $#{$self->layers} }, thread_cb => sub { my $q = shift; - while (defined (my $layer_id = $q->dequeue)) { - $self->layers->[$layer_id]->make_perimeters; + while (defined (my $i = $q->dequeue)) { + $self->layers->[$i]->make_perimeters; } }, collect_cb => sub {}, @@ -286,7 +290,7 @@ sub detect_surfaces_type { Slic3r::debugf "Detecting solid surfaces...\n"; for my $region_id (0 .. ($self->print->regions_count-1)) { - for my $i (0 .. ($self->layer_count-1)) { + for my $i (0 .. $#{$self->layers}) { my $layerm = $self->layers->[$i]->regions->[$region_id]; # prepare a reusable subroutine to make surface differences @@ -516,8 +520,8 @@ sub process_external_surfaces { for my $region_id (0 .. ($self->print->regions_count-1)) { $self->layers->[0]->regions->[$region_id]->process_external_surfaces(undef); - for my $layer_id (1 .. ($self->layer_count-1)) { - $self->layers->[$layer_id]->regions->[$region_id]->process_external_surfaces($self->layers->[$layer_id-1]); + for my $i (1 .. $#{$self->layers}) { + $self->layers->[$i]->regions->[$region_id]->process_external_surfaces($self->layers->[$i-1]); } } } @@ -528,7 +532,7 @@ sub discover_horizontal_shells { Slic3r::debugf "==> DISCOVERING HORIZONTAL SHELLS\n"; for my $region_id (0 .. ($self->print->regions_count-1)) { - for (my $i = 0; $i < $self->layer_count; $i++) { + for (my $i = 0; $i <= $#{$self->layers}; $i++) { my $layerm = $self->layers->[$i]->regions->[$region_id]; if ($self->config->solid_infill_every_layers && $self->config->fill_density > 0 @@ -560,7 +564,7 @@ sub discover_horizontal_shells { abs($n - $i) <= $solid_layers-1; ($type == S_TYPE_TOP) ? $n-- : $n++) { - next if $n < 0 || $n >= $self->layer_count; + next if $n < 0 || $n > $#{$self->layers}; Slic3r::debugf " looking for neighbors on layer %d...\n", $n; my $neighbor_fill_surfaces = $self->layers->[$n]->regions->[$region_id]->fill_surfaces; @@ -666,8 +670,7 @@ sub combine_infill { return unless $self->config->infill_every_layers > 1 && $self->config->fill_density > 0; my $every = $self->config->infill_every_layers; - my $layer_count = $self->layer_count; - my @layer_heights = map $self->layers->[$_]->height, 0 .. $layer_count-1; + my @layer_heights = map $_->height, @{$self->layers}; for my $region_id (0 .. ($self->print->regions_count-1)) { # limit the number of combined layers to the maximum height allowed by this regions' nozzle @@ -774,7 +777,7 @@ sub combine_infill { sub generate_support_material { my $self = shift; return unless ($self->config->support_material || $self->config->raft_layers > 0) - && $self->layer_count >= 2; + && scalar(@{$self->layers}) >= 2; Slic3r::Print::SupportMaterial ->new(config => $self->config, flow => $self->print->support_material_flow) diff --git a/t/gcode.t b/t/gcode.t index 4d0ed149..e68b899a 100644 --- a/t/gcode.t +++ b/t/gcode.t @@ -83,4 +83,21 @@ use Slic3r::Test; ok $print->extruders->[0]->absolute_E + $config->retract_length->[0] > 0, 'total filament length is positive'; } +{ + my $config = Slic3r::Config->new_from_defaults; + $config->set('gcode_flavor', 'sailfish'); + $config->set('raft_layers', 3); + my $print = Slic3r::Test::init_print('20mm_cube', config => $config); + my @percent = (); + Slic3r::GCode::Reader->new->parse(Slic3r::Test::gcode($print), sub { + my ($self, $cmd, $args, $info) = @_; + + if ($cmd eq 'M73') { + push @percent, $args->{P}; + } + }); + # the extruder heater is turned off when M73 P100 is reached + ok !(defined first { $_ > 100 } @percent), 'M73 is never given more than 100%'; +} + __END__ From b43ead06fe5c689b9cb0c3515a9c60439072c32c Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci Date: Sat, 11 Jan 2014 18:41:44 +0100 Subject: [PATCH 18/50] Fix regression introduced by max width check --- lib/Slic3r/Config.pm | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/Slic3r/Config.pm b/lib/Slic3r/Config.pm index d4096549..d6a7db1c 100644 --- a/lib/Slic3r/Config.pm +++ b/lib/Slic3r/Config.pm @@ -480,6 +480,7 @@ our $Options = { cli => 'first-layer-extrusion-width=s', type => 'f', default => '200%', + ratio_over => 'first_layer_height', }, 'perimeter_extrusion_width' => { label => 'Perimeters', @@ -489,6 +490,7 @@ our $Options = { type => 'f', aliases => [qw(perimeters_extrusion_width)], default => 0, + ratio_over => 'layer_height', }, 'infill_extrusion_width' => { label => 'Infill', @@ -497,6 +499,7 @@ our $Options = { cli => 'infill-extrusion-width=s', type => 'f', default => 0, + ratio_over => 'layer_height', }, 'solid_infill_extrusion_width' => { label => 'Solid infill', @@ -505,6 +508,7 @@ our $Options = { cli => 'solid-infill-extrusion-width=s', type => 'f', default => 0, + ratio_over => 'layer_height', }, 'top_infill_extrusion_width' => { label => 'Top solid infill', @@ -513,6 +517,7 @@ our $Options = { cli => 'top-infill-extrusion-width=s', type => 'f', default => 0, + ratio_over => 'layer_height', }, 'support_material_extrusion_width' => { label => 'Support material', @@ -521,6 +526,7 @@ our $Options = { cli => 'support-material-extrusion-width=s', type => 'f', default => 0, + ratio_over => 'layer_height', }, 'bridge_flow_ratio' => { label => 'Bridge flow ratio', @@ -1477,7 +1483,7 @@ sub validate { my $max_nozzle_diameter = max(@{ $self->nozzle_diameter }); die "Invalid extrusion width (too large)\n" if defined first { $_ > 10 * $max_nozzle_diameter } - map $self->get("${_}_extrusion_width"), + map $self->get_value("${_}_extrusion_width"), qw(perimeter infill solid_infill top_infill support_material first_layer); } From 26f0fab27af46afb24b47bd510534a2776e49669 Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci Date: Sat, 11 Jan 2014 21:27:37 +0100 Subject: [PATCH 19/50] Fix bug in regression infill causing bad clipping at very low layer heights. Includes regression test. #1669 --- lib/Slic3r/Fill/Rectilinear.pm | 2 +- t/fill.t | 33 +++++++++++++++++++++++++++++---- 2 files changed, 30 insertions(+), 5 deletions(-) diff --git a/lib/Slic3r/Fill/Rectilinear.pm b/lib/Slic3r/Fill/Rectilinear.pm index dd39b304..1252de64 100644 --- a/lib/Slic3r/Fill/Rectilinear.pm +++ b/lib/Slic3r/Fill/Rectilinear.pm @@ -59,7 +59,7 @@ sub fill_surface { # not perfectly straight my @polylines = map Slic3r::Polyline->new(@$_), @{ Boost::Geometry::Utils::multi_polygon_multi_linestring_intersection( - [ map $_->pp, @{$expolygon->offset_ex($line_spacing*0.05)} ], + [ map $_->pp, @{$expolygon->offset_ex(scaled_epsilon * 100)} ], [ @vertical_lines ], ) }; diff --git a/t/fill.t b/t/fill.t index 4885275d..8ee65d6c 100644 --- a/t/fill.t +++ b/t/fill.t @@ -2,13 +2,15 @@ use Test::More; use strict; use warnings; -plan tests => 34; +plan tests => 40; BEGIN { use FindBin; use lib "$FindBin::Bin/../lib"; } +use List::Util qw(first); +use Math::ConvexHull::MonotoneChain qw(convex_hull); use Slic3r; use Slic3r::Geometry qw(scale X Y); use Slic3r::Geometry::Clipper qw(diff_ex); @@ -155,11 +157,34 @@ sub scale_points (@) { map [scale $_->[X], scale $_->[Y]], @_ } 'chained path'; } -for my $pattern (qw(hilbertcurve concentric)) { +for my $pattern (qw(rectilinear honeycomb hilbertcurve concentric)) { my $config = Slic3r::Config->new_from_defaults; $config->set('fill_pattern', $pattern); - my $print = Slic3r::Test::init_print('20mm_cube', config => $config); - ok Slic3r::Test::gcode($print), "successful $pattern infill generation"; + $config->set('perimeters', 1); + $config->set('skirts', 0); + $config->set('fill_density', 0.2); + $config->set('layer_height', 0.05); + $config->set('perimeter_extruder', 1); + $config->set('infill_extruder', 2); + my $print = Slic3r::Test::init_print('20mm_cube', config => $config, scale => 2); + ok my $gcode = Slic3r::Test::gcode($print), "successful $pattern infill generation"; + my $tool = undef; + my @perimeter_points = my @infill_points = (); + Slic3r::GCode::Reader->new->parse($gcode, sub { + my ($self, $cmd, $args, $info) = @_; + + if ($cmd =~ /^T(\d+)/) { + $tool = $1; + } elsif ($cmd eq 'G1' && $info->{extruding} && $info->{dist_XY} > 0) { + if ($tool == $config->perimeter_extruder-1) { + push @perimeter_points, Slic3r::Point->new_scale($args->{X}, $args->{Y}); + } elsif ($tool == $config->infill_extruder-1) { + push @infill_points, Slic3r::Point->new_scale($args->{X}, $args->{Y}); + } + } + }); + my $convex_hull = Slic3r::Polygon->new(@{convex_hull([ map $_->pp, @perimeter_points ])}); + ok !(defined first { !$convex_hull->encloses_point($_) } @infill_points), "infill does not exceed perimeters ($pattern)"; } { From 130e8dd8e7f771e45f7e0633e701ac70d1e94775 Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci Date: Sat, 11 Jan 2014 23:16:33 +0100 Subject: [PATCH 20/50] Bugfix: incorrect number of raft layers was generated when too few were requested. #1678 --- lib/Slic3r/Print/Object.pm | 21 +++++++++++++++++++-- lib/Slic3r/Print/SupportMaterial.pm | 8 +++++++- t/gcode.t | 2 +- t/support.t | 29 ++++++++++++++++++++++++++++- 4 files changed, 55 insertions(+), 5 deletions(-) diff --git a/lib/Slic3r/Print/Object.pm b/lib/Slic3r/Print/Object.pm index 7c0f41f3..ac110c5e 100644 --- a/lib/Slic3r/Print/Object.pm +++ b/lib/Slic3r/Print/Object.pm @@ -26,17 +26,30 @@ sub BUILD { # make layers taking custom heights into account my $print_z = my $slice_z = my $height = my $id = 0; + my $first_object_layer_height = -1; # add raft layers if ($self->config->raft_layers > 0) { + $id += $self->config->raft_layers; + + # raise first object layer Z by the thickness of the raft itself + # plus the extra distance required by the support material logic $print_z += $Slic3r::Config->get_value('first_layer_height'); $print_z += $Slic3r::Config->layer_height * ($self->config->raft_layers - 1); - $id += $self->config->raft_layers; + + # at this stage we don't know which nozzles are actually used for the first layer + # so we compute the average of all of them + my $nozzle_diameter = sum(@{$Slic3r::Config->nozzle_diameter})/@{$Slic3r::Config->nozzle_diameter}; + my $distance = Slic3r::Print::SupportMaterial::contact_distance($nozzle_diameter); + + # force first layer print_z according to the contact distance + # (the loop below will raise print_z by such height) + $first_object_layer_height = $distance; } # loop until we have at least one layer and the max slice_z reaches the object height my $max_z = unscale $self->size->[Z]; - while (!@{$self->layers} || ($slice_z - $height) <= $max_z) { + while (($slice_z - $height) <= $max_z) { # assign the default height to the layer according to the general settings $height = ($id == 0) ? $Slic3r::Config->get_value('first_layer_height') @@ -53,6 +66,10 @@ sub BUILD { } } + if ($first_object_layer_height != -1 && !@{$self->layers}) { + $height = $first_object_layer_height; + } + $print_z += $height; $slice_z += $height/2; diff --git a/lib/Slic3r/Print/SupportMaterial.pm b/lib/Slic3r/Print/SupportMaterial.pm index 07f8624b..8bd92765 100644 --- a/lib/Slic3r/Print/SupportMaterial.pm +++ b/lib/Slic3r/Print/SupportMaterial.pm @@ -174,7 +174,7 @@ sub contact_area { @{$layer->regions}; my $nozzle_diameter = sum(@nozzle_diameters)/@nozzle_diameters; - my $contact_z = $layer->print_z - $nozzle_diameter * 1.5; + my $contact_z = $layer->print_z - contact_distance($nozzle_diameter); ###$contact_z = $layer->print_z - $layer->height; # ignore this contact area if it's too low @@ -636,4 +636,10 @@ sub overlapping_layers { } 0..$#$support_z; } +# class method +sub contact_distance { + my ($nozzle_diameter) = @_; + return $nozzle_diameter * 1.5; +} + 1; diff --git a/t/gcode.t b/t/gcode.t index e68b899a..a7d94251 100644 --- a/t/gcode.t +++ b/t/gcode.t @@ -1,4 +1,4 @@ -use Test::More tests => 7; +use Test::More tests => 8; use strict; use warnings; diff --git a/t/support.t b/t/support.t index b7d1810d..68dc04d3 100644 --- a/t/support.t +++ b/t/support.t @@ -1,4 +1,4 @@ -use Test::More tests => 14; +use Test::More tests => 15; use strict; use warnings; @@ -123,4 +123,31 @@ use Slic3r::Test; 'first object layer is completely supported by raft'; } +{ + my $config = Slic3r::Config->new_from_defaults; + $config->set('skirts', 0); + $config->set('raft_layers', 2); + $config->set('layer_height', 0.35); + $config->set('first_layer_height', 0.3); + $config->set('nozzle_diameter', [0.5]); + $config->set('support_material_extruder', 2); + $config->set('support_material_interface_extruder', 2); + my $print = Slic3r::Test::init_print('20mm_cube', config => $config); + my %raft_z = (); # z => 1 + my $tool = undef; + Slic3r::GCode::Reader->new->parse(Slic3r::Test::gcode($print), sub { + my ($self, $cmd, $args, $info) = @_; + + if ($cmd =~ /^T(\d+)/) { + $tool = $1; + } elsif ($info->{extruding} && $info->{dist_XY} > 0) { + if ($tool == $config->support_material_extruder-1) { + $raft_z{$self->Z} = 1; + } + } + }); + + is scalar(keys %raft_z), $config->raft_layers, 'correct number of raft layers is generated'; +} + __END__ From a64f7aa8df551d35404aff54c006326824ed89a6 Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci Date: Sun, 12 Jan 2014 00:46:23 +0100 Subject: [PATCH 21/50] Bugfix: lack of strong type checking when passing arrayref objects to XS caused random lack of infill. Now added strong type checking for all XS entities. Also fixes a potential issue with bridges caused by the same error. #1652 --- lib/Slic3r/Layer/Region.pm | 8 ++++---- xs/src/ExPolygon.cpp | 2 ++ xs/src/Line.cpp | 2 ++ xs/src/Point.cpp | 2 ++ xs/src/Polygon.cpp | 9 +++++++++ xs/src/Polygon.hpp | 1 + xs/src/Polyline.cpp | 9 +++++++++ xs/src/Polyline.hpp | 1 + 8 files changed, 30 insertions(+), 4 deletions(-) diff --git a/lib/Slic3r/Layer/Region.pm b/lib/Slic3r/Layer/Region.pm index 05713ba1..1cb7ae15 100644 --- a/lib/Slic3r/Layer/Region.pm +++ b/lib/Slic3r/Layer/Region.pm @@ -214,7 +214,7 @@ sub make_perimeters { # make sure we don't infill narrow parts that are already gap-filled # (we only consider this surface's gaps to reduce the diff() complexity) - @last = @{diff(\@last, \@last_gaps)}; + @last = @{diff(\@last, [ map @$_, @last_gaps ])}; # create one more offset to be used as boundary for fill # we offset by half the perimeter spacing (to get to the actual infill boundary) @@ -508,7 +508,7 @@ sub process_external_surfaces { sub _detect_bridge_direction { my ($self, $expolygon, $lower_layer) = @_; - my $grown = $expolygon->offset_ex(+$self->perimeter_flow->scaled_width); + my $grown = $expolygon->offset(+$self->perimeter_flow->scaled_width); my @lower = @{$lower_layer->slices}; # expolygons # detect what edges lie on lower slices @@ -516,7 +516,7 @@ sub _detect_bridge_direction { foreach my $lower (@lower) { # turn bridge contour and holes into polylines and then clip them # with each lower slice's contour - my @clipped = map $_->split_at_first_point->clip_with_polygon($lower->contour), map @$_, @$grown; + my @clipped = map $_->split_at_first_point->clip_with_polygon($lower->contour), @$grown; if (@clipped == 2) { # If the split_at_first_point() call above happens to split the polygon inside the clipping area # we would get two consecutive polylines instead of a single one, so we use this ugly hack to @@ -567,7 +567,7 @@ sub _detect_bridge_direction { # detect anchors as intersection between our bridge expolygon and the lower slices my $anchors = intersection_ex( - [ @$grown ], + $grown, [ map @$_, @lower ], 1, # safety offset required to avoid Clipper from detecting empty intersection while Boost actually found some @edges ); diff --git a/xs/src/ExPolygon.cpp b/xs/src/ExPolygon.cpp index 7a58e969..eaa20949 100644 --- a/xs/src/ExPolygon.cpp +++ b/xs/src/ExPolygon.cpp @@ -111,6 +111,8 @@ void ExPolygon::from_SV_check(SV* expoly_sv) { if (sv_isobject(expoly_sv) && (SvTYPE(SvRV(expoly_sv)) == SVt_PVMG)) { + if (!sv_isa(expoly_sv, "Slic3r::ExPolygon") && !sv_isa(expoly_sv, "Slic3r::ExPolygon::Ref")) + CONFESS("Not a valid Slic3r::ExPolygon object"); // a XS ExPolygon was supplied *this = *(ExPolygon *)SvIV((SV*)SvRV( expoly_sv )); } else { diff --git a/xs/src/Line.cpp b/xs/src/Line.cpp index 0e4698b7..31994a81 100644 --- a/xs/src/Line.cpp +++ b/xs/src/Line.cpp @@ -79,6 +79,8 @@ void Line::from_SV_check(SV* line_sv) { if (sv_isobject(line_sv) && (SvTYPE(SvRV(line_sv)) == SVt_PVMG)) { + if (!sv_isa(line_sv, "Slic3r::Line") && !sv_isa(line_sv, "Slic3r::Line::Ref")) + CONFESS("Not a valid Slic3r::Line object"); *this = *(Line*)SvIV((SV*)SvRV( line_sv )); } else { this->from_SV(line_sv); diff --git a/xs/src/Point.cpp b/xs/src/Point.cpp index b39a06c1..9251eca9 100644 --- a/xs/src/Point.cpp +++ b/xs/src/Point.cpp @@ -122,6 +122,8 @@ void Point::from_SV_check(SV* point_sv) { if (sv_isobject(point_sv) && (SvTYPE(SvRV(point_sv)) == SVt_PVMG)) { + if (!sv_isa(point_sv, "Slic3r::Point") && !sv_isa(point_sv, "Slic3r::Point::Ref")) + CONFESS("Not a valid Slic3r::Point object"); *this = *(Point*)SvIV((SV*)SvRV( point_sv )); } else { this->from_SV(point_sv); diff --git a/xs/src/Polygon.cpp b/xs/src/Polygon.cpp index 592503e2..e7fa7a6e 100644 --- a/xs/src/Polygon.cpp +++ b/xs/src/Polygon.cpp @@ -126,6 +126,15 @@ Polygon::to_SV_clone_ref() const { sv_setref_pv( sv, "Slic3r::Polygon", new Polygon(*this) ); return sv; } + +void +Polygon::from_SV_check(SV* poly_sv) +{ + if (sv_isobject(poly_sv) && !sv_isa(poly_sv, "Slic3r::Polygon") && !sv_isa(poly_sv, "Slic3r::Polygon::Ref")) + CONFESS("Not a valid Slic3r::Polygon object"); + + MultiPoint::from_SV_check(poly_sv); +} #endif } diff --git a/xs/src/Polygon.hpp b/xs/src/Polygon.hpp index ab04ed62..d31f3c4f 100644 --- a/xs/src/Polygon.hpp +++ b/xs/src/Polygon.hpp @@ -25,6 +25,7 @@ class Polygon : public MultiPoint { bool is_valid() const; #ifdef SLIC3RXS + void from_SV_check(SV* poly_sv); SV* to_SV_ref(); SV* to_SV_clone_ref() const; #endif diff --git a/xs/src/Polyline.cpp b/xs/src/Polyline.cpp index fc395075..e7b65eb5 100644 --- a/xs/src/Polyline.cpp +++ b/xs/src/Polyline.cpp @@ -96,6 +96,15 @@ Polyline::to_SV_clone_ref() const sv_setref_pv( sv, "Slic3r::Polyline", new Polyline(*this) ); return sv; } + +void +Polyline::from_SV_check(SV* poly_sv) +{ + if (!sv_isa(poly_sv, "Slic3r::Polyline") && !sv_isa(poly_sv, "Slic3r::Polyline::Ref")) + CONFESS("Not a valid Slic3r::Polyline object"); + + MultiPoint::from_SV_check(poly_sv); +} #endif } diff --git a/xs/src/Polyline.hpp b/xs/src/Polyline.hpp index c17b97f9..b7401bad 100644 --- a/xs/src/Polyline.hpp +++ b/xs/src/Polyline.hpp @@ -15,6 +15,7 @@ class Polyline : public MultiPoint { Points equally_spaced_points(double distance) const; #ifdef SLIC3RXS + void from_SV_check(SV* poly_sv); SV* to_SV_ref(); SV* to_SV_clone_ref() const; #endif From 4da71e8f135f5ba696411db9c2c0aaa973159f9f Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci Date: Tue, 14 Jan 2014 12:49:07 +0100 Subject: [PATCH 22/50] Fix tests in stable after stronger type checking was applied --- lib/Slic3r/Polygon.pm | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/Slic3r/Polygon.pm b/lib/Slic3r/Polygon.pm index 963c13fa..4e0d15c5 100644 --- a/lib/Slic3r/Polygon.pm +++ b/lib/Slic3r/Polygon.pm @@ -42,7 +42,10 @@ sub grow { # original orientation sub simplify { my $self = shift; - return @{Slic3r::Geometry::Clipper::simplify_polygons([ $self->SUPER::simplify(@_) ])}; + my $tolerance = shift || 10; + + my $simplified = Boost::Geometry::Utils::linestring_simplify($self->pp, $tolerance); + return @{Slic3r::Geometry::Clipper::simplify_polygons([ $simplified ])}; } # this method subdivides the polygon segments to that no one of them From cfbbb539a5b0b8577ec6e172e8519de320bdbde9 Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci Date: Wed, 15 Jan 2014 00:20:09 +0100 Subject: [PATCH 23/50] Bugfix: fatal error in the rare case that a bridge has no anchor points. #1607 --- lib/Slic3r/Layer/Region.pm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/Slic3r/Layer/Region.pm b/lib/Slic3r/Layer/Region.pm index 1cb7ae15..2f3487c3 100644 --- a/lib/Slic3r/Layer/Region.pm +++ b/lib/Slic3r/Layer/Region.pm @@ -585,8 +585,9 @@ sub _detect_bridge_direction { # generate lines in this direction my $bounding_box = Slic3r::Geometry::BoundingBox->new_from_points([ map @$_, map @$_, @$anchors ]); + # note that @$anchors might be empty my @lines = (); - for (my $x = $bounding_box->x_min; $x <= $bounding_box->x_max; $x += $line_increment) { + for (my $x = ($bounding_box->x_min // 0); $x <= ($bounding_box->x_max // -1); $x += $line_increment) { push @lines, [ [$x, $bounding_box->y_min], [$x, $bounding_box->y_max] ]; } From 7be042567de6ff8f8672b29c7de5967c27b0fc58 Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci Date: Fri, 7 Feb 2014 01:48:47 +0100 Subject: [PATCH 24/50] Bugfix: when processing with fill_density = 0, top/bottom solid shells were missing regions thinner than 3 * extrusion width. Includes regression test. #1602 --- lib/Slic3r/Print/Object.pm | 55 ++++++++++++++++++++++---------------- lib/Slic3r/Test.pm | 7 +++++ t/fill.t | 41 ++++++++++++++++++++++++++-- 3 files changed, 78 insertions(+), 25 deletions(-) diff --git a/lib/Slic3r/Print/Object.pm b/lib/Slic3r/Print/Object.pm index ac110c5e..ead971c7 100644 --- a/lib/Slic3r/Print/Object.pm +++ b/lib/Slic3r/Print/Object.pm @@ -584,7 +584,8 @@ sub discover_horizontal_shells { next if $n < 0 || $n > $#{$self->layers}; Slic3r::debugf " looking for neighbors on layer %d...\n", $n; - my $neighbor_fill_surfaces = $self->layers->[$n]->regions->[$region_id]->fill_surfaces; + my $neighbor_layerm = $self->layers->[$n]->regions->[$region_id]; + my $neighbor_fill_surfaces = $neighbor_layerm->fill_surfaces; my @neighbor_fill_surfaces = map $_->clone, @$neighbor_fill_surfaces; # clone because we will use these surfaces even after clearing the collection # find intersection between neighbor and current layer's surfaces @@ -603,41 +604,49 @@ sub discover_horizontal_shells { ); next EXTERNAL if !@$new_internal_solid; - # make sure the new internal solid is wide enough, as it might get collapsed when - # spacing is added in Fill.pm + if ($self->config->fill_density == 0) { + # if we're printing a hollow object we discard any solid shell thinner + # than a perimeter width, since it's probably just crossing a sloping wall + # and it's not wanted in a hollow print even if it would make sense when + # obeying the solid shell count option strictly (DWIM!) + my $margin = $neighbor_layerm->perimeter_flow->scaled_width; + my $too_narrow = diff( + $new_internal_solid, + offset2($new_internal_solid, -$margin, +$margin, CLIPPER_OFFSET_SCALE, JT_MITER, 5), + 1, + ); + $new_internal_solid = $solid = diff( + $new_internal_solid, + $too_narrow, + ) if @$too_narrow; + } + + # make sure the new internal solid is wide enough, as it might get collapsed + # when spacing is added in Fill.pm { + my $margin = 3 * $layerm->solid_infill_flow->scaled_width; # require at least this size # we use a higher miterLimit here to handle areas with acute angles # in those cases, the default miterLimit would cut the corner and we'd # get a triangle in $too_narrow; if we grow it below then the shell # would have a different shape from the external surface and we'd still # have the same angle, so the next shell would be grown even more and so on. - my $margin = 3 * $layerm->solid_infill_flow->scaled_width; # require at least this size my $too_narrow = diff( $new_internal_solid, offset2($new_internal_solid, -$margin, +$margin, CLIPPER_OFFSET_SCALE, JT_MITER, 5), 1, ); - # if some parts are going to collapse, use a different strategy according to fill density if (@$too_narrow) { - if ($self->config->fill_density > 0) { - # if we have internal infill, grow the collapsing parts and add the extra area to - # the neighbor layer as well as to our original surfaces so that we support this - # additional area in the next shell too - - # make sure our grown surfaces don't exceed the fill area - my @grown = @{intersection( - offset($too_narrow, +$margin), - [ map $_->p, @neighbor_fill_surfaces ], - )}; - $new_internal_solid = $solid = [ @grown, @$new_internal_solid ]; - } else { - # if we're printing a hollow object, we discard such small parts - $new_internal_solid = $solid = diff( - $new_internal_solid, - $too_narrow, - ); - } + # grow the collapsing parts and add the extra area to the neighbor layer + # as well as to our original surfaces so that we support this + # additional area in the next shell too + + # make sure our grown surfaces don't exceed the fill area + my @grown = @{intersection( + offset($too_narrow, +$margin), + [ map $_->p, @neighbor_fill_surfaces ], + )}; + $new_internal_solid = $solid = [ @grown, @$new_internal_solid ]; } } diff --git a/lib/Slic3r/Test.pm b/lib/Slic3r/Test.pm index 8c4a969e..42caf6c0 100644 --- a/lib/Slic3r/Test.pm +++ b/lib/Slic3r/Test.pm @@ -76,6 +76,13 @@ sub model { $facets = [ [0,1,2],[1,0,3],[4,5,6],[5,4,7],[8,9,10],[9,11,12],[11,9,8],[13,14,15],[14,13,16],[17,2,1],[2,17,18],[19,11,20],[11,19,12],[17,21,18],[21,2,18],[2,21,22],[22,21,23],[8,22,23],[22,8,10],[24,25,26],[25,24,27],[23,1,8],[1,23,21],[1,21,17],[5,15,3],[15,5,7],[15,7,28],[28,7,26],[28,26,25],[8,14,11],[14,8,3],[3,8,1],[14,3,15],[11,14,20],[26,4,24],[4,26,7],[12,16,9],[16,12,19],[29,4,13],[4,29,24],[24,29,27],[9,22,10],[22,9,0],[0,9,16],[0,16,13],[0,13,6],[6,13,4],[2,22,0],[19,14,16],[14,19,20],[15,29,13],[29,25,27],[25,29,15],[25,15,28],[6,3,0],[3,6,5] ]; + } elsif ($model_name eq 'A') { + $vertices = [ + [513.075988769531,51.6074333190918,36.0009002685547],[516.648803710938,51.7324333190918,36.0009002685547],[513.495178222656,51.7324333190918,36.0009002685547],[489.391204833984,51.4824333190918,24.0011005401611],[488.928588867188,51.7324333190918,24.0011005401611],[492.06201171875,51.7324333190918,24.0011005401611],[496.840393066406,51.2324333190918,24.0011005401611],[495.195404052734,51.7324333190918,24.0011005401611],[498.981994628906,51.7324333190918,24.0011005401611],[506.966613769531,51.6074333190918,24.0011005401611],[510.342010498047,51.7324333190918,24.0011005401611],[507.163818359375,51.6074333190918,24.0011005401611],[512.515380859375,54.7190322875977,36.0009002685547],[514.161987304688,54.5058326721191,36.0009002685547],[493.06201171875,54.7190322875977,36.0009002685547],[495.195404052734,51.7324333190918,36.0009002685547],[496.195404052734,54.7190322875977,36.0009002685547],[497.195404052734,57.7058334350586,36.0009002685547],[500.851989746094,60.2658309936523,36.0009002685547],[498.915405273438,62.8258323669434,36.0009002685547],[506.701995849609,62.8258323669434,36.0009002685547],[503.648590087891,60.2658309936523,36.0009002685547],[508.381805419922,57.7058334350586,36.0009002685547],[496.418792724609,60.052433013916,36.0009002685547],[506.515197753906,72.2124328613281,36.0009002685547],[502.808807373047,74.5324325561523,36.0009002685547],[503.781982421875,71.6058349609375,36.0009002685547],[515.358764648438,55.4658317565918,36.0009002685547],[499.375183105469,76.9058380126953,36.0009002685547],[501.168792724609,78.0658340454102,36.0009002685547],[504.568786621094,78.0658340454102,36.0009002685547],[506.32861328125,81.599235534668,36.0009002685547],[502.928588867188,81.599235534668,36.0009002685547],[499.528594970703,81.599235534668,36.0009002685547],[498.20361328125,77.8658294677734,36.0009002685547],[495.195404052734,51.7324333190918,30.0011005401611],[498.981994628906,51.7324333190918,27.0011005401611],[506.555206298828,51.7324333190918,33.0009002685547],[506.555206298828,51.7324333190918,36.0009002685547],[510.342010498047,51.7324333190918,36.0009002685547],[512.515380859375,54.7190322875977,24.0011005401611],[509.361999511719,54.7190322875977,24.0011005401611],[508.381805419922,57.7058334350586,24.0011005401611],[506.701995849609,62.8258323669434,24.0011005401611],[509.188812255859,60.052433013916,24.0011005401611],[493.06201171875,54.7190322875977,24.0011005401611],[503.648590087891,60.2658309936523,24.0011005401611],[500.851989746094,60.2658309936523,24.0011005401611],[498.915405273438,62.8258323669434,24.0011005401611],[502.808807373047,62.8258323669434,24.0011005401611],[491.425201416016,54.5058326721191,24.0011005401611],[506.421813964844,76.9058380126953,24.0011005401611],[502.808807373047,74.5324325561523,24.0011005401611],[504.568786621094,78.0658340454102,24.0011005401611],[506.32861328125,81.599235534668,24.0011005401611],[507.618804931641,77.8658294677734,24.0011005401611],[499.221801757812,72.2124328613281,24.0011005401611],[501.835388183594,71.6058349609375,24.0011005401611],[501.168792724609,78.0658340454102,24.0011005401611],[499.528594970703,81.599235534668,24.0011005401611],[502.048583984375,79.8324356079102,24.0011005401611],[490.253601074219,55.4658317565918,24.0011005401611],[488.928588867188,51.7324333190918,30.0011005401611],[488.928588867188,51.7324333190918,36.0009002685547],[490.253601074219,55.4658317565918,31.5009002685547],[498.20361328125,77.8658294677734,34.5009002685547],[508.381805419922,57.7058334350586,30.0011005401611],[505.585388183594,57.7058334350586,27.0011005401611],[502.788818359375,57.7058334350586,36.0009002685547],[499.992004394531,57.7058334350586,33.0009002685547],[509.851989746094,53.2258338928223,33.0009002685547],[509.361999511719,54.7190322875977,36.0009002685547],[508.871795654297,56.2124328613281,27.0011005401611],[496.695404052734,56.2124328613281,33.0009002685547],[495.695404052734,53.2258338928223,27.0011005401611],[506.32861328125,81.599235534668,30.0011005401611],[507.618804931641,77.8658294677734,25.5011005401611],[515.358764648438,55.4658317565918,34.5009002685547],[501.228607177734,81.599235534668,33.0009002685547],[504.628601074219,81.599235534668,27.0011005401611],[503.781982421875,71.6058349609375,33.0009002685547],[502.808807373047,74.5324325561523,30.0011005401611],[498.915405273438,62.8258323669434,30.0011005401611],[500.861999511719,62.8258323669434,27.0011005401611],[502.808807373047,62.8258323669434,36.0009002685547],[504.755187988281,62.8258323669434,33.0009002685547],[501.835388183594,71.6058349609375,33.0009002685547],[499.888793945312,65.7524337768555,33.0009002685547],[499.888793945312,65.7524337768555,36.0009002685547],[513.128601074219,51.4824333190918,36.0009002685547],[513.075988769531,51.6074333190918,24.0011005401611],[516.648803710938,51.7324333190918,24.0011005401611],[513.128601074219,51.4824333190918,24.0011005401611],[513.495178222656,51.7324333190918,24.0011005401611],[506.966613769531,51.6074333190918,36.0009002685547],[507.163818359375,51.6074333190918,36.0009002685547],[490.337799072266,51.4824333190918,24.0011005401611],[489.391204833984,51.4824333190918,36.0009002685547],[492.06201171875,51.7324333190918,36.0009002685547],[490.337799072266,51.4824333190918,36.0009002685547],[513.233764648438,51.2324333190918,24.0011005401611],[513.233764648438,51.2324333190918,36.0009002685547],[504.773803710938,51.4824333190918,36.0009002685547],[504.773803710938,51.4824333190918,24.0011005401611],[489.266998291016,51.2324333190918,24.0011005401611],[489.266998291016,51.2324333190918,36.0009002685547],[490.253601074219,55.4658317565918,25.5011005401611],[499.528594970703,81.599235534668,30.0011005401611],[498.20361328125,77.8658294677734,31.5009002685547],[515.358764648438,55.4658317565918,28.5011005401611],[515.358764648438,55.4658317565918,25.5011005401611],[495.246795654297,61.0124320983887,36.0009002685547],[490.253601074219,55.4658317565918,34.5009002685547],[490.253601074219,55.4658317565918,36.0009002685547],[494.228607177734,66.6658325195312,24.0011005401611],[499.068786621094,67.5192337036133,24.0011005401611],[498.20361328125,77.8658294677734,25.5011005401611],[498.20361328125,77.8658294677734,24.0011005401611],[506.608795166016,67.5192337036133,36.0009002685547],[509.09521484375,64.7458343505859,36.0009002685547],[507.618804931641,77.8658294677734,34.5009002685547],[507.618804931641,77.8658294677734,36.0009002685547],[510.385406494141,61.0124320983887,24.0011005401611],[515.358764648438,55.4658317565918,24.0011005401611],[489.32861328125,47.7324333190918,31.5009002685547],[492.95361328125,47.7324333190918,33.5634994506836],[489.32861328125,47.7324333190918,34.5009002685547],[489.32861328125,47.7324333190918,28.5011005401611],[489.32861328125,47.7324333190918,25.5011005401611],[492.95361328125,47.7324333190918,26.4385013580322],[492.95361328125,47.7324333190918,30.5635013580322],[492.95361328125,47.7324333190918,32.0634994506836],[492.95361328125,47.7324333190918,31.3135013580322],[492.95361328125,47.7324333190918,35.4384994506836],[489.32861328125,47.7324333190918,36.0009002685547],[492.95361328125,47.7324333190918,34.3134994506836],[492.95361328125,47.7324333190918,34.6884994506836],[492.95361328125,47.7324333190918,27.9385013580322],[492.95361328125,47.7324333190918,28.6885013580322],[492.95361328125,47.7324333190918,29.0635013580322],[489.32861328125,47.7324333190918,24.0011005401611],[492.95361328125,47.7324333190918,24.5635013580322],[492.95361328125,47.7324333190918,25.6885013580322],[492.95361328125,47.7324333190918,25.3135013580322],[492.95361328125,47.7324333190918,24.1885013580322],[492.95361328125,47.7324333190918,24.0011005401611],[513.443786621094,50.7324333190918,24.0011005401611],[492.95361328125,47.7324333190918,35.8134994506836],[492.95361328125,47.7324333190918,36.0009002685547],[513.443786621094,50.7324333190918,36.0009002685547],[506.350402832031,51.4824333190918,36.0009002685547],[506.350402832031,51.4824333190918,24.0011005401611],[492.743804931641,48.2324333190918,24.0011005401611],[492.638793945312,48.4824333190918,24.0011005401611],[492.743804931641,48.2324333190918,36.0009002685547],[492.638793945312,48.4824333190918,36.0009002685547],[490.089599609375,50.9824333190918,36.0009002685547],[490.089599609375,50.9824333190918,24.0011005401611],[510.342010498047,51.7324333190918,30.0011005401611],[499.068786621094,67.5192337036133,36.0009002685547],[494.228607177734,66.6658325195312,36.0009002685547],[499.375183105469,76.9058380126953,24.0011005401611],[506.421813964844,76.9058380126953,36.0009002685547],[506.608795166016,67.5192337036133,24.0011005401611],[505.728607177734,65.7524337768555,24.0011005401611],[509.09521484375,64.7458343505859,24.0011005401611],[506.701995849609,62.8258323669434,30.0011005401611],[505.728607177734,65.7524337768555,27.0011005401611],[501.835388183594,71.6058349609375,27.0011005401611],[499.888793945312,65.7524337768555,27.0011005401611],[494.228607177734,66.6658325195312,30.0011005401611],[495.553588867188,70.3992309570312,28.5011005401611],[492.903594970703,62.9324340820312,28.5011005401611],[495.553588867188,70.3992309570312,31.5009002685547],[492.903594970703,62.9324340820312,31.5009002685547],[511.488800048828,66.6658325195312,24.0011005401611],[511.488800048828,66.6658325195312,30.0011005401611],[512.778564453125,62.9324340820312,28.5011005401611],[515.358764648438,55.4658317565918,31.5009002685547],[507.618804931641,77.8658294677734,31.5009002685547],[510.198791503906,70.3992309570312,28.5011005401611],[511.488800048828,66.6658325195312,36.0009002685547],[512.778564453125,62.9324340820312,31.5009002685547],[510.198791503906,70.3992309570312,31.5009002685547],[502.788818359375,57.7058334350586,24.0011005401611],[497.195404052734,57.7058334350586,30.0011005401611],[492.903594970703,62.9324340820312,34.5009002685547],[492.903594970703,62.9324340820312,36.0009002685547],[495.553588867188,70.3992309570312,24.0011005401611],[496.725189208984,69.4392318725586,24.0011005401611],[495.553588867188,70.3992309570312,25.5011005401611],[495.246795654297,61.0124320983887,24.0011005401611],[492.903594970703,62.9324340820312,25.5011005401611],[492.903594970703,62.9324340820312,24.0011005401611],[495.553588867188,70.3992309570312,36.0009002685547],[496.725189208984,69.4392318725586,36.0009002685547],[495.553588867188,70.3992309570312,34.5009002685547],[510.198791503906,70.3992309570312,36.0009002685547],[509.002014160156,69.4392318725586,36.0009002685547],[510.198791503906,70.3992309570312,34.5009002685547],[512.778564453125,62.9324340820312,25.5011005401611],[512.778564453125,62.9324340820312,24.0011005401611],[510.198791503906,70.3992309570312,24.0011005401611],[509.002014160156,69.4392318725586,24.0011005401611],[510.198791503906,70.3992309570312,25.5011005401611],[510.385406494141,61.0124320983887,36.0009002685547],[512.778564453125,62.9324340820312,34.5009002685547],[512.778564453125,62.9324340820312,36.0009002685547],[496.840393066406,51.2324333190918,36.0009002685547],[498.981994628906,51.7324333190918,36.0009002685547],[498.981994628906,51.7324333190918,33.0009002685547],[506.555206298828,51.7324333190918,24.0011005401611],[506.555206298828,51.7324333190918,27.0011005401611],[503.82861328125,47.7324333190918,30.7509002685547],[507.45361328125,47.7324333190918,32.8134994506836],[503.82861328125,47.7324333190918,33.7509002685547],[503.82861328125,47.7324333190918,29.2511005401611],[503.82861328125,47.7324333190918,26.2511005401611],[507.45361328125,47.7324333190918,27.1885013580322],[493.921813964844,57.2792320251465,36.0009002685547],[491.425201416016,54.5058326721191,36.0009002685547],[497.195404052734,57.7058334350586,24.0011005401611],[496.418792724609,60.052433013916,24.0011005401611],[509.188812255859,60.052433013916,36.0009002685547],[511.675415039062,57.2792320251465,24.0011005401611],[514.161987304688,54.5058326721191,24.0011005401611],[507.45361328125,47.7324333190918,34.3134994506836],[503.82861328125,47.7324333190918,35.2509002685547],[507.45361328125,47.7324333190918,25.6885013580322],[503.82861328125,47.7324333190918,24.7511005401611],[500.20361328125,47.7324333190918,31.6885013580322],[500.20361328125,47.7324333190918,28.3135013580322],[500.20361328125,47.7324333190918,30.1885013580322],[507.45361328125,47.7324333190918,29.8135013580322],[507.45361328125,47.7324333190918,31.3135013580322],[507.45361328125,47.7324333190918,30.5635013580322],[503.82861328125,47.7324333190918,36.0009002685547],[507.45361328125,47.7324333190918,35.4384994506836],[507.45361328125,47.7324333190918,35.0634994506836],[507.45361328125,47.7324333190918,28.6885013580322],[507.45361328125,47.7324333190918,29.4385013580322],[503.82861328125,47.7324333190918,24.0011005401611],[507.45361328125,47.7324333190918,24.5635013580322],[507.45361328125,47.7324333190918,24.9385013580322],[500.20361328125,47.7324333190918,34.6884994506836],[500.20361328125,47.7324333190918,33.1884994506836],[500.20361328125,47.7324333190918,33.9384994506836],[500.20361328125,47.7324333190918,25.3135013580322],[500.20361328125,47.7324333190918,26.8135013580322],[500.20361328125,47.7324333190918,26.0635013580322],[500.20361328125,47.7324333190918,30.9385013580322],[500.20361328125,47.7324333190918,35.0634994506836],[500.20361328125,47.7324333190918,35.4384994506836],[500.20361328125,47.7324333190918,29.0635013580322],[500.20361328125,47.7324333190918,29.4385013580322],[500.20361328125,47.7324333190918,24.9385013580322],[500.20361328125,47.7324333190918,24.5635013580322],[507.45361328125,47.7324333190918,24.1885013580322],[507.45361328125,47.7324333190918,24.0011005401611],[513.86376953125,49.7324333190918,24.0011005401611],[507.45361328125,47.7324333190918,35.8134994506836],[507.45361328125,47.7324333190918,36.0009002685547],[513.86376953125,49.7324333190918,36.0009002685547],[500.20361328125,47.7324333190918,24.1885013580322],[500.20361328125,47.7324333190918,24.0011005401611],[502.988800048828,49.7324333190918,24.0011005401611],[500.20361328125,47.7324333190918,35.8134994506836],[500.20361328125,47.7324333190918,36.0009002685547],[502.988800048828,49.7324333190918,36.0009002685547],[504.755187988281,62.8258323669434,27.0011005401611],[499.205383300781,51.2324333190918,36.0009002685547],[498.786193847656,51.1074333190918,36.0009002685547],[502.358795166016,51.2324333190918,36.0009002685547],[499.205383300781,51.2324333190918,24.0011005401611],[502.358795166016,51.2324333190918,24.0011005401611],[498.786193847656,51.1074333190918,24.0011005401611],[502.568786621094,50.7324333190918,24.0011005401611],[505.931213378906,51.3574333190918,24.0011005401611],[509.503601074219,51.4824333190918,24.0011005401611],[502.568786621094,50.7324333190918,36.0009002685547],[505.931213378906,51.3574333190918,36.0009002685547],[509.503601074219,51.4824333190918,36.0009002685547],[499.048583984375,50.4824333190918,36.0009002685547],[492.428588867188,48.9824333190918,36.0009002685547],[499.048583984375,50.4824333190918,24.0011005401611],[492.428588867188,48.9824333190918,24.0011005401611],[506.088806152344,50.9824333190918,24.0011005401611],[506.036010742188,51.1074333190918,24.0011005401611],[506.088806152344,50.9824333190918,36.0009002685547],[506.036010742188,51.1074333190918,36.0009002685547],[498.891204833984,50.8574333190918,36.0009002685547],[498.943786621094,50.7324333190918,36.0009002685547],[498.891204833984,50.8574333190918,24.0011005401611],[498.943786621094,50.7324333190918,24.0011005401611],[499.573608398438,49.2324333190918,24.0011005401611],[499.783813476562,48.7324333190918,24.0011005401611],[499.573608398438,49.2324333190918,36.0009002685547],[499.783813476562,48.7324333190918,36.0009002685547],[506.403594970703,50.2324333190918,24.0011005401611],[506.298797607422,50.4824333190918,24.0011005401611],[506.403594970703,50.2324333190918,36.0009002685547],[506.298797607422,50.4824333190918,36.0009002685547],[501.228607177734,81.599235534668,27.0011005401611],[502.928588867188,81.599235534668,24.0011005401611],[499.2587890625,49.9824333190918,36.0009002685547],[499.363800048828,49.7324333190918,36.0009002685547],[499.2587890625,49.9824333190918,24.0011005401611],[499.363800048828,49.7324333190918,24.0011005401611],[496.695404052734,56.2124328613281,27.0011005401611],[496.195404052734,54.7190322875977,24.0011005401611],[509.851989746094,53.2258338928223,27.0011005401611],[493.464782714844,51.1074333190918,36.0009002685547],[493.464782714844,51.1074333190918,24.0011005401611],[502.768798828125,51.7324333190918,24.0011005401611],[500.215789794922,51.3574333190918,24.0011005401611],[497.628601074219,51.2324333190918,24.0011005401611],[502.768798828125,51.7324333190918,36.0009002685547],[500.215789794922,51.3574333190918,36.0009002685547],[497.628601074219,51.2324333190918,36.0009002685547],[507.033813476562,48.7324333190918,24.0011005401611],[506.823791503906,49.2324333190918,24.0011005401611],[507.033813476562,48.7324333190918,36.0009002685547],[506.823791503906,49.2324333190918,36.0009002685547],[494.4501953125,51.1074333190918,24.0011005401611],[494.4501953125,51.1074333190918,36.0009002685547],[500.807006835938,51.3574333190918,36.0009002685547],[503.591186523438,51.4824333190918,36.0009002685547],[503.591186523438,51.4824333190918,24.0011005401611],[500.807006835938,51.3574333190918,24.0011005401611],[505.728607177734,65.7524337768555,36.0009002685547],[505.728607177734,65.7524337768555,33.0009002685547],[499.221801757812,72.2124328613281,36.0009002685547],[501.835388183594,71.6058349609375,36.0009002685547],[506.515197753906,72.2124328613281,24.0011005401611],[503.781982421875,71.6058349609375,24.0011005401611],[503.781982421875,71.6058349609375,27.0011005401611],[499.888793945312,65.7524337768555,24.0011005401611],[495.695404052734,53.2258338928223,33.0009002685547],[516.648803710938,51.7324333190918,30.0011005401611],[498.20361328125,77.8658294677734,28.5011005401611],[505.585388183594,57.7058334350586,33.0009002685547],[508.871795654297,56.2124328613281,33.0009002685547],[499.992004394531,57.7058334350586,27.0011005401611],[504.628601074219,81.599235534668,33.0009002685547],[500.861999511719,62.8258323669434,33.0009002685547],[496.878601074219,74.1324310302734,27.0011005401611],[496.878601074219,74.1324310302734,33.0009002685547],[491.57861328125,59.199031829834,27.0011005401611],[490.253601074219,55.4658317565918,28.5011005401611],[491.57861328125,59.199031829834,33.0009002685547],[514.068786621094,59.199031829834,27.0011005401611],[514.068786621094,59.199031829834,33.0009002685547],[508.908813476562,74.1324310302734,27.0011005401611],[507.618804931641,77.8658294677734,28.5011005401611],[508.908813476562,74.1324310302734,33.0009002685547],[491.271789550781,50.9824333190918,36.0009002685547],[490.877807617188,50.9824333190918,36.0009002685547],[491.271789550781,50.9824333190918,24.0011005401611],[490.877807617188,50.9824333190918,24.0011005401611],[495.213806152344,50.9824333190918,36.0009002685547],[493.636993408203,50.9824333190918,36.0009002685547],[495.213806152344,50.9824333190918,24.0011005401611],[493.636993408203,50.9824333190918,24.0011005401611],[503.985412597656,51.4824333190918,36.0009002685547],[503.985412597656,51.4824333190918,24.0011005401611],[511.675415039062,57.2792320251465,36.0009002685547],[493.921813964844,57.2792320251465,24.0011005401611],[502.768798828125,51.7324333190918,30.0011005401611],[506.555206298828,51.7324333190918,30.0011005401611],[498.981994628906,51.7324333190918,30.0011005401611],[492.848815917969,50.9824333190918,24.0011005401611],[492.848815917969,50.9824333190918,36.0009002685547],[500.861999511719,68.6792297363281,36.0009002685547],[500.861999511719,68.6792297363281,24.0011005401611],[496.878601074219,74.1324310302734,24.0011005401611],[496.878601074219,74.1324310302734,36.0009002685547],[504.755187988281,68.6792297363281,24.0011005401611],[504.755187988281,68.6792297363281,36.0009002685547],[508.908813476562,74.1324310302734,36.0009002685547],[508.908813476562,74.1324310302734,24.0011005401611],[505.728607177734,65.7524337768555,30.0011005401611],[504.755187988281,68.6792297363281,30.0011005401611],[503.781982421875,71.6058349609375,30.0011005401611],[500.861999511719,68.6792297363281,30.0011005401611],[499.888793945312,65.7524337768555,30.0011005401611],[501.835388183594,71.6058349609375,30.0011005401611],[491.57861328125,59.199031829834,24.0011005401611],[491.57861328125,59.199031829834,36.0009002685547],[514.068786621094,59.199031829834,36.0009002685547],[514.068786621094,59.199031829834,24.0011005401611],[511.07861328125,47.7324333190918,34.8759002685547],[511.07861328125,47.7324333190918,31.8759002685547],[514.70361328125,47.7324333190918,33.9384994506836],[511.07861328125,47.7324333190918,25.1261005401611],[514.70361328125,47.7324333190918,26.0635013580322],[511.07861328125,47.7324333190918,28.1261005401611],[502.788818359375,57.7058334350586,30.0011005401611],[502.048583984375,79.8324356079102,36.0009002685547],[514.70361328125,47.7324333190918,30.9385013580322],[511.07861328125,47.7324333190918,30.3759002685547],[514.70361328125,47.7324333190918,29.0635013580322],[511.07861328125,47.7324333190918,29.6261005401611],[496.57861328125,47.7324333190918,31.1259002685547],[496.57861328125,47.7324333190918,32.6259002685547],[496.57861328125,47.7324333190918,34.1259002685547],[496.57861328125,47.7324333190918,28.8761005401611],[496.57861328125,47.7324333190918,27.3761005401611],[496.57861328125,47.7324333190918,25.8761005401611],[496.57861328125,47.7324333190918,29.6261005401611],[514.70361328125,47.7324333190918,35.4384994506836],[511.07861328125,47.7324333190918,35.6259002685547],[514.70361328125,47.7324333190918,24.5635013580322],[511.07861328125,47.7324333190918,24.3761005401611],[496.57861328125,47.7324333190918,34.8759002685547],[496.57861328125,47.7324333190918,25.1261005401611],[496.57861328125,47.7324333190918,35.6259002685547],[496.57861328125,47.7324333190918,24.3761005401611],[511.07861328125,47.7324333190918,36.0009002685547],[511.07861328125,47.7324333190918,24.0011005401611],[514.70361328125,47.7324333190918,30.1885013580322],[514.70361328125,47.7324333190918,35.8134994506836],[514.70361328125,47.7324333190918,29.8135013580322],[514.70361328125,47.7324333190918,24.1885013580322],[496.57861328125,47.7324333190918,36.0009002685547],[496.57861328125,47.7324333190918,24.0011005401611],[510.238800048828,49.7324333190918,24.0011005401611],[510.238800048828,49.7324333190918,36.0009002685547],[514.70361328125,47.7324333190918,24.0011005401611],[514.70361328125,47.7324333190918,36.0009002685547],[496.158813476562,48.7324333190918,36.0009002685547],[496.158813476562,48.7324333190918,24.0011005401611],[502.808807373047,62.8258323669434,30.0011005401611],[509.608795166016,51.2324333190918,24.0011005401611],[509.608795166016,51.2324333190918,36.0009002685547],[491.641204833984,50.8574333190918,24.0011005401611],[495.423797607422,50.4824333190918,36.0009002685547],[495.423797607422,50.4824333190918,24.0011005401611],[491.641204833984,50.8574333190918,36.0009002685547],[495.528594970703,50.2324333190918,24.0011005401611],[492.0087890625,49.9824333190918,24.0011005401611],[509.818786621094,50.7324333190918,24.0011005401611],[495.948608398438,49.2324333190918,36.0009002685547],[495.528594970703,50.2324333190918,36.0009002685547],[495.948608398438,49.2324333190918,24.0011005401611],[509.818786621094,50.7324333190918,36.0009002685547],[492.0087890625,49.9824333190918,36.0009002685547],[491.956207275391,50.1074333190918,24.0011005401611],[491.956207275391,50.1074333190918,36.0009002685547],[502.928588867188,81.599235534668,30.0011005401611],[491.851013183594,50.3574333190918,36.0009002685547],[491.851013183594,50.3574333190918,24.0011005401611],[496.195404052734,54.7190322875977,30.0011005401611],[509.361999511719,54.7190322875977,30.0011005401611],[488.632598876953,51.7256317138672,30.0011005401611],[488.632598876953,51.7256317138672,29.5091018676758],[488.632598876953,51.7188339233398,24.0011005401611],[488.632598876953,51.7256317138672,27.4929008483887],[488.632598876953,51.7324333190918,30.0011005401611],[488.632598876953,51.7324333190918,29.0175018310547],[488.632598876953,51.7324333190918,24.9847011566162],[488.632598876953,51.7324333190918,24.0011005401611],[488.632598876953,51.7188339233398,30.0011005401611],[488.632598876953,51.7176322937012,24.0011005401611],[488.632598876953,51.7182312011719,30.0011005401611],[488.632598876953,51.7176322937012,30.0011005401611],[488.632598876953,51.715030670166,24.0011005401611],[488.632598876953,51.7162322998047,30.0011005401611],[488.632598876953,50.761833190918,24.0011005401611],[488.632598876953,50.7578315734863,24.0011005401611],[488.632598876953,50.7598342895508,30.0011005401611],[488.632598876953,50.7522315979004,24.0011005401611],[488.632598876953,49.7838325500488,24.0011005401611],[488.632598876953,50.2680320739746,30.0011005401611],[488.632598876953,51.7046318054199,24.0011005401611],[488.632598876953,51.709831237793,30.0011005401611],[488.632598876953,50.9120330810547,24.0011005401611],[488.632598876953,50.8882331848145,24.0011005401611],[488.632598876953,50.9002304077148,30.0011005401611],[488.632598876953,47.7324333190918,24.0370998382568],[488.632598876953,48.5612335205078,30.0011005401611],[488.632598876953,47.7324333190918,24.0011005401611],[488.632598876953,47.7324333190918,24.1091003417969],[488.632598876953,48.5612335205078,30.0189018249512],[488.632598876953,47.7324333190918,25.3211002349854],[488.632598876953,48.5612335205078,30.0551013946533],[488.632598876953,47.7324333190918,25.4651012420654],[488.632598876953,48.5612335205078,30.6609001159668],[488.632598876953,47.7324333190918,25.5371017456055],[488.632598876953,48.5612335205078,30.7329006195068],[488.632598876953,47.7324333190918,25.6091003417969],[488.632598876953,48.5612335205078,30.7689018249512],[488.632598876953,47.7324333190918,25.8971004486084],[488.632598876953,48.5612335205078,30.8051013946533],[488.632598876953,47.7324333190918,28.321102142334],[488.632598876953,48.5612335205078,30.9491004943848],[488.632598876953,47.7324333190918,28.4651012420654],[488.632598876953,48.5612335205078,32.1609001159668],[488.632598876953,47.7324333190918,28.5371017456055],[488.632598876953,48.5612335205078,32.2329025268555],[488.632598876953,47.7324333190918,28.6811008453369],[488.632598876953,48.5612335205078,32.2689018249512],[488.632598876953,47.7324333190918,31.1049003601074],[488.632598876953,48.5612335205078,32.3411026000977],[488.632598876953,47.7324333190918,31.3929004669189],[488.632598876953,49.3900299072266,36.0009002685547],[488.632598876953,47.7324333190918,31.536901473999],[488.632598876953,47.7324333190918,31.6809005737305],[488.632598876953,47.7324333190918,34.1049003601074],[488.632598876953,47.7324333190918,34.3929023742676],[488.632598876953,47.7324333190918,34.464900970459],[488.632598876953,47.7324333190918,34.5369033813477],[488.632598876953,47.7324333190918,34.6809005737305],[488.632598876953,47.7324333190918,35.8929023742676],[488.632598876953,47.7324333190918,35.964900970459],[488.632598876953,47.7324333190918,36.0009002685547],[488.632598876953,50.8816299438477,24.0011005401611],[488.632598876953,50.8850326538086,30.0011005401611],[488.632598876953,49.7480316162109,24.0011005401611],[488.632598876953,49.7426300048828,24.0011005401611],[488.632598876953,49.745231628418,30.0011005401611],[488.632598876953,49.7592315673828,24.0011005401611],[488.632598876953,49.7536315917969,30.0011005401611],[488.632598876953,49.3900299072266,24.0011005401611],[488.632598876953,49.5664329528809,30.0011005401611],[488.632598876953,50.8786315917969,24.0011005401611],[488.632598876953,50.7764320373535,24.0011005401611],[488.632598876953,50.8274307250977,30.0011005401611],[488.632598876953,50.7550315856934,30.0011005401611],[488.632598876953,50.7692337036133,30.0011005401611],[488.632598876953,50.9284324645996,24.0011005401611],[488.632598876953,50.9202308654785,30.0011005401611],[488.632598876953,51.1788330078125,24.0011005401611],[488.632598876953,51.139232635498,24.0011005401611],[488.632598876953,51.1590309143066,30.0011005401611],[488.632598876953,51.2324333190918,24.0011005401611],[488.632598876953,51.2056312561035,30.0011005401611],[488.632598876953,51.4340324401855,24.0011005401611],[488.632598876953,51.3946304321289,24.0011005401611],[488.632598876953,51.4142303466797,30.0011005401611],[488.632598876953,51.4498329162598,24.0011005401611],[488.632598876953,51.5772323608398,30.0011005401611],[488.632598876953,51.4418334960938,30.0011005401611],[488.632598876953,51.3136329650879,30.0011005401611],[488.632598876953,49.7714309692383,30.0011005401611],[488.632598876953,51.0338325500488,30.0011005401611],[488.632598876953,50.8816299438477,30.0011005401611],[488.632598876953,50.8800315856934,30.0011005401611],[488.632598876953,51.7188339233398,36.0009002685547],[488.632598876953,51.7176322937012,36.0009002685547],[488.632598876953,49.3900299072266,30.0011005401611],[488.632598876953,50.7522315979004,30.0011005401611],[488.632598876953,50.7522315979004,36.0009002685547],[488.632598876953,49.7426300048828,30.0011005401611],[488.632598876953,49.7426300048828,36.0009002685547],[488.632598876953,49.7480316162109,30.0011005401611],[488.632598876953,49.7480316162109,36.0009002685547],[488.632598876953,51.715030670166,30.0011005401611],[488.632598876953,51.715030670166,36.0009002685547],[488.632598876953,50.7578315734863,30.0011005401611],[488.632598876953,50.7578315734863,36.0009002685547],[488.632598876953,50.761833190918,30.0011005401611],[488.632598876953,50.761833190918,36.0009002685547],[488.632598876953,50.8882331848145,30.0011005401611],[488.632598876953,50.8882331848145,36.0009002685547],[488.632598876953,49.7592315673828,30.0011005401611],[488.632598876953,49.7592315673828,36.0009002685547],[488.632598876953,51.1788330078125,30.0011005401611],[488.632598876953,51.1788330078125,36.0009002685547],[488.632598876953,50.9120330810547,30.0011005401611],[488.632598876953,50.9120330810547,36.0009002685547],[488.632598876953,51.4498329162598,30.0011005401611],[488.632598876953,51.4498329162598,36.0009002685547],[488.632598876953,51.7046318054199,30.0011005401611],[488.632598876953,51.7046318054199,36.0009002685547],[488.632598876953,51.2324333190918,30.0011005401611],[488.632598876953,51.2324333190918,36.0009002685547],[488.632598876953,51.3946304321289,30.0011005401611],[488.632598876953,51.3946304321289,36.0009002685547],[488.632598876953,51.4340324401855,30.0011005401611],[488.632598876953,51.4340324401855,36.0009002685547],[488.632598876953,49.7838325500488,30.0011005401611],[488.632598876953,49.7838325500488,36.0009002685547],[488.632598876953,50.7764320373535,30.0011005401611],[488.632598876953,50.7764320373535,36.0009002685547],[488.632598876953,51.139232635498,30.0011005401611],[488.632598876953,51.139232635498,36.0009002685547],[488.632598876953,50.9284324645996,30.0011005401611],[488.632598876953,50.9284324645996,36.0009002685547],[488.632598876953,50.8816299438477,36.0009002685547],[488.632598876953,50.8786315917969,30.0011005401611],[488.632598876953,50.8786315917969,36.0009002685547],[488.632598876953,51.7324333190918,35.0173034667969],[488.632598876953,51.7324333190918,36.0009002685547],[488.632598876953,51.7324333190918,30.9847011566162],[517.188415527344,51.7140884399414,24.0011005401611],[517.188415527344,51.7140884399414,36.0009002685547],[517.188415527344,50.4475173950195,24.0011005401611],[517.188415527344,51.7324333190918,35.3734130859375],[517.188415527344,51.7324333190918,36.0009002685547],[517.188415527344,51.7324333190918,34.1185760498047],[517.188415527344,51.7324333190918,31.88330078125],[517.188415527344,51.7324333190918,30.0011005401611],[517.188415527344,51.7324333190918,28.1187744140625],[517.188415527344,51.7324333190918,25.8834266662598],[517.188415527344,51.7324333190918,24.6285915374756],[517.188415527344,51.7324333190918,24.0011005401611],[517.188415527344,47.7324333190918,24.0600452423096],[517.188415527344,47.7324333190918,24.0011005401611],[517.188415527344,50.4475173950195,36.0009002685547],[517.188415527344,47.7324333190918,24.1779975891113],[517.188415527344,47.7324333190918,24.6498031616211],[517.188415527344,47.7324333190918,28.7625770568848],[517.188415527344,47.7324333190918,29.7061901092529],[517.188415527344,47.7324333190918,29.9420928955078],[517.188415527344,47.7324333190918,30.0600452423096],[517.188415527344,47.7324333190918,30.2959480285645],[517.188415527344,47.7324333190918,31.2395629882812],[517.188415527344,47.7324333190918,35.3521995544434],[517.188415527344,47.7324333190918,35.8240051269531],[517.188415527344,47.7324333190918,35.9419555664062],[517.188415527344,47.7324333190918,36.0009002685547] + ]; + $facets = [ + [0,1,2],[3,4,5],[6,7,8],[9,10,11],[12,2,1],[12,1,13],[14,15,16],[17,18,19],[20,21,22],[17,19,23],[24,25,26],[27,13,1],[28,25,29],[30,31,32],[28,33,34],[35,36,7],[37,38,39],[40,10,41],[42,43,44],[45,5,4],[46,47,48],[46,48,49],[45,4,50],[51,52,53],[51,54,55],[56,52,57],[58,59,60],[61,50,4],[62,63,64],[65,34,33],[66,67,42],[68,17,69],[70,71,22],[66,42,72],[73,16,15],[35,7,74],[75,76,54],[77,27,1],[78,32,31],[75,54,79],[80,26,25],[81,80,25],[82,83,48],[84,20,85],[81,25,86],[87,88,19],[0,89,1],[90,91,92],[90,10,93],[38,94,39],[94,95,39],[3,7,96],[97,15,98],[97,99,15],[92,91,100],[89,101,1],[102,39,95],[103,11,10],[104,96,7],[105,15,99],[106,61,4],[107,108,33],[76,55,54],[109,91,110],[111,23,19],[112,63,113],[114,115,48],[116,59,117],[118,20,119],[120,31,121],[122,44,43],[110,91,123],[124,125,126],[127,128,129],[127,130,124],[131,124,132],[126,133,134],[135,136,126],[137,138,127],[139,127,138],[128,140,141],[142,128,143],[144,140,145],[100,91,146],[147,148,134],[101,149,1],[102,150,39],[103,10,151],[145,140,152],[152,140,153],[148,154,134],[154,155,134],[156,15,105],[157,104,7],[36,8,7],[158,37,39],[159,19,88],[160,19,159],[161,59,58],[161,117,59],[162,31,30],[162,121,31],[163,43,164],[163,165,43],[166,167,43],[167,164,43],[168,57,52],[82,48,169],[114,170,171],[108,65,33],[64,63,112],[114,172,170],[160,173,170],[171,170,173],[172,174,170],[160,170,174],[175,176,177],[178,77,1],[179,31,120],[175,180,176],[181,182,176],[177,176,182],[180,183,176],[181,176,183],[184,42,67],[185,69,17],[160,111,19],[186,187,160],[188,189,114],[190,188,114],[114,48,191],[192,114,193],[194,160,195],[196,160,194],[197,198,181],[199,197,181],[122,43,165],[200,201,175],[202,175,203],[204,175,202],[205,119,20],[206,181,207],[208,209,15],[210,15,209],[211,10,9],[212,10,211],[213,214,215],[216,217,218],[219,14,17],[113,63,220],[221,222,48],[191,48,222],[22,223,20],[205,20,223],[224,40,42],[123,91,225],[214,226,215],[227,215,226],[218,217,228],[229,228,217],[215,230,213],[125,135,126],[217,216,231],[129,128,142],[216,213,232],[130,132,124],[213,216,233],[234,213,235],[236,227,237],[238,237,227],[239,240,216],[233,216,240],[241,242,229],[243,229,242],[215,227,244],[245,215,246],[217,247,229],[248,249,217],[232,213,250],[230,250,213],[133,147,134],[244,227,251],[236,252,227],[251,227,252],[231,216,253],[254,253,216],[141,140,144],[247,255,229],[241,229,256],[255,256,229],[257,241,258],[259,146,91],[260,261,236],[262,1,149],[263,264,241],[265,241,264],[266,236,267],[268,267,236],[49,48,83],[166,43,269],[270,271,272],[273,274,275],[276,274,277],[278,151,10],[279,280,272],[281,39,150],[272,282,279],[155,283,134],[274,276,284],[153,140,285],[286,276,287],[265,276,286],[288,289,279],[268,288,279],[290,291,272],[271,290,272],[292,274,293],[275,274,292],[294,265,295],[276,265,294],[296,297,268],[279,296,268],[241,265,298],[298,265,299],[236,300,268],[300,301,268],[107,33,78],[302,303,59],[304,305,279],[282,304,279],[306,276,307],[284,276,306],[185,17,73],[308,309,221],[158,39,70],[310,41,10],[15,311,208],[7,6,312],[313,314,6],[315,6,314],[316,208,317],[318,317,208],[258,241,319],[319,241,320],[261,321,236],[321,322,236],[6,315,323],[208,324,318],[270,325,318],[326,318,325],[327,328,315],[273,315,328],[118,329,20],[330,20,329],[331,332,25],[86,25,332],[333,334,52],[335,52,334],[115,336,48],[169,48,336],[62,106,4],[35,15,210],[35,337,15],[158,10,212],[158,310,10],[338,178,1],[339,59,116],[107,302,59],[66,22,340],[66,341,22],[185,221,342],[185,308,221],[75,31,179],[75,343,31],[166,20,330],[166,85,20],[81,52,335],[81,168,52],[82,19,344],[82,87,19],[108,339,345],[346,108,345],[64,347,348],[349,347,64],[178,109,350],[351,178,350],[179,352,353],[354,352,179],[355,208,356],[356,208,311],[357,358,6],[358,312,6],[68,22,21],[68,340,22],[221,48,47],[184,342,221],[359,270,360],[318,360,270],[361,362,273],[315,273,362],[272,102,270],[363,270,102],[274,273,103],[364,103,273],[21,19,18],[21,20,84],[184,46,42],[43,42,46],[12,22,71],[365,22,12],[14,98,15],[14,220,63],[40,93,10],[40,225,91],[45,221,309],[366,221,45],[313,367,212],[212,367,368],[36,369,367],[313,36,367],[316,37,367],[37,368,367],[210,367,369],[316,367,210],[362,370,315],[370,323,315],[360,318,371],[371,318,324],[372,331,159],[159,195,160],[373,115,56],[115,114,189],[52,56,161],[374,161,56],[25,28,331],[375,331,28],[376,333,163],[163,203,175],[377,118,24],[118,181,198],[25,24,162],[378,162,24],[52,51,333],[379,333,51],[167,380,381],[376,167,381],[377,381,330],[330,381,380],[335,381,382],[376,381,335],[373,383,169],[169,383,384],[168,385,383],[373,168,383],[372,87,383],[87,384,383],[377,80,381],[80,382,381],[86,383,385],[372,383,86],[106,348,347],[386,106,347],[375,65,346],[108,346,65],[64,112,349],[387,349,112],[171,190,114],[346,345,171],[374,190,345],[171,345,190],[349,172,347],[172,114,192],[386,347,192],[172,192,347],[173,160,196],[171,173,346],[375,346,196],[173,196,346],[172,349,174],[174,186,160],[387,186,349],[174,349,186],[64,348,62],[106,62,348],[108,107,339],[59,339,107],[374,345,116],[339,116,345],[76,353,352],[379,76,352],[388,77,351],[178,351,77],[179,120,354],[378,354,120],[177,200,175],[351,350,177],[389,200,350],[177,350,200],[354,180,352],[180,175,204],[379,352,204],[180,204,352],[182,181,206],[177,182,351],[388,351,206],[182,206,351],[180,354,183],[183,199,181],[378,199,354],[183,354,199],[91,109,338],[178,338,109],[76,75,353],[179,353,75],[389,350,110],[109,110,350],[390,391,392],[393,394,395],[224,122,389],[122,175,201],[365,388,205],[205,207,181],[66,340,396],[68,396,340],[184,396,342],[185,342,396],[66,396,67],[184,67,396],[68,69,396],[185,396,69],[219,111,387],[111,160,187],[366,386,191],[191,193,114],[150,272,280],[102,272,150],[151,277,274],[103,151,274],[161,374,117],[116,117,374],[366,61,386],[106,386,61],[111,187,387],[186,387,187],[56,188,374],[190,374,188],[191,386,193],[192,193,386],[331,375,194],[196,194,375],[28,34,375],[65,375,34],[219,387,113],[112,113,387],[224,389,123],[110,123,389],[51,55,379],[76,379,55],[24,197,378],[199,378,197],[122,201,389],[200,389,201],[333,379,202],[204,202,379],[205,388,207],[206,207,388],[365,27,388],[77,388,27],[162,378,121],[120,121,378],[162,30,25],[30,29,25],[51,53,54],[303,60,59],[28,29,33],[29,397,33],[161,58,52],[53,52,58],[21,84,19],[84,344,19],[46,49,43],[49,269,43],[208,316,209],[210,209,316],[327,313,211],[212,211,313],[36,35,369],[210,369,35],[37,158,368],[212,368,158],[6,8,313],[36,313,8],[326,38,316],[37,316,38],[392,391,398],[399,398,391],[394,400,395],[401,395,400],[390,214,391],[214,213,234],[393,395,218],[218,239,216],[402,230,403],[230,215,245],[125,124,131],[404,125,403],[405,406,231],[231,248,217],[129,137,127],[407,406,129],[130,127,139],[402,130,408],[194,195,331],[159,331,195],[115,189,56],[188,56,189],[14,219,220],[113,220,219],[45,50,366],[61,366,50],[221,366,222],[191,222,366],[17,23,219],[111,219,23],[118,198,24],[197,24,198],[202,203,333],[163,333,203],[40,224,225],[123,225,224],[12,13,365],[27,365,13],[22,365,223],[205,223,365],[42,44,224],[122,224,44],[399,391,234],[214,234,391],[401,239,395],[218,395,239],[214,390,226],[226,238,227],[218,228,393],[228,229,243],[401,399,233],[233,235,213],[392,409,390],[410,390,409],[394,393,411],[412,411,393],[402,403,131],[125,131,403],[405,137,406],[129,406,137],[405,408,139],[130,139,408],[230,245,403],[404,403,245],[231,406,248],[407,248,406],[232,254,216],[402,408,232],[413,404,244],[244,246,215],[414,247,407],[247,217,249],[133,126,136],[415,133,413],[141,143,128],[416,414,141],[410,238,390],[226,390,238],[412,393,243],[228,243,393],[233,399,235],[234,235,399],[237,260,236],[238,410,237],[417,260,410],[237,410,260],[239,401,240],[233,240,401],[242,241,257],[243,242,412],[418,412,257],[242,257,412],[401,419,399],[398,399,419],[417,410,420],[409,420,410],[400,421,401],[419,401,421],[418,422,412],[411,412,422],[413,135,404],[125,404,135],[414,407,142],[129,142,407],[130,402,132],[131,132,402],[133,136,413],[135,413,136],[423,147,415],[133,415,147],[137,405,138],[139,138,405],[141,414,143],[142,143,414],[424,416,144],[141,144,416],[405,254,408],[232,408,254],[244,404,246],[245,246,404],[247,249,407],[248,407,249],[232,250,402],[230,402,250],[415,413,251],[244,251,413],[252,236,266],[251,252,415],[423,415,266],[252,266,415],[231,253,405],[254,405,253],[416,255,414],[247,414,255],[256,263,241],[255,416,256],[424,263,416],[256,416,263],[257,258,418],[425,418,258],[260,417,261],[426,261,417],[422,418,427],[427,259,91],[420,428,417],[428,1,262],[147,423,148],[429,148,423],[263,424,264],[264,295,265],[266,267,423],[267,268,297],[144,145,424],[430,424,145],[49,431,269],[166,269,431],[82,431,83],[49,83,431],[84,85,431],[166,431,85],[82,344,431],[84,431,344],[432,278,90],[10,90,278],[433,0,281],[39,281,0],[362,361,434],[435,271,359],[270,359,271],[436,361,275],[273,275,361],[360,437,359],[277,287,276],[151,278,277],[280,279,289],[150,280,281],[436,438,439],[439,285,140],[90,92,432],[440,432,92],[282,272,291],[441,282,442],[284,293,274],[443,438,284],[278,432,286],[286,299,265],[281,288,433],[288,268,301],[0,433,89],[444,89,433],[435,445,442],[445,134,283],[439,446,436],[361,436,446],[442,290,435],[271,435,290],[438,436,292],[275,292,436],[445,435,447],[359,447,435],[286,287,278],[277,278,287],[288,281,289],[280,289,281],[145,152,430],[443,430,152],[148,429,154],[441,154,429],[424,430,294],[294,307,276],[423,296,429],[296,279,305],[425,440,100],[92,100,440],[290,442,291],[282,291,442],[292,293,438],[284,438,293],[298,320,241],[432,440,298],[300,236,322],[433,300,444],[426,101,444],[89,444,101],[107,448,302],[302,79,54],[78,31,343],[107,78,448],[75,79,448],[302,448,79],[78,343,448],[75,448,343],[427,418,259],[425,259,418],[428,262,417],[426,417,262],[437,449,359],[447,359,449],[434,361,450],[446,450,361],[32,33,397],[78,33,32],[53,303,54],[302,54,303],[152,153,443],[438,443,153],[429,304,441],[282,441,304],[430,443,306],[284,306,443],[154,441,155],[442,155,441],[298,299,432],[286,432,299],[300,433,301],[288,301,433],[185,451,308],[308,74,7],[73,15,337],[185,73,451],[35,74,451],[308,451,74],[73,337,451],[35,451,337],[158,452,310],[310,72,42],[70,22,341],[158,70,452],[66,72,452],[310,452,72],[70,341,452],[66,452,341],[313,327,314],[315,314,327],[316,317,326],[318,326,317],[15,156,311],[356,311,156],[7,312,157],[358,157,312],[211,9,327],[364,327,9],[38,326,94],[363,94,326],[294,295,424],[264,424,295],[296,423,297],[267,297,423],[262,149,426],[101,426,149],[258,319,425],[440,425,319],[261,426,321],[444,321,426],[259,425,146],[100,146,425],[306,307,430],[294,430,307],[304,429,305],[296,305,429],[319,320,440],[298,440,320],[321,444,322],[300,322,444],[445,283,442],[155,442,283],[439,438,285],[153,285,438],[17,68,18],[21,18,68],[46,184,47],[221,47,184],[102,95,363],[94,363,95],[9,11,364],[103,364,11],[6,323,357],[370,357,323],[371,324,355],[208,355,324],[270,363,325],[326,325,363],[327,364,328],[273,328,364],[0,2,39],[12,39,2],[90,93,91],[40,91,93],[14,16,17],[73,17,16],[45,309,7],[308,7,309],[12,71,39],[70,39,71],[40,41,42],[310,42,41],[97,98,63],[14,63,98],[3,5,7],[45,7,5],[118,377,329],[330,329,377],[331,372,332],[86,332,372],[333,376,334],[335,334,376],[115,373,336],[169,336,373],[167,166,380],[330,380,166],[80,81,382],[335,382,81],[86,385,81],[168,81,385],[169,384,82],[87,82,384],[159,88,372],[87,372,88],[163,164,376],[167,376,164],[24,26,377],[80,377,26],[56,57,373],[168,373,57],[32,397,30],[29,30,397],[58,60,53],[303,53,60],[205,181,119],[118,119,181],[163,175,165],[122,165,175],[453,454,455],[454,456,455],[457,455,456],[458,455,457],[459,455,458],[460,455,459],[461,462,463],[464,465,466],[467,468,469],[470,471,472],[465,473,474],[475,476,477],[478,479,480],[481,482,478],[483,484,481],[485,486,483],[487,488,485],[489,490,487],[491,492,489],[493,494,491],[495,496,493],[497,498,495],[499,500,497],[501,502,499],[503,504,501],[505,504,503],[506,504,505],[507,504,506],[508,504,507],[509,504,508],[510,504,509],[511,504,510],[512,504,511],[513,504,512],[514,504,513],[476,515,516],[517,518,519],[520,517,521],[518,522,523],[522,480,479],[524,525,526],[468,470,527],[525,467,528],[529,475,530],[531,532,533],[534,531,535],[536,537,538],[473,539,540],[539,536,541],[537,534,542],[471,520,543],[532,529,544],[545,524,546],[453,461,547],[463,464,548],[523,549,504],[527,550,551],[519,552,553],[521,554,555],[466,556,557],[469,558,559],[528,560,561],[477,562,563],[543,564,565],[535,566,567],[530,568,569],[540,570,571],[474,572,573],[542,574,575],[538,576,577],[541,578,579],[472,580,581],[526,582,583],[533,584,585],[544,586,587],[516,545,588],[588,589,590],[455,460,4],[591,592,63],[462,455,4],[592,547,63],[547,548,63],[465,462,4],[548,557,63],[127,124,501],[127,501,499],[505,503,124],[124,126,507],[124,507,506],[509,508,126],[126,134,512],[126,512,511],[510,509,126],[128,127,493],[128,493,491],[497,495,127],[489,487,128],[140,128,483],[140,483,481],[487,485,128],[478,480,140],[480,522,140],[514,513,134],[504,514,134],[551,581,437],[471,470,434],[445,447,555],[445,555,553],[134,445,553],[134,553,504],[446,439,518],[446,518,517],[439,140,522],[439,522,518],[515,476,358],[563,588,356],[557,573,63],[473,465,4],[437,360,559],[437,559,551],[360,371,561],[360,561,559],[362,434,470],[362,470,468],[370,362,468],[370,468,467],[499,497,127],[506,505,124],[495,493,127],[513,512,134],[481,478,140],[447,449,565],[447,565,555],[450,446,517],[450,517,520],[356,156,569],[356,569,563],[157,358,476],[157,476,475],[357,370,467],[357,467,525],[371,355,583],[371,583,561],[460,459,4],[63,62,593],[63,593,591],[62,4,459],[62,459,458],[532,531,104],[531,534,104],[567,585,105],[575,567,105],[4,3,539],[4,539,473],[536,539,3],[97,63,573],[97,573,571],[571,579,97],[99,97,579],[99,579,577],[105,99,577],[105,577,575],[96,104,534],[96,534,537],[3,96,537],[3,537,536],[503,501,124],[508,507,126],[491,489,128],[511,510,126],[485,483,128],[434,450,520],[434,520,471],[449,437,581],[449,581,565],[156,105,585],[156,585,587],[587,569,156],[104,157,529],[104,529,532],[475,529,157],[590,583,355],[355,356,588],[355,588,590],[358,357,524],[358,524,515],[525,524,357],[458,457,62],[457,593,62],[479,478,482],[479,504,549],[479,482,504],[482,481,484],[472,551,550],[581,551,472],[482,484,504],[484,483,486],[523,553,552],[504,553,523],[540,573,572],[571,573,540],[544,585,584],[587,585,544],[542,577,576],[575,577,542],[526,590,589],[583,590,526],[535,575,574],[567,575,535],[533,567,566],[585,567,533],[538,579,578],[577,579,538],[543,581,580],[565,581,543],[477,569,568],[563,569,477],[530,587,586],[569,587,530],[541,571,570],[579,571,541],[528,583,582],[561,583,528],[591,453,592],[547,592,453],[521,565,564],[555,565,521],[474,557,556],[573,557,474],[516,563,562],[588,563,516],[519,555,554],[553,555,519],[527,559,558],[551,559,527],[469,561,560],[559,561,469],[462,461,455],[453,455,461],[461,463,547],[548,547,463],[465,464,462],[463,462,464],[464,466,548],[557,548,466],[469,560,467],[528,467,560],[472,550,470],[527,470,550],[474,556,465],[466,465,556],[477,568,475],[530,475,568],[516,562,476],[477,476,562],[519,554,517],[521,517,554],[521,564,520],[543,520,564],[523,552,518],[519,518,552],[479,549,522],[523,522,549],[526,589,524],[589,546,524],[527,558,468],[469,468,558],[528,582,525],[526,525,582],[530,586,529],[544,529,586],[533,566,531],[535,531,566],[535,574,534],[542,534,574],[538,578,536],[541,536,578],[540,572,473],[474,473,572],[541,570,539],[540,539,570],[542,576,537],[538,537,576],[543,580,471],[472,471,580],[544,584,532],[533,532,584],[524,545,515],[516,515,545],[545,546,588],[589,588,546],[453,591,454],[593,454,591],[484,486,504],[486,485,488],[486,488,504],[488,487,490],[488,490,504],[490,489,492],[490,492,504],[492,491,494],[492,494,504],[494,493,496],[494,496,504],[496,495,498],[496,498,504],[498,497,500],[498,500,504],[500,499,502],[500,502,504],[501,504,502],[454,593,456],[457,456,593],[594,595,596],[597,598,594],[599,597,594],[600,599,594],[601,600,594],[602,601,594],[603,602,594],[604,603,594],[605,604,594],[606,607,608],[609,606,608],[610,609,608],[611,610,608],[612,611,608],[613,612,608],[614,613,608],[615,614,608],[616,615,608],[617,616,608],[618,617,608],[619,618,608],[620,619,608],[596,608,607],[595,594,598],[608,596,595],[605,594,91],[91,338,602],[91,602,603],[598,597,1],[594,596,91],[608,595,1],[595,598,1],[616,617,392],[610,611,394],[419,421,613],[419,613,614],[422,427,607],[422,607,606],[427,91,596],[427,596,607],[428,420,619],[428,619,620],[1,428,620],[1,620,608],[420,409,618],[420,618,619],[411,422,606],[411,606,609],[398,419,614],[398,614,615],[421,400,612],[421,612,613],[409,392,617],[409,617,618],[394,411,609],[394,609,610],[604,605,91],[338,1,599],[338,599,600],[392,398,615],[392,615,616],[400,394,611],[400,611,612],[603,604,91],[601,602,338],[597,599,1],[600,601,338] + ]; } else { return undef; } diff --git a/t/fill.t b/t/fill.t index 8ee65d6c..02b6a307 100644 --- a/t/fill.t +++ b/t/fill.t @@ -2,7 +2,7 @@ use Test::More; use strict; use warnings; -plan tests => 40; +plan tests => 41; BEGIN { use FindBin; @@ -13,7 +13,7 @@ use List::Util qw(first); use Math::ConvexHull::MonotoneChain qw(convex_hull); use Slic3r; use Slic3r::Geometry qw(scale X Y); -use Slic3r::Geometry::Clipper qw(diff_ex); +use Slic3r::Geometry::Clipper qw(union diff_ex); use Slic3r::Surface qw(:types); use Slic3r::Test; @@ -208,4 +208,41 @@ for my $pattern (qw(rectilinear honeycomb hilbertcurve concentric)) { "solid_infill_below_area and solid_infill_every_layers are ignored when fill_density is 0"; } +{ + my $config = Slic3r::Config->new_from_defaults; + $config->set('skirts', 0); + $config->set('perimeters', 3); + $config->set('fill_density', 0); + $config->set('layer_height', 0.2); + $config->set('first_layer_height', 0.2); + $config->set('nozzle_diameter', [0.35]); + $config->set('infill_extruder', 2); + $config->set('infill_extrusion_width', 0.52); + + my $print = Slic3r::Test::init_print('A', config => $config); + my %infill = (); # Z => [ Line, Line ... ] + my $tool = undef; + Slic3r::GCode::Reader->new->parse(Slic3r::Test::gcode($print), sub { + my ($self, $cmd, $args, $info) = @_; + + if ($cmd =~ /^T(\d+)/) { + $tool = $1; + } elsif ($cmd eq 'G1' && $info->{extruding} && $info->{dist_XY} > 0) { + if ($tool == $config->infill_extruder-1) { + my $z = 1 * $self->Z; + $infill{$z} ||= []; + push @{$infill{$z}}, Slic3r::Line->new_scale( + [ $self->X, $self->Y ], + [ $info->{new_X}, $info->{new_Y} ], + ); + } + } + }); + my $grow_d = scale($config->infill_extrusion_width)/2; + my $layer0_infill = union([ map $_->grow($grow_d), @{ $infill{0.2} } ]); + my $layer1_infill = union([ map $_->grow($grow_d), @{ $infill{0.4} } ]); + my $diff = [ grep $_->area >= 2*$grow_d**2, @{diff_ex($layer0_infill, $layer1_infill)} ]; + is scalar(@$diff), 0, 'no missing parts in solid shell when fill_density is 0'; +} + __END__ From 7ce49fc2b28bcfd7d455f43e431987a380fae3c4 Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci Date: Mon, 10 Feb 2014 01:27:36 +0100 Subject: [PATCH 25/50] Perform additional checks before merging solid surfaces (i.e. take flow and fill pattern into account) --- lib/Slic3r/Fill.pm | 7 ++++++- lib/Slic3r/Surface.pm | 21 ++++++++++++++++++++- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/lib/Slic3r/Fill.pm b/lib/Slic3r/Fill.pm index 8e2f51e0..49097530 100644 --- a/lib/Slic3r/Fill.pm +++ b/lib/Slic3r/Fill.pm @@ -62,7 +62,12 @@ sub make_fill { my @surfaces_with_bridge_angle = grep defined $_->bridge_angle, @fill_surfaces; # give priority to bridges - my @groups = Slic3r::Surface->group({merge_solid => 1}, @fill_surfaces); + my @groups = Slic3r::Surface->group({ + bridged_bottom => ($layerm->id > 0), + solid_infill_flow => $layerm->solid_infill_flow, + top_infill_flow => $layerm->top_infill_flow, + solid_fill_pattern => $layerm->config->solid_fill_pattern, + }, @fill_surfaces); @groups = sort { defined $a->[0]->bridge_angle ? -1 : 0 } @groups; foreach my $group (@groups) { diff --git a/lib/Slic3r/Surface.pm b/lib/Slic3r/Surface.pm index d0b9ec77..03a48a1d 100644 --- a/lib/Slic3r/Surface.pm +++ b/lib/Slic3r/Surface.pm @@ -21,8 +21,20 @@ sub group { my %unique_types = (); foreach my $surface (@surfaces) { + my $stype = $surface->surface_type; + if ($surface->is_bridge && ($params->{bridged_bottom} || $surface->surface_type != S_TYPE_BOTTOM)) { + $stype = 'bridge'; + } elsif ($surface->is_solid) { + my $fw = $params->{solid_infill_flow}; + if ($surface->surface_type == S_TYPE_TOP && $params->{top_infill_flow}) { + $fw = $params->{top_infill_flow}->width; + } + my $pattern = $surface->is_external ? $params->{solid_fill_pattern} : 'rectilinear'; + $stype = join '_', $fw // '', $pattern // ''; + } + my $type = join '_', - ($params->{merge_solid} && $surface->is_solid) ? 'solid' : $surface->surface_type, + $stype, $surface->bridge_angle // '', $surface->thickness // '', $surface->thickness_layers; @@ -57,6 +69,13 @@ sub is_solid { || $type == S_TYPE_INTERNALSOLID; } +sub is_external { + my $self = shift; + my $type = $self->surface_type; + return $type == S_TYPE_TOP + || $type == S_TYPE_BOTTOM; +} + sub is_bridge { my $self = shift; my $type = $self->surface_type; From d099118ca7bb88d9da7da51daab33d2c90e32b8d Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci Date: Mon, 10 Feb 2014 13:06:42 +0100 Subject: [PATCH 26/50] Better implementation of previous commit (7ce49fc2b28bcfd7d455f43e431987a380fae3c4) --- lib/Slic3r/Fill.pm | 52 ++++++++++++++++++++++++++++++++++++++----- lib/Slic3r/Surface.pm | 15 +------------ 2 files changed, 47 insertions(+), 20 deletions(-) diff --git a/lib/Slic3r/Fill.pm b/lib/Slic3r/Fill.pm index 49097530..3e3dd358 100644 --- a/lib/Slic3r/Fill.pm +++ b/lib/Slic3r/Fill.pm @@ -61,13 +61,53 @@ sub make_fill { my @fill_surfaces = @{$layerm->fill_surfaces}; my @surfaces_with_bridge_angle = grep defined $_->bridge_angle, @fill_surfaces; + # group surfaces by distinct properties + my @groups = Slic3r::Surface->group(@fill_surfaces); + + # merge compatible groups (we can generate continuous infill for them) + { + # cache flow widths and patterns used for all solid groups + # (we'll use them for comparing compatible groups) + my @is_solid = my @fw = my @pattern = (); + for (my $i = 0; $i <= $#groups; $i++) { + # we can only merge solid non-bridge surfaces, so discard + # non-solid surfaces + if ($groups[$i][0]->is_solid && (!$groups[$i][0]->is_bridge || $layerm->id == 0)) { + $is_solid[$i] = 1; + $fw[$i] = ($groups[$i][0]->surface_type == S_TYPE_TOP) + ? $layerm->top_infill_flow->width + : $layerm->solid_infill_flow->width; + $pattern[$i] = $groups[$i][0]->is_external + ? $layerm->config->solid_fill_pattern + : 'rectilinear'; + } else { + $is_solid[$i] = 0; + $fw[$i] = 0; + $pattern[$i] = 'none'; + } + } + + # loop through solid groups + for (my $i = 0; $i <= $#groups; $i++) { + next if !$is_solid[$i]; + + # find compatible groups and append them to this one + for (my $j = $i+1; $j <= $#groups; $j++) { + next if !$is_solid[$j]; + + if ($fw[$i] == $fw[$j] && $pattern[$i] eq $pattern[$j]) { + # groups are compatible, merge them + push @{$groups[$i]}, @{$groups[$j]}; + splice @groups, $j, 1; + splice @is_solid, $j, 1; + splice @fw, $j, 1; + splice @pattern, $j, 1; + } + } + } + } + # give priority to bridges - my @groups = Slic3r::Surface->group({ - bridged_bottom => ($layerm->id > 0), - solid_infill_flow => $layerm->solid_infill_flow, - top_infill_flow => $layerm->top_infill_flow, - solid_fill_pattern => $layerm->config->solid_fill_pattern, - }, @fill_surfaces); @groups = sort { defined $a->[0]->bridge_angle ? -1 : 0 } @groups; foreach my $group (@groups) { diff --git a/lib/Slic3r/Surface.pm b/lib/Slic3r/Surface.pm index 03a48a1d..e4ae3f44 100644 --- a/lib/Slic3r/Surface.pm +++ b/lib/Slic3r/Surface.pm @@ -16,25 +16,12 @@ sub holes { $_[0]->expolygon->holes } # static method to group surfaces having same surface_type, bridge_angle and thickness* sub group { my $class = shift; - my $params = ref $_[0] eq 'HASH' ? shift(@_) : {}; my (@surfaces) = @_; my %unique_types = (); foreach my $surface (@surfaces) { - my $stype = $surface->surface_type; - if ($surface->is_bridge && ($params->{bridged_bottom} || $surface->surface_type != S_TYPE_BOTTOM)) { - $stype = 'bridge'; - } elsif ($surface->is_solid) { - my $fw = $params->{solid_infill_flow}; - if ($surface->surface_type == S_TYPE_TOP && $params->{top_infill_flow}) { - $fw = $params->{top_infill_flow}->width; - } - my $pattern = $surface->is_external ? $params->{solid_fill_pattern} : 'rectilinear'; - $stype = join '_', $fw // '', $pattern // ''; - } - my $type = join '_', - $stype, + $surface->surface_type, $surface->bridge_angle // '', $surface->thickness // '', $surface->thickness_layers; From ee82e56a4fff52a9bc2e01f5a961be5eb34cf891 Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci Date: Mon, 10 Feb 2014 16:02:47 +0100 Subject: [PATCH 27/50] Bugfix: crashing when concentric infill produced very narrow loops. #1740 --- lib/Slic3r/Fill/Concentric.pm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/Slic3r/Fill/Concentric.pm b/lib/Slic3r/Fill/Concentric.pm index 75dce8d2..10cc7aeb 100644 --- a/lib/Slic3r/Fill/Concentric.pm +++ b/lib/Slic3r/Fill/Concentric.pm @@ -47,9 +47,10 @@ sub fill_surface { $last_pos = $paths[-1]->last_point; } - # clip the paths to avoid the extruder to get exactly on the first point of the loop + # clip the paths to prevent the extruder from getting exactly on the first point of the loop my $clip_length = scale $flow_spacing * &Slic3r::LOOP_CLIPPING_LENGTH_OVER_SPACING; $_->clip_end($clip_length) for @paths; + @paths = grep $_->is_valid, @paths; # remove empty paths (too short, thus eaten by clipping) # TODO: return ExtrusionLoop objects to get better chained paths return { flow_spacing => $flow_spacing, no_sort => 1 }, @paths; From 1ec6494d65212fda27e067083050c21f0024612d Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci Date: Thu, 13 Feb 2014 01:00:17 +0100 Subject: [PATCH 28/50] Regression test and incomplete fix for bug affecting wrong spiral vase output. #1773 --- lib/Slic3r/GCode/Layer.pm | 17 +++++--- lib/Slic3r/GCode/SpiralVase.pm | 34 +++++++++++++--- t/shells.t | 71 ++++++++++++++++++++++++++++++++-- 3 files changed, 108 insertions(+), 14 deletions(-) diff --git a/lib/Slic3r/GCode/Layer.pm b/lib/Slic3r/GCode/Layer.pm index 8709ed8e..e8a5b3a3 100644 --- a/lib/Slic3r/GCode/Layer.pm +++ b/lib/Slic3r/GCode/Layer.pm @@ -46,13 +46,16 @@ sub process_layer { my $gcode = ""; # check whether we're going to apply spiralvase logic - my $spiralvase = defined $self->spiralvase - && ($layer->id > 0 || $Slic3r::Config->brim_width == 0) - && ($layer->id >= $Slic3r::Config->skirt_height) - && ($layer->id >= $Slic3r::Config->bottom_solid_layers); + if (defined $self->spiralvase) { + $self->spiralvase->enable( + ($layer->id > 0 || $Slic3r::Config->brim_width == 0) + && ($layer->id >= $Slic3r::Config->skirt_height) + && ($layer->id >= $Slic3r::Config->bottom_solid_layers) + ); + } # if we're going to apply spiralvase to this layer, disable loop clipping - $self->gcodegen->enable_loop_clipping(!$spiralvase); + $self->gcodegen->enable_loop_clipping(!defined $self->spiralvase && !$self->spiralvase->enable); if (!$self->second_layer_things_done && $layer->id == 1) { for my $t (grep $self->extruders->[$_], 0 .. $#{$Slic3r::Config->temperature}) { @@ -178,8 +181,10 @@ sub process_layer { } # apply spiral vase post-processing if this layer contains suitable geometry + # (we must feed all the G-code into the post-processor otherwise it will + # mess with positions) $gcode = $self->spiralvase->process_layer($gcode, $layer) - if $spiralvase; + if defined $self->spiralvase; # apply vibration limit if enabled $gcode = $self->vibration_limit->process($gcode) diff --git a/lib/Slic3r/GCode/SpiralVase.pm b/lib/Slic3r/GCode/SpiralVase.pm index e9f36ba7..c8b3ca5e 100644 --- a/lib/Slic3r/GCode/SpiralVase.pm +++ b/lib/Slic3r/GCode/SpiralVase.pm @@ -2,6 +2,8 @@ package Slic3r::GCode::SpiralVase; use Moo; has 'config' => (is => 'ro', required => 1); +has 'enable' => (is => 'rw', default => sub { 0 }); +has 'gcode_reader' => (is => 'ro', default => sub { Slic3r::GCode::Reader->new }); use Slic3r::Geometry qw(unscale); @@ -9,26 +11,48 @@ sub process_layer { my $self = shift; my ($gcode, $layer) = @_; + # if we're not going to modify G-code, just feed it to the reader + # in order to update positions + if (!$self->enable) { + $self->gcode_reader->parse($gcode, sub {}); + return $gcode; + } + + # get total XY length for this layer by summing all extrusion moves my $total_layer_length = 0; + my $z = undef; Slic3r::GCode::Reader->new->parse($gcode, sub { my ($reader, $cmd, $args, $info) = @_; - $total_layer_length += $info->{dist_XY} - if $cmd eq 'G1' && $info->{extruding}; + + if ($cmd eq 'G1') { + $total_layer_length += $info->{dist_XY} + if $info->{extruding}; + + # get first Z + $z //= $args->{Z} + if exists $args->{Z}; + } }); my $new_gcode = ""; my $layer_height = $layer->height; - my $z = $layer->print_z + $self->config->z_offset - $layer_height; + + # remove layer height from initial Z + $z -= $layer_height; + my $newlayer = 0; - Slic3r::GCode::Reader->new->parse($gcode, sub { + $self->gcode_reader->parse($gcode, sub { my ($reader, $cmd, $args, $info) = @_; if ($cmd eq 'G1' && exists $args->{Z}) { + # if this is the initial Z move of the layer, replace it with a + # (redundant) move to the last Z of previous layer my $line = $info->{raw}; - $line =~ s/Z([^ ]+)/Z$z/; + $line =~ s/Z[.0-9]+/Z$z/; $new_gcode .= "$line\n"; $newlayer = 1; } elsif ($cmd eq 'G1' && !exists $args->{Z} && $info->{dist_XY}) { + # horizontal move my $line = $info->{raw}; if ($info->{extruding}) { $z += $info->{dist_XY} * $layer_height / $total_layer_length; diff --git a/t/shells.t b/t/shells.t index 10da9055..c46b6b25 100644 --- a/t/shells.t +++ b/t/shells.t @@ -1,4 +1,4 @@ -use Test::More tests => 12; +use Test::More tests => 17; use strict; use warnings; @@ -7,10 +7,11 @@ BEGIN { use lib "$FindBin::Bin/../lib"; } -use List::Util qw(first); +use List::Util qw(first sum); use Slic3r; +use Slic3r::Geometry qw(epsilon); use Slic3r::Test; - +goto T; { my $config = Slic3r::Config->new_from_defaults; $config->set('skirts', 0); @@ -163,6 +164,7 @@ use Slic3r::Test; if $started_extruding && exists $args->{Z}; $travel_moves_after_first_extrusion++ if $info->{travel} && $started_extruding && !exists $args->{Z}; + print "\n\n\n\n" if $info->{travel} && $started_extruding && !exists $args->{Z}; }); is $travel_moves_after_first_extrusion, 0, "no gaps in spiral vase ($description)"; ok !(grep { $_ > $config->layer_height } @z_steps), "no gaps in Z ($description)"; @@ -175,4 +177,67 @@ use Slic3r::Test; $test->('20mm_cube', 'solid model with negative z-offset'); } +T: { + my $config = Slic3r::Config->new_from_defaults; + $config->set('spiral_vase', 1); + $config->set('bottom_solid_layers', 0); + $config->set('skirts', 0); + $config->set('first_layer_height', '100%'); + $config->set('layer_height', 0.4); + $config->set('start_gcode', ''); + + my $print = Slic3r::Test::init_print('20mm_cube', config => $config); + my $first_z_move_done = 0; + my $first_layer_done = 0; + my @this_layer = (); # [ dist_Z, dist_XY ], ... + + my $bottom_layer_not_flat = 0; + my $null_z_moves_not_layer_changes = 0; + my $null_z_moves_not_multiples_of_layer_height = 0; + my $sum_of_partial_z_equals_to_layer_height = 0; + my $all_layer_segments_have_same_slope = 0; + my $horizontal_extrusions = 0; + Slic3r::GCode::Reader->new->parse(Slic3r::Test::gcode($print), sub { + my ($self, $cmd, $args, $info) = @_; + + if ($cmd eq 'G1') { + if (!$first_z_move_done) { + $bottom_layer_not_flat = 1 + if $info->{dist_Z} != $config->layer_height; + $first_z_move_done = 1; + } elsif (!$first_layer_done) { + $first_layer_done = 1 if $info->{dist_Z} > 0; + } elsif ($info->{dist_Z} == 0 && $args->{Z}) { + $null_z_moves_not_layer_changes = 1 + if $info->{dist_XY} != 0; + + # % doesn't work easily with floats + $null_z_moves_not_multiples_of_layer_height = 1 + if abs(($args->{Z} / $config->layer_height) * $config->layer_height - $args->{Z}) > epsilon; + + my $total_dist_XY = sum(map $_->[1], @this_layer); + $sum_of_partial_z_equals_to_layer_height = 1 + if abs(sum(map $_->[0], @this_layer) - $config->layer_height) > epsilon; + foreach my $segment (@this_layer) { + # check that segment's dist_Z is proportioned to its dist_XY + $all_layer_segments_have_same_slope = 1 + if abs($segment->[0]*$total_dist_XY/$config->layer_height - $segment->[1]) > epsilon; + } + + @this_layer = (); + } else { + $horizontal_extrusions = 1 + if $info->{dist_Z} == 0; + push @this_layer, [ $info->{dist_Z}, $info->{dist_XY} ]; + } + } + }); + ok !$bottom_layer_not_flat, 'bottom layer is flat when using spiral vase'; + ok !$null_z_moves_not_layer_changes, 'null Z moves are layer changes'; + ok !$null_z_moves_not_multiples_of_layer_height, 'null Z moves are multiples of layer height'; + ok !$sum_of_partial_z_equals_to_layer_height, 'sum of partial Z increments equals to a full layer height'; + ok !$all_layer_segments_have_same_slope, 'all layer segments have the same slope'; + ok !$horizontal_extrusions, 'no horizontal extrusions'; +} + __END__ From 0c7a1777dede80e1bc3c5af103037aa785156526 Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci Date: Thu, 13 Feb 2014 16:06:52 +0100 Subject: [PATCH 29/50] Fixed spiral vase regressions. Includes regression tests. #1773 --- lib/Slic3r/GCode/Layer.pm | 8 ++--- lib/Slic3r/GCode/Reader.pm | 7 +++++ lib/Slic3r/GCode/SpiralVase.pm | 45 +++++++++++++++-------------- t/shells.t | 53 ++++++++++++++++++++-------------- 4 files changed, 66 insertions(+), 47 deletions(-) diff --git a/lib/Slic3r/GCode/Layer.pm b/lib/Slic3r/GCode/Layer.pm index e8a5b3a3..0745b070 100644 --- a/lib/Slic3r/GCode/Layer.pm +++ b/lib/Slic3r/GCode/Layer.pm @@ -55,7 +55,7 @@ sub process_layer { } # if we're going to apply spiralvase to this layer, disable loop clipping - $self->gcodegen->enable_loop_clipping(!defined $self->spiralvase && !$self->spiralvase->enable); + $self->gcodegen->enable_loop_clipping(!defined $self->spiralvase || !$self->spiralvase->enable); if (!$self->second_layer_things_done && $layer->id == 1) { for my $t (grep $self->extruders->[$_], 0 .. $#{$Slic3r::Config->temperature}) { @@ -181,9 +181,9 @@ sub process_layer { } # apply spiral vase post-processing if this layer contains suitable geometry - # (we must feed all the G-code into the post-processor otherwise it will - # mess with positions) - $gcode = $self->spiralvase->process_layer($gcode, $layer) + # (we must feed all the G-code into the post-processor, including the first + # bottom non-spiral layers otherwise it will mess with positions) + $gcode = $self->spiralvase->process_layer($gcode) if defined $self->spiralvase; # apply vibration limit if enabled diff --git a/lib/Slic3r/GCode/Reader.pm b/lib/Slic3r/GCode/Reader.pm index d2a7c184..40d93032 100644 --- a/lib/Slic3r/GCode/Reader.pm +++ b/lib/Slic3r/GCode/Reader.pm @@ -10,6 +10,13 @@ has 'F' => (is => 'rw', default => sub {0}); our $Verbose = 0; my @AXES = qw(X Y Z E); +sub clone { + my $self = shift; + return (ref $self)->new( + map { $_ => $self->$_ } (@AXES, 'F'), + ); +} + sub parse { my $self = shift; my ($gcode, $cb) = @_; diff --git a/lib/Slic3r/GCode/SpiralVase.pm b/lib/Slic3r/GCode/SpiralVase.pm index c8b3ca5e..0f511a6c 100644 --- a/lib/Slic3r/GCode/SpiralVase.pm +++ b/lib/Slic3r/GCode/SpiralVase.pm @@ -3,54 +3,60 @@ use Moo; has 'config' => (is => 'ro', required => 1); has 'enable' => (is => 'rw', default => sub { 0 }); -has 'gcode_reader' => (is => 'ro', default => sub { Slic3r::GCode::Reader->new }); +has 'reader' => (is => 'ro', default => sub { Slic3r::GCode::Reader->new }); use Slic3r::Geometry qw(unscale); sub process_layer { my $self = shift; - my ($gcode, $layer) = @_; + my ($gcode) = @_; + + # This post-processor relies on several assumptions: + # - all layers are processed through it, including those that are not supposed + # to be transformed, in order to update the reader with the XY positions + # - each call to this method includes a full layer, with a single Z move + # at the beginning + # - each layer is composed by suitable geometry (i.e. a single complete loop) + # - loops were not clipped before calling this method # if we're not going to modify G-code, just feed it to the reader # in order to update positions if (!$self->enable) { - $self->gcode_reader->parse($gcode, sub {}); + $self->reader->parse($gcode, sub {}); return $gcode; } # get total XY length for this layer by summing all extrusion moves my $total_layer_length = 0; + my $layer_height = 0; my $z = undef; - Slic3r::GCode::Reader->new->parse($gcode, sub { + $self->reader->clone->parse($gcode, sub { my ($reader, $cmd, $args, $info) = @_; if ($cmd eq 'G1') { - $total_layer_length += $info->{dist_XY} - if $info->{extruding}; - - # get first Z - $z //= $args->{Z} - if exists $args->{Z}; + if ($info->{extruding}) { + $total_layer_length += $info->{dist_XY}; + } elsif (exists $args->{Z}) { + $layer_height += $info->{dist_Z}; + $z //= $args->{Z}; + } } }); - my $new_gcode = ""; - my $layer_height = $layer->height; - + #use XXX; YYY [ $gcode, $layer_height, $z, $total_layer_length ]; # remove layer height from initial Z $z -= $layer_height; - my $newlayer = 0; - $self->gcode_reader->parse($gcode, sub { + my $new_gcode = ""; + $self->reader->parse($gcode, sub { my ($reader, $cmd, $args, $info) = @_; if ($cmd eq 'G1' && exists $args->{Z}) { # if this is the initial Z move of the layer, replace it with a # (redundant) move to the last Z of previous layer my $line = $info->{raw}; - $line =~ s/Z[.0-9]+/Z$z/; + $line =~ s/ Z[.0-9]+/ Z$z/; $new_gcode .= "$line\n"; - $newlayer = 1; } elsif ($cmd eq 'G1' && !exists $args->{Z} && $info->{dist_XY}) { # horizontal move my $line = $info->{raw}; @@ -58,11 +64,6 @@ sub process_layer { $z += $info->{dist_XY} * $layer_height / $total_layer_length; $line =~ s/^G1 /sprintf 'G1 Z%.3f ', $z/e; $new_gcode .= "$line\n"; - } elsif ($newlayer) { - # remove the first travel move after layer change; extrusion - # will just blend to the first loop vertex - # TODO: should we adjust (stretch) E for the first loop segment? - $newlayer = 0; } else { $new_gcode .= "$line\n"; } diff --git a/t/shells.t b/t/shells.t index c46b6b25..02757292 100644 --- a/t/shells.t +++ b/t/shells.t @@ -1,4 +1,4 @@ -use Test::More tests => 17; +use Test::More tests => 16; use strict; use warnings; @@ -11,7 +11,7 @@ use List::Util qw(first sum); use Slic3r; use Slic3r::Geometry qw(epsilon); use Slic3r::Test; -goto T; + { my $config = Slic3r::Config->new_from_defaults; $config->set('skirts', 0); @@ -145,6 +145,7 @@ goto T; $config->set('bottom_solid_layers', 0); $config->set('skirts', 0); $config->set('first_layer_height', '100%'); + $config->set('start_gcode', ''); # TODO: this needs to be tested with a model with sloping edges, where starting # points of each layer are not aligned - in that case we would test that no @@ -159,25 +160,33 @@ goto T; Slic3r::GCode::Reader->new->parse(Slic3r::Test::gcode($print), sub { my ($self, $cmd, $args, $info) = @_; - $started_extruding = 1 if $info->{extruding}; - push @z_steps, ($args->{Z} - $self->Z) - if $started_extruding && exists $args->{Z}; - $travel_moves_after_first_extrusion++ - if $info->{travel} && $started_extruding && !exists $args->{Z}; - print "\n\n\n\n" if $info->{travel} && $started_extruding && !exists $args->{Z}; + if ($cmd eq 'G1') { + $started_extruding = 1 if $info->{extruding}; + push @z_steps, $info->{dist_Z} + if $started_extruding && $info->{dist_Z} > 0; + $travel_moves_after_first_extrusion++ + if $info->{travel} && $started_extruding && !exists $args->{Z}; + } }); - is $travel_moves_after_first_extrusion, 0, "no gaps in spiral vase ($description)"; - ok !(grep { $_ > $config->layer_height } @z_steps), "no gaps in Z ($description)"; + + # we allow one travel move after first extrusion: i.e. when moving to the first + # spiral point after moving to second layer (bottom layer had loop clipping, so + # we're slightly distant from the starting point of the loop) + ok $travel_moves_after_first_extrusion <= 1, "no gaps in spiral vase ($description)"; + ok !(grep { $_ > $config->layer_height + epsilon } @z_steps), "no gaps in Z ($description)"; }; $test->('20mm_cube', 'solid model'); - $test->('40x10', 'hollow model'); $config->set('z_offset', -10); $test->('20mm_cube', 'solid model with negative z-offset'); + + ### Disabled because the current unreliable medial axis code doesn't + ### always produce valid loops. + ###$test->('40x10', 'hollow model with negative z-offset'); } -T: { +{ my $config = Slic3r::Config->new_from_defaults; $config->set('spiral_vase', 1); $config->set('bottom_solid_layers', 0); @@ -187,8 +196,7 @@ T: { $config->set('start_gcode', ''); my $print = Slic3r::Test::init_print('20mm_cube', config => $config); - my $first_z_move_done = 0; - my $first_layer_done = 0; + my $z_moves = 0; my @this_layer = (); # [ dist_Z, dist_XY ], ... my $bottom_layer_not_flat = 0; @@ -201,12 +209,14 @@ T: { my ($self, $cmd, $args, $info) = @_; if ($cmd eq 'G1') { - if (!$first_z_move_done) { - $bottom_layer_not_flat = 1 - if $info->{dist_Z} != $config->layer_height; - $first_z_move_done = 1; - } elsif (!$first_layer_done) { - $first_layer_done = 1 if $info->{dist_Z} > 0; + if ($z_moves < 2) { + # skip everything up to the second Z move + # (i.e. start of second layer) + if (exists $args->{Z}) { + $z_moves++; + $bottom_layer_not_flat = 1 + if $info->{dist_Z} > 0 && $info->{dist_Z} != $config->layer_height; + } } elsif ($info->{dist_Z} == 0 && $args->{Z}) { $null_z_moves_not_layer_changes = 1 if $info->{dist_XY} != 0; @@ -218,6 +228,7 @@ T: { my $total_dist_XY = sum(map $_->[1], @this_layer); $sum_of_partial_z_equals_to_layer_height = 1 if abs(sum(map $_->[0], @this_layer) - $config->layer_height) > epsilon; + exit if $sum_of_partial_z_equals_to_layer_height; foreach my $segment (@this_layer) { # check that segment's dist_Z is proportioned to its dist_XY $all_layer_segments_have_same_slope = 1 @@ -225,7 +236,7 @@ T: { } @this_layer = (); - } else { + } elsif ($info->{extruding} && $info->{dist_XY} > 0) { $horizontal_extrusions = 1 if $info->{dist_Z} == 0; push @this_layer, [ $info->{dist_Z}, $info->{dist_XY} ]; From 35095ff12ee91a769a6f7f9bd4698b138ccc4a04 Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci Date: Sat, 15 Feb 2014 16:55:35 +0100 Subject: [PATCH 30/50] Releasing 1.0.0RC3 --- lib/Slic3r.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Slic3r.pm b/lib/Slic3r.pm index da2de023..6047e070 100644 --- a/lib/Slic3r.pm +++ b/lib/Slic3r.pm @@ -7,7 +7,7 @@ use strict; use warnings; require v5.10; -our $VERSION = "1.0.0RC3-dev"; +our $VERSION = "1.0.0RC3"; our $debug = 0; sub debugf { From 9ec7ae08ade645a784eb5af8f2bdc96c04860dc6 Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci Date: Sun, 16 Feb 2014 12:44:08 +0100 Subject: [PATCH 31/50] Fixed regression when using --infill-only-where-needed. Includes regression test. #1721 --- lib/Slic3r/Print/Object.pm | 8 ++++---- t/fill.t | 9 ++++++++- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/lib/Slic3r/Print/Object.pm b/lib/Slic3r/Print/Object.pm index ead971c7..9c20da09 100644 --- a/lib/Slic3r/Print/Object.pm +++ b/lib/Slic3r/Print/Object.pm @@ -416,8 +416,8 @@ sub clip_fill_surfaces { my $overhangs = []; # arrayref of polygons for my $layer_id (reverse 0..$#{$self->layers}) { my $layer = $self->layers->[$layer_id]; - my @layer_internal = (); - my @new_internal = (); + my @layer_internal = (); # arrayref of Surface objects + my @new_internal = (); # arrayref of Surface objects # clip this layer's internal surfaces to @overhangs foreach my $layerm (@{$layer->regions}) { @@ -451,10 +451,10 @@ sub clip_fill_surfaces { if ($layer_id > 0) { my $solid = diff( [ map @$_, @{$layer->slices} ], - \@layer_internal, + [ map $_->p, @layer_internal ], ); $overhangs = offset($solid, +$additional_margin); - push @$overhangs, @new_internal; # propagate upper overhangs + push @$overhangs, map $_->p, @new_internal; # propagate upper overhangs } } } diff --git a/t/fill.t b/t/fill.t index 02b6a307..0a5a0a72 100644 --- a/t/fill.t +++ b/t/fill.t @@ -2,7 +2,7 @@ use Test::More; use strict; use warnings; -plan tests => 41; +plan tests => 42; BEGIN { use FindBin; @@ -187,6 +187,13 @@ for my $pattern (qw(rectilinear honeycomb hilbertcurve concentric)) { ok !(defined first { !$convex_hull->encloses_point($_) } @infill_points), "infill does not exceed perimeters ($pattern)"; } +{ + my $config = Slic3r::Config->new_from_defaults; + $config->set('infill_only_where_needed', 1); + my $print = Slic3r::Test::init_print('20mm_cube', config => $config); + ok my $gcode = Slic3r::Test::gcode($print), "successful G-code generation when infill_only_where_needed is set"; +} + { my $config = Slic3r::Config->new_from_defaults; $config->set('skirts', 0); From 71322cc49d735507f9a676d2f60485f0466e8035 Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci Date: Wed, 26 Feb 2014 11:36:37 +0100 Subject: [PATCH 32/50] Bugfix: crash when using non-consecutive extruders. #1808 --- lib/Slic3r/Print.pm | 2 +- t/multi.t | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/Slic3r/Print.pm b/lib/Slic3r/Print.pm index 2b413360..a84ba70c 100644 --- a/lib/Slic3r/Print.pm +++ b/lib/Slic3r/Print.pm @@ -228,7 +228,7 @@ sub init_extruders { (map $self->config->get("${_}_extruder")-1, qw(perimeter infill support_material support_material_interface)), (values %extruder_mapping), ); - for my $extruder_id (keys %{{ map {$_ => 1} @used_extruders }}) { + for my $extruder_id (0 .. max(@used_extruders)) { $self->extruders->[$extruder_id] = Slic3r::Extruder->new( config => $self->config, id => $extruder_id, diff --git a/t/multi.t b/t/multi.t index c7214e8b..1a46f353 100644 --- a/t/multi.t +++ b/t/multi.t @@ -1,4 +1,4 @@ -use Test::More tests => 1; +use Test::More tests => 2; use strict; use warnings; @@ -59,4 +59,12 @@ use Slic3r::Test; ok !(first { $convex_hull->encloses_point($_) } @toolchange_points), 'all toolchanges happen outside skirt'; } +{ + my $config = Slic3r::Config->new_from_defaults; + $config->set('support_material_extruder', 3); + + my $print = Slic3r::Test::init_print('20mm_cube', config => $config); + ok Slic3r::Test::gcode($print), 'no errors when using non-consecutive extruders'; +} + __END__ From c1a5cddcd22a4656b3599c59748743692059e3de Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci Date: Sat, 1 Mar 2014 20:34:22 +0100 Subject: [PATCH 33/50] Use bridge speed for first solid layer above sparse infill. Includes unit test. #1792 --- lib/Slic3r/GCode.pm | 2 +- t/shells.t | 30 +++++++++++++++++++++++------- 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/lib/Slic3r/GCode.pm b/lib/Slic3r/GCode.pm index 5bace196..da973186 100644 --- a/lib/Slic3r/GCode.pm +++ b/lib/Slic3r/GCode.pm @@ -58,7 +58,7 @@ my %role_speeds = ( &EXTR_ROLE_SOLIDFILL => 'solid_infill', &EXTR_ROLE_TOPSOLIDFILL => 'top_solid_infill', &EXTR_ROLE_BRIDGE => 'bridge', - &EXTR_ROLE_INTERNALBRIDGE => 'solid_infill', + &EXTR_ROLE_INTERNALBRIDGE => 'bridge', &EXTR_ROLE_SKIRT => 'perimeter', &EXTR_ROLE_SUPPORTMATERIAL => 'support_material', &EXTR_ROLE_GAPFILL => 'gap_fill', diff --git a/t/shells.t b/t/shells.t index 02757292..e967ea0e 100644 --- a/t/shells.t +++ b/t/shells.t @@ -18,6 +18,7 @@ use Slic3r::Test; $config->set('perimeters', 0); $config->set('solid_infill_speed', 99); $config->set('top_solid_infill_speed', 99); + $config->set('bridge_speed', 72); $config->set('first_layer_speed', '100%'); $config->set('cooling', 0); @@ -27,19 +28,25 @@ use Slic3r::Test; my $print = Slic3r::Test::init_print('20mm_cube', config => $config); - my %layers_with_shells = (); # Z => $count + my %z = (); # Z => 1 + my %layers_with_solid_infill = (); # Z => $count + my %layers_with_bridge_infill = (); # Z => $count Slic3r::GCode::Reader->new->parse(Slic3r::Test::gcode($print), sub { my ($self, $cmd, $args, $info) = @_; if ($self->Z > 0) { - $layers_with_shells{$self->Z} //= 0; - $layers_with_shells{$self->Z} = 1 - if $info->{extruding} - && $info->{dist_XY} > 0 - && ($args->{F} // $self->F) == $config->solid_infill_speed*60; + $z{ $self->Z } = 1; + if ($info->{extruding} && $info->{dist_XY} > 0) { + my $F = $args->{F} // $self->F; + $layers_with_solid_infill{$self->Z} = 1 + if $F == $config->solid_infill_speed*60; + $layers_with_bridge_infill{$self->Z} = 1 + if $F == $config->bridge_speed*60; + } } }); - my @shells = @layers_with_shells{sort { $a <=> $b } keys %layers_with_shells}; + my @z = sort { $a <=> $b } keys %z; + my @shells = map $layers_with_solid_infill{$_} || $layers_with_bridge_infill{$_}, @z; fail "insufficient number of bottom solid layers" unless !defined(first { !$_ } @shells[0..$config->bottom_solid_layers-1]); fail "excessive number of bottom solid layers" @@ -48,9 +55,17 @@ use Slic3r::Test; unless !defined(first { !$_ } @shells[-$config->top_solid_layers..-1]); fail "excessive number of top solid layers" unless scalar(grep $_, @shells[($#shells/2)..$#shells]) == $config->top_solid_layers; + if ($config->top_solid_layers > 0) { + fail "unexpected solid infill speed in first solid layer over sparse infill" + if $layers_with_solid_infill{ $z[-$config->top_solid_layers] }; + die "bridge speed not used in first solid layer over sparse infill" + if !$layers_with_bridge_infill{ $z[-$config->top_solid_layers] }; + } 1; }; + $config->set('top_solid_layers', 3); + $config->set('bottom_solid_layers', 3); ok $test->(), "proper number of shells is applied"; $config->set('top_solid_layers', 0); @@ -69,6 +84,7 @@ use Slic3r::Test; $config->set('bottom_solid_layers', 0); $config->set('top_solid_layers', 3); $config->set('cooling', 0); + $config->set('bridge_speed', 99); $config->set('solid_infill_speed', 99); $config->set('top_solid_infill_speed', 99); $config->set('first_layer_speed', '100%'); From 8c4a0f23df3162af52762132ea7cbf01a6166457 Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci Date: Sun, 2 Mar 2014 00:28:10 +0100 Subject: [PATCH 34/50] Better pruning of thin walls to avoid unwanted extra extrusions. Includes regression test. #1794 --- lib/Slic3r/Layer/Region.pm | 19 +++++++++++++-- lib/Slic3r/SVG.pm | 4 ++-- lib/Slic3r/Test.pm | 7 ++++++ t/thin.t | 48 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 74 insertions(+), 4 deletions(-) create mode 100644 t/thin.t diff --git a/lib/Slic3r/Layer/Region.pm b/lib/Slic3r/Layer/Region.pm index 2f3487c3..374e7699 100644 --- a/lib/Slic3r/Layer/Region.pm +++ b/lib/Slic3r/Layer/Region.pm @@ -175,14 +175,14 @@ sub make_perimeters { # the minimum thickness of a single loop is: # width/2 + spacing/2 + spacing/2 + width/2 @offsets = @{offset2(\@last, -(0.5*$pwidth + 0.5*$pspacing - 1), +(0.5*$pspacing - 1))}; - + # look for thin walls if ($self->config->thin_walls) { my $diff = diff_ex( \@last, offset(\@offsets, +0.5*$pwidth), ); - push @thin_walls, grep abs($_->area) >= $gap_area_threshold, @$diff; + push @thin_walls, @$diff; } } else { @offsets = @{offset2(\@last, -(1.5*$pspacing - 1), +(0.5*$pspacing - 1))}; @@ -305,14 +305,29 @@ sub make_perimeters { $self->perimeters->append(@loops); # process thin walls by collapsing slices to single passes + my $min_thin_wall_width = $pwidth/3; + my $min_thin_wall_length = 2*$pwidth; + @thin_walls = @{offset2_ex([ map @$_, @thin_walls ], -0.5*$min_thin_wall_width, +0.5*$min_thin_wall_width)}; if (@thin_walls) { + if (0) { + require "Slic3r/SVG.pm"; + Slic3r::SVG::output( + "thin_walls.svg", + no_arrows => 1, + expolygons => \@thin_walls, + red_polylines => [ map $_->polygon->split_at_first_point, @{$self->perimeters} ], + ); + } + my @p = map $_->medial_axis($pspacing), @thin_walls; my @paths = (); for my $p (@p) { + next if $p->length < $min_thin_wall_length; my %params = ( role => EXTR_ROLE_EXTERNAL_PERIMETER, flow_spacing => $self->perimeter_flow->spacing, ); + printf "len = %s\n", unscale($p->length); push @paths, $p->isa('Slic3r::Polygon') ? Slic3r::ExtrusionLoop->new(polygon => $p, %params) : Slic3r::ExtrusionPath->new(polyline => $p, %params); diff --git a/lib/Slic3r/SVG.pm b/lib/Slic3r/SVG.pm index 40b0c7c9..1aa7dd27 100644 --- a/lib/Slic3r/SVG.pm +++ b/lib/Slic3r/SVG.pm @@ -50,7 +50,7 @@ sub output { my $g = $svg->group( style => { - 'stroke-width' => 2, + 'stroke-width' => 0, 'stroke' => $colour || 'black', 'fill' => ($type !~ /polygons/ ? 'none' : ($colour || 'grey')), 'fill-type' => $filltype, @@ -68,7 +68,7 @@ sub output { my $g = $svg->group( style => { - 'stroke-width' => 2, + 'stroke-width' => ($method eq 'polyline') ? 1 : 0, 'stroke' => $colour || 'black', 'fill' => ($type !~ /polygons/ ? 'none' : ($colour || 'grey')), }, diff --git a/lib/Slic3r/Test.pm b/lib/Slic3r/Test.pm index 42caf6c0..3b547482 100644 --- a/lib/Slic3r/Test.pm +++ b/lib/Slic3r/Test.pm @@ -83,6 +83,13 @@ sub model { $facets = [ [0,1,2],[3,4,5],[6,7,8],[9,10,11],[12,2,1],[12,1,13],[14,15,16],[17,18,19],[20,21,22],[17,19,23],[24,25,26],[27,13,1],[28,25,29],[30,31,32],[28,33,34],[35,36,7],[37,38,39],[40,10,41],[42,43,44],[45,5,4],[46,47,48],[46,48,49],[45,4,50],[51,52,53],[51,54,55],[56,52,57],[58,59,60],[61,50,4],[62,63,64],[65,34,33],[66,67,42],[68,17,69],[70,71,22],[66,42,72],[73,16,15],[35,7,74],[75,76,54],[77,27,1],[78,32,31],[75,54,79],[80,26,25],[81,80,25],[82,83,48],[84,20,85],[81,25,86],[87,88,19],[0,89,1],[90,91,92],[90,10,93],[38,94,39],[94,95,39],[3,7,96],[97,15,98],[97,99,15],[92,91,100],[89,101,1],[102,39,95],[103,11,10],[104,96,7],[105,15,99],[106,61,4],[107,108,33],[76,55,54],[109,91,110],[111,23,19],[112,63,113],[114,115,48],[116,59,117],[118,20,119],[120,31,121],[122,44,43],[110,91,123],[124,125,126],[127,128,129],[127,130,124],[131,124,132],[126,133,134],[135,136,126],[137,138,127],[139,127,138],[128,140,141],[142,128,143],[144,140,145],[100,91,146],[147,148,134],[101,149,1],[102,150,39],[103,10,151],[145,140,152],[152,140,153],[148,154,134],[154,155,134],[156,15,105],[157,104,7],[36,8,7],[158,37,39],[159,19,88],[160,19,159],[161,59,58],[161,117,59],[162,31,30],[162,121,31],[163,43,164],[163,165,43],[166,167,43],[167,164,43],[168,57,52],[82,48,169],[114,170,171],[108,65,33],[64,63,112],[114,172,170],[160,173,170],[171,170,173],[172,174,170],[160,170,174],[175,176,177],[178,77,1],[179,31,120],[175,180,176],[181,182,176],[177,176,182],[180,183,176],[181,176,183],[184,42,67],[185,69,17],[160,111,19],[186,187,160],[188,189,114],[190,188,114],[114,48,191],[192,114,193],[194,160,195],[196,160,194],[197,198,181],[199,197,181],[122,43,165],[200,201,175],[202,175,203],[204,175,202],[205,119,20],[206,181,207],[208,209,15],[210,15,209],[211,10,9],[212,10,211],[213,214,215],[216,217,218],[219,14,17],[113,63,220],[221,222,48],[191,48,222],[22,223,20],[205,20,223],[224,40,42],[123,91,225],[214,226,215],[227,215,226],[218,217,228],[229,228,217],[215,230,213],[125,135,126],[217,216,231],[129,128,142],[216,213,232],[130,132,124],[213,216,233],[234,213,235],[236,227,237],[238,237,227],[239,240,216],[233,216,240],[241,242,229],[243,229,242],[215,227,244],[245,215,246],[217,247,229],[248,249,217],[232,213,250],[230,250,213],[133,147,134],[244,227,251],[236,252,227],[251,227,252],[231,216,253],[254,253,216],[141,140,144],[247,255,229],[241,229,256],[255,256,229],[257,241,258],[259,146,91],[260,261,236],[262,1,149],[263,264,241],[265,241,264],[266,236,267],[268,267,236],[49,48,83],[166,43,269],[270,271,272],[273,274,275],[276,274,277],[278,151,10],[279,280,272],[281,39,150],[272,282,279],[155,283,134],[274,276,284],[153,140,285],[286,276,287],[265,276,286],[288,289,279],[268,288,279],[290,291,272],[271,290,272],[292,274,293],[275,274,292],[294,265,295],[276,265,294],[296,297,268],[279,296,268],[241,265,298],[298,265,299],[236,300,268],[300,301,268],[107,33,78],[302,303,59],[304,305,279],[282,304,279],[306,276,307],[284,276,306],[185,17,73],[308,309,221],[158,39,70],[310,41,10],[15,311,208],[7,6,312],[313,314,6],[315,6,314],[316,208,317],[318,317,208],[258,241,319],[319,241,320],[261,321,236],[321,322,236],[6,315,323],[208,324,318],[270,325,318],[326,318,325],[327,328,315],[273,315,328],[118,329,20],[330,20,329],[331,332,25],[86,25,332],[333,334,52],[335,52,334],[115,336,48],[169,48,336],[62,106,4],[35,15,210],[35,337,15],[158,10,212],[158,310,10],[338,178,1],[339,59,116],[107,302,59],[66,22,340],[66,341,22],[185,221,342],[185,308,221],[75,31,179],[75,343,31],[166,20,330],[166,85,20],[81,52,335],[81,168,52],[82,19,344],[82,87,19],[108,339,345],[346,108,345],[64,347,348],[349,347,64],[178,109,350],[351,178,350],[179,352,353],[354,352,179],[355,208,356],[356,208,311],[357,358,6],[358,312,6],[68,22,21],[68,340,22],[221,48,47],[184,342,221],[359,270,360],[318,360,270],[361,362,273],[315,273,362],[272,102,270],[363,270,102],[274,273,103],[364,103,273],[21,19,18],[21,20,84],[184,46,42],[43,42,46],[12,22,71],[365,22,12],[14,98,15],[14,220,63],[40,93,10],[40,225,91],[45,221,309],[366,221,45],[313,367,212],[212,367,368],[36,369,367],[313,36,367],[316,37,367],[37,368,367],[210,367,369],[316,367,210],[362,370,315],[370,323,315],[360,318,371],[371,318,324],[372,331,159],[159,195,160],[373,115,56],[115,114,189],[52,56,161],[374,161,56],[25,28,331],[375,331,28],[376,333,163],[163,203,175],[377,118,24],[118,181,198],[25,24,162],[378,162,24],[52,51,333],[379,333,51],[167,380,381],[376,167,381],[377,381,330],[330,381,380],[335,381,382],[376,381,335],[373,383,169],[169,383,384],[168,385,383],[373,168,383],[372,87,383],[87,384,383],[377,80,381],[80,382,381],[86,383,385],[372,383,86],[106,348,347],[386,106,347],[375,65,346],[108,346,65],[64,112,349],[387,349,112],[171,190,114],[346,345,171],[374,190,345],[171,345,190],[349,172,347],[172,114,192],[386,347,192],[172,192,347],[173,160,196],[171,173,346],[375,346,196],[173,196,346],[172,349,174],[174,186,160],[387,186,349],[174,349,186],[64,348,62],[106,62,348],[108,107,339],[59,339,107],[374,345,116],[339,116,345],[76,353,352],[379,76,352],[388,77,351],[178,351,77],[179,120,354],[378,354,120],[177,200,175],[351,350,177],[389,200,350],[177,350,200],[354,180,352],[180,175,204],[379,352,204],[180,204,352],[182,181,206],[177,182,351],[388,351,206],[182,206,351],[180,354,183],[183,199,181],[378,199,354],[183,354,199],[91,109,338],[178,338,109],[76,75,353],[179,353,75],[389,350,110],[109,110,350],[390,391,392],[393,394,395],[224,122,389],[122,175,201],[365,388,205],[205,207,181],[66,340,396],[68,396,340],[184,396,342],[185,342,396],[66,396,67],[184,67,396],[68,69,396],[185,396,69],[219,111,387],[111,160,187],[366,386,191],[191,193,114],[150,272,280],[102,272,150],[151,277,274],[103,151,274],[161,374,117],[116,117,374],[366,61,386],[106,386,61],[111,187,387],[186,387,187],[56,188,374],[190,374,188],[191,386,193],[192,193,386],[331,375,194],[196,194,375],[28,34,375],[65,375,34],[219,387,113],[112,113,387],[224,389,123],[110,123,389],[51,55,379],[76,379,55],[24,197,378],[199,378,197],[122,201,389],[200,389,201],[333,379,202],[204,202,379],[205,388,207],[206,207,388],[365,27,388],[77,388,27],[162,378,121],[120,121,378],[162,30,25],[30,29,25],[51,53,54],[303,60,59],[28,29,33],[29,397,33],[161,58,52],[53,52,58],[21,84,19],[84,344,19],[46,49,43],[49,269,43],[208,316,209],[210,209,316],[327,313,211],[212,211,313],[36,35,369],[210,369,35],[37,158,368],[212,368,158],[6,8,313],[36,313,8],[326,38,316],[37,316,38],[392,391,398],[399,398,391],[394,400,395],[401,395,400],[390,214,391],[214,213,234],[393,395,218],[218,239,216],[402,230,403],[230,215,245],[125,124,131],[404,125,403],[405,406,231],[231,248,217],[129,137,127],[407,406,129],[130,127,139],[402,130,408],[194,195,331],[159,331,195],[115,189,56],[188,56,189],[14,219,220],[113,220,219],[45,50,366],[61,366,50],[221,366,222],[191,222,366],[17,23,219],[111,219,23],[118,198,24],[197,24,198],[202,203,333],[163,333,203],[40,224,225],[123,225,224],[12,13,365],[27,365,13],[22,365,223],[205,223,365],[42,44,224],[122,224,44],[399,391,234],[214,234,391],[401,239,395],[218,395,239],[214,390,226],[226,238,227],[218,228,393],[228,229,243],[401,399,233],[233,235,213],[392,409,390],[410,390,409],[394,393,411],[412,411,393],[402,403,131],[125,131,403],[405,137,406],[129,406,137],[405,408,139],[130,139,408],[230,245,403],[404,403,245],[231,406,248],[407,248,406],[232,254,216],[402,408,232],[413,404,244],[244,246,215],[414,247,407],[247,217,249],[133,126,136],[415,133,413],[141,143,128],[416,414,141],[410,238,390],[226,390,238],[412,393,243],[228,243,393],[233,399,235],[234,235,399],[237,260,236],[238,410,237],[417,260,410],[237,410,260],[239,401,240],[233,240,401],[242,241,257],[243,242,412],[418,412,257],[242,257,412],[401,419,399],[398,399,419],[417,410,420],[409,420,410],[400,421,401],[419,401,421],[418,422,412],[411,412,422],[413,135,404],[125,404,135],[414,407,142],[129,142,407],[130,402,132],[131,132,402],[133,136,413],[135,413,136],[423,147,415],[133,415,147],[137,405,138],[139,138,405],[141,414,143],[142,143,414],[424,416,144],[141,144,416],[405,254,408],[232,408,254],[244,404,246],[245,246,404],[247,249,407],[248,407,249],[232,250,402],[230,402,250],[415,413,251],[244,251,413],[252,236,266],[251,252,415],[423,415,266],[252,266,415],[231,253,405],[254,405,253],[416,255,414],[247,414,255],[256,263,241],[255,416,256],[424,263,416],[256,416,263],[257,258,418],[425,418,258],[260,417,261],[426,261,417],[422,418,427],[427,259,91],[420,428,417],[428,1,262],[147,423,148],[429,148,423],[263,424,264],[264,295,265],[266,267,423],[267,268,297],[144,145,424],[430,424,145],[49,431,269],[166,269,431],[82,431,83],[49,83,431],[84,85,431],[166,431,85],[82,344,431],[84,431,344],[432,278,90],[10,90,278],[433,0,281],[39,281,0],[362,361,434],[435,271,359],[270,359,271],[436,361,275],[273,275,361],[360,437,359],[277,287,276],[151,278,277],[280,279,289],[150,280,281],[436,438,439],[439,285,140],[90,92,432],[440,432,92],[282,272,291],[441,282,442],[284,293,274],[443,438,284],[278,432,286],[286,299,265],[281,288,433],[288,268,301],[0,433,89],[444,89,433],[435,445,442],[445,134,283],[439,446,436],[361,436,446],[442,290,435],[271,435,290],[438,436,292],[275,292,436],[445,435,447],[359,447,435],[286,287,278],[277,278,287],[288,281,289],[280,289,281],[145,152,430],[443,430,152],[148,429,154],[441,154,429],[424,430,294],[294,307,276],[423,296,429],[296,279,305],[425,440,100],[92,100,440],[290,442,291],[282,291,442],[292,293,438],[284,438,293],[298,320,241],[432,440,298],[300,236,322],[433,300,444],[426,101,444],[89,444,101],[107,448,302],[302,79,54],[78,31,343],[107,78,448],[75,79,448],[302,448,79],[78,343,448],[75,448,343],[427,418,259],[425,259,418],[428,262,417],[426,417,262],[437,449,359],[447,359,449],[434,361,450],[446,450,361],[32,33,397],[78,33,32],[53,303,54],[302,54,303],[152,153,443],[438,443,153],[429,304,441],[282,441,304],[430,443,306],[284,306,443],[154,441,155],[442,155,441],[298,299,432],[286,432,299],[300,433,301],[288,301,433],[185,451,308],[308,74,7],[73,15,337],[185,73,451],[35,74,451],[308,451,74],[73,337,451],[35,451,337],[158,452,310],[310,72,42],[70,22,341],[158,70,452],[66,72,452],[310,452,72],[70,341,452],[66,452,341],[313,327,314],[315,314,327],[316,317,326],[318,326,317],[15,156,311],[356,311,156],[7,312,157],[358,157,312],[211,9,327],[364,327,9],[38,326,94],[363,94,326],[294,295,424],[264,424,295],[296,423,297],[267,297,423],[262,149,426],[101,426,149],[258,319,425],[440,425,319],[261,426,321],[444,321,426],[259,425,146],[100,146,425],[306,307,430],[294,430,307],[304,429,305],[296,305,429],[319,320,440],[298,440,320],[321,444,322],[300,322,444],[445,283,442],[155,442,283],[439,438,285],[153,285,438],[17,68,18],[21,18,68],[46,184,47],[221,47,184],[102,95,363],[94,363,95],[9,11,364],[103,364,11],[6,323,357],[370,357,323],[371,324,355],[208,355,324],[270,363,325],[326,325,363],[327,364,328],[273,328,364],[0,2,39],[12,39,2],[90,93,91],[40,91,93],[14,16,17],[73,17,16],[45,309,7],[308,7,309],[12,71,39],[70,39,71],[40,41,42],[310,42,41],[97,98,63],[14,63,98],[3,5,7],[45,7,5],[118,377,329],[330,329,377],[331,372,332],[86,332,372],[333,376,334],[335,334,376],[115,373,336],[169,336,373],[167,166,380],[330,380,166],[80,81,382],[335,382,81],[86,385,81],[168,81,385],[169,384,82],[87,82,384],[159,88,372],[87,372,88],[163,164,376],[167,376,164],[24,26,377],[80,377,26],[56,57,373],[168,373,57],[32,397,30],[29,30,397],[58,60,53],[303,53,60],[205,181,119],[118,119,181],[163,175,165],[122,165,175],[453,454,455],[454,456,455],[457,455,456],[458,455,457],[459,455,458],[460,455,459],[461,462,463],[464,465,466],[467,468,469],[470,471,472],[465,473,474],[475,476,477],[478,479,480],[481,482,478],[483,484,481],[485,486,483],[487,488,485],[489,490,487],[491,492,489],[493,494,491],[495,496,493],[497,498,495],[499,500,497],[501,502,499],[503,504,501],[505,504,503],[506,504,505],[507,504,506],[508,504,507],[509,504,508],[510,504,509],[511,504,510],[512,504,511],[513,504,512],[514,504,513],[476,515,516],[517,518,519],[520,517,521],[518,522,523],[522,480,479],[524,525,526],[468,470,527],[525,467,528],[529,475,530],[531,532,533],[534,531,535],[536,537,538],[473,539,540],[539,536,541],[537,534,542],[471,520,543],[532,529,544],[545,524,546],[453,461,547],[463,464,548],[523,549,504],[527,550,551],[519,552,553],[521,554,555],[466,556,557],[469,558,559],[528,560,561],[477,562,563],[543,564,565],[535,566,567],[530,568,569],[540,570,571],[474,572,573],[542,574,575],[538,576,577],[541,578,579],[472,580,581],[526,582,583],[533,584,585],[544,586,587],[516,545,588],[588,589,590],[455,460,4],[591,592,63],[462,455,4],[592,547,63],[547,548,63],[465,462,4],[548,557,63],[127,124,501],[127,501,499],[505,503,124],[124,126,507],[124,507,506],[509,508,126],[126,134,512],[126,512,511],[510,509,126],[128,127,493],[128,493,491],[497,495,127],[489,487,128],[140,128,483],[140,483,481],[487,485,128],[478,480,140],[480,522,140],[514,513,134],[504,514,134],[551,581,437],[471,470,434],[445,447,555],[445,555,553],[134,445,553],[134,553,504],[446,439,518],[446,518,517],[439,140,522],[439,522,518],[515,476,358],[563,588,356],[557,573,63],[473,465,4],[437,360,559],[437,559,551],[360,371,561],[360,561,559],[362,434,470],[362,470,468],[370,362,468],[370,468,467],[499,497,127],[506,505,124],[495,493,127],[513,512,134],[481,478,140],[447,449,565],[447,565,555],[450,446,517],[450,517,520],[356,156,569],[356,569,563],[157,358,476],[157,476,475],[357,370,467],[357,467,525],[371,355,583],[371,583,561],[460,459,4],[63,62,593],[63,593,591],[62,4,459],[62,459,458],[532,531,104],[531,534,104],[567,585,105],[575,567,105],[4,3,539],[4,539,473],[536,539,3],[97,63,573],[97,573,571],[571,579,97],[99,97,579],[99,579,577],[105,99,577],[105,577,575],[96,104,534],[96,534,537],[3,96,537],[3,537,536],[503,501,124],[508,507,126],[491,489,128],[511,510,126],[485,483,128],[434,450,520],[434,520,471],[449,437,581],[449,581,565],[156,105,585],[156,585,587],[587,569,156],[104,157,529],[104,529,532],[475,529,157],[590,583,355],[355,356,588],[355,588,590],[358,357,524],[358,524,515],[525,524,357],[458,457,62],[457,593,62],[479,478,482],[479,504,549],[479,482,504],[482,481,484],[472,551,550],[581,551,472],[482,484,504],[484,483,486],[523,553,552],[504,553,523],[540,573,572],[571,573,540],[544,585,584],[587,585,544],[542,577,576],[575,577,542],[526,590,589],[583,590,526],[535,575,574],[567,575,535],[533,567,566],[585,567,533],[538,579,578],[577,579,538],[543,581,580],[565,581,543],[477,569,568],[563,569,477],[530,587,586],[569,587,530],[541,571,570],[579,571,541],[528,583,582],[561,583,528],[591,453,592],[547,592,453],[521,565,564],[555,565,521],[474,557,556],[573,557,474],[516,563,562],[588,563,516],[519,555,554],[553,555,519],[527,559,558],[551,559,527],[469,561,560],[559,561,469],[462,461,455],[453,455,461],[461,463,547],[548,547,463],[465,464,462],[463,462,464],[464,466,548],[557,548,466],[469,560,467],[528,467,560],[472,550,470],[527,470,550],[474,556,465],[466,465,556],[477,568,475],[530,475,568],[516,562,476],[477,476,562],[519,554,517],[521,517,554],[521,564,520],[543,520,564],[523,552,518],[519,518,552],[479,549,522],[523,522,549],[526,589,524],[589,546,524],[527,558,468],[469,468,558],[528,582,525],[526,525,582],[530,586,529],[544,529,586],[533,566,531],[535,531,566],[535,574,534],[542,534,574],[538,578,536],[541,536,578],[540,572,473],[474,473,572],[541,570,539],[540,539,570],[542,576,537],[538,537,576],[543,580,471],[472,471,580],[544,584,532],[533,532,584],[524,545,515],[516,515,545],[545,546,588],[589,588,546],[453,591,454],[593,454,591],[484,486,504],[486,485,488],[486,488,504],[488,487,490],[488,490,504],[490,489,492],[490,492,504],[492,491,494],[492,494,504],[494,493,496],[494,496,504],[496,495,498],[496,498,504],[498,497,500],[498,500,504],[500,499,502],[500,502,504],[501,504,502],[454,593,456],[457,456,593],[594,595,596],[597,598,594],[599,597,594],[600,599,594],[601,600,594],[602,601,594],[603,602,594],[604,603,594],[605,604,594],[606,607,608],[609,606,608],[610,609,608],[611,610,608],[612,611,608],[613,612,608],[614,613,608],[615,614,608],[616,615,608],[617,616,608],[618,617,608],[619,618,608],[620,619,608],[596,608,607],[595,594,598],[608,596,595],[605,594,91],[91,338,602],[91,602,603],[598,597,1],[594,596,91],[608,595,1],[595,598,1],[616,617,392],[610,611,394],[419,421,613],[419,613,614],[422,427,607],[422,607,606],[427,91,596],[427,596,607],[428,420,619],[428,619,620],[1,428,620],[1,620,608],[420,409,618],[420,618,619],[411,422,606],[411,606,609],[398,419,614],[398,614,615],[421,400,612],[421,612,613],[409,392,617],[409,617,618],[394,411,609],[394,609,610],[604,605,91],[338,1,599],[338,599,600],[392,398,615],[392,615,616],[400,394,611],[400,611,612],[603,604,91],[601,602,338],[597,599,1],[600,601,338] ]; + } elsif ($model_name eq 'gt2_teeth') { + $vertices = [ + [15.8899993896484,19.444055557251,2.67489433288574],[15.9129991531372,19.1590557098389,2.67489433288574],[15.9039993286133,19.1500549316406,2.67489433288574],[15.9489994049072,19.2490558624268,2.67489433288574],[15.9579992294312,19.3570556640625,2.67489433288574],[15.8819999694824,18.690055847168,2.67489433288574],[15.8319997787476,17.7460556030273,2.67489433288574],[15.8489999771118,18.819055557251,2.67489433288574],[15.8589992523193,17.7190551757812,2.67489433288574],[15.8769998550415,19.0490550994873,2.67489433288574],[15.7529993057251,17.8080558776855,2.67489433288574],[15.7869997024536,19.5010547637939,2.67489433288574],[14.0329990386963,18.7170543670654,2.67489433288574],[13.9599990844727,18.7460556030273,2.67489433288574],[13.9869995117188,20.2840557098389,2.67489433288574],[14.2029991149902,20.149055480957,2.67489433288574],[14.1939992904663,19.9560546875,2.67489433288574],[14.1939992904663,20.1670551300049,2.67489433288574],[14.2119998931885,20.0590553283691,2.67489433288574],[12.1899995803833,19.1840553283691,2.67489433288574],[12.096999168396,19.1950550079346,2.67489433288574],[12.1099996566772,20.6690559387207,2.67489433288574],[11.382999420166,19.9750556945801,2.67489433288574],[11.2599992752075,19.2490558624268,2.67489433288574],[11.2369995117188,19.9320545196533,2.67489433288574],[11.5349998474121,20.0640544891357,2.67489433288574],[11.6259994506836,20.1550559997559,2.67489433288574],[11.6829986572266,20.2390556335449,2.67489433288574],[11.7369995117188,20.3570556640625,2.67489433288574],[11.8449993133545,20.645055770874,2.67489433288574],[11.7729988098145,20.4640560150146,2.67489433288574],[11.7799987792969,20.5370559692383,9.41389465332031],[11.7639999389648,20.4470558166504,2.67489433288574],[11.9559993743896,20.6810550689697,2.67489433288574],[12.3079996109009,20.6020545959473,2.67489433288574],[12.1959991455078,19.1860542297363,2.67489433288574],[12.2059993743896,20.6540546417236,2.67489433288574],[12.3489990234375,20.3740558624268,2.67489433288574],[12.3579998016357,20.2750549316406,2.67489433288574],[12.3669996261597,20.266056060791,2.67489433288574],[12.3849992752075,20.1670551300049,2.67489433288574],[12.4269990921021,20.0680541992188,2.67489433288574],[12.5029993057251,19.9540557861328,2.67489433288574],[12.6169996261597,19.8550548553467,2.67489433288574],[12.7449989318848,19.7800559997559,2.67489433288574],[12.7629995346069,19.7800559997559,2.67489433288574],[12.8799991607666,19.7350559234619,2.67489433288574],[13.0369997024536,19.7250556945801,2.67489433288574],[13.0149993896484,19.0340557098389,2.67489433288574],[11.1699991226196,19.2580547332764,2.67489433288574],[11.0959987640381,19.2580547332764,2.67489433288574],[11.1209993362427,19.9230556488037,2.67489433288574],[13.0599994659424,19.024055480957,2.67489433288574],[14.9049997329712,18.3170547485352,2.67489433288574],[14.8779993057251,18.3400554656982,2.67489433288574],[14.8779993057251,19.149055480957,2.67489433288574],[13.3039989471436,19.77805519104,2.67489433288574],[13.1589994430542,18.9890556335449,2.67489433288574],[13.1559991836548,19.7350559234619,2.67489433288574],[13.4269990921021,19.8600559234619,2.67489433288574],[13.5339994430542,19.9700546264648,2.67389440536499],[13.6359996795654,20.1220550537109,2.67489433288574],[13.6359996795654,20.1400547027588,2.67489433288574],[13.6719989776611,20.2210559844971,2.67489433288574],[13.6899995803833,20.2300548553467,2.67489433288574],[13.7509994506836,20.3010559082031,2.67489433288574],[13.8539991378784,20.3180541992188,2.67489433288574],[14.8329992294312,18.3580551147461,2.67489433288574],[14.1849994659424,19.8530559539795,2.67489433288574],[14.0769996643066,18.7000541687012,2.67489433288574],[14.1099996566772,20.2400550842285,2.67489433288574],[14.2009992599487,19.6230545043945,2.67489433288574],[14.2729997634888,19.4670543670654,2.67489433288574],[14.3379993438721,19.3790550231934,2.67489433288574],[14.4549999237061,19.2770557403564,2.67489433288574],[14.5899991989136,19.2040557861328,2.67489433288574],[14.6079998016357,19.2040557861328,2.67489433288574],[14.7209997177124,19.1600551605225,2.67489433288574],[15.1379995346069,19.210054397583,2.67489433288574],[14.9949998855591,18.2680549621582,2.67489433288574],[15.0029993057251,19.1580543518066,2.67489433288574],[15.2369995117188,19.2760543823242,2.67489433288574],[15.3779993057251,19.4060554504395,2.67489433288574],[15.4539995193481,19.520055770874,2.67489433288574],[15.471999168396,19.52805519104,2.67489433288574],[15.5449991226196,19.5830554962158,2.67489433288574],[15.6529998779297,19.573055267334,2.67489433288574],[15.7059993743896,17.8360557556152,2.67489433288574],[15.9449996948242,18.5560550689697,2.67489433288574],[15.8589992523193,18.9380550384521,2.67489433288574],[14.9589996337891,18.2950553894043,2.67489433288574],[15.7779998779297,19.5100555419922,2.67489433288574],[14.0049991607666,20.2750549316406,2.67489433288574],[12.3489990234375,20.5000553131104,2.67489433288574],[13.0689992904663,19.0150547027588,2.67489433288574],[13.0999994277954,19.0100555419922,2.67489433288574],[15.9489994049072,19.3670558929443,9.41489505767822],[15.9489994049072,19.2490558624268,9.41489505767822],[15.75,17.8080558776855,9.41489505767822],[15.6639995574951,19.5710544586182,9.41489505767822],[15.5709991455078,17.9260559082031,9.41489505767822],[15.8769998550415,18.690055847168,9.41489505767822],[15.8499994277954,18.8170547485352,9.41489505767822],[15.9459991455078,18.5520553588867,9.41489505767822],[15.914999961853,17.6890544891357,9.41489505767822],[15.3999996185303,19.4290542602539,9.41489505767822],[15.3099994659424,19.339054107666,9.41489505767822],[15.3729991912842,18.0440559387207,9.41489505767822],[15.4579992294312,19.5170555114746,9.41489505767822],[15.5469999313354,19.5820541381836,9.41489505767822],[13.2309989929199,19.7610549926758,9.41489505767822],[13.168999671936,19.7360553741455,9.41489505767822],[13.096999168396,19.0140552520752,9.41489505767822],[13.1999988555908,18.9870548248291,9.41489505767822],[15.1399993896484,19.2080554962158,9.41489505767822],[15.0159997940063,19.1600551605225,9.41489505767822],[14.9859991073608,18.2770557403564,9.41489505767822],[15.1749992370605,18.1690559387207,9.41489505767822],[15.9039993286133,19.1320552825928,9.41489505767822],[15.8949995040894,19.4460544586182,9.41489505767822],[15.8769998550415,19.0420551300049,9.41489505767822],[12.2169990539551,20.6500549316406,9.41489505767822],[11.9379997253418,20.6810550689697,9.41489505767822],[11.8629989624023,19.2130546569824,9.41489505767822],[12.096999168396,19.1950550079346,9.41489505767822],[14.1669998168945,18.6640548706055,9.41489505767822],[14.1039991378784,20.2460556030273,9.41489505767822],[13.9849996566772,18.7360553741455,9.41489505767822],[14.7349996566772,19.1590557098389,9.41489505767822],[14.5849990844727,19.2050552368164,9.41489505767822],[14.5719995498657,18.4850559234619,9.41489505767822],[14.1939992904663,19.6760559082031,9.41489505767822],[14.1849994659424,19.9330558776855,9.41489505767822],[14.1759996414185,18.6640548706055,9.41489505767822],[14.261999130249,19.4890556335449,9.41489505767822],[14.3539991378784,19.3610553741455,9.41489505767822],[14.3559989929199,18.5830554962158,9.41489505767822],[11.6039991378784,20.1250553131104,9.41489505767822],[11.5209999084473,20.0520553588867,9.41489505767822],[11.4209995269775,19.2480545043945,9.41489505767822],[11.6989994049072,20.2690544128418,9.41389465332031],[11.7609996795654,20.4310550689697,9.41489505767822],[11.8359994888306,19.2130546569824,9.41489505767822],[14.1889991760254,20.1710548400879,9.41489505767822],[13.9689998626709,20.2840557098389,9.41489505767822],[13.8739995956421,20.315055847168,9.41489505767822],[13.7799997329712,18.8080558776855,9.41489505767822],[13.9869995117188,20.2750549316406,9.41489505767822],[12.3129997253418,20.5980548858643,9.41489505767822],[12.3399991989136,20.5090560913086,9.41489505767822],[12.3489990234375,20.3830547332764,9.41489505767822],[12.3599996566772,20.2680549621582,9.41489505767822],[12.3849992752075,20.1850547790527,9.41489505767822],[12.3849992752075,20.1670551300049,9.41489505767822],[12.4249992370605,20.065055847168,9.41489505767822],[12.4729995727539,19.1350555419922,9.41489505767822],[14.4399995803833,19.2900543212891,9.41489505767822],[14.3649997711182,18.5740547180176,9.41489505767822],[13.5729999542236,20.0310554504395,9.41489505767822],[13.4889993667603,19.9140548706055,9.41489505767822],[13.5639991760254,18.8710556030273,9.41489505767822],[13.6389999389648,20.1310558319092,9.41489505767822],[13.6719989776611,20.2130546569824,9.41489505767822],[13.75,20.3020553588867,9.41489505767822],[12.7399997711182,19.7810554504395,9.41489505767822],[12.6189994812012,19.8520545959473,9.41489505767822],[12.5799999237061,19.1200542449951,9.41489505767822],[12.8349990844727,19.069055557251,9.41489505767822],[11.2669992446899,19.9350547790527,9.41489505767822],[11.1029987335205,19.9230556488037,9.41489505767822],[11.0209999084473,19.2600555419922,9.41489505767822],[11.3819999694824,19.9710559844971,9.41489505767822],[13.418999671936,19.8530559539795,9.41489505767822],[13.4329996109009,18.9160556793213,9.41489505767822],[11.8399991989136,20.6430549621582,9.41489505767822],[13.3119993209839,19.7800559997559,9.41489505767822],[15.2189998626709,19.2600555419922,9.41489505767822],[15.1839990615845,18.1600551605225,9.41489505767822],[15.3639993667603,18.0520553588867,9.41489505767822],[13.0189990997314,19.7250556945801,9.41489505767822],[12.8949995040894,19.7350559234619,9.41489505767822],[15.9039993286133,19.1500549316406,9.41489505767822],[15.7699995040894,19.5140552520752,9.41489505767822],[15.8589992523193,18.9340553283691,9.41489505767822],[14.1939992904663,19.9510555267334,9.41489505767822],[14.2119998931885,20.0630550384521,9.41489505767822],[14.8589992523193,19.149055480957,9.41489505767822],[14.8159999847412,18.3670558929443,9.41489505767822],[14.8959999084473,18.3220558166504,9.41489505767822],[12.5189990997314,19.9360542297363,9.41489505767822],[11.0209999084473,19.9290542602539,9.41489505767822],[11.0209999084473,19.2530555725098,2.67489433288574],[11.0209999084473,19.9300556182861,2.67489433288574],[15.9799995422363,18.505931854248,5.58724021911621],[15.9799995422363,18.5044555664062,9.41489505767822],[15.9799995422363,18.5041732788086,2.67489433288574],[15.9799995422363,18.1684837341309,2.67489433288574],[15.9799995422363,18.1288299560547,9.41489505767822],[15.9799995422363,17.9876575469971,2.67489433288574],[15.9799995422363,17.6247596740723,3.91620373725891],[15.9799995422363,17.6247596740723,2.67489433288574],[15.9799995422363,17.6254329681396,4.32245063781738],[15.9799995422363,17.8920269012451,9.41489505767822],[15.9799995422363,17.8795108795166,2.67489433288574],[15.9799995422363,17.629810333252,4.58585262298584],[15.9799995422363,17.6336059570312,5.27938556671143],[15.9799995422363,17.8311748504639,2.67489433288574],[15.9799995422363,17.638355255127,9.41489505767822],[15.9799995422363,17.6346111297607,5.98653984069824],[15.9799995422363,17.8728256225586,2.67489433288574],[15.9799995422363,18.2221603393555,2.67489433288574] + ]; + $facets = [ + [0,1,2],[0,3,1],[0,4,3],[5,6,7],[8,6,5],[2,9,0],[6,10,11],[12,13,14],[15,16,17],[18,16,15],[19,20,21],[22,23,24],[25,23,22],[26,23,25],[27,23,26],[28,23,27],[29,30,31],[29,32,30],[29,28,32],[33,28,29],[33,23,28],[21,23,33],[20,23,21],[34,35,36],[37,35,34],[38,35,37],[39,35,38],[40,35,39],[41,35,40],[42,35,41],[43,35,42],[44,35,43],[45,35,44],[46,35,45],[47,35,46],[48,35,47],[49,50,51],[52,48,47],[23,49,24],[53,54,55],[56,57,58],[59,57,56],[60,57,59],[61,57,60],[62,57,61],[63,57,62],[64,57,63],[65,57,64],[66,57,65],[13,57,66],[54,67,55],[68,69,70],[71,69,68],[72,69,71],[73,69,72],[74,69,73],[75,69,74],[76,69,75],[77,69,76],[67,69,77],[70,16,68],[70,17,16],[78,79,80],[81,79,78],[82,79,81],[83,79,82],[84,79,83],[85,79,84],[86,79,85],[87,79,86],[88,8,5],[11,7,6],[11,89,7],[11,9,89],[11,0,9],[55,90,53],[55,79,90],[55,80,79],[91,11,10],[92,69,12],[92,70,69],[34,93,37],[47,94,52],[47,95,94],[47,57,95],[47,58,57],[51,24,49],[21,35,19],[21,36,35],[14,92,12],[86,10,87],[86,91,10],[77,55,67],[66,14,13],[96,97,4],[98,99,100],[101,102,98],[103,101,98],[104,103,98],[105,106,107],[108,105,107],[109,108,107],[100,109,107],[110,111,112],[113,110,112],[114,115,116],[117,114,116],[118,119,120],[121,122,123],[124,121,123],[125,126,127],[128,129,130],[131,132,133],[71,131,133],[134,71,133],[135,134,133],[136,135,133],[137,138,139],[140,137,139],[141,140,139],[142,31,141],[142,141,139],[143,126,132],[144,145,146],[147,144,146],[127,147,146],[148,121,124],[149,148,124],[150,149,124],[151,150,124],[152,151,124],[153,152,124],[154,153,124],[155,154,124],[129,156,157],[130,129,157],[158,159,160],[161,158,160],[162,161,160],[163,162,160],[146,163,160],[164,165,166],[167,164,166],[168,169,170],[171,168,170],[139,171,170],[159,172,173],[123,174,142],[175,110,113],[173,175,113],[106,176,177],[178,106,177],[179,180,167],[112,179,167],[175,173,172],[119,118,181],[119,181,97],[119,97,96],[182,98,102],[182,102,183],[182,183,120],[182,120,119],[143,132,184],[184,185,143],[147,127,126],[174,123,122],[159,173,160],[126,125,133],[126,133,132],[186,187,188],[186,188,116],[186,116,115],[99,98,182],[109,100,99],[106,178,107],[114,117,177],[114,177,176],[128,130,187],[128,187,186],[135,136,157],[135,157,156],[163,146,145],[164,167,180],[179,112,111],[171,139,138],[189,155,166],[189,166,165],[149,150,93],[154,155,189],[31,142,174],[114,176,78],[81,78,176],[7,89,183],[89,9,120],[89,120,183],[78,80,114],[176,106,81],[88,5,103],[183,102,7],[118,120,9],[9,2,181],[9,181,118],[115,114,80],[82,81,106],[101,103,5],[102,101,5],[5,7,102],[97,181,2],[2,1,97],[1,3,97],[80,55,115],[172,159,59],[59,56,172],[3,4,97],[4,0,96],[105,108,82],[186,115,55],[82,106,105],[83,82,108],[60,59,159],[175,172,56],[119,96,0],[0,11,119],[108,109,84],[84,83,108],[55,77,186],[56,58,110],[56,110,175],[60,159,158],[11,91,182],[182,119,11],[91,86,182],[85,84,109],[86,85,99],[128,186,77],[58,111,110],[158,161,60],[26,25,137],[138,137,25],[99,182,86],[109,99,85],[77,76,128],[58,47,111],[61,60,161],[137,140,26],[27,26,140],[25,22,138],[129,128,76],[76,75,129],[75,74,129],[74,73,156],[73,72,135],[68,16,184],[68,184,132],[16,18,185],[161,162,62],[62,61,161],[179,111,47],[171,138,22],[156,129,74],[135,156,73],[134,135,72],[72,71,134],[68,132,131],[185,184,16],[18,15,185],[63,62,162],[28,27,140],[22,24,171],[71,68,131],[15,17,143],[15,143,185],[17,70,143],[70,92,126],[162,163,64],[64,63,162],[180,179,47],[47,46,180],[140,141,28],[168,171,24],[126,143,70],[92,14,147],[147,126,92],[14,66,144],[14,144,147],[65,64,163],[66,65,145],[46,45,180],[32,28,141],[24,51,168],[145,144,66],[163,145,65],[164,180,45],[45,44,164],[44,43,164],[43,42,165],[38,37,151],[150,151,37],[37,93,150],[141,31,30],[30,32,141],[169,168,51],[165,164,43],[189,165,42],[42,41,189],[40,39,152],[40,152,153],[151,152,39],[39,38,151],[93,34,149],[154,189,41],[153,154,41],[41,40,153],[148,149,34],[34,36,148],[36,21,121],[31,174,29],[121,148,36],[21,33,122],[21,122,121],[33,29,122],[174,122,29],[116,188,53],[104,98,10],[87,10,98],[98,100,87],[79,87,100],[79,100,107],[90,79,107],[90,107,178],[178,177,90],[53,90,177],[53,177,117],[117,116,53],[54,53,188],[54,188,187],[67,54,187],[67,187,130],[69,67,130],[69,130,157],[12,69,157],[12,157,136],[136,133,12],[12,133,125],[125,127,12],[13,12,127],[127,146,13],[57,13,146],[57,146,160],[95,57,160],[95,160,173],[173,113,95],[94,95,113],[113,112,94],[52,94,112],[48,52,112],[112,167,48],[35,48,167],[35,167,166],[19,35,166],[139,170,50],[50,49,139],[166,155,19],[20,19,155],[155,124,20],[23,20,124],[23,124,123],[49,23,123],[49,123,142],[142,139,49],[190,191,170],[192,191,190],[191,192,51],[191,51,50],[170,169,190],[169,51,192],[169,192,190],[170,191,50],[193,194,195],[196,197,198],[199,200,201],[198,202,203],[204,201,200],[205,204,200],[206,207,208],[206,208,205],[206,205,200],[207,206,209],[207,209,203],[207,203,202],[202,198,197],[197,196,210],[197,210,195],[197,195,194],[8,88,195],[8,195,210],[210,196,8],[196,198,8],[198,203,8],[203,209,8],[209,206,8],[206,200,8],[202,197,104],[207,202,104],[103,104,197],[103,197,194],[193,195,88],[88,103,194],[88,194,193],[200,199,8],[199,201,8],[204,205,6],[6,8,201],[6,201,204],[10,6,205],[10,205,208],[104,10,208],[104,208,207] + ]; } else { return undef; } diff --git a/t/thin.t b/t/thin.t new file mode 100644 index 00000000..09b060d8 --- /dev/null +++ b/t/thin.t @@ -0,0 +1,48 @@ +use Test::More tests => 1; +use strict; +use warnings; + +BEGIN { + use FindBin; + use lib "$FindBin::Bin/../lib"; +} + +use Slic3r; +use List::Util qw(first); +use Slic3r::Geometry qw(epsilon); +use Slic3r::Test; + +{ + my $config = Slic3r::Config->new_from_defaults; + $config->set('layer_height', 0.2); + $config->set('first_layer_height', '100%'); + $config->set('extrusion_width', 0.5); + $config->set('first_layer_extrusion_width', '200%'); # check this one too + $config->set('skirts', 0); + $config->set('thin_walls', 1); + + my $print = Slic3r::Test::init_print('gt2_teeth', config => $config); + + my %extrusion_paths = (); # Z => count of continuous extrusions + my $extruding = 0; + Slic3r::GCode::Reader->new->parse(Slic3r::Test::gcode($print), sub { + my ($self, $cmd, $args, $info) = @_; + + if ($cmd eq 'G1') { + if ($info->{extruding} && $info->{dist_XY}) { + if (!$extruding) { + $extrusion_paths{$self->Z} //= 0; + $extrusion_paths{$self->Z}++; + } + $extruding = 1; + } else { + $extruding = 0; + } + } + }); + + ok !(first { $_ != 3 } values %extrusion_paths), + 'no superfluous thin walls are generated for toothed profile'; +} + +__END__ From fd6b78f7f233bd5bac2b4aa9f933195e2ca56765 Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci Date: Sun, 2 Mar 2014 00:43:54 +0100 Subject: [PATCH 35/50] Removed debugging line --- lib/Slic3r/Layer/Region.pm | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/Slic3r/Layer/Region.pm b/lib/Slic3r/Layer/Region.pm index 374e7699..f9a55a06 100644 --- a/lib/Slic3r/Layer/Region.pm +++ b/lib/Slic3r/Layer/Region.pm @@ -327,7 +327,6 @@ sub make_perimeters { role => EXTR_ROLE_EXTERNAL_PERIMETER, flow_spacing => $self->perimeter_flow->spacing, ); - printf "len = %s\n", unscale($p->length); push @paths, $p->isa('Slic3r::Polygon') ? Slic3r::ExtrusionLoop->new(polygon => $p, %params) : Slic3r::ExtrusionPath->new(polyline => $p, %params); From a712284afbdec946602c7894c0d4eb257813d9ba Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci Date: Mon, 13 Jan 2014 00:06:16 +0100 Subject: [PATCH 36/50] Add a (failing) test for slicing at the same height of a horizontal surface attached to a volume. In this case, the loop isn't completed. #1672 Conflicts: xs/t/01_trianglemesh.t --- utils/dump-stl.pl | 1 + xs/t/01_trianglemesh.t | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/utils/dump-stl.pl b/utils/dump-stl.pl index 1810d9a3..240f10b2 100644 --- a/utils/dump-stl.pl +++ b/utils/dump-stl.pl @@ -18,6 +18,7 @@ $ARGV[0] or usage(1); if (-e $ARGV[0]) { my $model = Slic3r::Format::STL->read_file($ARGV[0]); + $model->objects->[0]->add_instance(offset => [0,0]); my $mesh = $model->mesh; $mesh->repair; printf "VERTICES = %s\n", join ',', map "[$_->[0],$_->[1],$_->[2]]", @{$mesh->vertices}; diff --git a/xs/t/01_trianglemesh.t b/xs/t/01_trianglemesh.t index 127c8c92..c80d603f 100644 --- a/xs/t/01_trianglemesh.t +++ b/xs/t/01_trianglemesh.t @@ -88,4 +88,14 @@ my $cube = { } } +{ + my $m = Slic3r::TriangleMesh->new; + $m->ReadFromPerl( + [ [0,0,0],[0,0,20],[0,5,0],[0,5,20],[50,0,0],[50,0,20],[15,5,0],[35,5,0],[15,20,0],[50,5,0],[35,20,0],[15,5,10],[50,5,20],[35,5,10],[35,20,10],[15,20,10] ], + [ [0,1,2],[2,1,3],[1,0,4],[5,1,4],[0,2,4],[4,2,6],[7,6,8],[4,6,7],[9,4,7],[7,8,10],[2,3,6],[11,3,12],[7,12,9],[13,12,7],[6,3,11],[11,12,13],[3,1,5],[12,3,5],[5,4,9],[12,5,9],[13,7,10],[14,13,10],[8,15,10],[10,15,14],[6,11,8],[8,11,15],[15,11,13],[14,15,13] ], + ); + $m->repair; + my $slices = $m->slice([ 5, 10 ]); + is $slices->[0][0]->area, $slices->[1][0]->area, 'slicing a tangent plane includes its area'; +} __END__ From 2d9c399d96cbe92f64b28faa79f9d369d2c8f4fe Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci Date: Mon, 13 Jan 2014 00:45:19 +0100 Subject: [PATCH 37/50] Bugfix: incomplete slicing when a horizontal surface was tangent to the slicing plane and it shared an edge with an adjacent volume. #1672 Conflicts: xs/src/TriangleMesh.cpp --- xs/src/TriangleMesh.cpp | 32 +++++++++++++++++++++++--------- xs/src/TriangleMesh.hpp | 2 +- xs/t/01_trianglemesh.t | 6 ++++-- 3 files changed, 28 insertions(+), 12 deletions(-) diff --git a/xs/src/TriangleMesh.cpp b/xs/src/TriangleMesh.cpp index 9eae734c..bf29f72e 100644 --- a/xs/src/TriangleMesh.cpp +++ b/xs/src/TriangleMesh.cpp @@ -253,16 +253,11 @@ TriangleMesh::slice(const std::vector &z) printf("z: min = %.2f, max = %.2f\n", min_z, max_z); #endif - if (min_z == max_z) { - #ifdef SLIC3R_DEBUG - printf("Facet is horizontal; ignoring\n"); - #endif - continue; - } - + // find layer extents std::vector::const_iterator min_layer, max_layer; min_layer = std::lower_bound(z.begin(), z.end(), min_z); // first layer whose slice_z is >= min_z max_layer = std::upper_bound(z.begin() + (min_layer - z.begin()), z.end(), max_z) - 1; // last layer whose slice_z is <= max_z + /* If no layer is <= max_z, then max_layer == -1 */ #ifdef SLIC3R_DEBUG printf("layers: min = %d, max = %d\n", (int)(min_layer - z.begin()), (int)(max_layer - z.begin())); #endif @@ -298,7 +293,9 @@ TriangleMesh::slice(const std::vector &z) /* We assume that this method is never being called for horizontal facets, so no other edge is going to be on this layer. */ IntersectionLine line; - if (facet->vertex[0].z < slice_z || facet->vertex[1].z < slice_z || facet->vertex[2].z < slice_z) { + if (min_z == max_z) { + line.edge_type = feHorizontal; + } else if (facet->vertex[0].z < slice_z || facet->vertex[1].z < slice_z || facet->vertex[2].z < slice_z) { line.edge_type = feTop; std::swap(a, b); std::swap(a_id, b_id); @@ -314,7 +311,10 @@ TriangleMesh::slice(const std::vector &z) lines[layer_idx].push_back(line); found_horizontal_edge = true; - break; + + // if this is a top or bottom edge, we can stop looping through edges + // because we won't find anything interesting + if (line.edge_type != feHorizontal) break; } else if (a->z == slice_z) { IntersectionPoint point; point.x = a->x; @@ -375,6 +375,13 @@ TriangleMesh::slice(const std::vector &z) printf("Layer %d:\n", layer_idx); #endif + /* + SVG svg("lines.svg"); + for (IntersectionLines::iterator line = it->begin(); line != it->end(); ++line) + svg.AddLine(*line); + svg.Close(); + */ + // remove tangent edges for (IntersectionLines::iterator line = it->begin(); line != it->end(); ++line) { if (line->skip || line->edge_type == feNone) continue; @@ -398,6 +405,13 @@ TriangleMesh::slice(const std::vector &z) line->skip = true; break; } + } else if (line->a_id == line2->b_id && line->b_id == line2->a_id) { + /* if this edge joins two horizontal facets, remove both of them */ + if (line->edge_type == feHorizontal && line2->edge_type == feHorizontal) { + line->skip = true; + line2->skip = true; + break; + } } } } diff --git a/xs/src/TriangleMesh.hpp b/xs/src/TriangleMesh.hpp index d341fa09..e96b1741 100644 --- a/xs/src/TriangleMesh.hpp +++ b/xs/src/TriangleMesh.hpp @@ -40,7 +40,7 @@ class TriangleMesh #endif }; -enum FacetEdgeType { feNone, feTop, feBottom }; +enum FacetEdgeType { feNone, feTop, feBottom, feHorizontal }; class IntersectionPoint : public Point { diff --git a/xs/t/01_trianglemesh.t b/xs/t/01_trianglemesh.t index c80d603f..4a88cff2 100644 --- a/xs/t/01_trianglemesh.t +++ b/xs/t/01_trianglemesh.t @@ -4,7 +4,8 @@ use strict; use warnings; use Slic3r::XS; -use Test::More tests => 52; +use List::Util qw(sum); +use Test::More tests => 53; is Slic3r::TriangleMesh::hello_world(), 'Hello world!', 'hello world'; @@ -96,6 +97,7 @@ my $cube = { ); $m->repair; my $slices = $m->slice([ 5, 10 ]); - is $slices->[0][0]->area, $slices->[1][0]->area, 'slicing a tangent plane includes its area'; + is sum(map $_->area, @{$slices->[0]}), sum(map $_->area, @{$slices->[1]}), + 'slicing a tangent plane includes its area'; } __END__ From 280a1a369eb832636fec775f06ffaac462953ade Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci Date: Sun, 23 Mar 2014 19:17:02 +0100 Subject: [PATCH 38/50] Bugfix: binary STL export produced corrupt results on Windows. #1814 --- xs/src/admesh/stl_io.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xs/src/admesh/stl_io.c b/xs/src/admesh/stl_io.c index daa999b8..95dff856 100644 --- a/xs/src/admesh/stl_io.c +++ b/xs/src/admesh/stl_io.c @@ -249,7 +249,7 @@ stl_write_binary(stl_file *stl, const char *file, const char *label) /* Open the file */ - fp = fopen(file, "w"); + fp = fopen(file, "wb"); if(fp == NULL) { error_msg = (char*) From 96ad37f6e00b5e32790e2082dc3911756e2c0358 Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci Date: Sun, 23 Mar 2014 19:44:14 +0100 Subject: [PATCH 39/50] Bugfix: holes were not sorted using the nearest-neighbor search, resulting in inefficient paths. #1785 --- lib/Slic3r/Layer/Region.pm | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/Slic3r/Layer/Region.pm b/lib/Slic3r/Layer/Region.pm index f9a55a06..b815e45d 100644 --- a/lib/Slic3r/Layer/Region.pm +++ b/lib/Slic3r/Layer/Region.pm @@ -261,6 +261,12 @@ sub make_perimeters { $i--; } } + + # order holes efficiently + @holes = @{Slic3r::Geometry::chained_path_items( + [ map [ ($_->{outer} // $_->{hole})->first_point, $_ ], @holes ], + )}; + push @loops, reverse map $traverse->([$_], 0), @holes; } push @loops, $traverse->($polynode->{children}, $depth+1, $is_contour); From bf1fd0cf9a4826dd3c34f421a50336931eefb6f3 Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci Date: Mon, 24 Mar 2014 16:37:20 +0100 Subject: [PATCH 40/50] Bugfix: prevent crash when user entered Unicode characters in notes. #1590 --- lib/Slic3r/Print.pm | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/Slic3r/Print.pm b/lib/Slic3r/Print.pm index a84ba70c..15851bad 100644 --- a/lib/Slic3r/Print.pm +++ b/lib/Slic3r/Print.pm @@ -704,6 +704,9 @@ sub write_gcode { or die "Failed to open $file for writing\n"; } + # enable UTF-8 output since user might have entered Unicode characters in fields like notes + binmode $fh, ':utf8'; + # write some information my @lt = localtime; printf $fh "; generated by Slic3r $Slic3r::VERSION on %04d-%02d-%02d at %02d:%02d:%02d\n\n", From 2a52a318fe9ae37b0844a25a37ea03825142bc80 Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci Date: Mon, 24 Mar 2014 17:02:25 +0100 Subject: [PATCH 41/50] Error in previous commit: Bugfix: prevent crash when user entered Unicode characters in notes. #1590 --- lib/Slic3r/Print.pm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/Slic3r/Print.pm b/lib/Slic3r/Print.pm index 15851bad..094b0951 100644 --- a/lib/Slic3r/Print.pm +++ b/lib/Slic3r/Print.pm @@ -702,11 +702,11 @@ sub write_gcode { } else { Slic3r::open(\$fh, ">", $file) or die "Failed to open $file for writing\n"; + + # enable UTF-8 output since user might have entered Unicode characters in fields like notes + binmode $fh, ':utf8'; } - # enable UTF-8 output since user might have entered Unicode characters in fields like notes - binmode $fh, ':utf8'; - # write some information my @lt = localtime; printf $fh "; generated by Slic3r $Slic3r::VERSION on %04d-%02d-%02d at %02d:%02d:%02d\n\n", From 630004d15614f61a5e85dcd4d6449cc84c88a126 Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci Date: Mon, 24 Mar 2014 19:56:18 +0100 Subject: [PATCH 42/50] Bugfix: wrong inwards moves were calculated for 2+ copies because ExtrusionLoop objects were modified in place. Includes regression test. #1842 --- lib/Slic3r/GCode.pm | 4 ++++ t/perimeters.t | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/lib/Slic3r/GCode.pm b/lib/Slic3r/GCode.pm index da973186..cbac719b 100644 --- a/lib/Slic3r/GCode.pm +++ b/lib/Slic3r/GCode.pm @@ -175,6 +175,10 @@ sub extrude { sub extrude_loop { my ($self, $loop, $description) = @_; + # make a copy; don't modify the orientation of the original loop object otherwise + # next copies (if any) would not detect the correct orientation + $loop = $loop->clone; + # extrude all loops ccw my $was_clockwise = $loop->make_counter_clockwise; my $polygon = $loop->polygon; diff --git a/t/perimeters.t b/t/perimeters.t index eeb0b404..8cdf2473 100644 --- a/t/perimeters.t +++ b/t/perimeters.t @@ -43,6 +43,7 @@ use Slic3r::Test; { $config->set('external_perimeter_speed', 68); + $config->set('duplicate', 2); # we test two copies to make sure ExtrusionLoop objects are not modified in-place (the second object would not detect cw loops and thus would calculate wrong inwards moves) my $print = Slic3r::Test::init_print('cube_with_hole', config => $config); my $has_cw_loops = my $has_outwards_move = 0; my $cur_loop; @@ -58,6 +59,11 @@ use Slic3r::Test; $has_cw_loops = 1 if Slic3r::Polygon->new_scale(@$cur_loop)->is_clockwise; if ($self->F == $config->external_perimeter_speed*60) { my $move_dest = Slic3r::Point->new_scale(@$info{qw(new_X new_Y)}); + + # reset counter for second object + $external_loops{$self->Z} = 0 + if defined($external_loops{$self->Z}) && $external_loops{$self->Z} == 2; + $external_loops{$self->Z}++; $has_outwards_move = 1 if !Slic3r::Polygon->new_scale(@$cur_loop)->encloses_point($move_dest) From 97d9c9f5e70972f40326af2d847018066b4a6d4b Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci Date: Thu, 27 Mar 2014 11:18:48 +0100 Subject: [PATCH 43/50] Releasing 1.0.0 --- lib/Slic3r.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Slic3r.pm b/lib/Slic3r.pm index 6047e070..915ff5a2 100644 --- a/lib/Slic3r.pm +++ b/lib/Slic3r.pm @@ -7,7 +7,7 @@ use strict; use warnings; require v5.10; -our $VERSION = "1.0.0RC3"; +our $VERSION = "1.0.0"; our $debug = 0; sub debugf { From 2ac3b1fba9e1d72c3565567828cb3ebc1c42a575 Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci Date: Wed, 9 Apr 2014 18:43:48 +0200 Subject: [PATCH 44/50] Support the percent format for fill_density introduced in 1.1.x (forward compatibility). #1880 --- lib/Slic3r/Config.pm | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/Slic3r/Config.pm b/lib/Slic3r/Config.pm index d6a7db1c..880f13d4 100644 --- a/lib/Slic3r/Config.pm +++ b/lib/Slic3r/Config.pm @@ -1279,6 +1279,9 @@ sub set { if ($opt_key eq 'gcode_flavor' && $value eq 'makerbot') { $value = 'makerware'; } + if ($opt_key eq 'fill_density' && $value =~ /^(.+?)%$/) { + $value = $1/100; + } # For historical reasons, the world's full of configs having these very low values; # to avoid unexpected behavior we need to ignore them. Banning these two hard-coded From 859bf46401b1bb5e94ed12662d63be7a79514073 Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci Date: Fri, 11 Apr 2014 23:10:14 +0200 Subject: [PATCH 45/50] Bugfix: sometimes a tiny gap was left between infill and perimeters. Includes regression test. #1803 --- lib/Slic3r/Layer/Region.pm | 1 + t/perimeters.t | 42 ++++++++++++++++++++++++++++++++++++-- 2 files changed, 41 insertions(+), 2 deletions(-) diff --git a/lib/Slic3r/Layer/Region.pm b/lib/Slic3r/Layer/Region.pm index b815e45d..a6fc1e90 100644 --- a/lib/Slic3r/Layer/Region.pm +++ b/lib/Slic3r/Layer/Region.pm @@ -192,6 +192,7 @@ sub make_perimeters { my $diff = diff_ex( offset(\@last, -0.5*$pspacing), offset(\@offsets, +0.5*$pspacing), + 1, ); push @gaps, @last_gaps = grep abs($_->area) >= $gap_area_threshold, @$diff; } diff --git a/t/perimeters.t b/t/perimeters.t index 8cdf2473..e9e1aa0c 100644 --- a/t/perimeters.t +++ b/t/perimeters.t @@ -1,4 +1,4 @@ -use Test::More tests => 6; +use Test::More tests => 7; use strict; use warnings; @@ -8,7 +8,9 @@ BEGIN { } use Slic3r; -use Slic3r::Geometry qw(PI); +use Slic3r::Geometry qw(PI scale); +use Slic3r::Geometry::Clipper qw(union_ex diff union offset); +use Slic3r::Surface ':types'; use Slic3r::Test; { @@ -174,4 +176,40 @@ use Slic3r::Test; ok !(grep { $_ % $config->perimeters } values %perimeters), 'no superfluous extra perimeters'; } +{ + my $config = Slic3r::Config->new_from_defaults; + $config->set('perimeters', 2); + $config->set('perimeter_extrusion_width', 0.4); + + # we just need a pre-filled Print object + my $print = Slic3r::Test::init_print('20mm_cube', config => $config); + $print->init_extruders; + + # override a layer's slices + my $expolygon = Slic3r::ExPolygon->new([[43000000,0],[43025538,621],[43268205,12545],[43293449,14390],[43317871,17354],[43558753,53080],[43582517,57102],[43620621,66007],[43858200,125524],[43894754,137108],[44126456,220007],[44161408,234134],[44385058,339915],[44418218,356416],[44631631,484329],[44676243,512138],[44877834,661647],[44917594,693352],[45105199,863384],[45121323,878678],[45292005,1067001],[45331421,1112662],[45481223,1314648],[45515660,1368372],[45643575,1581787],[45749961,1806713],[45779081,1871040],[45862012,2102826],[45873905,2139747],[45933434,2377381],[45942897,2417481],[45946921,2441244],[45982644,2682128],[45985606,2706543],[45987451,2731792],[46000632,3000000],[50999999,3000000],[51242592,3011921],[51294051,3014450],[51345014,3022008],[51585267,3057639],[51635243,3070158],[51870848,3129180],[51919357,3146535],[52148048,3228360],[52194623,3250389],[52414191,3354239],[52622517,3479104],[52666708,3505589],[52708089,3536280],[52903180,3680970],[52941354,3715568],[53121323,3878679],[53155922,3916854],[53319031,4096819],[53349722,4138202],[53494408,4333290],[53619272,4541617],[53645760,4585809],[53667788,4632383],[53771640,4851949],[53788995,4900458],[53870820,5129149],[53883338,5179125],[53942360,5414730],[53949916,5465692],[53985548,5705950],[53997469,5948540],[54000000,6000000],[54000000,32000000],[53988076,32242592],[53985548,32294051],[53977989,32345015],[53942360,32585269],[53929840,32635245],[53870819,32870850],[53853463,32919358],[53771639,33148048],[53749610,33194623],[53645760,33414191],[53520893,33622517],[53494407,33666708],[53463717,33708089],[53319031,33903180],[53284433,33941353],[53121323,34121320],[53083147,34155919],[52903180,34319031],[52861796,34349722],[52666708,34494408],[52458382,34619272],[52414192,34645759],[52367615,34667789],[52148048,34771640],[52099538,34788995],[51870847,34870820],[51820870,34883339],[51585267,34942360],[51534305,34949916],[51294052,34985547],[51051459,34997469],[50999999,35000000],[46000632,35000000],[45987450,35268206],[45985607,35293449],[45982642,35317872],[45946919,35558753],[45942897,35582516],[45933991,35620621],[45874476,35858201],[45862890,35894754],[45779990,36126456],[45765864,36161407],[45660083,36385058],[45643581,36418219],[45515668,36631630],[45487858,36676244],[45338352,36877834],[45306647,36917594],[45136618,37105198],[45121324,37121323],[44932998,37292005],[44887337,37331422],[44685348,37481223],[44631625,37515660],[44418214,37643574],[44193284,37749961],[44128955,37779082],[43897172,37862011],[43860250,37873905],[43622616,37933434],[43582516,37942897],[43558752,37946921],[43317871,37982644],[43293456,37985606],[43268208,37987450],[43025539,37999377],[42999999,38000000],[11000000,38000000],[10974460,37999377],[10731793,37987450],[10706552,37985607],[10682127,37982642],[10441244,37946920],[10417480,37942896],[10379374,37933990],[10141796,37874476],[10105243,37862890],[9873541,37779990],[9838588,37765863],[9614941,37660082],[9581782,37643582],[9368365,37515667],[9323752,37487858],[9122165,37338352],[9082405,37306647],[8894803,37136618],[8878678,37121323],[8707995,36932999],[8668577,36887336],[8518773,36685348],[8484336,36631625],[8356425,36418214],[8250036,36193284],[8220917,36128956],[8137988,35897172],[8126094,35860250],[8066563,35622615],[8057101,35582516],[8053078,35558753],[8017352,35317871],[8014390,35293456],[8012545,35268207],[7999365,35000000],[2999999,35000000],[2757408,34988077],[2705948,34985547],[2654986,34977990],[2414730,34942360],[2302727,34914301],[2302727,34914302],[2129149,34870819],[2080639,34853462],[1851949,34771640],[1805374,34749610],[1585808,34645759],[1377480,34520893],[1333289,34494407],[1291907,34463716],[1096820,34319032],[1058646,34284432],[878678,34121319],[844080,34083145],[680969,33903180],[650276,33861796],[505589,33666707],[380725,33458381],[354240,33414192],[332211,33367616],[228358,33148047],[211002,33099537],[129180,32870850],[116660,32820872],[57640,32585270],[50080,32534305],[14450,32294051],[2528,32051459],[0,31999999],[0,6000000],[11920,5757408],[14450,5705949],[22008,5654985],[57639,5414730],[70159,5364752],[129180,5129150],[146537,5080639],[228358,4851949],[236877,4833939],[354239,4585809],[479104,4377479],[505590,4333289],[536280,4291907],[680969,4096819],[715567,4058645],[878679,3878679],[916854,3844080],[1096819,3680970],[1138202,3650277],[1333290,3505590],[1541617,3380726],[1585809,3354239],[1632384,3332210],[1851948,3228360],[1900459,3211002],[2129149,3129180],[2179125,3116660],[2414730,3057640],[2465693,3050080],[2705949,3014449],[2948540,3002528],[3000000,3000000],[7999365,3000000],[8012545,2731794],[8014390,2706550],[8017355,2682127],[8053080,2441243],[8057101,2417481],[8066007,2379375],[8125524,2141796],[8137108,2105243],[8220008,1873540],[8234134,1838589],[8339915,1614942],[8356417,1581780],[8484328,1368366],[8512139,1323752],[8661647,1122165],[8693352,1082405],[8863384,894802],[8878679,878678],[9067000,707995],[9112663,668577],[9314647,518774],[9368373,484336],[9581787,356425],[9806712,250038],[9871041,220917],[10102825,137987],[10139746,126094],[10377381,66564],[10417481,57102],[10441244,53077],[10682128,17352],[10706544,14390],[10731792,12546],[10974459,621],[10999999,0]],[[10000000,2000000],[10000000,36000000],[44000000,36000000],[44000000,2000000]],[[46000000,8000000],[46000000,30000000],[50008820,30000000],[50008820,8000000]],[[3991180,8000000],[3991180,30000000],[8000000,30000000],[8000000,8000000]]); + my $layer = $print->objects->[0]->layers->[1]; + my $layerm = $layer->region(0); + $layerm->slices->clear; + $layerm->slices->append(Slic3r::Surface->new(surface_type => S_TYPE_INTERNAL, expolygon => $expolygon)); + + # make perimeters + $layer->make_perimeters; + + # We subtract the area covered by infill and gap fill from the expolygon area. + # This should coincide with the area covered by perimeters. This test ensures + # no additional unfilled gap is added between perimeters and infill. This could + # happen when gap detection didn't use safety offset and narrow polygons were + # detected as gaps (but failed to be infilled of course). GH #1803 + my $non_fill = diff( + \@$expolygon, + [ + (map $_->p, @{$layerm->fill_surfaces}), + @{union([ map $_->polyline->grow(scale $_->flow_spacing/2), @{$layerm->thin_fills} ])}, + ] + ); + + my $pflow = $layerm->perimeter_flow; + ok scalar(@{$non_fill = offset($non_fill, -$pflow->scaled_width*1.1)}) <= 4, 'no gap between perimeters and infill'; +} + __END__ From a0133ba093ee154088d30eb0c018b78df4df7905 Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci Date: Fri, 18 Apr 2014 21:40:27 +0200 Subject: [PATCH 46/50] Fixed regression in --infill-only-where-needed. Includes a minimal test suite for such feature. #1871 --- lib/Slic3r/Print/Object.pm | 5 ++-- lib/Slic3r/Test.pm | 7 ++++++ t/fill.t | 51 +++++++++++++++++++++++++++++++++----- 3 files changed, 55 insertions(+), 8 deletions(-) diff --git a/lib/Slic3r/Print/Object.pm b/lib/Slic3r/Print/Object.pm index 9c20da09..785344d7 100644 --- a/lib/Slic3r/Print/Object.pm +++ b/lib/Slic3r/Print/Object.pm @@ -411,7 +411,7 @@ sub clip_fill_surfaces { # We only want infill under ceilings; this is almost like an # internal support material. - my $additional_margin = scale 3; + my $additional_margin = scale 3*0; my $overhangs = []; # arrayref of polygons for my $layer_id (reverse 0..$#{$self->layers}) { @@ -450,10 +450,11 @@ sub clip_fill_surfaces { # (thus we also consider perimeters) if ($layer_id > 0) { my $solid = diff( - [ map @$_, @{$layer->slices} ], + [ map $_->p, map @{$_->fill_surfaces}, @{$layer->regions} ], [ map $_->p, @layer_internal ], ); $overhangs = offset($solid, +$additional_margin); + push @$overhangs, map $_->p, @new_internal; # propagate upper overhangs } } diff --git a/lib/Slic3r/Test.pm b/lib/Slic3r/Test.pm index 3b547482..b7ea6171 100644 --- a/lib/Slic3r/Test.pm +++ b/lib/Slic3r/Test.pm @@ -90,6 +90,13 @@ sub model { $facets = [ [0,1,2],[0,3,1],[0,4,3],[5,6,7],[8,6,5],[2,9,0],[6,10,11],[12,13,14],[15,16,17],[18,16,15],[19,20,21],[22,23,24],[25,23,22],[26,23,25],[27,23,26],[28,23,27],[29,30,31],[29,32,30],[29,28,32],[33,28,29],[33,23,28],[21,23,33],[20,23,21],[34,35,36],[37,35,34],[38,35,37],[39,35,38],[40,35,39],[41,35,40],[42,35,41],[43,35,42],[44,35,43],[45,35,44],[46,35,45],[47,35,46],[48,35,47],[49,50,51],[52,48,47],[23,49,24],[53,54,55],[56,57,58],[59,57,56],[60,57,59],[61,57,60],[62,57,61],[63,57,62],[64,57,63],[65,57,64],[66,57,65],[13,57,66],[54,67,55],[68,69,70],[71,69,68],[72,69,71],[73,69,72],[74,69,73],[75,69,74],[76,69,75],[77,69,76],[67,69,77],[70,16,68],[70,17,16],[78,79,80],[81,79,78],[82,79,81],[83,79,82],[84,79,83],[85,79,84],[86,79,85],[87,79,86],[88,8,5],[11,7,6],[11,89,7],[11,9,89],[11,0,9],[55,90,53],[55,79,90],[55,80,79],[91,11,10],[92,69,12],[92,70,69],[34,93,37],[47,94,52],[47,95,94],[47,57,95],[47,58,57],[51,24,49],[21,35,19],[21,36,35],[14,92,12],[86,10,87],[86,91,10],[77,55,67],[66,14,13],[96,97,4],[98,99,100],[101,102,98],[103,101,98],[104,103,98],[105,106,107],[108,105,107],[109,108,107],[100,109,107],[110,111,112],[113,110,112],[114,115,116],[117,114,116],[118,119,120],[121,122,123],[124,121,123],[125,126,127],[128,129,130],[131,132,133],[71,131,133],[134,71,133],[135,134,133],[136,135,133],[137,138,139],[140,137,139],[141,140,139],[142,31,141],[142,141,139],[143,126,132],[144,145,146],[147,144,146],[127,147,146],[148,121,124],[149,148,124],[150,149,124],[151,150,124],[152,151,124],[153,152,124],[154,153,124],[155,154,124],[129,156,157],[130,129,157],[158,159,160],[161,158,160],[162,161,160],[163,162,160],[146,163,160],[164,165,166],[167,164,166],[168,169,170],[171,168,170],[139,171,170],[159,172,173],[123,174,142],[175,110,113],[173,175,113],[106,176,177],[178,106,177],[179,180,167],[112,179,167],[175,173,172],[119,118,181],[119,181,97],[119,97,96],[182,98,102],[182,102,183],[182,183,120],[182,120,119],[143,132,184],[184,185,143],[147,127,126],[174,123,122],[159,173,160],[126,125,133],[126,133,132],[186,187,188],[186,188,116],[186,116,115],[99,98,182],[109,100,99],[106,178,107],[114,117,177],[114,177,176],[128,130,187],[128,187,186],[135,136,157],[135,157,156],[163,146,145],[164,167,180],[179,112,111],[171,139,138],[189,155,166],[189,166,165],[149,150,93],[154,155,189],[31,142,174],[114,176,78],[81,78,176],[7,89,183],[89,9,120],[89,120,183],[78,80,114],[176,106,81],[88,5,103],[183,102,7],[118,120,9],[9,2,181],[9,181,118],[115,114,80],[82,81,106],[101,103,5],[102,101,5],[5,7,102],[97,181,2],[2,1,97],[1,3,97],[80,55,115],[172,159,59],[59,56,172],[3,4,97],[4,0,96],[105,108,82],[186,115,55],[82,106,105],[83,82,108],[60,59,159],[175,172,56],[119,96,0],[0,11,119],[108,109,84],[84,83,108],[55,77,186],[56,58,110],[56,110,175],[60,159,158],[11,91,182],[182,119,11],[91,86,182],[85,84,109],[86,85,99],[128,186,77],[58,111,110],[158,161,60],[26,25,137],[138,137,25],[99,182,86],[109,99,85],[77,76,128],[58,47,111],[61,60,161],[137,140,26],[27,26,140],[25,22,138],[129,128,76],[76,75,129],[75,74,129],[74,73,156],[73,72,135],[68,16,184],[68,184,132],[16,18,185],[161,162,62],[62,61,161],[179,111,47],[171,138,22],[156,129,74],[135,156,73],[134,135,72],[72,71,134],[68,132,131],[185,184,16],[18,15,185],[63,62,162],[28,27,140],[22,24,171],[71,68,131],[15,17,143],[15,143,185],[17,70,143],[70,92,126],[162,163,64],[64,63,162],[180,179,47],[47,46,180],[140,141,28],[168,171,24],[126,143,70],[92,14,147],[147,126,92],[14,66,144],[14,144,147],[65,64,163],[66,65,145],[46,45,180],[32,28,141],[24,51,168],[145,144,66],[163,145,65],[164,180,45],[45,44,164],[44,43,164],[43,42,165],[38,37,151],[150,151,37],[37,93,150],[141,31,30],[30,32,141],[169,168,51],[165,164,43],[189,165,42],[42,41,189],[40,39,152],[40,152,153],[151,152,39],[39,38,151],[93,34,149],[154,189,41],[153,154,41],[41,40,153],[148,149,34],[34,36,148],[36,21,121],[31,174,29],[121,148,36],[21,33,122],[21,122,121],[33,29,122],[174,122,29],[116,188,53],[104,98,10],[87,10,98],[98,100,87],[79,87,100],[79,100,107],[90,79,107],[90,107,178],[178,177,90],[53,90,177],[53,177,117],[117,116,53],[54,53,188],[54,188,187],[67,54,187],[67,187,130],[69,67,130],[69,130,157],[12,69,157],[12,157,136],[136,133,12],[12,133,125],[125,127,12],[13,12,127],[127,146,13],[57,13,146],[57,146,160],[95,57,160],[95,160,173],[173,113,95],[94,95,113],[113,112,94],[52,94,112],[48,52,112],[112,167,48],[35,48,167],[35,167,166],[19,35,166],[139,170,50],[50,49,139],[166,155,19],[20,19,155],[155,124,20],[23,20,124],[23,124,123],[49,23,123],[49,123,142],[142,139,49],[190,191,170],[192,191,190],[191,192,51],[191,51,50],[170,169,190],[169,51,192],[169,192,190],[170,191,50],[193,194,195],[196,197,198],[199,200,201],[198,202,203],[204,201,200],[205,204,200],[206,207,208],[206,208,205],[206,205,200],[207,206,209],[207,209,203],[207,203,202],[202,198,197],[197,196,210],[197,210,195],[197,195,194],[8,88,195],[8,195,210],[210,196,8],[196,198,8],[198,203,8],[203,209,8],[209,206,8],[206,200,8],[202,197,104],[207,202,104],[103,104,197],[103,197,194],[193,195,88],[88,103,194],[88,194,193],[200,199,8],[199,201,8],[204,205,6],[6,8,201],[6,201,204],[10,6,205],[10,205,208],[104,10,208],[104,208,207] ]; + } elsif ($model_name eq 'pyramid') { + $vertices = [ + [10,10,40],[0,0,0],[20,0,0],[20,20,0],[0,20,0], + ]; + $facets = [ + [0,1,2],[0,3,4],[3,1,4],[1,3,2],[3,0,2],[4,1,0], + ]; } else { return undef; } diff --git a/t/fill.t b/t/fill.t index 0a5a0a72..67dd6be1 100644 --- a/t/fill.t +++ b/t/fill.t @@ -2,18 +2,18 @@ use Test::More; use strict; use warnings; -plan tests => 42; +plan tests => 43; BEGIN { use FindBin; use lib "$FindBin::Bin/../lib"; } -use List::Util qw(first); +use List::Util qw(first sum); use Math::ConvexHull::MonotoneChain qw(convex_hull); use Slic3r; -use Slic3r::Geometry qw(scale X Y); -use Slic3r::Geometry::Clipper qw(union diff_ex); +use Slic3r::Geometry qw(scale unscale X Y); +use Slic3r::Geometry::Clipper qw(union diff_ex offset); use Slic3r::Surface qw(:types); use Slic3r::Test; @@ -190,8 +190,47 @@ for my $pattern (qw(rectilinear honeycomb hilbertcurve concentric)) { { my $config = Slic3r::Config->new_from_defaults; $config->set('infill_only_where_needed', 1); - my $print = Slic3r::Test::init_print('20mm_cube', config => $config); - ok my $gcode = Slic3r::Test::gcode($print), "successful G-code generation when infill_only_where_needed is set"; + $config->set('bottom_solid_layers', 0); + $config->set('infill_extruder', 2); + $config->set('infill_extrusion_width', 0.5); + $config->set('cooling', 0); # for preventing speeds from being altered + $config->set('first_layer_speed', '100%'); # for preventing speeds from being altered + + my $test = sub { + my $print = Slic3r::Test::init_print('pyramid', config => $config); + + my $tool = undef; + my @infill_extrusions = (); # array of polylines + Slic3r::GCode::Reader->new->parse(Slic3r::Test::gcode($print), sub { + my ($self, $cmd, $args, $info) = @_; + + if ($cmd =~ /^T(\d+)/) { + $tool = $1; + } elsif ($cmd eq 'G1' && $info->{extruding} && $info->{dist_XY} > 0) { + if ($tool == $config->infill_extruder-1) { + push @infill_extrusions, Slic3r::Line->new_scale( + [ $self->X, $self->Y ], + [ $info->{new_X}, $info->{new_Y} ], + ); + } + } + }); + return 0 if !@infill_extrusions; # prevent calling convex_hull() with no points + + my $convex_hull = Slic3r::Polygon->new(@{convex_hull([ map $_->pp, map @$_, @infill_extrusions ])}); + + return unscale unscale sum(map $_->area, @{offset([$convex_hull], scale(+$config->infill_extrusion_width/2))}); + }; + + my $tolerance = 5; # mm^2 + + $config->set('solid_infill_below_area', 0); + ok $test->() < $tolerance, + 'no infill is generated when using infill_only_where_needed on a pyramid'; + + $config->set('solid_infill_below_area', 70); + ok abs($test->() - $config->solid_infill_below_area) < $tolerance, + 'infill is only generated under the forced solid shells'; } { From 46191bf254014cd929459bca818b226e283f030f Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci Date: Sat, 19 Apr 2014 17:03:43 +0200 Subject: [PATCH 47/50] Upgrade ExtUtils::ParseXS dependency because 3.18_04 was removed from CPAN --- Build.PL | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/Build.PL b/Build.PL index f7117e66..9c251240 100644 --- a/Build.PL +++ b/Build.PL @@ -10,6 +10,7 @@ my %prereqs = qw( Boost::Geometry::Utils 0.15 Encode::Locale 0 ExtUtils::MakeMaker 6.80 + ExtUtils::ParseXS 3.22 File::Basename 0 File::Spec 0 Getopt::Long 0 @@ -122,10 +123,6 @@ EOF } if (!$gui) { - # temporarily require this dev version until this upstream bug - # is resolved: https://rt.cpan.org/Ticket/Display.html?id=86367 - system $cpanm, 'SMUELLER/ExtUtils-ParseXS-3.18_04.tar.gz'; - # clean xs directory before reinstalling, to make sure Build is called # with current perl binary if (-e './xs/Build') { From 370df56f732598a9de9db6966f517c552470cebb Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci Date: Tue, 22 Apr 2014 11:59:01 +0200 Subject: [PATCH 48/50] Bugfix: version check caused crash --- lib/Slic3r/GUI.pm | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/Slic3r/GUI.pm b/lib/Slic3r/GUI.pm index 9388ff90..89706149 100644 --- a/lib/Slic3r/GUI.pm +++ b/lib/Slic3r/GUI.pm @@ -334,6 +334,7 @@ sub check_version { } else { Slic3r::GUI::show_error(undef, "Failed to check for updates. Try later.") if $p{manual}; } + Slic3r::thread_cleanup(); })->detach; } From 138c16963431f0a6a2094b7ef3a15c28f94ed2a5 Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci Date: Tue, 22 Apr 2014 12:03:19 +0200 Subject: [PATCH 49/50] Releasing 1.0.1 --- lib/Slic3r.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Slic3r.pm b/lib/Slic3r.pm index 915ff5a2..c4c818ad 100644 --- a/lib/Slic3r.pm +++ b/lib/Slic3r.pm @@ -7,7 +7,7 @@ use strict; use warnings; require v5.10; -our $VERSION = "1.0.0"; +our $VERSION = "1.0.1"; our $debug = 0; sub debugf { From 83435aebb4484b6da9dd8fe9586912fa2b7d73f5 Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci Date: Wed, 30 Apr 2014 14:42:08 +0200 Subject: [PATCH 50/50] Make sure spiral vase mode is not enabled for multi-island layers. #1938 Conflicts: lib/Slic3r/GCode/Layer.pm t/shells.t --- lib/Slic3r/GCode/Layer.pm | 2 ++ lib/Slic3r/Test.pm | 7 +++++++ t/shells.t | 39 ++++++++++++++++++++++++++++++++++++--- 3 files changed, 45 insertions(+), 3 deletions(-) diff --git a/lib/Slic3r/GCode/Layer.pm b/lib/Slic3r/GCode/Layer.pm index 0745b070..11e31586 100644 --- a/lib/Slic3r/GCode/Layer.pm +++ b/lib/Slic3r/GCode/Layer.pm @@ -51,6 +51,8 @@ sub process_layer { ($layer->id > 0 || $Slic3r::Config->brim_width == 0) && ($layer->id >= $Slic3r::Config->skirt_height) && ($layer->id >= $Slic3r::Config->bottom_solid_layers) + && !defined(first { @{$_->perimeters} > 1 } @{$layer->regions}) + && !defined(first { @{$_->fills} > 0 } @{$layer->regions}) ); } diff --git a/lib/Slic3r/Test.pm b/lib/Slic3r/Test.pm index b7ea6171..25ba2f9e 100644 --- a/lib/Slic3r/Test.pm +++ b/lib/Slic3r/Test.pm @@ -97,6 +97,13 @@ sub model { $facets = [ [0,1,2],[0,3,4],[3,1,4],[1,3,2],[3,0,2],[4,1,0], ]; + } elsif ($model_name eq 'two_hollow_squares') { + $vertices = [ + [66.7133483886719,104.286666870117,0],[66.7133483886719,95.7133331298828,0],[65.6666870117188,94.6666717529297,0],[75.2866821289062,95.7133331298828,0],[76.3333435058594,105.333335876465,0],[76.3333435058594,94.6666717529297,0],[65.6666870117188,105.33332824707,0],[75.2866821289062,104.286666870117,0],[71.1066818237305,104.58666229248,2.79999995231628],[66.4133529663086,104.58666229248,2.79999995231628],[75.5866851806641,104.58666229248,2.79999995231628],[66.4133529663086,99.8933334350586,2.79999995231628],[66.4133529663086,95.4133377075195,2.79999995231628],[71.1066818237305,95.4133377075195,2.79999995231628],[75.5866851806641,95.4133377075195,2.79999995231628],[75.5866851806641,100.106666564941,2.79999995231628],[74.5400161743164,103.540000915527,2.79999995231628],[70.0320129394531,103.540000915527,2.79999995231628],[67.4600067138672,103.540000915527,2.79999995231628],[67.4600067138672,100.968002319336,2.79999995231628],[67.4600067138672,96.4599990844727,2.79999995231628],[74.5400161743164,99.0319976806641,2.79999995231628],[74.5400161743164,96.4599990844727,2.79999995231628],[70.0320129394531,96.4599990844727,2.79999995231628],[123.666717529297,94.6666717529297,0],[134.333312988281,94.6666717529297,0],[124.413360595703,95.4133377075195,2.79999995231628],[129.106674194336,95.4133377075195,2.79999995231628],[133.586669921875,95.4133377075195,2.79999995231628],[123.666717529297,105.33332824707,0],[124.413360595703,104.58666229248,2.79999995231628],[124.413360595703,99.8933334350586,2.79999995231628],[134.333312988281,105.33332824707,0],[129.106674194336,104.58666229248,2.79999995231628],[133.586669921875,104.58666229248,2.79999995231628],[133.586669921875,100.106666564941,2.79999995231628],[124.713317871094,104.286666870117,0],[124.713317871094,95.7133331298828,0],[133.286712646484,95.7133331298828,0],[133.286712646484,104.286666870117,0],[132.540023803711,103.540000915527,2.79999995231628],[128.032028198242,103.540008544922,2.79999995231628],[125.460006713867,103.540000915527,2.79999995231628],[125.460006713867,100.968002319336,2.79999995231628],[125.460006713867,96.4599990844727,2.79999995231628],[132.540023803711,99.0319976806641,2.79999995231628],[132.540023803711,96.4599990844727,2.79999995231628],[128.032028198242,96.4599990844727,2.79999995231628], + ]; + $facets = [ + [0,1,2],[3,4,5],[6,4,0],[6,0,2],[2,1,5],[7,4,3],[1,3,5],[0,4,7],[4,6,8],[6,9,8],[4,8,10],[6,2,9],[2,11,9],[2,12,11],[2,5,12],[5,13,12],[5,14,13],[4,10,15],[5,4,14],[4,15,14],[7,16,17],[0,7,18],[7,17,18],[1,19,20],[1,0,19],[0,18,19],[7,3,21],[3,22,21],[7,21,16],[3,23,22],[3,1,23],[1,20,23],[24,25,26],[25,27,26],[25,28,27],[29,24,30],[24,31,30],[24,26,31],[32,29,33],[29,30,33],[32,33,34],[32,34,35],[25,32,28],[32,35,28],[36,37,24],[38,32,25],[29,32,36],[29,36,24],[24,37,25],[39,32,38],[37,38,25],[36,32,39],[39,40,41],[36,39,42],[39,41,42],[37,43,44],[37,36,43],[36,42,43],[39,38,45],[38,46,45],[39,45,40],[38,47,46],[38,37,47],[37,44,47],[16,8,9],[16,10,8],[10,16,15],[15,16,21],[22,15,21],[15,22,14],[22,23,14],[23,20,14],[17,16,9],[18,17,9],[19,18,9],[19,9,11],[19,11,20],[13,14,20],[20,11,12],[13,20,12],[41,40,30],[42,41,30],[43,42,30],[43,30,31],[43,31,44],[27,28,44],[44,31,26],[27,44,26],[40,33,30],[40,34,33],[34,40,35],[35,40,45],[46,35,45],[35,46,28],[46,47,28],[47,44,28], + ]; } else { return undef; } diff --git a/t/shells.t b/t/shells.t index e967ea0e..f257f970 100644 --- a/t/shells.t +++ b/t/shells.t @@ -1,4 +1,4 @@ -use Test::More tests => 16; +use Test::More tests => 17; use strict; use warnings; @@ -205,11 +205,16 @@ use Slic3r::Test; { my $config = Slic3r::Config->new_from_defaults; $config->set('spiral_vase', 1); + $config->set('perimeters', 1); + $config->set('fill_density', 0); + $config->set('top_solid_layers', 0); $config->set('bottom_solid_layers', 0); + $config->set('retract_layer_change', [0]); $config->set('skirts', 0); $config->set('first_layer_height', '100%'); $config->set('layer_height', 0.4); $config->set('start_gcode', ''); + $config->validate; my $print = Slic3r::Test::init_print('20mm_cube', config => $config); my $z_moves = 0; @@ -221,6 +226,7 @@ use Slic3r::Test; my $sum_of_partial_z_equals_to_layer_height = 0; my $all_layer_segments_have_same_slope = 0; my $horizontal_extrusions = 0; + Slic3r::GCode::Reader->new->parse(Slic3r::Test::gcode($print), sub { my ($self, $cmd, $args, $info) = @_; @@ -244,11 +250,11 @@ use Slic3r::Test; my $total_dist_XY = sum(map $_->[1], @this_layer); $sum_of_partial_z_equals_to_layer_height = 1 if abs(sum(map $_->[0], @this_layer) - $config->layer_height) > epsilon; - exit if $sum_of_partial_z_equals_to_layer_height; + foreach my $segment (@this_layer) { # check that segment's dist_Z is proportioned to its dist_XY $all_layer_segments_have_same_slope = 1 - if abs($segment->[0]*$total_dist_XY/$config->layer_height - $segment->[1]) > epsilon; + if abs($segment->[0]*$total_dist_XY/$config->layer_height - $segment->[1]) > 0.1; } @this_layer = (); @@ -267,4 +273,31 @@ use Slic3r::Test; ok !$horizontal_extrusions, 'no horizontal extrusions'; } +{ + my $config = Slic3r::Config->new_from_defaults; + $config->set('perimeters', 1); + $config->set('fill_density', 0); + $config->set('top_solid_layers', 0); + $config->set('spiral_vase', 1); + $config->set('bottom_solid_layers', 0); + $config->set('skirts', 0); + $config->set('first_layer_height', '100%'); + $config->set('start_gcode', ''); + + my $print = Slic3r::Test::init_print('two_hollow_squares', config => $config); + my $diagonal_moves = 0; + Slic3r::GCode::Reader->new->parse(Slic3r::Test::gcode($print), sub { + my ($self, $cmd, $args, $info) = @_; + + if ($cmd eq 'G1') { + if ($info->{extruding} && $info->{dist_XY} > 0) { + if ($info->{dist_Z} > 0) { + $diagonal_moves++; + } + } + } + }); + is $diagonal_moves, 0, 'no spiral moves on two-island object'; +} + __END__