Speed up encloses_point calls from medial_axis code.
The points shouldn't be on hole borders so we can make the check much quicker. Gives over 50% speed up slicing reprap shot glass (thing:11944) with default settings and 0.3 layer height.
This commit is contained in:
parent
7d858338fa
commit
840752194f
1 changed files with 10 additions and 1 deletions
|
@ -99,6 +99,15 @@ sub encloses_point {
|
||||||
|| grep($_->point_on_segment($point), $self->holes));
|
|| grep($_->point_on_segment($point), $self->holes));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# A version of encloses_point for use when hole borders do not matter.
|
||||||
|
# Useful because point_on_segment is slow
|
||||||
|
sub encloses_point_quick {
|
||||||
|
my $self = shift;
|
||||||
|
my ($point) = @_;
|
||||||
|
return $self->contour->encloses_point($point)
|
||||||
|
&& !grep($_->encloses_point($point), $self->holes);
|
||||||
|
}
|
||||||
|
|
||||||
sub encloses_line {
|
sub encloses_line {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
my ($line) = @_;
|
my ($line) = @_;
|
||||||
|
@ -200,7 +209,7 @@ sub medial_axis {
|
||||||
$a = $vertices->[$edge->[1]];
|
$a = $vertices->[$edge->[1]];
|
||||||
$b = $vertices->[$edge->[2]];
|
$b = $vertices->[$edge->[2]];
|
||||||
|
|
||||||
next if !$self->encloses_point($a) || !$self->encloses_point($b);
|
next if !$self->encloses_point_quick($a) || !$self->encloses_point_quick($b);
|
||||||
|
|
||||||
push @skeleton_lines, [$edge->[1], $edge->[2]];
|
push @skeleton_lines, [$edge->[1], $edge->[2]];
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue