From 4a894b1e20a8b267e61ad884ef41c048f76d0b62 Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci Date: Wed, 5 Mar 2014 00:45:17 +0100 Subject: [PATCH] Add safety offset to thin wall regions to prevent overlapping geometry and corrupt Voronoi diagram --- lib/Slic3r/Layer/Region.pm | 5 ++--- xs/src/Geometry.cpp | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/Slic3r/Layer/Region.pm b/lib/Slic3r/Layer/Region.pm index f4c425a19..798fe363a 100644 --- a/lib/Slic3r/Layer/Region.pm +++ b/lib/Slic3r/Layer/Region.pm @@ -99,6 +99,7 @@ sub make_perimeters { my $diff = diff_ex( \@last, offset(\@offsets, +0.5*$pwidth), + 1, # medial axis requires non-overlapping geometry ); push @thin_walls, @$diff; } @@ -222,9 +223,6 @@ sub make_perimeters { $self->perimeters->append(@loops); # process thin walls by collapsing slices to single passes - my $min_thin_wall_width = $pwidth/3; - my $min_thin_wall_length = 2*$pwidth; - #@thin_walls = @{offset2_ex([ map @$_, @thin_walls ], -0.5*$min_thin_wall_width, +0.5*$min_thin_wall_width)}; if (@thin_walls) { my @p = map @{$_->medial_axis($pspacing)}, @thin_walls; @@ -240,6 +238,7 @@ sub make_perimeters { } my @paths = (); + my $min_thin_wall_length = 2*$pwidth; for my $p (@p) { next if $p->length < $min_thin_wall_length; my %params = ( diff --git a/xs/src/Geometry.cpp b/xs/src/Geometry.cpp index a4ff2f24d..c324a162c 100644 --- a/xs/src/Geometry.cpp +++ b/xs/src/Geometry.cpp @@ -237,7 +237,7 @@ MedialAxis::is_valid_edge(const VD::edge_type& edge) const // if we only process segments representing closed loops, none if the // infinite edges (if any) would be part of our MAT anyway if (edge.is_secondary() || edge.is_infinite()) return false; - + /* If the cells sharing this edge have a common vertex, we're not interested in this edge. Why? Because it means that the edge lies on the bisector of two contiguous input lines and it was included in the Voronoi graph because