Remove residual uses of Boost for line clipping

This commit is contained in:
Alessandro Ranellucci 2013-11-21 18:47:25 +01:00
parent 5f2b2c90b6
commit 7475762a27
4 changed files with 22 additions and 22 deletions

View File

@ -110,8 +110,8 @@ sub _medial_axis_clip {
push @$covered, map $grow->($_, $width*1.1), @$clipped;
# if the first remaining segment is connected to the last polyline, append it
# to that -- NOTE: this assumes that multi_linestring_multi_polygon_difference()
# preserved the orientation of the input linestring
# to that -- FIXME: this assumes that diff_pl()
# preserved the orientation of the input linestring but this is not generally true
if (@polylines && @$clipped && $clipped->[0]->first_point->distance_to($polylines[-1]->last_point) <= $width/10) {
$polylines[-1]->append_polyline(shift @$clipped);
}

View File

@ -4,7 +4,8 @@ use Moo;
use List::Util qw(sum min max);
use Slic3r::ExtrusionPath ':roles';
use Slic3r::Geometry qw(scale scaled_epsilon PI rad2deg deg2rad);
use Slic3r::Geometry::Clipper qw(offset diff union union_ex intersection offset_ex offset2);
use Slic3r::Geometry::Clipper qw(offset diff union union_ex intersection offset_ex offset2
intersection_pl);
use Slic3r::Surface ':types';
has 'config' => (is => 'rw', required => 1);
@ -442,11 +443,11 @@ sub generate_toolpaths {
# only consider the loops facing the overhang
{
my $overhang_with_margin = offset_ex($overhang, +$flow->scaled_width/2);
my $overhang_with_margin = offset($overhang, +$flow->scaled_width/2);
@external_loops = grep {
@{ Boost::Geometry::Utils::multi_polygon_multi_linestring_intersection(
[ map $_->pp, @$overhang_with_margin ],
[ $_->split_at_first_point->pp ],
@{intersection_pl(
[ $_->split_at_first_point ],
$overhang_with_margin,
)}
} @external_loops;
}
@ -467,10 +468,9 @@ sub generate_toolpaths {
}
# clip such loops to the side oriented towards the object
@loops = map Slic3r::Polyline->new(@$_),
@{ Boost::Geometry::Utils::multi_polygon_multi_linestring_intersection(
[ map $_->pp, @{offset_ex($overhang, +scale MARGIN)} ],
[ map $_->split_at_first_point->pp, @loops ],
@loops = @{intersection_pl(
[ map $_->split_at_first_point, @loops ],
offset($overhang, +scale MARGIN),
)};
# add the contact infill area to the interface area

View File

@ -3,7 +3,7 @@ use Moo;
use List::Util qw(first max);
use Slic3r::Geometry qw(X Y A B X1 Y1 X2 Y2 unscale);
use Slic3r::Geometry::Clipper qw(union_ex);
use Slic3r::Geometry::Clipper qw(union_ex intersection_pl);
use SVG;
has 'scale' => (is => 'ro', default => sub {30});
@ -17,7 +17,7 @@ sub _build_line {
my $bb = $self->print->bounding_box;
my $y = $bb->size->[Y] * $self->y_percent;
return [ [ $bb->x_min, $y ], [ $bb->x_max, $y ] ]
return Slic3r::Line->new([ $bb->x_min, $y ], [ $bb->x_max, $y ]);
}
sub export_svg {
@ -91,9 +91,9 @@ sub _plot {
foreach my $path (@paths) {
foreach my $line (@{$path->lines}) {
my @intersections = @{ Boost::Geometry::Utils::polygon_multi_linestring_intersection(
Slic3r::ExPolygon->new(@{$line->grow(Slic3r::Geometry::scale $path->flow_spacing/2)})->pp,
[ $self->line ],
my @intersections = @{intersection_pl(
[ $self->line->as_polyline ],
$line->grow(Slic3r::Geometry::scale $path->flow_spacing/2),
)};
die "Intersection has more than two points!\n" if first { @$_ > 2 } @intersections;

View File

@ -80,9 +80,9 @@ my %opt = (
# draw paths
foreach my $z (sort keys %paths) {
foreach my $line (@{ $paths{$z} }) {
my @intersections = @{ Boost::Geometry::Utils::polygon_multi_linestring_intersection(
Slic3r::ExPolygon->new(_grow($line, $opt{extrusion_width}/2)),
my @intersections = @{intersection_pl(
[ $section_line ],
[ _grow($line, $opt{extrusion_width}/2) ],
)};
$g->rectangle(