Finish porting Print classes to XS

This commit is contained in:
Alessandro Ranellucci 2014-06-10 16:01:57 +02:00
parent ba8148f4ad
commit 3f6360ee8f
10 changed files with 78 additions and 87 deletions

View file

@ -169,10 +169,11 @@ sub extrude_loop {
if ($self->config->seam_position eq 'nearest') {
$loop->split_at_vertex($last_pos->nearest_point(\@candidates));
} elsif ($self->config->seam_position eq 'aligned') {
if (defined $self->layer && defined $self->_seam_position->{$self->layer->object}) {
$last_pos = $self->_seam_position->{$self->layer->object};
my $obj_ptr = $self->layer->object->ptr;
if (defined $self->layer && defined $self->_seam_position->{$obj_ptr}) {
$last_pos = $self->_seam_position->{$obj_ptr};
}
my $point = $self->_seam_position->{$self->layer->object} = $last_pos->nearest_point(\@candidates);
my $point = $self->_seam_position->{$obj_ptr} = $last_pos->nearest_point(\@candidates);
$loop->split_at_vertex($point);
}
} elsif ($self->config->seam_position eq 'random') {

View file

@ -19,12 +19,12 @@ sub update_timestamp {
my @lt = localtime; $lt[5] += 1900; $lt[4] += 1;
$self->_single_set('timestamp', sprintf '%04d%02d%02d-%02d%02d%02d', @lt[5,4,3,2,1,0]);
$self->_single_set('year', $lt[5]);
$self->_single_set('month', $lt[4]);
$self->_single_set('day', $lt[3]);
$self->_single_set('hour', $lt[2]);
$self->_single_set('minute', $lt[1]);
$self->_single_set('second', $lt[0]);
$self->_single_set('year', "$lt[5]");
$self->_single_set('month', "$lt[4]");
$self->_single_set('day', "$lt[3]");
$self->_single_set('hour', "$lt[2]");
$self->_single_set('minute', "$lt[1]");
$self->_single_set('second', "$lt[0]");
$self->_single_set('version', $Slic3r::VERSION);
}
@ -42,11 +42,11 @@ sub apply_config {
# TODO: this is a workaroud for XS string param handling
# https://rt.cpan.org/Public/Bug/Display.html?id=94110
"$_" for @$value;
$self->_multiple_set("${opt_key}_" . $_, $value->[$_]) for 0..$#$value;
$self->_multiple_set($opt_key, $value->[0]);
$self->_multiple_set("${opt_key}_" . $_, $value->[$_]."") for 0..$#$value;
$self->_multiple_set($opt_key, $value->[0]."");
if ($Slic3r::Config::Options->{$opt_key}{type} eq 'point') {
$self->_multiple_set("${opt_key}_X", $value->[0]);
$self->_multiple_set("${opt_key}_Y", $value->[1]);
$self->_multiple_set("${opt_key}_X", $value->[0]."");
$self->_multiple_set("${opt_key}_Y", $value->[1]."");
}
}
}

View file

@ -540,7 +540,6 @@ sub rotate {
$model_object->update_bounding_box;
# update print
$self->{print}->delete_object($obj_idx);
$self->{print}->add_model_object($model_object, $obj_idx);
$object->transform_thumbnail($self->{model}, $obj_idx);
@ -576,7 +575,6 @@ sub changescale {
$model_object->update_bounding_box;
# update print
$self->{print}->delete_object($obj_idx);
$self->{print}->add_model_object($model_object, $obj_idx);
$object->transform_thumbnail($self->{model}, $obj_idx);

View file

@ -1,4 +1,6 @@
package Slic3r::Print;
use strict;
use warnings;
use File::Basename qw(basename fileparse);
use File::Spec;
@ -16,7 +18,7 @@ our $status_cb;
sub new {
# TODO: port PlaceholderParser methods to C++, then its own constructor
# can call them and no need for this new() method at all
# can call them and no need for this new() method at all
my ($class) = @_;
my $self = $class->_new;
$self->placeholder_parser->apply_env_variables;
@ -840,10 +842,10 @@ sub write_gcode {
# TODO: only do this when M73 is enabled
my $layer_count;
if ($self->config->complete_objects) {
$layer_count = sum(map { $_->layer_count * @{$_->copies} } @{$self->objects});
$layer_count = sum(map { $_->total_layer_count * @{$_->copies} } @{$self->objects});
} else {
# if sequential printing is not enable, all copies of the same object share the same layer change command(s)
$layer_count = sum(map { $_->layer_count } @{$self->objects});
$layer_count = sum(map { $_->total_layer_count } @{$self->objects});
}
# set up our helper object

View file

@ -1,4 +1,6 @@
package Slic3r::Print::Object;
use strict;
use warnings;
use List::Util qw(min max sum first);
use Slic3r::Flow ':roles';
@ -54,7 +56,7 @@ sub _trigger_copies {
# in unscaled coordinates
sub add_copy {
my ($self, $x, $y) = @_;
my @copies = $self->copies;
my @copies = @{$self->copies};
push @copies, Slic3r::Point->new_scale($x, $y);
$self->set_copies(\@copies);
$self->_trigger_copies;

View file

@ -1,4 +1,6 @@
package Slic3r::Print::Region;
use strict;
use warnings;
use Slic3r::Extruder ':roles';
use Slic3r::Flow ':roles';
@ -47,14 +49,14 @@ sub flow {
} else {
die "Unknown role $role";
}
my $nozzle_diameter = $self->print_config->get_at('nozzle_diameter', $extruder-1);
my $nozzle_diameter = $self->print->config->get_at('nozzle_diameter', $extruder-1);
return Slic3r::Flow->new_from_width(
width => $config_width,
role => $role,
nozzle_diameter => $nozzle_diameter,
layer_height => $layer_height,
bridge_flow_ratio => ($bridge ? $self->print_config->bridge_flow_ratio : 0),
bridge_flow_ratio => ($bridge ? $self->print->config->bridge_flow_ratio : 0),
);
}