From 280f3f38d7d4168dffe173bf9aaf4a77e87f2ff2 Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci Date: Wed, 1 Jul 2015 21:01:42 +0200 Subject: [PATCH] Ported Slic3r::GCode::OozePrevention storage to XS --- lib/Slic3r.pm | 1 + lib/Slic3r/GCode.pm | 6 ++---- lib/Slic3r/Print/GCode.pm | 4 ++-- xs/lib/Slic3r/XS.pm | 1 + xs/src/libslic3r/GCode.cpp | 9 +++++++++ xs/src/libslic3r/GCode.hpp | 8 ++++++++ xs/xsp/GCode.xsp | 15 +++++++++++++++ xs/xsp/my.map | 4 ++++ 8 files changed, 42 insertions(+), 6 deletions(-) diff --git a/lib/Slic3r.pm b/lib/Slic3r.pm index 26acb564c..f0e85e629 100644 --- a/lib/Slic3r.pm +++ b/lib/Slic3r.pm @@ -195,6 +195,7 @@ sub thread_cleanup { *Slic3r::ExtrusionPath::Collection::DESTROY = sub {}; *Slic3r::Flow::DESTROY = sub {}; *Slic3r::GCode::AvoidCrossingPerimeters::DESTROY = sub {}; + *Slic3r::GCode::OozePrevention::DESTROY = sub {}; *Slic3r::GCode::PlaceholderParser::DESTROY = sub {}; *Slic3r::GCode::Wipe::DESTROY = sub {}; *Slic3r::GCode::Writer::DESTROY = sub {}; diff --git a/lib/Slic3r/GCode.pm b/lib/Slic3r/GCode.pm index 38374975d..a1524a12d 100644 --- a/lib/Slic3r/GCode.pm +++ b/lib/Slic3r/GCode.pm @@ -504,13 +504,11 @@ sub set_extruder { } package Slic3r::GCode::OozePrevention; -use Moo; +use strict; +use warnings; use Slic3r::Geometry qw(scale); -has 'enable' => (is => 'rw', default => sub { 0 }); -has 'standby_points' => (is => 'rw'); - sub pre_toolchange { my ($self, $gcodegen) = @_; diff --git a/lib/Slic3r/Print/GCode.pm b/lib/Slic3r/Print/GCode.pm index b71deaf60..79200df4f 100644 --- a/lib/Slic3r/Print/GCode.pm +++ b/lib/Slic3r/Print/GCode.pm @@ -212,8 +212,8 @@ sub export { } my $convex_hull = convex_hull([ map @$_, @skirts ]); - $gcodegen->ooze_prevention->enable(1); - $gcodegen->ooze_prevention->standby_points( + $gcodegen->ooze_prevention->set_enable(1); + $gcodegen->ooze_prevention->set_standby_points( [ map @{$_->equally_spaced_points(scale 10)}, @{offset([$convex_hull], scale 3)} ] ); diff --git a/xs/lib/Slic3r/XS.pm b/xs/lib/Slic3r/XS.pm index 2abad09b6..8c6956bbc 100644 --- a/xs/lib/Slic3r/XS.pm +++ b/xs/lib/Slic3r/XS.pm @@ -216,6 +216,7 @@ for my $class (qw( Slic3r::ExtrusionPath::Collection Slic3r::Flow Slic3r::GCode::AvoidCrossingPerimeters + Slic3r::GCode::OozePrevention Slic3r::GCode::PlaceholderParser Slic3r::GCode::Wipe Slic3r::Geometry::BoundingBox diff --git a/xs/src/libslic3r/GCode.cpp b/xs/src/libslic3r/GCode.cpp index bdc822090..313af8a2e 100644 --- a/xs/src/libslic3r/GCode.cpp +++ b/xs/src/libslic3r/GCode.cpp @@ -67,6 +67,15 @@ AvoidCrossingPerimeters::travel_to(Point point, const Pointf &gcodegen_origin, REGISTER_CLASS(AvoidCrossingPerimeters, "GCode::AvoidCrossingPerimeters"); #endif +OozePrevention::OozePrevention() + : enable(false) +{ +} + +#ifdef SLIC3RXS +REGISTER_CLASS(OozePrevention, "GCode::OozePrevention"); +#endif + Wipe::Wipe() : enable(false) { diff --git a/xs/src/libslic3r/GCode.hpp b/xs/src/libslic3r/GCode.hpp index a44fce616..bfefa4044 100644 --- a/xs/src/libslic3r/GCode.hpp +++ b/xs/src/libslic3r/GCode.hpp @@ -35,6 +35,14 @@ class AvoidCrossingPerimeters { MotionPlanner* _layer_mp; }; +class OozePrevention { + public: + bool enable; + Points standby_points; + + OozePrevention(); +}; + class Wipe { public: bool enable; diff --git a/xs/xsp/GCode.xsp b/xs/xsp/GCode.xsp index ec939a8b6..c981259a0 100644 --- a/xs/xsp/GCode.xsp +++ b/xs/xsp/GCode.xsp @@ -30,6 +30,21 @@ %code{% THIS->disable_once = value; %}; }; +%name{Slic3r::GCode::OozePrevention} class OozePrevention { + OozePrevention(); + ~OozePrevention(); + + bool enable() + %code{% RETVAL = THIS->enable; %}; + void set_enable(bool value) + %code{% THIS->enable = value; %}; + + Points standby_points() + %code{% RETVAL = THIS->standby_points; %}; + void set_standby_points(Points points) + %code{% THIS->standby_points = points; %}; +}; + %name{Slic3r::GCode::Wipe} class Wipe { Wipe(); ~Wipe(); diff --git a/xs/xsp/my.map b/xs/xsp/my.map index d594ceacd..5f36db078 100644 --- a/xs/xsp/my.map +++ b/xs/xsp/my.map @@ -178,6 +178,10 @@ Wipe* O_OBJECT_SLIC3R Ref O_OBJECT_SLIC3R_T Clone O_OBJECT_SLIC3R_T +OozePrevention* O_OBJECT_SLIC3R +Ref O_OBJECT_SLIC3R_T +Clone O_OBJECT_SLIC3R_T + MotionPlanner* O_OBJECT_SLIC3R Ref O_OBJECT_SLIC3R_T Clone O_OBJECT_SLIC3R_T