From 907ba55aab40231e8e2b99b30ff7939b77aace9a Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci Date: Fri, 6 Sep 2013 22:52:56 +0200 Subject: [PATCH] Some minor fixes needed after the xsdata merge. #1421 --- lib/Slic3r/GCode.pm | 2 +- lib/Slic3r/GCode/MotionPlanner.pm | 10 +++++----- lib/Slic3r/Print/Object.pm | 4 ++-- xs/xsp/ExtrusionEntityCollection.xsp | 4 ++++ xs/xsp/ExtrusionLoop.xsp | 4 ++++ 5 files changed, 16 insertions(+), 8 deletions(-) diff --git a/lib/Slic3r/GCode.pm b/lib/Slic3r/GCode.pm index 4173907e3..819f813bc 100644 --- a/lib/Slic3r/GCode.pm +++ b/lib/Slic3r/GCode.pm @@ -427,7 +427,7 @@ sub _plan { my ($self, $mp, $point, $comment) = @_; my $gcode = ""; - my @travel = $mp->shortest_path($self->last_pos, $point)->lines; + my @travel = @{$mp->shortest_path($self->last_pos, $point)->lines}; # if the path is not contained in a single island we need to retract my $need_retract = !$self->config->only_retract_when_crossing_perimeters; diff --git a/lib/Slic3r/GCode/MotionPlanner.pm b/lib/Slic3r/GCode/MotionPlanner.pm index f24becfa4..68c386aa9 100644 --- a/lib/Slic3r/GCode/MotionPlanner.pm +++ b/lib/Slic3r/GCode/MotionPlanner.pm @@ -52,7 +52,7 @@ sub BUILD { : $self->islands->[$i]->offset_ex(-$self->_inner_margin); # offset the island outwards to make the boundaries for external movements - $self->_outer->[$i] = offset([ $self->islands->[$i]->contour], $self->_outer_margin); + $self->_outer->[$i] = offset([ $self->islands->[$i]->contour ], $self->_outer_margin); # if internal motion is enabled, build a set of utility expolygons representing # the outer boundaries (as contours) and the inner boundaries (as holes). whenever @@ -74,7 +74,7 @@ sub BUILD { { my @outer = (map @$_, @{$self->_outer}); - my @outer_ex = map [$_], @outer; # as ExPolygons + my @outer_ex = map Slic3r::ExPolygon->new($_), @outer; # build ExPolygons for Boost # lines of outer polygons connect visible points for my $i (0 .. $#outer) { @@ -91,7 +91,7 @@ sub BUILD { 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(\@outer_ex, [$line])}) { + 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; @@ -106,13 +106,13 @@ sub BUILD { # lines connecting inner polygons contours are visible but discouraged if (!$self->no_internal) { my @inner = (map $_->contour, map @$_, @{$self->_inner}); - my @inner_ex = map [$_], @inner; # as ExPolygons + 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(\@inner_ex, [$line])}) { + 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; diff --git a/lib/Slic3r/Print/Object.pm b/lib/Slic3r/Print/Object.pm index 4b54325e5..6e21a442d 100644 --- a/lib/Slic3r/Print/Object.pm +++ b/lib/Slic3r/Print/Object.pm @@ -934,7 +934,7 @@ sub generate_support_material { { my $projection = []; foreach my $layer (reverse @{$self->layers}) { - if (my @top = grep $_->surface_type == S_TYPE_TOP, map @{$_->slices}, @{$layer->regions}) { + if (my @top = map @{$_->slices->filter_by_type(S_TYPE_TOP)}, @{$layer->regions}) { # compute projection of the contact areas above this top layer # first add all the 'new' contact areas to the current projection # ('new' means all the areas that are lower than the last top layer @@ -950,7 +950,7 @@ sub generate_support_material { # grow top surfaces so that interface and support generation are generated # with some spacing from object - it looks we don't need the actual # top shapes so this can be done here - $top{ $layer->print_z } = [ offset($touching, $flow->scaled_spacing) ]; + $top{ $layer->print_z } = offset($touching, $flow->scaled_spacing); } # remove the areas that touched from the projection that will continue on diff --git a/xs/xsp/ExtrusionEntityCollection.xsp b/xs/xsp/ExtrusionEntityCollection.xsp index 90adaf3dc..e5a8230fa 100644 --- a/xs/xsp/ExtrusionEntityCollection.xsp +++ b/xs/xsp/ExtrusionEntityCollection.xsp @@ -13,6 +13,10 @@ %code{% const char* CLASS = "Slic3r::ExtrusionPath::Collection"; RETVAL = THIS->chained_path(no_reverse); %}; ExtrusionEntityCollection* chained_path_from(Point* start_near, bool no_reverse) %code{% const char* CLASS = "Slic3r::ExtrusionPath::Collection"; RETVAL = THIS->chained_path_from(start_near, no_reverse); %}; + Point* first_point() + %code{% const char* CLASS = "Slic3r::Point"; RETVAL = THIS->first_point(); %}; + Point* last_point() + %code{% const char* CLASS = "Slic3r::Point"; RETVAL = THIS->last_point(); %}; %{ void diff --git a/xs/xsp/ExtrusionLoop.xsp b/xs/xsp/ExtrusionLoop.xsp index 9c9249bf2..984b8d5d6 100644 --- a/xs/xsp/ExtrusionLoop.xsp +++ b/xs/xsp/ExtrusionLoop.xsp @@ -18,6 +18,10 @@ ExtrusionPath* split_at_first_point() %code{% const char* CLASS = "Slic3r::ExtrusionPath"; RETVAL = THIS->split_at_first_point(); %}; bool make_counter_clockwise(); + Point* first_point() + %code{% const char* CLASS = "Slic3r::Point"; RETVAL = THIS->first_point(); %}; + Point* last_point() + %code{% const char* CLASS = "Slic3r::Point"; RETVAL = THIS->last_point(); %}; %{ ExtrusionLoop*