diff --git a/lib/Slic3r/Layer/Region.pm b/lib/Slic3r/Layer/Region.pm index 05713ba12..1cb7ae155 100644 --- a/lib/Slic3r/Layer/Region.pm +++ b/lib/Slic3r/Layer/Region.pm @@ -214,7 +214,7 @@ sub make_perimeters { # make sure we don't infill narrow parts that are already gap-filled # (we only consider this surface's gaps to reduce the diff() complexity) - @last = @{diff(\@last, \@last_gaps)}; + @last = @{diff(\@last, [ map @$_, @last_gaps ])}; # create one more offset to be used as boundary for fill # we offset by half the perimeter spacing (to get to the actual infill boundary) @@ -508,7 +508,7 @@ sub process_external_surfaces { sub _detect_bridge_direction { my ($self, $expolygon, $lower_layer) = @_; - my $grown = $expolygon->offset_ex(+$self->perimeter_flow->scaled_width); + my $grown = $expolygon->offset(+$self->perimeter_flow->scaled_width); my @lower = @{$lower_layer->slices}; # expolygons # detect what edges lie on lower slices @@ -516,7 +516,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 = map $_->split_at_first_point->clip_with_polygon($lower->contour), @$grown; 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 @@ -567,7 +567,7 @@ sub _detect_bridge_direction { # detect anchors as intersection between our bridge expolygon and the lower slices my $anchors = intersection_ex( - [ @$grown ], + $grown, [ map @$_, @lower ], 1, # safety offset required to avoid Clipper from detecting empty intersection while Boost actually found some @edges ); diff --git a/xs/src/ExPolygon.cpp b/xs/src/ExPolygon.cpp index 7a58e969e..eaa209494 100644 --- a/xs/src/ExPolygon.cpp +++ b/xs/src/ExPolygon.cpp @@ -111,6 +111,8 @@ void ExPolygon::from_SV_check(SV* expoly_sv) { if (sv_isobject(expoly_sv) && (SvTYPE(SvRV(expoly_sv)) == SVt_PVMG)) { + if (!sv_isa(expoly_sv, "Slic3r::ExPolygon") && !sv_isa(expoly_sv, "Slic3r::ExPolygon::Ref")) + CONFESS("Not a valid Slic3r::ExPolygon object"); // a XS ExPolygon was supplied *this = *(ExPolygon *)SvIV((SV*)SvRV( expoly_sv )); } else { diff --git a/xs/src/Line.cpp b/xs/src/Line.cpp index 0e4698b7f..31994a818 100644 --- a/xs/src/Line.cpp +++ b/xs/src/Line.cpp @@ -79,6 +79,8 @@ void Line::from_SV_check(SV* line_sv) { if (sv_isobject(line_sv) && (SvTYPE(SvRV(line_sv)) == SVt_PVMG)) { + if (!sv_isa(line_sv, "Slic3r::Line") && !sv_isa(line_sv, "Slic3r::Line::Ref")) + CONFESS("Not a valid Slic3r::Line object"); *this = *(Line*)SvIV((SV*)SvRV( line_sv )); } else { this->from_SV(line_sv); diff --git a/xs/src/Point.cpp b/xs/src/Point.cpp index b39a06c11..9251eca93 100644 --- a/xs/src/Point.cpp +++ b/xs/src/Point.cpp @@ -122,6 +122,8 @@ void Point::from_SV_check(SV* point_sv) { if (sv_isobject(point_sv) && (SvTYPE(SvRV(point_sv)) == SVt_PVMG)) { + if (!sv_isa(point_sv, "Slic3r::Point") && !sv_isa(point_sv, "Slic3r::Point::Ref")) + CONFESS("Not a valid Slic3r::Point object"); *this = *(Point*)SvIV((SV*)SvRV( point_sv )); } else { this->from_SV(point_sv); diff --git a/xs/src/Polygon.cpp b/xs/src/Polygon.cpp index 592503e2e..e7fa7a6ef 100644 --- a/xs/src/Polygon.cpp +++ b/xs/src/Polygon.cpp @@ -126,6 +126,15 @@ Polygon::to_SV_clone_ref() const { sv_setref_pv( sv, "Slic3r::Polygon", new Polygon(*this) ); return sv; } + +void +Polygon::from_SV_check(SV* poly_sv) +{ + if (sv_isobject(poly_sv) && !sv_isa(poly_sv, "Slic3r::Polygon") && !sv_isa(poly_sv, "Slic3r::Polygon::Ref")) + CONFESS("Not a valid Slic3r::Polygon object"); + + MultiPoint::from_SV_check(poly_sv); +} #endif } diff --git a/xs/src/Polygon.hpp b/xs/src/Polygon.hpp index ab04ed624..d31f3c4ff 100644 --- a/xs/src/Polygon.hpp +++ b/xs/src/Polygon.hpp @@ -25,6 +25,7 @@ class Polygon : public MultiPoint { bool is_valid() const; #ifdef SLIC3RXS + void from_SV_check(SV* poly_sv); SV* to_SV_ref(); SV* to_SV_clone_ref() const; #endif diff --git a/xs/src/Polyline.cpp b/xs/src/Polyline.cpp index fc3950757..e7b65eb5f 100644 --- a/xs/src/Polyline.cpp +++ b/xs/src/Polyline.cpp @@ -96,6 +96,15 @@ Polyline::to_SV_clone_ref() const sv_setref_pv( sv, "Slic3r::Polyline", new Polyline(*this) ); return sv; } + +void +Polyline::from_SV_check(SV* poly_sv) +{ + if (!sv_isa(poly_sv, "Slic3r::Polyline") && !sv_isa(poly_sv, "Slic3r::Polyline::Ref")) + CONFESS("Not a valid Slic3r::Polyline object"); + + MultiPoint::from_SV_check(poly_sv); +} #endif } diff --git a/xs/src/Polyline.hpp b/xs/src/Polyline.hpp index c17b97f9f..b7401bad4 100644 --- a/xs/src/Polyline.hpp +++ b/xs/src/Polyline.hpp @@ -15,6 +15,7 @@ class Polyline : public MultiPoint { Points equally_spaced_points(double distance) const; #ifdef SLIC3RXS + void from_SV_check(SV* poly_sv); SV* to_SV_ref(); SV* to_SV_clone_ref() const; #endif