Render brim and skirt in 3D toolpaths preview. #2649

This commit is contained in:
Alessandro Ranellucci 2015-05-18 00:49:16 +02:00
parent 36ba2eb5d6
commit c64308a5e7
4 changed files with 51 additions and 4 deletions

View File

@ -937,7 +937,7 @@ package Slic3r::GUI::3DScene;
use base qw(Slic3r::GUI::3DScene::Base);
use OpenGL qw(:glconstants :gluconstants :glufunctions);
use List::Util qw(first);
use List::Util qw(first min max);
use Slic3r::Geometry qw(scale unscale epsilon);
use Slic3r::Print::State ':steps';
@ -1079,6 +1079,50 @@ sub load_print_object_slices {
);
}
sub load_print_toolpaths {
my ($self, $print) = @_;
return if !$print->step_done(STEP_SKIRT);
return if !$print->step_done(STEP_BRIM);
return if !$print->has_skirt && $print->config->brim_width == 0;
my $qverts = Slic3r::GUI::_3DScene::GLVertexArray->new;
my $tverts = Slic3r::GUI::_3DScene::GLVertexArray->new;
my %offsets = (); # print_z => [ qverts, tverts ]
my $skirt_height = 0; # number of layers
if ($print->has_infinite_skirt) {
$skirt_height = $print->total_layer_count;
} else {
$skirt_height = min($print->config->skirt_height, $print->total_layer_count);
}
foreach my $i (0..max(0, $skirt_height-1)) {
my $layer = $print->get_object(0)->get_layer($i);
my $top_z = $layer->print_z;
$offsets{$top_z} = [$qverts->size, $tverts->size];
if ($i == 0) {
$self->_extrusionentity_to_verts($print->brim, $top_z, Slic3r::Point->new(0,0), $qverts, $tverts);
}
$self->_extrusionentity_to_verts($print->skirt, $top_z, Slic3r::Point->new(0,0), $qverts, $tverts);
}
my $bb = Slic3r::Geometry::BoundingBoxf3->new;
{
my $pbb = $print->bounding_box;
$bb->merge_point(Slic3r::Pointf3->new_unscale(@{$pbb->min_point}));
$bb->merge_point(Slic3r::Pointf3->new_unscale(@{$pbb->max_point}));
}
push @{$self->volumes}, Slic3r::GUI::3DScene::Volume->new(
bounding_box => $bb,
color => COLORS->[2],
qverts => $qverts,
tverts => $tverts,
offsets => { %offsets },
);
}
sub load_print_object_toolpaths {
my ($self, $object) = @_;

View File

@ -116,6 +116,9 @@ sub load_print {
}
if ($self->IsShown) {
# load skirt and brim
$self->canvas->load_print_toolpaths($self->print);
foreach my $object (@{$self->print->objects}) {
$self->canvas->load_print_object_toolpaths($object);

View File

@ -225,8 +225,8 @@ sub make_skirt {
my $skirt_height_z = -1;
foreach my $object (@{$self->objects}) {
my $skirt_height = $self->has_infinite_skirt
? scalar(@{$object->layers})
: min($self->config->skirt_height, scalar(@{$object->layers}));
? $object->layer_count
: min($self->config->skirt_height, $object->layer_count);
my $highest_layer = $object->get_layer($skirt_height - 1);
$skirt_height_z = max($skirt_height_z, $highest_layer->print_z);
}

View File

@ -33,7 +33,6 @@ my %opt = ();
# load config
my $config = Slic3r::Config->new_from_defaults;
$config->set('skirts', 0);
if ($opt{load}) {
$config->apply(Slic3r::Config->load($opt{load}));
}
@ -84,6 +83,7 @@ sub OnInit {
if ($d3) {
$canvas = Slic3r::GUI::3DScene->new($panel);
$canvas->set_bed_shape($print->config->bed_shape);
$canvas->load_print_toolpaths($print);
foreach my $object (@{$print->objects}) {
#$canvas->load_print_object_slices($object);