Ported Slic3r::Print::State to XS
This commit is contained in:
parent
d2295cdf70
commit
a6a6a6888b
9 changed files with 124 additions and 45 deletions
|
@ -143,6 +143,7 @@ sub thread_cleanup {
|
|||
*Slic3r::Polygon::DESTROY = sub {};
|
||||
*Slic3r::Polyline::DESTROY = sub {};
|
||||
*Slic3r::Polyline::Collection::DESTROY = sub {};
|
||||
*Slic3r::Print::State::DESTROY = sub {};
|
||||
*Slic3r::Surface::DESTROY = sub {};
|
||||
*Slic3r::Surface::Collection::DESTROY = sub {};
|
||||
*Slic3r::TriangleMesh::DESTROY = sub {};
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -35,6 +35,8 @@ src/Polyline.cpp
|
|||
src/Polyline.hpp
|
||||
src/PolylineCollection.cpp
|
||||
src/PolylineCollection.hpp
|
||||
src/PrintState.cpp
|
||||
src/PrintState.hpp
|
||||
src/ppport.h
|
||||
src/Surface.cpp
|
||||
src/Surface.hpp
|
||||
|
@ -72,6 +74,7 @@ xsp/Point.xsp
|
|||
xsp/Polygon.xsp
|
||||
xsp/Polyline.xsp
|
||||
xsp/PolylineCollection.xsp
|
||||
xsp/PrintState.xsp
|
||||
xsp/Surface.xsp
|
||||
xsp/SurfaceCollection.xsp
|
||||
xsp/TriangleMesh.xsp
|
||||
|
|
36
xs/src/Print.cpp
Normal file
36
xs/src/Print.cpp
Normal file
|
@ -0,0 +1,36 @@
|
|||
#include "Print.hpp"
|
||||
|
||||
namespace Slic3r {
|
||||
|
||||
bool
|
||||
PrintState::started(PrintStep step) const
|
||||
{
|
||||
return this->_started.find(step) != this->_started.end();
|
||||
}
|
||||
|
||||
bool
|
||||
PrintState::done(PrintStep step) const
|
||||
{
|
||||
return this->_done.find(step) != this->_done.end();
|
||||
}
|
||||
|
||||
void
|
||||
PrintState::set_started(PrintStep step)
|
||||
{
|
||||
this->_started.insert(step);
|
||||
}
|
||||
|
||||
void
|
||||
PrintState::set_done(PrintStep step)
|
||||
{
|
||||
this->_done.insert(step);
|
||||
}
|
||||
|
||||
void
|
||||
PrintState::invalidate(PrintStep step)
|
||||
{
|
||||
this->_started.erase(step);
|
||||
this->_done.erase(step);
|
||||
}
|
||||
|
||||
}
|
29
xs/src/Print.hpp
Normal file
29
xs/src/Print.hpp
Normal file
|
@ -0,0 +1,29 @@
|
|||
#ifndef slic3r_Print_hpp_
|
||||
#define slic3r_Print_hpp_
|
||||
|
||||
#include <set>
|
||||
|
||||
namespace Slic3r {
|
||||
|
||||
enum PrintStep {
|
||||
psInitExtruders, psSlice, psPerimeters, prPrepareInfill,
|
||||
psInfill, psSupportMaterial, psSkirt, psBrim,
|
||||
};
|
||||
|
||||
class PrintState
|
||||
{
|
||||
private:
|
||||
std::set<PrintStep> _started;
|
||||
std::set<PrintStep> _done;
|
||||
|
||||
public:
|
||||
bool started(PrintStep step) const;
|
||||
bool done(PrintStep step) const;
|
||||
void set_started(PrintStep step);
|
||||
void set_done(PrintStep step);
|
||||
void invalidate(PrintStep step);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
41
xs/xsp/Print.xsp
Normal file
41
xs/xsp/Print.xsp
Normal file
|
@ -0,0 +1,41 @@
|
|||
%module{Slic3r::XS};
|
||||
|
||||
%{
|
||||
#include <myinit.h>
|
||||
#include "Print.hpp"
|
||||
%}
|
||||
|
||||
%name{Slic3r::Print::State} class PrintState {
|
||||
PrintState();
|
||||
~PrintState();
|
||||
bool started(PrintStep step) const;
|
||||
bool done(PrintStep step) const;
|
||||
void set_started(PrintStep step);
|
||||
void set_done(PrintStep step);
|
||||
void invalidate(PrintStep step);
|
||||
%{
|
||||
|
||||
%}
|
||||
};
|
||||
|
||||
%package{Slic3r::Print::State};
|
||||
%{
|
||||
|
||||
IV
|
||||
_constant()
|
||||
ALIAS:
|
||||
STEP_INIT_EXTRUDERS = psInitExtruders
|
||||
STEP_SLICE = psSlice
|
||||
STEP_PERIMETERS = psPerimeters
|
||||
STEP_PREPARE_INFILL = prPrepareInfill
|
||||
STEP_INFILL = psInfill
|
||||
STEP_SUPPORTMATERIAL = psSupportMaterial
|
||||
STEP_SKIRT = psSkirt
|
||||
STEP_BRIM = psBrim
|
||||
PROTOTYPE:
|
||||
CODE:
|
||||
RETVAL = ix;
|
||||
OUTPUT: RETVAL
|
||||
|
||||
%}
|
||||
|
|
@ -12,10 +12,12 @@ ExPolygonCollection* O_OBJECT
|
|||
ExtrusionEntityCollection* O_OBJECT
|
||||
ExtrusionPath* O_OBJECT
|
||||
ExtrusionLoop* O_OBJECT
|
||||
PrintState* O_OBJECT
|
||||
Surface* O_OBJECT
|
||||
SurfaceCollection* O_OBJECT
|
||||
|
||||
ExtrusionRole T_UV
|
||||
PrintStep T_UV
|
||||
SurfaceType T_UV
|
||||
ClipperLib::JoinType T_UV
|
||||
ClipperLib::PolyFillType T_UV
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
%typemap{Lines};
|
||||
%typemap{Polygons};
|
||||
%typemap{Polylines};
|
||||
%typemap{PrintState};
|
||||
%typemap{ExPolygons};
|
||||
%typemap{Surfaces};
|
||||
%typemap{Polygons*};
|
||||
|
@ -35,3 +36,9 @@
|
|||
$CVar = (ExtrusionRole)SvUV($PerlVar);
|
||||
%};
|
||||
};
|
||||
%typemap{PrintStep}{parsed}{
|
||||
%cpp_type{PrintStep};
|
||||
%precall_code{%
|
||||
$CVar = (PrintStep)SvUV($PerlVar);
|
||||
%};
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue