mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-08 23:46:24 -06:00
Fixes for bridges
This commit is contained in:
parent
459577f9a2
commit
84abd41cf4
9 changed files with 131 additions and 31 deletions
|
@ -15,6 +15,8 @@ our @EXPORT_OK = qw(
|
|||
sum_vectors multiply_vector subtract_vectors dot perp polygon_points_visibility
|
||||
line_intersection bounding_box bounding_box_intersect
|
||||
clip_segment_complex_polygon longest_segment angle3points
|
||||
polyline_remove_parallel_continuous_edges polyline_remove_acute_vertices
|
||||
polygon_remove_acute_vertices polygon_remove_parallel_continuous_edges
|
||||
);
|
||||
|
||||
use Slic3r::Geometry::DouglasPeucker qw(Douglas_Peucker);
|
||||
|
@ -575,4 +577,39 @@ sub angle3points {
|
|||
return $angle <= 0 ? $angle + 2*PI() : $angle;
|
||||
}
|
||||
|
||||
sub polyline_remove_parallel_continuous_edges {
|
||||
my ($points, $isPolygon) = @_;
|
||||
|
||||
for (my $i = $isPolygon ? 0 : 2; $i <= $#$points; $i++) {
|
||||
if (Slic3r::Geometry::lines_parallel([$points->[$i-2], $points->[$i-1]], [$points->[$i-1], $points->[$i]])) {
|
||||
# we can remove $points->[$i-1]
|
||||
splice @$points, $i-1, 1;
|
||||
$i--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sub polygon_remove_parallel_continuous_edges {
|
||||
my ($points) = @_;
|
||||
return polyline_remove_parallel_continuous_edges($points, 1);
|
||||
}
|
||||
|
||||
sub polyline_remove_acute_vertices {
|
||||
my ($points, $isPolygon) = @_;
|
||||
|
||||
for (my $i = $isPolygon ? -1 : 1; $i < $#$points; $i++) {
|
||||
my $angle = angle3points($points->[$i], $points->[$i-1], $points->[$i+1]);
|
||||
if ($angle < 0.01 || $angle >= 2*PI - 0.01) {
|
||||
# we can remove $points->[$i]
|
||||
splice @$points, $i, 1;
|
||||
$i--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sub polygon_remove_acute_vertices {
|
||||
my ($points) = @_;
|
||||
return polyline_remove_acute_vertices($points, 1);
|
||||
}
|
||||
|
||||
1;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue