Workaround for the Clipper issue causing extra points in grid segments
This commit is contained in:
parent
f8fa73fa4a
commit
69ea88473d
3 changed files with 12 additions and 13 deletions
|
@ -364,25 +364,24 @@ sub set_bed_shape {
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
my @lines = ();
|
my @polylines = ();
|
||||||
for (my $x = $bed_bb->x_min; $x <= $bed_bb->x_max; $x += scale 10) {
|
for (my $x = $bed_bb->x_min; $x <= $bed_bb->x_max; $x += scale 10) {
|
||||||
push @lines, Slic3r::Polyline->new([$x,$bed_bb->y_min], [$x,$bed_bb->y_max]);
|
push @polylines, Slic3r::Polyline->new([$x,$bed_bb->y_min], [$x,$bed_bb->y_max]);
|
||||||
}
|
}
|
||||||
for (my $y = $bed_bb->y_min; $y <= $bed_bb->y_max; $y += scale 10) {
|
for (my $y = $bed_bb->y_min; $y <= $bed_bb->y_max; $y += scale 10) {
|
||||||
push @lines, Slic3r::Polyline->new([$bed_bb->x_min,$y], [$bed_bb->x_max,$y]);
|
push @polylines, Slic3r::Polyline->new([$bed_bb->x_min,$y], [$bed_bb->x_max,$y]);
|
||||||
}
|
}
|
||||||
# clip with a slightly grown expolygon because our lines lay on the contours and
|
# clip with a slightly grown expolygon because our lines lay on the contours and
|
||||||
# may get erroneously clipped
|
# may get erroneously clipped
|
||||||
@lines = @{intersection_pl(\@lines, [ @{$expolygon->offset(+scaled_epsilon)} ])};
|
my @lines = map Slic3r::Line->new(@$_[0,-1]),
|
||||||
|
@{intersection_pl(\@polylines, [ @{$expolygon->offset(+scaled_epsilon)} ])};
|
||||||
|
|
||||||
# append bed contours
|
# append bed contours
|
||||||
foreach my $line (map @{$_->lines}, @$expolygon) {
|
push @lines, map @{$_->lines}, @$expolygon;
|
||||||
push @lines, $line->as_polyline;
|
|
||||||
}
|
|
||||||
|
|
||||||
my @points = ();
|
my @points = ();
|
||||||
foreach my $polyline (@lines) {
|
foreach my $line (@lines) {
|
||||||
push @points, map {+ unscale($_->x), unscale($_->y), GROUND_Z } @$polyline; #))
|
push @points, map {+ unscale($_->x), unscale($_->y), GROUND_Z } @$line; #))
|
||||||
}
|
}
|
||||||
$self->bed_grid_lines(OpenGL::Array->new_list(GL_FLOAT, @points));
|
$self->bed_grid_lines(OpenGL::Array->new_list(GL_FLOAT, @points));
|
||||||
}
|
}
|
||||||
|
|
|
@ -299,15 +299,15 @@ sub _repaint_canvas {
|
||||||
my $step = 10; # 1cm grid
|
my $step = 10; # 1cm grid
|
||||||
my @polylines = ();
|
my @polylines = ();
|
||||||
for (my $x = $bb->x_min - ($bb->x_min % $step) + $step; $x < $bb->x_max; $x += $step) {
|
for (my $x = $bb->x_min - ($bb->x_min % $step) + $step; $x < $bb->x_max; $x += $step) {
|
||||||
push @polylines, Slic3r::Polyline->new_scale([$x, $bb->y_min], [$x, $bb->y_max]);last;
|
push @polylines, Slic3r::Polyline->new_scale([$x, $bb->y_min], [$x, $bb->y_max]);
|
||||||
}
|
}
|
||||||
for (my $y = $bb->y_min - ($bb->y_min % $step) + $step; $y < $bb->y_max; $y += $step) {
|
for (my $y = $bb->y_min - ($bb->y_min % $step) + $step; $y < $bb->y_max; $y += $step) {
|
||||||
push @polylines, Slic3r::Polyline->new_scale([$bb->x_min, $y], [$bb->x_max, $y]);
|
push @polylines, Slic3r::Polyline->new_scale([$bb->x_min, $y], [$bb->x_max, $y]);
|
||||||
}my @orig = @polylines;
|
}
|
||||||
@polylines = @{intersection_pl(\@polylines, [$bed_polygon])};
|
@polylines = @{intersection_pl(\@polylines, [$bed_polygon])};
|
||||||
|
|
||||||
$dc->SetPen(Wx::Pen->new(Wx::Colour->new(230,230,230), 1, wxSOLID));
|
$dc->SetPen(Wx::Pen->new(Wx::Colour->new(230,230,230), 1, wxSOLID));
|
||||||
$dc->DrawLine(map @{$to_pixel->([map unscale($_), @$_])}, @$_) for @polylines;
|
$dc->DrawLine(map @{$to_pixel->([map unscale($_), @$_])}, @$_[0,-1]) for @polylines;
|
||||||
}
|
}
|
||||||
|
|
||||||
# draw bed contour
|
# draw bed contour
|
||||||
|
|
|
@ -276,7 +276,7 @@ sub update_bed_size {
|
||||||
push @polylines, Slic3r::Polyline->new([$bb->x_min, $y], [$bb->x_max, $y]);
|
push @polylines, Slic3r::Polyline->new([$bb->x_min, $y], [$bb->x_max, $y]);
|
||||||
}
|
}
|
||||||
@polylines = @{intersection_pl(\@polylines, [$polygon])};
|
@polylines = @{intersection_pl(\@polylines, [$polygon])};
|
||||||
$self->{grid} = [ map $self->scaled_points_to_pixel(\@$_, 1), @polylines ];
|
$self->{grid} = [ map $self->scaled_points_to_pixel([ @$_[0,-1] ], 1), @polylines ];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue