Parse and write multi-material AMF files. Convert multiple STL files into a single multi-material AMF

This commit is contained in:
Alessandro Ranellucci 2012-02-20 16:43:45 +01:00
parent aa98a9deb2
commit b6bffacb9d
5 changed files with 97 additions and 33 deletions

View file

@ -25,14 +25,16 @@ sub go {
# each layer has surfaces with holes
$self->status_cb->(10, "Processing triangulated mesh");
my $print;
{
my $mesh = $self->input_file =~ /\.stl$/i
? Slic3r::STL->read_file($self->input_file)
: $self->input_file =~ /\.amf(\.xml)?$/i
? Slic3r::AMF->read_file($self->input_file)
: die "Input file must have .stl or .amf(.xml) extension\n";
if ($self->input_file =~ /\.stl$/i) {
my $mesh = Slic3r::STL->read_file($self->input_file);
$mesh->check_manifoldness;
$print = Slic3r::Print->new_from_mesh($mesh);
} elsif ( $self->input_file =~ /\.amf(\.xml)?$/i) {
my ($materials, $meshes_by_material) = Slic3r::AMF->read_file($self->input_file);
$_->check_manifoldness for values %$meshes_by_material;
$print = Slic3r::Print->new_from_mesh($meshes_by_material->{_} || +(values %$meshes_by_material)[0]);
} else {
die "Input file must have .stl or .amf(.xml) extension\n";
}
# make perimeters