Generate a better error when input file is too thin and no layers could be generated. #1127

This commit is contained in:
Alessandro Ranellucci 2013-06-02 19:44:59 +02:00
parent 086ec4af9c
commit 8a01cb9e96

View File

@ -184,13 +184,13 @@ sub slice {
$self->meshes->[$region_id] = undef; # free memory
}
die "Invalid input file\n" if !@{$self->layers};
# free memory
$self->meshes(undef);
# remove last layer(s) if empty
pop @{$self->layers} while !map @{$_->lines}, @{$self->layers->[-1]->regions};
pop @{$self->layers} while @{$self->layers} && (!map @{$_->lines}, @{$self->layers->[-1]->regions});
die "Invalid or too thin input file: no layers could be generated\n" if !@{$self->layers};
foreach my $layer (@{ $self->layers }) {
# make sure all layers contain layer region objects for all regions