Slicing preview incorrect in terms of visible solid layers
This commit is contained in:
parent
443e900e07
commit
b8590180d8
2 changed files with 17 additions and 18 deletions
|
@ -978,32 +978,30 @@ sub draw_volumes {
|
|||
}
|
||||
|
||||
my $qverts_begin = 0;
|
||||
my $qverts_end = defined($volume->qverts) ? $volume->qverts->size() : 0;
|
||||
my $qverts_end = defined($volume->qverts) ? $volume->qverts->size() : 0;
|
||||
my $tverts_begin = 0;
|
||||
my $tverts_end = defined($volume->tverts) ? $volume->tverts->size() : 0;
|
||||
if ($volume->range && $volume->offsets && @{$volume->offsets}) {
|
||||
my $tverts_end = defined($volume->tverts) ? $volume->tverts->size() : 0;
|
||||
my $n_offsets = ($volume->range && $volume->offsets) ? scalar(@{$volume->offsets}) : 0;
|
||||
if ($n_offsets) {
|
||||
# The Z layer range is specified.
|
||||
# First test whether the Z span of this object is not out of ($min_z, $max_z) completely.
|
||||
my ($min_z, $max_z) = @{$volume->range};
|
||||
next if ($volume->offsets->[0] > $max_z || $volume->offsets->[-3] < $min_z);
|
||||
# Then find the lowest layer to be displayed.
|
||||
my $i = 0;
|
||||
while ($i < @{$volume->offsets} && $volume->offsets->[$i] < $min_z) {
|
||||
while ($i < $n_offsets && $volume->offsets->[$i] < $min_z) {
|
||||
$i += 3;
|
||||
}
|
||||
# This shall not happen.
|
||||
next if ($i == @{$volume->offsets});
|
||||
next if ($i == $n_offsets);
|
||||
# Remember start of the layer.
|
||||
if ($i >= 3) {
|
||||
# Get end of the preceding layer, which is the start of the current layer.
|
||||
$qverts_begin = $volume->offsets->[$i-2];
|
||||
$tverts_begin = $volume->offsets->[$i-1];
|
||||
}
|
||||
$qverts_begin = $volume->offsets->[$i+1];
|
||||
$tverts_begin = $volume->offsets->[$i+2];
|
||||
# Some layers are above $min_z. Which?
|
||||
while ($i < @{$volume->offsets} && $volume->offsets->[$i] <= $max_z) {
|
||||
while ($i < $n_offsets && $volume->offsets->[$i] <= $max_z) {
|
||||
$i += 3;
|
||||
}
|
||||
if ($i < @{$volume->offsets}) {
|
||||
if ($i < $n_offsets) {
|
||||
$qverts_end = $volume->offsets->[$i+1];
|
||||
$tverts_end = $volume->offsets->[$i+2];
|
||||
}
|
||||
|
|
|
@ -145,14 +145,15 @@ sub load_print {
|
|||
}
|
||||
$self->enabled(1);
|
||||
$self->{layers_z} = [ sort { $a <=> $b } keys %z ];
|
||||
$self->slider_low->SetRange(0, scalar(@{$self->{layers_z}})-1);
|
||||
$self->slider_high->SetRange(0, scalar(@{$self->{layers_z}})-1);
|
||||
my $num_layers = scalar(@{$self->{layers_z}});
|
||||
$self->slider_low->SetRange(0, $num_layers-1);
|
||||
$self->slider_high->SetRange(0, $num_layers-1);
|
||||
$self->slider_low->SetValue(0);
|
||||
if (($z_idx = $self->slider_high->GetValue) <= $#{$self->{layers_z}} && $self->slider_high->GetValue != 0) {
|
||||
if (($z_idx = $self->slider_high->GetValue) < $num_layers && $self->slider_high->GetValue != 0) {
|
||||
# use $z_idx
|
||||
} else {
|
||||
$self->slider_high->SetValue(scalar(@{$self->{layers_z}})-1);
|
||||
$z_idx = @{$self->{layers_z}} ? -1 : undef;
|
||||
$self->slider_high->SetValue($num_layers-1);
|
||||
$z_idx = $num_layers ? ($num_layers-1) : undef;
|
||||
}
|
||||
$self->slider_low->Show;
|
||||
$self->slider_high->Show;
|
||||
|
@ -184,7 +185,7 @@ sub set_z_range
|
|||
return if !$self->enabled;
|
||||
$self->{z_label_low}->SetLabel(sprintf '%.2f', $z_low);
|
||||
$self->{z_label_high}->SetLabel(sprintf '%.2f', $z_high);
|
||||
$self->canvas->set_toolpaths_range($z_low, $z_high);
|
||||
$self->canvas->set_toolpaths_range($z_low-1e-5, $z_high+1e-5);
|
||||
$self->canvas->Refresh if $self->IsShown;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue