mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-08-12 20:29:04 +08:00
Some cleanup for the Voronoi code
This commit is contained in:
parent
a88ce0cb5e
commit
78167f56ee
@ -105,29 +105,30 @@ sub medial_axis {
|
|||||||
my $self = shift;
|
my $self = shift;
|
||||||
my ($width) = @_;
|
my ($width) = @_;
|
||||||
|
|
||||||
my @points = ();
|
my $voronoi;
|
||||||
foreach my $polygon (@$self) {
|
{
|
||||||
{
|
my @points = ();
|
||||||
my $p = $polygon->pp;
|
foreach my $polygon (@$self) {
|
||||||
Slic3r::Geometry::polyline_remove_short_segments($p, $width / 2);
|
{
|
||||||
$polygon = Slic3r::Polygon->new(@$p);
|
my $p = $polygon->pp;
|
||||||
|
Slic3r::Geometry::polyline_remove_short_segments($p, $width / 2);
|
||||||
|
$polygon = Slic3r::Polygon->new(@$p);
|
||||||
|
}
|
||||||
|
|
||||||
|
# subdivide polygon segments so that we don't have anyone of them
|
||||||
|
# being longer than $width / 2
|
||||||
|
$polygon = $polygon->subdivide($width/2);
|
||||||
|
|
||||||
|
push @points, map $_->pp, @$polygon;
|
||||||
}
|
}
|
||||||
|
$voronoi = Math::Geometry::Voronoi->new(points => \@points);
|
||||||
# subdivide polygon segments so that we don't have anyone of them
|
|
||||||
# being longer than $width / 2
|
|
||||||
$polygon = $polygon->subdivide($width/2);
|
|
||||||
|
|
||||||
push @points, map $_->clone, @$polygon;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
my $voronoi = Math::Geometry::Voronoi->new(points => [ map $_->pp, @points ]);
|
|
||||||
$voronoi->compute;
|
$voronoi->compute;
|
||||||
|
my $vertices = $voronoi->vertices;
|
||||||
|
|
||||||
my @skeleton_lines = ();
|
my @skeleton_lines = ();
|
||||||
|
foreach my $edge (@{ $voronoi->edges }) {
|
||||||
my $vertices = $voronoi->vertices;
|
|
||||||
my $edges = $voronoi->edges;
|
|
||||||
foreach my $edge (@$edges) {
|
|
||||||
# ignore lines going to infinite
|
# ignore lines going to infinite
|
||||||
next if $edge->[1] == -1 || $edge->[2] == -1;
|
next if $edge->[1] == -1 || $edge->[2] == -1;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user