mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-23 22:54:08 -06:00
Optimization: use Boost.Geometry for point in polygon
This commit is contained in:
parent
f7be746599
commit
b414c50b68
2 changed files with 5 additions and 7 deletions
|
@ -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 {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue