Ported Slic3r::Print::State to XS

This commit is contained in:
Alessandro Ranellucci 2013-12-20 01:36:42 +01:00
parent d2295cdf70
commit a6a6a6888b
9 changed files with 124 additions and 45 deletions

View file

@ -350,10 +350,10 @@ sub process {
my ($step, $cb) = @_;
for my $obj_idx (0..$#{$self->objects}) {
my $object = $self->objects->[$obj_idx];
if (!$object->_state->done($step, $obj_idx)) {
$object->_state->set_started($step, $obj_idx);
if (!$object->_state->done($step)) {
$object->_state->set_started($step);
$cb->($obj_idx);
$object->_state->set_done($step, $obj_idx);
$object->_state->set_done($step);
}
}
};

View file

@ -1,5 +1,6 @@
package Slic3r::Print::State;
use Moo;
use strict;
use warnings;
require Exporter;
our @ISA = qw(Exporter);
@ -7,18 +8,6 @@ our @EXPORT_OK = qw(STEP_INIT_EXTRUDERS STEP_SLICE STEP_PERIMETERS STEP_PREPAR
STEP_INFILL STEP_SUPPORTMATERIAL STEP_SKIRT STEP_BRIM);
our %EXPORT_TAGS = (steps => \@EXPORT_OK);
has '_started' => (is => 'ro', default => sub {{}}); # { step => 1, ... }
has '_done' => (is => 'ro', default => sub {{}}); # { step => 1, ... }
use constant STEP_INIT_EXTRUDERS => 0;
use constant STEP_SLICE => 1;
use constant STEP_PERIMETERS => 2;
use constant STEP_PREPARE_INFILL => 3;
use constant STEP_INFILL => 4;
use constant STEP_SUPPORTMATERIAL => 5;
use constant STEP_SKIRT => 6;
use constant STEP_BRIM => 7;
our %print_steps = map { $_ => 1 } (
STEP_INIT_EXTRUDERS,
STEP_SKIRT,
@ -36,33 +25,4 @@ our %prereqs = (
STEP_BRIM => [STEP_PERIMETERS, STEP_INFILL, STEP_SKIRT],
);
sub started {
my ($self, $step) = @_;
return $self->_started->{$step};
}
sub done {
my ($self, $step) = @_;
return $self->_done->{$step};
}
sub set_started {
my ($self, $step) = @_;
$self->_started->{$step} = 1;
delete $self->_done->{$step};
}
sub set_done {
my ($self, $step) = @_;
$self->_done->{$step} = 1;
}
sub invalidate {
my ($self, $step) = @_;
delete $self->_started->{$step};
delete $self->_done->{$step};
}
1;