PrusaSlicer-NonPlainar/lib/Slic3r/Skein.pm

76 lines
2.2 KiB
Perl
Raw Normal View History

2011-10-03 09:55:32 +00:00
package Slic3r::Skein;
use Moo;
use Time::HiRes qw(gettimeofday tv_interval);
use XXX;
2011-10-03 09:55:32 +00:00
has 'input_file' => (is => 'ro', required => 1);
has 'output_file' => (is => 'rw', required => 0);
sub go {
my $self = shift;
die "Input file must have .stl extension\n"
if $self->input_file !~ /\.stl$/i;
my $t0 = [gettimeofday];
# skein the STL into layers
# each layer has surfaces with holes
2011-10-03 09:55:32 +00:00
my $print = Slic3r::Print->new_from_stl($self->input_file);
# this will detect the type of each surface (top/bottom/internal)
# by splitting them if necessary
$print->detect_surfaces_type;
# this will remove unprintable surfaces
# (those that are too tight for extrusion)
$print->remove_small_surfaces;
# make bridges printable
# this will add a set of bridges to each layer
$print->process_bridges;
2011-11-13 17:41:12 +00:00
# make skirt
$print->extrude_skirt;
# make perimeters
# this will add a set of extrusion loops to each layer
# as well as a set of surfaces to be filled
2011-10-03 09:55:32 +00:00
$print->extrude_perimeters;
# this will remove unprintable perimeter loops
# (those that are too tight for extrusion)
$print->remove_small_perimeters;
# split fill_surfaces in internal and bridge surfaces
$print->split_bridges_fills;
# detect which fill surfaces are near external layers
# they will be split in internal and internal-solid surfaces
$print->discover_horizontal_shells;
# combine fill surfaces to honor the "infill every N layers" option
$print->infill_every_layers;
# this will generate extrusion paths for each layer
2011-10-03 09:55:32 +00:00
$print->extrude_fills;
# output everything to a GCODE file
2011-10-03 09:55:32 +00:00
if (!$self->output_file) {
my $output_file = $self->input_file;
$output_file =~ s/\.stl$/.gcode/i;
$self->output_file($output_file);
}
$print->export_gcode($self->output_file);
# output some statistics
2011-10-03 09:55:32 +00:00
my $processing_time = tv_interval($t0);
printf "Done. Process took %d minutes and %.3f seconds\n",
int($processing_time/60), $processing_time - int($processing_time/60)*60;
# TODO: more statistics!
2011-10-03 09:55:32 +00:00
}
1;