Require Math::Clipper 1.14 and increase scale factor for offset(). #720
This commit is contained in:
parent
705d6b3179
commit
68e1edab80
2
Build.PL
2
Build.PL
@ -11,7 +11,7 @@ my $build = Module::Build->new(
|
||||
'File::Basename' => '0',
|
||||
'File::Spec' => '0',
|
||||
'Getopt::Long' => '0',
|
||||
'Math::Clipper' => '1.09',
|
||||
'Math::Clipper' => '1.14',
|
||||
'Math::ConvexHull::MonotoneChain' => '0.01',
|
||||
'Math::Geometry::Voronoi' => '1.3',
|
||||
'Math::PlanePath' => '53',
|
||||
|
@ -8,20 +8,20 @@ our @EXPORT_OK = qw(safety_offset offset offset_ex
|
||||
diff_ex diff union_ex intersection_ex xor_ex PFT_EVENODD JT_MITER JT_ROUND
|
||||
JT_SQUARE is_counter_clockwise);
|
||||
|
||||
use Math::Clipper 1.09 qw(:cliptypes :polyfilltypes :jointypes is_counter_clockwise area);
|
||||
use Math::Clipper 1.14 qw(:cliptypes :polyfilltypes :jointypes is_counter_clockwise area);
|
||||
use Slic3r::Geometry qw(scale);
|
||||
our $clipper = Math::Clipper->new;
|
||||
|
||||
sub safety_offset {
|
||||
my ($polygons, $factor) = @_;
|
||||
return Math::Clipper::offset($polygons, $factor || (scale 1e-05), 1, JT_MITER, 2);
|
||||
return Math::Clipper::offset($polygons, $factor || (scale 1e-05), 100000, JT_MITER, 2);
|
||||
}
|
||||
|
||||
sub offset {
|
||||
my ($polygons, $distance, $scale, $joinType, $miterLimit) = @_;
|
||||
$scale ||= 1;
|
||||
$joinType = JT_MITER if !defined $joinType;
|
||||
$miterLimit ||= 2;
|
||||
$scale ||= 100000;
|
||||
$joinType //= JT_MITER;
|
||||
$miterLimit //= 2;
|
||||
|
||||
my $offsets = Math::Clipper::offset($polygons, $distance, $scale, $joinType, $miterLimit);
|
||||
return @$offsets;
|
||||
|
@ -1,7 +1,6 @@
|
||||
package Slic3r::Layer::Region;
|
||||
use Moo;
|
||||
|
||||
use Math::Clipper ':all';
|
||||
use Slic3r::ExtrusionPath ':roles';
|
||||
use Slic3r::Geometry qw(scale shortest_path);
|
||||
use Slic3r::Geometry::Clipper qw(safety_offset union_ex diff_ex intersection_ex);
|
||||
@ -109,7 +108,7 @@ sub make_surfaces {
|
||||
|
||||
# now detect thin walls by re-outgrowing offsetted surfaces and subtracting
|
||||
# them from the original slices
|
||||
my $outgrown = Math::Clipper::offset([ map $_->p, @{$self->slices} ], $distance);
|
||||
my $outgrown = [ Slic3r::Geometry::Clipper::offset([ map $_->p, @{$self->slices} ], $distance) ];
|
||||
my $diff = diff_ex(
|
||||
[ map $_->p, @surfaces ],
|
||||
$outgrown,
|
||||
@ -410,7 +409,7 @@ sub prepare_fill_surfaces {
|
||||
|
||||
# offset inwards
|
||||
my @offsets = $surface->expolygon->offset_ex(-$distance);
|
||||
@offsets = @{union_ex(Math::Clipper::offset([ map @$_, @offsets ], $distance, 1, JT_MITER))};
|
||||
@offsets = @{union_ex([ Slic3r::Geometry::Clipper::offset([ map @$_, @offsets ], $distance)] )}; # isn't the union_ex useless?
|
||||
map Slic3r::Surface->new(
|
||||
expolygon => $_,
|
||||
surface_type => $surface->surface_type,
|
||||
|
@ -21,7 +21,7 @@ sub boost_linestring {
|
||||
|
||||
sub is_counter_clockwise {
|
||||
my $self = shift;
|
||||
return Math::Clipper::is_counter_clockwise($self);
|
||||
return Slic3r::Geometry::Clipper::is_counter_clockwise($self);
|
||||
}
|
||||
|
||||
sub make_counter_clockwise {
|
||||
|
@ -2,7 +2,6 @@ package Slic3r::Polyline;
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use Math::Clipper qw();
|
||||
use Scalar::Util qw(reftype);
|
||||
use Slic3r::Geometry qw(A B X Y X1 X2 Y1 Y2 polyline_remove_parallel_continuous_edges polyline_remove_acute_vertices
|
||||
polyline_lines move_points same_point);
|
||||
|
@ -579,7 +579,7 @@ sub make_skirt {
|
||||
my $distance = scale $Slic3r::Config->skirt_distance;
|
||||
for (my $i = $Slic3r::Config->skirts; $i > 0; $i--) {
|
||||
$distance += scale $spacing;
|
||||
my $loop = Math::Clipper::offset([$convex_hull], $distance, &Slic3r::SCALING_FACTOR * 100, JT_ROUND)->[0];
|
||||
my ($loop) = Slic3r::Geometry::Clipper::offset([$convex_hull], $distance, 0.0001, JT_ROUND);
|
||||
push @{$self->skirt}, Slic3r::ExtrusionLoop->pack(
|
||||
polygon => Slic3r::Polygon->new(@$loop),
|
||||
role => EXTR_ROLE_SKIRT,
|
||||
@ -634,7 +634,7 @@ sub make_brim {
|
||||
polygon => Slic3r::Polygon->new($_),
|
||||
role => EXTR_ROLE_SKIRT,
|
||||
flow_spacing => $Slic3r::first_layer_flow->spacing,
|
||||
) for @{Math::Clipper::offset(\@islands, $i * $Slic3r::first_layer_flow->scaled_spacing, 100, JT_SQUARE)};
|
||||
) for Slic3r::Geometry::Clipper::offset(\@islands, $i * $Slic3r::first_layer_flow->scaled_spacing, undef, JT_SQUARE);
|
||||
# TODO: we need the offset inwards/offset outwards logic to avoid overlapping extrusions
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user