From 6b8894cf9aab685c471c412545e5ce57f47d468a Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci <aar@cpan.org> Date: Fri, 10 May 2013 13:56:29 +0200 Subject: [PATCH] Rename ex_int_offset2 to offset2_ex --- lib/Slic3r/Geometry/Clipper.pm | 24 ++++++++++++------------ lib/Slic3r/Layer/Region.pm | 6 +++--- lib/Slic3r/Print.pm | 2 +- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/lib/Slic3r/Geometry/Clipper.pm b/lib/Slic3r/Geometry/Clipper.pm index d454b3b1c..5bd2a74e4 100644 --- a/lib/Slic3r/Geometry/Clipper.pm +++ b/lib/Slic3r/Geometry/Clipper.pm @@ -6,7 +6,7 @@ require Exporter; our @ISA = qw(Exporter); our @EXPORT_OK = qw(safety_offset safety_offset_ex offset offset_ex collapse_ex diff_ex diff union_ex intersection_ex xor_ex PFT_EVENODD JT_MITER JT_ROUND - JT_SQUARE is_counter_clockwise union_pt ex_int_offset2 offset2); + JT_SQUARE is_counter_clockwise union_pt offset2 offset2_ex); use Math::Clipper 1.17 qw(:cliptypes :polyfilltypes :jointypes is_counter_clockwise area); use Slic3r::Geometry qw(scale); @@ -53,6 +53,16 @@ sub offset_ex { return map Slic3r::ExPolygon->new($_), @$offsets; } +sub offset2_ex { + my ($polygons, $delta1, $delta2, $scale, $joinType, $miterLimit) = @_; + $scale ||= 100000; + $joinType //= JT_MITER; + $miterLimit //= 3; + + my $offsets = Math::Clipper::ex_int_offset2($polygons, $delta1, $delta2, $scale, $joinType, $miterLimit); + return map Slic3r::ExPolygon->new($_), @$offsets; +} + sub diff_ex { my ($subject, $clip, $safety_offset) = @_; @@ -120,19 +130,9 @@ sub xor_ex { ]; } -sub ex_int_offset2 { - my ($polygons, $delta1, $delta2, $scale, $joinType, $miterLimit) = @_; - $scale ||= 100000; - $joinType //= JT_MITER; - $miterLimit //= 3; - - my $offsets = Math::Clipper::ex_int_offset2($polygons, $delta1, $delta2, $scale, $joinType, $miterLimit); - return map Slic3r::ExPolygon->new($_), @$offsets; -} - sub collapse_ex { my ($polygons, $width) = @_; - return [ ex_int_offset2($polygons, -$width/2, +$width/2) ]; + return [ offset2_ex($polygons, -$width/2, +$width/2) ]; } sub simplify_polygon { diff --git a/lib/Slic3r/Layer/Region.pm b/lib/Slic3r/Layer/Region.pm index 551c3ac63..6974c8f21 100644 --- a/lib/Slic3r/Layer/Region.pm +++ b/lib/Slic3r/Layer/Region.pm @@ -4,7 +4,7 @@ use Moo; use List::Util qw(sum first); use Slic3r::ExtrusionPath ':roles'; use Slic3r::Geometry qw(PI X1 X2 Y1 Y2 A B scale chained_path_items points_coincide); -use Slic3r::Geometry::Clipper qw(safety_offset union_ex diff_ex intersection_ex); +use Slic3r::Geometry::Clipper qw(safety_offset union_ex diff_ex intersection_ex offset2_ex); use Slic3r::Surface ':types'; has 'layer' => ( @@ -97,7 +97,7 @@ sub make_surfaces { { my $width = $self->perimeter_flow->scaled_width; my $outgrown = [ - Slic3r::Geometry::Clipper::ex_int_offset2([ map @$_, map $_->expolygon, @{$self->slices} ], -$width, +$width), + offset2_ex([ map @$_, map $_->expolygon, @{$self->slices} ], -$width, +$width), ]; my $diff = diff_ex( [ map $_->p, @{$self->slices} ], @@ -227,7 +227,7 @@ sub make_perimeters { # offsetting a polygon can result in one or many offset polygons my @new_offsets = (); foreach my $expolygon (@last_offsets) { - my @offsets = Slic3r::Geometry::Clipper::ex_int_offset2($expolygon, -1.5*$spacing, +0.5*$spacing); + my @offsets = offset2_ex($expolygon, -1.5*$spacing, +0.5*$spacing); push @new_offsets, @offsets; # where the above check collapses the expolygon, then there's no room for an inner loop diff --git a/lib/Slic3r/Print.pm b/lib/Slic3r/Print.pm index 69d84475c..d5589227a 100644 --- a/lib/Slic3r/Print.pm +++ b/lib/Slic3r/Print.pm @@ -8,7 +8,7 @@ use Math::ConvexHull::MonotoneChain qw(convex_hull); use Slic3r::ExtrusionPath ':roles'; use Slic3r::Geometry qw(X Y Z X1 Y1 X2 Y2 MIN PI scale unscale move_points nearest_point chained_path_items); use Slic3r::Geometry::Clipper qw(diff_ex union_ex union_pt intersection_ex offset - ex_int_offset2 offset2 JT_ROUND JT_SQUARE PFT_EVENODD); + offset2 JT_ROUND JT_SQUARE PFT_EVENODD); use Time::HiRes qw(gettimeofday tv_interval); has 'config' => (is => 'rw', default => sub { Slic3r::Config->new_from_defaults }, trigger => 1);