Store width and height in ExtrusionEntity objects for debugging purposes

This commit is contained in:
Alessandro Ranellucci 2014-04-29 23:15:36 +02:00
parent 78a08e0665
commit 98e40d3fe4
11 changed files with 113 additions and 15 deletions

View file

@ -9,6 +9,8 @@ sub split_at {
polyline => $self->polygon->split_at(@_),
role => $self->role,
mm3_per_mm => $self->mm3_per_mm,
width => $self->width,
height => $self->height,
);
}

View file

@ -237,7 +237,9 @@ sub make_fill {
: $is_solid
? (($surface->surface_type == S_TYPE_TOP) ? EXTR_ROLE_TOPSOLIDFILL : EXTR_ROLE_SOLIDFILL)
: EXTR_ROLE_FILL),
mm3_per_mm => $mm3_per_mm,
mm3_per_mm => $mm3_per_mm,
width => $flow->width,
height => $h,
), @polylines,
);
push @fills_ordering_points, $polylines[0]->first_point;

View file

@ -264,6 +264,8 @@ sub make_perimeters {
polygon => $polygon,
role => $role,
mm3_per_mm => $mm3_per_mm,
width => $perimeter_flow->width,
height => $self->height,
));
# save the children
@ -278,6 +280,8 @@ sub make_perimeters {
polyline => $polyline,
role => EXTR_ROLE_EXTERNAL_PERIMETER,
mm3_per_mm => $mm3_per_mm,
width => $perimeter_flow->width,
height => $self->height,
));
}
}
@ -355,6 +359,8 @@ sub _fill_gaps {
my %path_args = (
role => EXTR_ROLE_GAPFILL,
mm3_per_mm => $flow->mm3_per_mm($self->height),
width => $flow->width,
height => $self->height,
);
my @polylines = map @{$_->medial_axis($max, $min/2)}, @$this;

View file

@ -709,6 +709,8 @@ sub make_skirt {
polygon => Slic3r::Polygon->new(@$loop),
role => EXTR_ROLE_SKIRT,
mm3_per_mm => $mm3_per_mm,
width => $flow->width,
height => $first_layer_height,
));
if ($self->config->min_skirt_length > 0) {
@ -790,6 +792,8 @@ sub make_brim {
polygon => Slic3r::Polygon->new(@$_),
role => EXTR_ROLE_SKIRT,
mm3_per_mm => $mm3_per_mm,
width => $flow->width,
height => $first_layer_height,
), reverse @{union_pt_chained(\@loops)});
}

View file

@ -544,6 +544,8 @@ sub generate_toolpaths {
polyline => $_,
role => EXTR_ROLE_SUPPORTMATERIAL,
mm3_per_mm => $mm3_per_mm,
width => $interface_flow->width,
height => $layer->height,
), @loops;
$layer->support_interface_fills->append(@loops);
@ -587,6 +589,8 @@ sub generate_toolpaths {
polyline => Slic3r::Polyline->new(@$_),
role => EXTR_ROLE_SUPPORTMATERIAL,
mm3_per_mm => $mm3_per_mm,
width => $params->{flow}->width,
height => $layer->height,
), @p;
}
@ -618,6 +622,8 @@ sub generate_toolpaths {
polyline => $_->split_at_first_point,
role => EXTR_ROLE_SUPPORTMATERIAL,
mm3_per_mm => $mm3_per_mm,
width => $flow->width,
height => $layer->height,
), map @$_, @$to_infill;
# TODO: use offset2_ex()
@ -638,6 +644,8 @@ sub generate_toolpaths {
polyline => Slic3r::Polyline->new(@$_),
role => EXTR_ROLE_SUPPORTMATERIAL,
mm3_per_mm => $mm3_per_mm,
width => $params->{flow}->width,
height => $layer->height,
), @p;
}

View file

@ -5,19 +5,21 @@ use List::Util qw(first max);
use Slic3r::Geometry qw(X Y A B X1 Y1 X2 Y2 unscale);
use Slic3r::Geometry::Clipper qw(union_ex intersection_pl);
use SVG;
use Slic3r::SVG;
has 'scale' => (is => 'ro', default => sub {30});
has 'print' => (is => 'ro', required => 1);
has 'y_percent' => (is => 'ro', default => sub {0.5});
has 'line' => (is => 'lazy');
has 'line' => (is => 'rw');
has 'height' => (is => 'rw');
sub _build_line {
sub BUILD {
my $self = shift;
my $bb = $self->print->bounding_box;
my $y = $bb->size->[Y] * $self->y_percent;
return Slic3r::Line->new([ $bb->x_min, $y ], [ $bb->x_max, $y ]);
my $y = ($bb->y_min + $bb->y_max) * $self->y_percent;
my $line = Slic3r::Line->new([ $bb->x_min, $y ], [ $bb->x_max, $y ]);
$self->line($line);
}
sub export_svg {
@ -79,27 +81,40 @@ sub _plot {
my (@rectangles, @circles) = ();
foreach my $object (@{$self->print->objects}) {
foreach my $copy (@{$object->shifted_copies}) {
foreach my $copy (@{$object->_shifted_copies}) {
foreach my $layer (@{$object->layers}, @{$object->support_layers}) {
# get all ExtrusionPath objects
my @paths =
map { $_->polyline->translate(@$copy); $_ }
map { $_->isa('Slic3r::ExtrusionLoop') ? $_->split_at_first_point : $_ }
map { $_->isa('Slic3r::ExtrusionLoop') ? $_->split_at_first_point : $_->clone }
map { $_->isa('Slic3r::ExtrusionPath::Collection') ? @$_ : $_ }
grep defined $_,
$filter->($layer);
$_->polyline->translate(@$copy) for @paths;
require "Slic3r/SVG.pm";
Slic3r::SVG::output(
"line.svg",
no_arrows => 1,
#polygon => $line->grow(Slic3r::Geometry::scale $path->width/2),
polygons => [ $object->bounding_box->polygon ],
lines => [ $self->line ],
red_polylines => [ map $_->polyline, @paths ],
);
exit;
foreach my $path (@paths) {
foreach my $line (@{$path->lines}) {
my @intersections = @{intersection_pl(
[ $self->line->as_polyline ],
$line->grow(Slic3r::Geometry::scale $path->flow_spacing/2),
$line->grow(Slic3r::Geometry::scale $path->width/2),
)};
die "Intersection has more than two points!\n" if first { @$_ > 2 } @intersections;
if ($path->is_bridge) {
foreach my $line (@intersections) {
my $radius = $path->flow_spacing / 2;
my $radius = $path->width / 2;
my $width = unscale abs($line->[B][X] - $line->[A][X]);
if ((10 * Slic3r::Geometry::scale $radius) < $width) {
# we're cutting the path in the longitudinal direction, so we've got a rectangle
@ -148,7 +163,7 @@ sub _plot {
sub _y {
my $self = shift;
my ($y) = @_;
return $y;
return $self->height - $y;
}