mirror of
https://git.mirrors.martin98.com/https://github.com/slic3r/Slic3r.git
synced 2025-08-14 00:36:24 +08:00
Use Slic3r::IO::STL for reading STL files
This commit is contained in:
parent
de19e5dabc
commit
62675a2b18
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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); %};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user