mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-08-14 04:35:54 +08:00
Center hilbertcurve, archimedeanchords, octagramspiral around object's center and align them across layers
This commit is contained in:
parent
1b582ea66a
commit
45cc204f74
@ -23,19 +23,32 @@ sub fill_surface {
|
|||||||
|
|
||||||
my $flow = $params{flow};
|
my $flow = $params{flow};
|
||||||
my $distance_between_lines = $flow->scaled_spacing / $params{density} * $self->multiplier;
|
my $distance_between_lines = $flow->scaled_spacing / $params{density} * $self->multiplier;
|
||||||
my $bounding_box = $expolygon->bounding_box;
|
|
||||||
|
|
||||||
# since not all PlanePath infills extend in negative coordinate space,
|
# align infill across layers using the object's bounding box
|
||||||
# move expolygon in positive coordinate space
|
my $bb_polygon = $self->bounding_box->polygon;
|
||||||
$expolygon->translate(-$bounding_box->x_min, -$bounding_box->y_min);
|
$self->rotate_points($bb_polygon, $rotate_vector);
|
||||||
|
my $bounding_box = $bb_polygon->bounding_box;
|
||||||
|
|
||||||
(ref $self) =~ /::([^:]+)$/;
|
(ref $self) =~ /::([^:]+)$/;
|
||||||
my $path = "Math::PlanePath::$1"->new;
|
my $path = "Math::PlanePath::$1"->new;
|
||||||
|
|
||||||
|
my $translate = Slic3r::Point->new(0,0); # vector
|
||||||
|
if ($path->x_negative || $path->y_negative) {
|
||||||
|
# if the curve extends on both positive and negative coordinate space,
|
||||||
|
# center our expolygon around origin
|
||||||
|
$translate = $bounding_box->center->negative;
|
||||||
|
} else {
|
||||||
|
# if the curve does not extend in negative coordinate space,
|
||||||
|
# move expolygon entirely in positive coordinate space
|
||||||
|
$translate = $bounding_box->min_point->negative;
|
||||||
|
}
|
||||||
|
$expolygon->translate(@$translate);
|
||||||
|
$bounding_box->translate(@$translate);
|
||||||
|
|
||||||
my ($n_lo, $n_hi) = $path->rect_to_n_range(
|
my ($n_lo, $n_hi) = $path->rect_to_n_range(
|
||||||
map { $_ / $distance_between_lines }
|
map { $_ / $distance_between_lines }
|
||||||
0, 0,
|
@{$bounding_box->min_point},
|
||||||
@{$bounding_box->size},
|
@{$bounding_box->max_point},
|
||||||
);
|
);
|
||||||
|
|
||||||
my $polyline = Slic3r::Polyline->new(
|
my $polyline = Slic3r::Polyline->new(
|
||||||
@ -52,12 +65,13 @@ sub fill_surface {
|
|||||||
Slic3r::SVG::output("fill.svg",
|
Slic3r::SVG::output("fill.svg",
|
||||||
no_arrows => 1,
|
no_arrows => 1,
|
||||||
polygons => \@$expolygon,
|
polygons => \@$expolygon,
|
||||||
|
red_polygons => [ $bounding_box->polygon ],
|
||||||
polylines => \@paths,
|
polylines => \@paths,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
# paths must be repositioned and rotated back
|
# paths must be repositioned and rotated back
|
||||||
$_->translate($bounding_box->x_min, $bounding_box->y_min) for @paths;
|
$_->translate(@{$translate->negative}) for @paths;
|
||||||
$self->rotate_points_back(\@paths, $rotate_vector);
|
$self->rotate_points_back(\@paths, $rotate_vector);
|
||||||
|
|
||||||
return { flow => $flow }, @paths;
|
return { flow => $flow }, @paths;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user