CLIPPER_OFFSET_SCALE was made a power of two, the scaling functions

inside ClipperUtils are now using bit shifts instead of multiplication
by doubles, which makes the scaling precise.

Removed the scale parameter from all offset functions.

Modified the safety offset to calculate offset per polygon instead
of over all polygons at once. The old way was not safe and very slow,
sometimes this meant a kiss of death for supports for example.
This commit is contained in:
bubnikv 2016-11-28 17:33:17 +01:00
parent e93253e270
commit 695c92fb00
14 changed files with 214 additions and 152 deletions

View file

@ -7,7 +7,7 @@ use List::Util qw(min max sum first);
use Slic3r::Flow ':roles';
use Slic3r::Geometry qw(X Y Z PI scale unscale chained_path epsilon);
use Slic3r::Geometry::Clipper qw(diff diff_ex intersection intersection_ex union union_ex
offset offset_ex offset2 offset2_ex intersection_ppl CLIPPER_OFFSET_SCALE JT_MITER);
offset offset_ex offset2 offset2_ex intersection_ppl JT_MITER);
use Slic3r::Print::State ':steps';
use Slic3r::Surface ':types';
@ -863,7 +863,7 @@ sub discover_horizontal_shells {
# and it's not wanted in a hollow print even if it would make sense when
# obeying the solid shell count option strictly (DWIM!)
my $margin = $neighbor_layerm->flow(FLOW_ROLE_EXTERNAL_PERIMETER)->scaled_width;
my $regularized = offset2($new_internal_solid, -$margin, +$margin, CLIPPER_OFFSET_SCALE, JT_MITER, 5);
my $regularized = offset2($new_internal_solid, -$margin, +$margin, JT_MITER, 5);
my $too_narrow = diff(
$new_internal_solid,
$regularized,
@ -893,7 +893,7 @@ sub discover_horizontal_shells {
# have the same angle, so the next shell would be grown even more and so on.
my $too_narrow = diff(
$new_internal_solid,
offset2($new_internal_solid, -$margin, +$margin, CLIPPER_OFFSET_SCALE, JT_MITER, 5),
offset2($new_internal_solid, -$margin, +$margin, JT_MITER, 5),
1,
);

View file

@ -8,7 +8,7 @@ use Slic3r::ExtrusionPath ':roles';
use Slic3r::Flow ':roles';
use Slic3r::Geometry qw(epsilon scale scaled_epsilon PI rad2deg deg2rad convex_hull);
use Slic3r::Geometry::Clipper qw(offset diff union union_ex intersection offset_ex offset2
intersection_pl offset2_ex diff_pl CLIPPER_OFFSET_SCALE JT_MITER JT_ROUND);
intersection_pl offset2_ex diff_pl JT_MITER JT_ROUND);
use Slic3r::Surface ':types';
has 'print_config' => (is => 'rw', required => 1);
@ -299,9 +299,8 @@ sub contact_area {
offset(
$diff,
$_,
CLIPPER_OFFSET_SCALE,
JT_ROUND,
scale(0.05)*CLIPPER_OFFSET_SCALE),
scale(0.05)),
$slices_margin
);
}
@ -584,9 +583,8 @@ sub generate_base_layers {
$fillet_radius_scaled,
-$fillet_radius_scaled,
# Use a geometric offsetting for filleting.
CLIPPER_OFFSET_SCALE,
JT_ROUND,
0.2*$fillet_radius_scaled*CLIPPER_OFFSET_SCALE),
0.2*$fillet_radius_scaled),
$trim_polygons,
0); # don't apply the safety offset.
}