123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115 |
- package Slic3r::Print::Object;
- use strict;
- use warnings;
- use List::Util qw(min max sum first);
- use Slic3r::Flow ':roles';
- use Slic3r::Geometry qw(scale epsilon);
- use Slic3r::Geometry::Clipper qw(diff diff_ex intersection intersection_ex union union_ex
- offset offset2 offset_ex offset2_ex JT_MITER);
- use Slic3r::Print::State ':steps';
- use Slic3r::Surface ':types';
- sub layers {
- my $self = shift;
- return [ map $self->get_layer($_), 0..($self->layer_count - 1) ];
- }
- sub support_layers {
- my $self = shift;
- return [ map $self->get_support_layer($_), 0..($self->support_layer_count - 1) ];
- }
- sub slice {
- my $self = shift;
-
- return if $self->step_done(STEP_SLICE);
- $self->set_step_started(STEP_SLICE);
- $self->print->status_cb->(10, "Processing triangulated mesh");
-
- $self->_slice;
- my $warning = $self->_fix_slicing_errors;
- warn $warning if (defined($warning) && $warning ne '');
-
- $self->_simplify_slices(scale($self->print->config->resolution))
- if ($self->print->config->resolution);
-
- die "No layers were detected. You might want to repair your STL file(s) or check their size or thickness and retry.\n"
- if !@{$self->layers};
-
- $self->set_step_done(STEP_SLICE);
- }
- sub make_perimeters {
- my ($self) = @_;
-
-
- $self->slice;
- if (! $self->step_done(STEP_PERIMETERS)) {
- $self->print->status_cb->(20, "Generating perimeters");
- $self->_make_perimeters;
- }
- }
- sub prepare_infill {
- my ($self) = @_;
-
-
- $self->make_perimeters;
-
- return if $self->step_done(STEP_PREPARE_INFILL);
- $self->set_step_started(STEP_PREPARE_INFILL);
- $self->print->status_cb->(30, "Preparing infill");
-
- $self->_prepare_infill;
- $self->set_step_done(STEP_PREPARE_INFILL);
- }
- sub infill {
- my ($self) = @_;
-
-
- $self->prepare_infill;
- $self->_infill;
- }
- sub generate_support_material {
- my $self = shift;
-
-
- $self->slice;
-
- return if $self->step_done(STEP_SUPPORTMATERIAL);
- $self->set_step_started(STEP_SUPPORTMATERIAL);
-
- $self->clear_support_layers;
-
- if (($self->config->support_material || $self->config->raft_layers > 0) && scalar(@{$self->layers}) > 1) {
- $self->print->status_cb->(85, "Generating support material");
-
- $self->_generate_support_material;
- }
-
- $self->set_step_done(STEP_SUPPORTMATERIAL);
- my $stats = sprintf "Weight: %.1fg, Cost: %.1f" , $self->print->total_weight, $self->print->total_cost;
- $self->print->status_cb->(85, $stats);
- }
- 1;
|