Ported get_layer_range() to C

This commit is contained in:
Alessandro Ranellucci 2013-06-23 15:33:07 +02:00
parent ff795f2918
commit 37105e8237
14 changed files with 72 additions and 738 deletions

View file

@ -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 {