diff --git a/lib/Slic3r/Format/STL.pm b/lib/Slic3r/Format/STL.pm index a3b859104..5a9359df6 100644 --- a/lib/Slic3r/Format/STL.pm +++ b/lib/Slic3r/Format/STL.pm @@ -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; } diff --git a/xs/xsp/Model.xsp b/xs/xsp/Model.xsp index b47689d27..0591de4ab 100644 --- a/xs/xsp/Model.xsp +++ b/xs/xsp/Model.xsp @@ -14,6 +14,8 @@ Clone 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); %};