mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-23 22:54:08 -06:00
Reapply correct optimization for simplifiying fill_surfaces before performing the offset. #1325
This commit is contained in:
parent
9433048873
commit
e29aca3553
5 changed files with 40 additions and 12 deletions
|
@ -145,15 +145,21 @@ sub clip_line {
|
|||
return Boost::Geometry::Utils::polygon_multi_linestring_intersection($self, [$line]);
|
||||
}
|
||||
|
||||
sub simplify {
|
||||
sub simplify_as_polygons {
|
||||
my $self = shift;
|
||||
my ($tolerance) = @_;
|
||||
|
||||
# it would be nice to have a multilinestring_simplify method in B::G::U
|
||||
my @simplified = Slic3r::Geometry::Clipper::simplify_polygons(
|
||||
return Slic3r::Geometry::Clipper::simplify_polygons(
|
||||
[ map Boost::Geometry::Utils::linestring_simplify($_, $tolerance), @$self ],
|
||||
);
|
||||
return @{ Slic3r::Geometry::Clipper::union_ex([ @simplified ]) };
|
||||
}
|
||||
|
||||
sub simplify {
|
||||
my $self = shift;
|
||||
my ($tolerance) = @_;
|
||||
|
||||
return @{ Slic3r::Geometry::Clipper::union_ex([ $self->simplify_as_polygons($tolerance) ]) };
|
||||
}
|
||||
|
||||
sub scale {
|
||||
|
|
|
@ -150,12 +150,14 @@ sub collapse_ex {
|
|||
|
||||
sub simplify_polygon {
|
||||
my ($polygon, $pft) = @_;
|
||||
return @{ Math::Clipper::simplify_polygon($polygon, $pft // PFT_NONZERO) };
|
||||
return map Slic3r::Polygon->new(@$_),
|
||||
@{ Math::Clipper::simplify_polygon($polygon, $pft // PFT_NONZERO) };
|
||||
}
|
||||
|
||||
sub simplify_polygons {
|
||||
my ($polygons, $pft) = @_;
|
||||
return @{ Math::Clipper::simplify_polygons($polygons, $pft // PFT_NONZERO) };
|
||||
return map Slic3r::Polygon->new(@$_),
|
||||
@{ Math::Clipper::simplify_polygons($polygons, $pft // PFT_NONZERO) };
|
||||
}
|
||||
|
||||
sub traverse_pt {
|
||||
|
|
|
@ -209,12 +209,11 @@ sub make_perimeters {
|
|||
# and then we offset back and forth by the infill spacing to only consider the
|
||||
# non-collapsing regions
|
||||
push @{ $self->fill_surfaces },
|
||||
map $_->simplify(&Slic3r::SCALED_RESOLUTION),
|
||||
offset2_ex(
|
||||
\@last,
|
||||
-($perimeter_spacing/2 + $infill_spacing),
|
||||
+$infill_spacing,
|
||||
);
|
||||
offset2_ex(
|
||||
[ map $_->simplify_as_polygons(&Slic3r::SCALED_RESOLUTION), @{union_ex(\@last)} ],
|
||||
-($perimeter_spacing/2 + $infill_spacing),
|
||||
+$infill_spacing,
|
||||
);
|
||||
}
|
||||
|
||||
$self->_fill_gaps(\@gaps);
|
||||
|
|
|
@ -72,6 +72,8 @@ sub grow {
|
|||
return $self->split_at_first_point->grow(@_);
|
||||
}
|
||||
|
||||
# NOTE that this will turn the polygon to ccw regardless of its
|
||||
# original orientation
|
||||
sub simplify {
|
||||
my $self = shift;
|
||||
return Slic3r::Geometry::Clipper::simplify_polygon( $self->SUPER::simplify(@_) );
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue