mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-12 01:07:57 -06:00
Fixing of slicing errors ported to C++, parallelized.
This commit is contained in:
parent
73439b7acb
commit
4331f38912
4 changed files with 87 additions and 60 deletions
|
@ -46,66 +46,10 @@ sub slice {
|
|||
$self->print->status_cb->(10, "Processing triangulated mesh");
|
||||
|
||||
$self->_slice;
|
||||
|
||||
# detect slicing errors
|
||||
my $warning_thrown = 0;
|
||||
for my $i (0 .. ($self->layer_count - 1)) {
|
||||
my $layer = $self->get_layer($i);
|
||||
next unless $layer->slicing_errors;
|
||||
if (!$warning_thrown) {
|
||||
warn "The model has overlapping or self-intersecting facets. I tried to repair it, "
|
||||
. "however you might want to check the results or repair the input file and retry.\n";
|
||||
$warning_thrown = 1;
|
||||
}
|
||||
|
||||
# try to repair the layer surfaces by merging all contours and all holes from
|
||||
# neighbor layers
|
||||
Slic3r::debugf "Attempting to repair layer %d\n", $i;
|
||||
|
||||
foreach my $region_id (0 .. ($layer->region_count - 1)) {
|
||||
my $layerm = $layer->region($region_id);
|
||||
|
||||
my (@upper_surfaces, @lower_surfaces);
|
||||
for (my $j = $i+1; $j < $self->layer_count; $j++) {
|
||||
if (!$self->get_layer($j)->slicing_errors) {
|
||||
@upper_surfaces = @{$self->get_layer($j)->region($region_id)->slices};
|
||||
last;
|
||||
}
|
||||
}
|
||||
for (my $j = $i-1; $j >= 0; $j--) {
|
||||
if (!$self->get_layer($j)->slicing_errors) {
|
||||
@lower_surfaces = @{$self->get_layer($j)->region($region_id)->slices};
|
||||
last;
|
||||
}
|
||||
}
|
||||
|
||||
my $union = union_ex([
|
||||
map $_->expolygon->contour, @upper_surfaces, @lower_surfaces,
|
||||
]);
|
||||
my $diff = diff_ex(
|
||||
[ map @$_, @$union ],
|
||||
[ map @{$_->expolygon->holes}, @upper_surfaces, @lower_surfaces, ],
|
||||
);
|
||||
|
||||
$layerm->slices->clear;
|
||||
$layerm->slices->append($_)
|
||||
for map Slic3r::Surface->new
|
||||
(expolygon => $_, surface_type => S_TYPE_INTERNAL),
|
||||
@$diff;
|
||||
}
|
||||
|
||||
# update layer slices after repairing the single regions
|
||||
$layer->make_slices;
|
||||
}
|
||||
|
||||
# remove empty layers from bottom
|
||||
while (@{$self->layers} && !@{$self->get_layer(0)->slices}) {
|
||||
$self->delete_layer(0);
|
||||
for (my $i = 0; $i <= $#{$self->layers}; $i++) {
|
||||
$self->get_layer($i)->set_id( $self->get_layer($i)->id-1 );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
my $warning = $self->_fix_slicing_errors;
|
||||
warn $warning if (defined($warning) && $warning ne '');
|
||||
|
||||
# simplify slices if required
|
||||
if ($self->print->config->resolution) {
|
||||
$self->_simplify_slices(scale($self->print->config->resolution));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue