mirror of https://github.com/vitalif/Slic3r
Unfinished work for displaying bridge paths in section cuts
parent
06ad6b70f8
commit
632652d924
|
@ -111,6 +111,12 @@ sub is_fill {
|
||||||
|| $self->role == EXTR_ROLE_TOPSOLIDFILL;
|
|| $self->role == EXTR_ROLE_TOPSOLIDFILL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub is_bridge {
|
||||||
|
my $self = shift;
|
||||||
|
return $self->role == EXTR_ROLE_BRIDGE
|
||||||
|
|| $self->role == EXTR_ROLE_INTERNALBRIDGE;
|
||||||
|
}
|
||||||
|
|
||||||
sub split_at_acute_angles {
|
sub split_at_acute_angles {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package Slic3r::Test::SectionCut;
|
package Slic3r::Test::SectionCut;
|
||||||
use Moo;
|
use Moo;
|
||||||
|
|
||||||
|
use List::Util qw(first max);
|
||||||
use Slic3r::Geometry qw(X Y A B X1 Y1 X2 Y2 unscale);
|
use Slic3r::Geometry qw(X Y A B X1 Y1 X2 Y2 unscale);
|
||||||
use Slic3r::Geometry::Clipper qw(union_ex);
|
use Slic3r::Geometry::Clipper qw(union_ex);
|
||||||
use SVG;
|
use SVG;
|
||||||
|
@ -24,7 +25,7 @@ sub export_svg {
|
||||||
my ($filename) = @_;
|
my ($filename) = @_;
|
||||||
|
|
||||||
my $print_size = $self->print->size;
|
my $print_size = $self->print->size;
|
||||||
$self->height(unscale($print_size->[X]));
|
$self->height(unscale max(map $_->print_z, map @{$_->layers}, @{$self->print->objects}));
|
||||||
my $svg = SVG->new(
|
my $svg = SVG->new(
|
||||||
width => $self->scale * unscale($print_size->[X]),
|
width => $self->scale * unscale($print_size->[X]),
|
||||||
height => $self->scale * $self->height,
|
height => $self->scale * $self->height,
|
||||||
|
@ -33,7 +34,9 @@ sub export_svg {
|
||||||
my $group = sub {
|
my $group = sub {
|
||||||
my %p = @_;
|
my %p = @_;
|
||||||
my $g = $svg->group(style => $p{style});
|
my $g = $svg->group(style => $p{style});
|
||||||
$g->rectangle(%$_) for $self->_get_rectangles($p{filter});
|
my $items = $self->_plot($p{filter});
|
||||||
|
$g->rectangle(%$_) for @{ $items->{rectangles} };
|
||||||
|
$g->circle(%$_) for @{ $items->{circles} };
|
||||||
};
|
};
|
||||||
|
|
||||||
$group->(
|
$group->(
|
||||||
|
@ -69,11 +72,11 @@ sub export_svg {
|
||||||
printf "Section cut SVG written to %s\n", $filename;
|
printf "Section cut SVG written to %s\n", $filename;
|
||||||
}
|
}
|
||||||
|
|
||||||
sub _get_rectangles {
|
sub _plot {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
my ($filter) = @_;
|
my ($filter) = @_;
|
||||||
|
|
||||||
my @rectangles = ();
|
my (@rectangles, @circles) = ();
|
||||||
|
|
||||||
foreach my $object (@{$self->print->objects}) {
|
foreach my $object (@{$self->print->objects}) {
|
||||||
foreach my $copy (@{$object->copies}) {
|
foreach my $copy (@{$object->copies}) {
|
||||||
|
@ -93,26 +96,53 @@ sub _get_rectangles {
|
||||||
Slic3r::ExPolygon->new($line->grow(Slic3r::Geometry::scale $path->flow_spacing/2)),
|
Slic3r::ExPolygon->new($line->grow(Slic3r::Geometry::scale $path->flow_spacing/2)),
|
||||||
[ $self->line ],
|
[ $self->line ],
|
||||||
) };
|
) };
|
||||||
|
die "Intersection has more than two points!\n" if first { @$_ > 2 } @intersections;
|
||||||
|
|
||||||
push @rectangles, map {
|
if ($path->is_bridge) {
|
||||||
die "Intersection has more than two points!\n" if @$_ > 2;
|
foreach my $line (@intersections) {
|
||||||
my $height = $path->height // $layer->height;
|
my $radius = $path->flow_spacing / 2;
|
||||||
{
|
my $width = abs($line->[B][X] - $line->[A][X]);
|
||||||
'x' => $self->scale * unscale $_->[A][X],
|
if ((10 * Slic3r::Geometry::scale $radius) < $width) {
|
||||||
'y' => $self->scale * $self->_y(unscale($layer->print_z)),
|
# we're cutting the path in the longitudinal direction, so we've got a rectangle
|
||||||
'width' => $self->scale * unscale(abs($_->[B][X] - $_->[A][X])),
|
push @rectangles, {
|
||||||
'height' => $self->scale * $height,
|
'x' => $self->scale * unscale $line->[A][X],
|
||||||
'rx' => $self->scale * $height * 0.35,
|
'y' => $self->scale * $self->_y(unscale($layer->print_z)),
|
||||||
'ry' => $self->scale * $height * 0.35,
|
'width' => $self->scale * unscale(abs($line->[B][X] - $line->[A][X])),
|
||||||
};
|
'height' => $self->scale * $radius * 2,
|
||||||
} @intersections;
|
'rx' => $self->scale * $radius * 0.35,
|
||||||
|
'ry' => $self->scale * $radius * 0.35,
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
push @circles, {
|
||||||
|
'cx' => $self->scale * unscale($line->[A][X] + $radius),
|
||||||
|
'cy' => $self->scale * $self->_y(unscale($layer->print_z - $radius)),
|
||||||
|
'r' => $self->scale * unscale $radius,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
push @rectangles, map {
|
||||||
|
my $height = $path->height // $layer->height;
|
||||||
|
{
|
||||||
|
'x' => $self->scale * unscale $_->[A][X],
|
||||||
|
'y' => $self->scale * $self->_y(unscale($layer->print_z)),
|
||||||
|
'width' => $self->scale * unscale(abs($_->[B][X] - $_->[A][X])),
|
||||||
|
'height' => $self->scale * $height,
|
||||||
|
'rx' => $self->scale * $height * 0.35,
|
||||||
|
'ry' => $self->scale * $height * 0.35,
|
||||||
|
};
|
||||||
|
} @intersections;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return @rectangles;
|
return {
|
||||||
|
rectangles => \@rectangles,
|
||||||
|
circles => \@circles,
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
sub _y {
|
sub _y {
|
||||||
|
|
Loading…
Reference in New Issue