diff --git a/lib/Slic3r/ExPolygon.pm b/lib/Slic3r/ExPolygon.pm index c2a4cea07..3056d7053 100644 --- a/lib/Slic3r/ExPolygon.pm +++ b/lib/Slic3r/ExPolygon.pm @@ -104,18 +104,16 @@ sub noncollapsing_offset_ex { sub encloses_point { my $self = shift; my ($point) = @_; - return $self->contour->encloses_point($point) - && (!grep($_->encloses_point($point), $self->holes) - || grep($_->point_on_segment($point), $self->holes)); + return Boost::Geometry::Utils::point_covered_by_polygon($point, $self); } # A version of encloses_point for use when hole borders do not matter. -# Useful because point_on_segment is slow +# Useful because point_on_segment is probably slower (this was true +# before the switch to Boost.Geometry, not sure about now) sub encloses_point_quick { my $self = shift; my ($point) = @_; - return $self->contour->encloses_point($point) - && !grep($_->encloses_point($point), $self->holes); + return Boost::Geometry::Utils::point_within_polygon($point, $self); } sub encloses_line { diff --git a/lib/Slic3r/Polygon.pm b/lib/Slic3r/Polygon.pm index 18d4494d5..c69b9e00b 100644 --- a/lib/Slic3r/Polygon.pm +++ b/lib/Slic3r/Polygon.pm @@ -65,7 +65,7 @@ sub point_on_segment { sub encloses_point { my $self = shift; my ($point) = @_; - return point_in_polygon($point, $self); + return Boost::Geometry::Utils::point_covered_by_polygon($point, [$self]); } sub area {