From 93a7d87fc66aabd3554dca2c320d942789d634a9 Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci Date: Mon, 7 Apr 2014 15:24:17 +0200 Subject: [PATCH] Bugfix: pillars support material crashed when no overhangs were detected --- lib/Slic3r/Print/SupportMaterial.pm | 5 ++++- xs/src/BoundingBox.cpp | 2 ++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/Slic3r/Print/SupportMaterial.pm b/lib/Slic3r/Print/SupportMaterial.pm index 864d2682..724ecc92 100644 --- a/lib/Slic3r/Print/SupportMaterial.pm +++ b/lib/Slic3r/Print/SupportMaterial.pm @@ -647,6 +647,9 @@ sub generate_toolpaths { sub generate_pillars_shape { my ($self, $contact, $support_z, $shape) = @_; + # this prevents supplying an empty point set to BoundingBox constructor + return if !%$contact; + my $pillar_size = scale PILLAR_SIZE; my $pillar_spacing = scale PILLAR_SPACING; @@ -658,7 +661,7 @@ sub generate_pillars_shape { [$pillar_size, $pillar_size], [0, $pillar_size], ); - + my @pillars = (); my $bb = Slic3r::Geometry::BoundingBox->new_from_points([ map @$_, map @$_, values %$contact ]); for (my $x = $bb->x_min; $x <= $bb->x_max-$pillar_size; $x += $pillar_spacing) { diff --git a/xs/src/BoundingBox.cpp b/xs/src/BoundingBox.cpp index 70d688e5..44641411 100644 --- a/xs/src/BoundingBox.cpp +++ b/xs/src/BoundingBox.cpp @@ -6,6 +6,7 @@ namespace Slic3r { template BoundingBoxBase::BoundingBoxBase(const std::vector &points) { + if (points.empty()) CONFESS("Empty point set supplied to BoundingBoxBase constructor"); typename std::vector::const_iterator it = points.begin(); this->min.x = this->max.x = it->x; this->min.y = this->max.y = it->y; @@ -22,6 +23,7 @@ template BoundingBox3Base::BoundingBox3Base(const std::vector &points) : BoundingBoxBase(points) { + if (points.empty()) CONFESS("Empty point set supplied to BoundingBox3Base constructor"); typename std::vector::const_iterator it = points.begin(); this->min.z = this->max.z = it->z; for (++it; it != points.end(); ++it) {