Recent changes made Slic3r less tolerant with dirty STL files. Now we are able again to slice Prusa parts. #16

This commit is contained in:
Alessandro Ranellucci 2011-12-04 19:10:43 +01:00
parent eb64cc4965
commit b79ae44e3d
2 changed files with 34 additions and 22 deletions

View File

@ -38,7 +38,7 @@ use constant MIN => 0;
use constant MAX => 1;
our $parallel_degrees_limit = abs(deg2rad(3));
our $epsilon = 1E-6;
our $epsilon = 1E-4;
sub epsilon () { $epsilon }
sub scale ($) { $_[0] / $Slic3r::resolution }
@ -212,7 +212,7 @@ sub polyline_lines {
my @lines = ();
my $last_point;
foreach my $point (@$polygon) {
push @lines, [ $last_point, $point ] if $last_point;
push @lines, Slic3r::Line->new($last_point, $point) if $last_point;
$last_point = $point;
}

View File

@ -2,7 +2,7 @@ package Slic3r::TriangleMesh;
use Moo;
use Slic3r::Geometry qw(X Y Z A B PI epsilon same_point points_coincide angle3points
merge_collinear_lines nearest_point);
merge_collinear_lines nearest_point polyline_lines);
use XXX;
has 'facets' => (is => 'ro', default => sub { [] });
@ -194,17 +194,28 @@ sub make_loops {
Slic3r::debugf " %d lines out of %d were discarded and %d polylines were not closed\n",
scalar(@discarded_lines), scalar(@lines), scalar(@discarded_polylines);
print " Warning: errors while parsing this layer (dirty or non-manifold model).\n";
my $total_detected_length = 0;
$total_detected_length += $_->length for map $_->lines, @polygons;
my $total_discarded_length = 0;
$total_discarded_length += $_->length for map polyline_lines($_), @discarded_polylines;
$total_discarded_length += $_->length for @discarded_lines;
my $discarded_ratio = $total_discarded_length / $total_detected_length;
Slic3r::debugf " length ratio of discarded lines is %f\n", $discarded_ratio;
if ($discarded_ratio > 0.00001) {
print " Retrying with slower algorithm.\n";
if (0) {
require "Slic3r/SVG.pm";
Slic3r::SVG::output(undef, "layer" . $self->id . "_detected.svg",
Slic3r::SVG::output(undef, "layer" . $layer->id . "_detected.svg",
white_polygons => \@polygons,
);
Slic3r::SVG::output(undef, "layer" . $self->id . "_discarded_lines.svg",
Slic3r::SVG::output(undef, "layer" . $layer->id . "_discarded_lines.svg",
red_lines => \@discarded_lines,
);
Slic3r::SVG::output(undef, "layer" . $self->id . "_discarded_polylines.svg",
Slic3r::SVG::output(undef, "layer" . $layer->id . "_discarded_polylines.svg",
polylines => \@discarded_polylines,
);
}
@ -218,6 +229,7 @@ sub make_loops {
$layer->slicing_errors(1);
}
}
}
return [@polygons];
}