mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-14 02:07:54 -06:00
Ported get_layer_range() to C
This commit is contained in:
parent
ff795f2918
commit
37105e8237
14 changed files with 72 additions and 738 deletions
|
@ -101,37 +101,7 @@ sub get_layer_range {
|
|||
my $self = shift;
|
||||
my ($min_z, $max_z) = @_;
|
||||
|
||||
# $min_layer is the uppermost layer having slice_z <= $min_z
|
||||
# $max_layer is the lowermost layer having slice_z >= $max_z
|
||||
my ($min_layer, $max_layer);
|
||||
|
||||
my ($bottom, $top) = (0, $#{$self->layers});
|
||||
while (1) {
|
||||
my $mid = $bottom+int(($top - $bottom)/2);
|
||||
if ($mid == $top || $mid == $bottom) {
|
||||
$min_layer = $mid;
|
||||
last;
|
||||
}
|
||||
if ($self->layers->[$mid]->slice_z >= $min_z) {
|
||||
$top = $mid;
|
||||
} else {
|
||||
$bottom = $mid;
|
||||
}
|
||||
}
|
||||
$top = $#{$self->layers};
|
||||
while (1) {
|
||||
my $mid = $bottom+int(($top - $bottom)/2);
|
||||
if ($mid == $top || $mid == $bottom) {
|
||||
$max_layer = $mid;
|
||||
last;
|
||||
}
|
||||
if ($self->layers->[$mid]->slice_z < $max_z) {
|
||||
$bottom = $mid;
|
||||
} else {
|
||||
$top = $mid;
|
||||
}
|
||||
}
|
||||
return ($min_layer, $max_layer);
|
||||
return @{ Slic3r::Object::XS::get_layer_range([ map $_->slice_z, @{$self->layers} ], $min_z, $max_z) };
|
||||
}
|
||||
|
||||
sub bounding_box {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue