Removed clip_with_polygon() and clip_with_expolygon()

This commit is contained in:
Alessandro Ranellucci 2013-11-21 18:16:03 +01:00
parent ac88fbcbb0
commit 3aef663f7f
4 changed files with 4 additions and 39 deletions

View File

@ -10,29 +10,9 @@ our @EXPORT_OK = qw(EXTR_ROLE_PERIMETER EXTR_ROLE_EXTERNAL_PERIMETER
EXTR_ROLE_INTERNALBRIDGE EXTR_ROLE_SKIRT EXTR_ROLE_SUPPORTMATERIAL EXTR_ROLE_GAPFILL);
our %EXPORT_TAGS = (roles => \@EXPORT_OK);
sub clip_with_polygon {
my $self = shift;
my ($polygon) = @_;
return $self->clip_with_expolygon(Slic3r::ExPolygon->new($polygon));
}
sub clip_with_expolygon {
my $self = shift;
my ($expolygon) = @_;
return map $self->clone(polyline => $_),
$self->polyline->clip_with_expolygon($expolygon);
}
sub simplify {
my $self = shift;
$self->polyline($self->polyline->simplify(@_));
}
sub points {
my $self = shift;
return $self->polyline;
}
1;

View File

@ -4,6 +4,7 @@ use Moo;
extends 'Slic3r::Fill::Base';
use Slic3r::Geometry qw(scale X1 Y1 X2 Y2);
use Slic3r::Geometry::Clipper qw(intersection_pl);
sub multiplier () { 1 }
@ -40,8 +41,7 @@ sub fill_surface {
$self->process_polyline($polyline, $bounding_box);
my @paths = map $_->clip_with_expolygon($expolygon),
$polyline->clip_with_polygon($bounding_box->polygon);
my @paths = @{intersection_pl([$polyline], \@$expolygon)};
if (0) {
require "Slic3r/SVG.pm";

View File

@ -6,7 +6,7 @@ use Slic3r::ExtrusionPath ':roles';
use Slic3r::Geometry qw(PI A B scale unscale chained_path_items points_coincide);
use Slic3r::Geometry::Clipper qw(union_ex diff_ex intersection_ex
offset offset2 offset2_ex union_pt traverse_pt diff intersection
union diff);
union diff intersection_pl);
use Slic3r::Surface ':types';
has 'layer' => (
@ -491,7 +491,7 @@ sub _detect_bridge_direction {
foreach my $lower (@lower) {
# turn bridge contour and holes into polylines and then clip them
# with each lower slice's contour
my @clipped = map $_->split_at_first_point->clip_with_polygon($lower->contour), map @$_, @$grown;
my @clipped = @{intersection_pl([ map $_->split_at_first_point, map @$_, @$grown ], [$lower->contour])};
if (@clipped == 2) {
# If the split_at_first_point() call above happens to split the polygon inside the clipping area
# we would get two consecutive polylines instead of a single one, so we use this ugly hack to

View File

@ -35,21 +35,6 @@ sub simplify {
return __PACKAGE__->new(@$simplified);
}
sub clip_with_polygon {
my $self = shift;
my ($polygon) = @_;
return $self->clip_with_expolygon(Slic3r::ExPolygon->new($polygon));
}
sub clip_with_expolygon {
my $self = shift;
my ($expolygon) = @_;
my $result = Boost::Geometry::Utils::polygon_multi_linestring_intersection($expolygon->pp, [$self->pp]);
return map { __PACKAGE__->new(@$_) } @$result;
}
sub bounding_box {
my $self = shift;
return Slic3r::Geometry::BoundingBox->new_from_points($self);