From ad03a88733ce0f5e687a22609df6cf9dd54b3a9b Mon Sep 17 00:00:00 2001 From: "Y. Sapir" Date: Mon, 28 Apr 2014 01:13:50 +0300 Subject: [PATCH] Add xsp wrapper for Pointf class. --- lib/Slic3r/GCode.pm | 2 +- xs/lib/Slic3r/XS.pm | 5 +++++ xs/xsp/Point.xsp | 11 +++++++++++ 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/lib/Slic3r/GCode.pm b/lib/Slic3r/GCode.pm index a4471c470..37eed4797 100644 --- a/lib/Slic3r/GCode.pm +++ b/lib/Slic3r/GCode.pm @@ -587,7 +587,7 @@ sub _G0_G1 { if ($point) { $gcode .= sprintf " X%.3f Y%.3f", - ($point->x * &Slic3r::SCALING_FACTOR) + $self->shift_x - $self->extruder->extruder_offset->[X], + ($point->x * &Slic3r::SCALING_FACTOR) + $self->shift_x - $self->extruder->extruder_offset->[X], ($point->y * &Slic3r::SCALING_FACTOR) + $self->shift_y - $self->extruder->extruder_offset->[Y]; #** $self->last_pos($point->clone); } diff --git a/xs/lib/Slic3r/XS.pm b/xs/lib/Slic3r/XS.pm index 2c6a985b7..d30f84299 100644 --- a/xs/lib/Slic3r/XS.pm +++ b/xs/lib/Slic3r/XS.pm @@ -28,6 +28,11 @@ our @ISA = 'Slic3r::Point'; sub DESTROY {} +package Slic3r::Pointf; +use overload + '@{}' => sub { [ $_[0]->x, $_[0]->y ] }, #, + 'fallback' => 1; + package Slic3r::Pointf3; use overload '@{}' => sub { [ $_[0]->x, $_[0]->y, $_[0]->z ] }, #, diff --git a/xs/xsp/Point.xsp b/xs/xsp/Point.xsp index f2c1a699f..952cd161f 100644 --- a/xs/xsp/Point.xsp +++ b/xs/xsp/Point.xsp @@ -56,6 +56,17 @@ Point::coincides_with(point_sv) }; +%name{Slic3r::Pointf} class Pointf { + Pointf(double _x = 0, double _y = 0); + ~Pointf(); + Clone clone() + %code{% RETVAL = THIS; %}; + double x() + %code{% RETVAL = THIS->x; %}; + double y() + %code{% RETVAL = THIS->y; %}; +}; + %name{Slic3r::Pointf3} class Pointf3 { Pointf3(double _x = 0, double _y = 0, double _z = 0); ~Pointf3();