Use Slic3r::IO::STL for reading STL files

This commit is contained in:
Alessandro Ranellucci 2017-03-01 20:18:45 +01:00
parent de19e5dabc
commit 62675a2b18
2 changed files with 3 additions and 16 deletions

View File

@ -1,27 +1,12 @@
package Slic3r::Format::STL;
use Moo;
use File::Basename qw(basename);
sub read_file {
my $self = shift;
my ($file) = @_;
my $path = Slic3r::encode_path($file);
die "Failed to open $file\n" if !-e $path;
my $mesh = Slic3r::TriangleMesh->new;
$mesh->ReadSTLFile($path);
$mesh->check_topology;
die "This STL file couldn't be read because it's empty.\n"
if $mesh->facets_count == 0;
my $model = Slic3r::Model->new;
my $basename = basename($file);
my $object = $model->add_object(input_file => $file, name => $basename);
my $volume = $object->add_volume(mesh => $mesh, name => $basename);
$model->read_stl($file);
return $model;
}

View File

@ -14,6 +14,8 @@
Clone<Model> clone()
%code%{ RETVAL = THIS; %};
bool read_stl(std::string input_file)
%code%{ RETVAL = Slic3r::IO::STL::read(input_file, THIS); %};
bool read_obj(std::string input_file)
%code%{ RETVAL = Slic3r::IO::OBJ::read(input_file, THIS); %};