From 5f2b2c90b6030e00677433bdfb19ad39cea9c18b Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci Date: Thu, 21 Nov 2013 18:42:16 +0100 Subject: [PATCH] Fix error in contains_point() port --- t/perimeters.t | 6 +++--- xs/src/Polygon.cpp | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/t/perimeters.t b/t/perimeters.t index 6647bada0..7ce92fa39 100644 --- a/t/perimeters.t +++ b/t/perimeters.t @@ -59,10 +59,10 @@ use Slic3r::Test; if ($self->F == $config->external_perimeter_speed*60) { my $move_dest = Slic3r::Point->new_scale(@$info{qw(new_X new_Y)}); $external_loops{$self->Z}++; + my $loop_contains_point = Slic3r::Polygon->new_scale(@$cur_loop)->contains_point($move_dest); $has_outwards_move = 1 - if !Slic3r::Polygon->new_scale(@$cur_loop)->contains_point($move_dest) - ? ($external_loops{$self->Z} == 2) # contour should include destination - : ($external_loops{$self->Z} == 1); # hole should not + if (!$loop_contains_point && $external_loops{$self->Z} == 2) # contour should include destination + || ($loop_contains_point && $external_loops{$self->Z} == 1); # hole should not } $cur_loop = undef; } diff --git a/xs/src/Polygon.cpp b/xs/src/Polygon.cpp index 06d110c72..a6e6afebf 100644 --- a/xs/src/Polygon.cpp +++ b/xs/src/Polygon.cpp @@ -114,7 +114,7 @@ bool Polygon::contains_point(const Point* point) const { // http://www.ecse.rpi.edu/Homepages/wrf/Research/Short_Notes/pnpoly.html - bool result; + bool result = false; Points::const_iterator i = this->points.begin(); Points::const_iterator j = this->points.end() - 1; for (; i != this->points.end(); j = i++) {