From fb7cea3cb9280ef1ba4eb25225af35107b0e3f0c Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci Date: Thu, 11 Jul 2013 19:13:43 +0200 Subject: [PATCH] Make plater work with XS data in single-thread environment --- lib/Slic3r/Geometry/Clipper.pm | 1 + lib/Slic3r/TriangleMesh.pm | 1 + xs/src/Point.hpp | 10 +++++----- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/Slic3r/Geometry/Clipper.pm b/lib/Slic3r/Geometry/Clipper.pm index 142acbd0e..e8af9e4d1 100644 --- a/lib/Slic3r/Geometry/Clipper.pm +++ b/lib/Slic3r/Geometry/Clipper.pm @@ -94,6 +94,7 @@ sub union_ex { my ($polygons, $jointype, $safety_offset) = @_; $jointype = PFT_NONZERO unless defined $jointype; $clipper->clear; + $polygons = $polygons->arrayref if ref $polygons eq 'Slic3r::ExPolygon::XS'; $clipper->add_subject_polygons($safety_offset ? safety_offset($polygons) : $polygons); return [ map Slic3r::ExPolygon::XS->new($_->{outer}, @{$_->{holes}}), diff --git a/lib/Slic3r/TriangleMesh.pm b/lib/Slic3r/TriangleMesh.pm index 5f58d0e20..8a0ef5706 100644 --- a/lib/Slic3r/TriangleMesh.pm +++ b/lib/Slic3r/TriangleMesh.pm @@ -533,6 +533,7 @@ sub horizontal_projection { my $scale_vector = Math::Clipper::integerize_coordinate_sets({ bits => 32 }, @f); $_->make_counter_clockwise for @f; # do this after scaling, as winding order might change while doing that my $union = union_ex([ Slic3r::Geometry::Clipper::offset(\@f, 10000) ]); + $union = [ map $_->arrayref, @$union ]; Math::Clipper::unscale_coordinate_sets($scale_vector, $_) for @$union; return $union; } diff --git a/xs/src/Point.hpp b/xs/src/Point.hpp index 4b14b9115..6b5ea3b06 100644 --- a/xs/src/Point.hpp +++ b/xs/src/Point.hpp @@ -13,9 +13,9 @@ extern "C" { class Point { public: - unsigned long x; - unsigned long y; - Point(unsigned long _x = 0, unsigned long _y = 0): x(_x), y(_y) {}; + long x; + long y; + Point(long _x = 0, long _y = 0): x(_x), y(_y) {}; void rotate(double angle, Point* center); }; @@ -24,8 +24,8 @@ Point::rotate(double angle, Point* center) { double cur_x = (double)x; double cur_y = (double)y; - x = (unsigned long)( (double)center->x + cos(angle) * (cur_x - (double)center->x) - sin(angle) * (cur_y - (double)center->y) ); - y = (unsigned long)( (double)center->y + cos(angle) * (cur_y - (double)center->y) + sin(angle) * (cur_x - (double)center->x) ); + x = (long)( (double)center->x + cos(angle) * (cur_x - (double)center->x) - sin(angle) * (cur_y - (double)center->y) ); + y = (long)( (double)center->y + cos(angle) * (cur_y - (double)center->y) + sin(angle) * (cur_x - (double)center->x) ); } SV*