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:
parent
eb64cc4965
commit
b79ae44e3d
@ -38,7 +38,7 @@ use constant MIN => 0;
|
|||||||
use constant MAX => 1;
|
use constant MAX => 1;
|
||||||
our $parallel_degrees_limit = abs(deg2rad(3));
|
our $parallel_degrees_limit = abs(deg2rad(3));
|
||||||
|
|
||||||
our $epsilon = 1E-6;
|
our $epsilon = 1E-4;
|
||||||
sub epsilon () { $epsilon }
|
sub epsilon () { $epsilon }
|
||||||
|
|
||||||
sub scale ($) { $_[0] / $Slic3r::resolution }
|
sub scale ($) { $_[0] / $Slic3r::resolution }
|
||||||
@ -212,7 +212,7 @@ sub polyline_lines {
|
|||||||
my @lines = ();
|
my @lines = ();
|
||||||
my $last_point;
|
my $last_point;
|
||||||
foreach my $point (@$polygon) {
|
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;
|
$last_point = $point;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@ package Slic3r::TriangleMesh;
|
|||||||
use Moo;
|
use Moo;
|
||||||
|
|
||||||
use Slic3r::Geometry qw(X Y Z A B PI epsilon same_point points_coincide angle3points
|
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;
|
use XXX;
|
||||||
|
|
||||||
has 'facets' => (is => 'ro', default => sub { [] });
|
has 'facets' => (is => 'ro', default => sub { [] });
|
||||||
@ -194,28 +194,40 @@ sub make_loops {
|
|||||||
Slic3r::debugf " %d lines out of %d were discarded and %d polylines were not closed\n",
|
Slic3r::debugf " %d lines out of %d were discarded and %d polylines were not closed\n",
|
||||||
scalar(@discarded_lines), scalar(@lines), scalar(@discarded_polylines);
|
scalar(@discarded_lines), scalar(@lines), scalar(@discarded_polylines);
|
||||||
print " Warning: errors while parsing this layer (dirty or non-manifold model).\n";
|
print " Warning: errors while parsing this layer (dirty or non-manifold model).\n";
|
||||||
print " Retrying with slower algorithm.\n";
|
|
||||||
|
|
||||||
if (0) {
|
my $total_detected_length = 0;
|
||||||
require "Slic3r/SVG.pm";
|
$total_detected_length += $_->length for map $_->lines, @polygons;
|
||||||
Slic3r::SVG::output(undef, "layer" . $self->id . "_detected.svg",
|
my $total_discarded_length = 0;
|
||||||
white_polygons => \@polygons,
|
$total_discarded_length += $_->length for map polyline_lines($_), @discarded_polylines;
|
||||||
);
|
$total_discarded_length += $_->length for @discarded_lines;
|
||||||
Slic3r::SVG::output(undef, "layer" . $self->id . "_discarded_lines.svg",
|
my $discarded_ratio = $total_discarded_length / $total_detected_length;
|
||||||
red_lines => \@discarded_lines,
|
|
||||||
);
|
|
||||||
Slic3r::SVG::output(undef, "layer" . $self->id . "_discarded_polylines.svg",
|
|
||||||
polylines => \@discarded_polylines,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
$sparse_lines = merge_collinear_lines($sparse_lines);
|
Slic3r::debugf " length ratio of discarded lines is %f\n", $discarded_ratio;
|
||||||
eval { $detect->(); };
|
|
||||||
warn $@ if $@;
|
|
||||||
|
|
||||||
if (@discarded_lines) {
|
if ($discarded_ratio > 0.00001) {
|
||||||
print " Warning: even slow detection algorithm threw errors. Review the output before printing.\n";
|
print " Retrying with slower algorithm.\n";
|
||||||
$layer->slicing_errors(1);
|
|
||||||
|
if (0) {
|
||||||
|
require "Slic3r/SVG.pm";
|
||||||
|
Slic3r::SVG::output(undef, "layer" . $layer->id . "_detected.svg",
|
||||||
|
white_polygons => \@polygons,
|
||||||
|
);
|
||||||
|
Slic3r::SVG::output(undef, "layer" . $layer->id . "_discarded_lines.svg",
|
||||||
|
red_lines => \@discarded_lines,
|
||||||
|
);
|
||||||
|
Slic3r::SVG::output(undef, "layer" . $layer->id . "_discarded_polylines.svg",
|
||||||
|
polylines => \@discarded_polylines,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
$sparse_lines = merge_collinear_lines($sparse_lines);
|
||||||
|
eval { $detect->(); };
|
||||||
|
warn $@ if $@;
|
||||||
|
|
||||||
|
if (@discarded_lines) {
|
||||||
|
print " Warning: even slow detection algorithm threw errors. Review the output before printing.\n";
|
||||||
|
$layer->slicing_errors(1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user