More incomplete work for Flow/Extruder refactoring

This commit is contained in:
Alessandro Ranellucci 2014-01-03 18:27:46 +01:00
parent 52ce6e4a7b
commit 8ed738d3f7
27 changed files with 250 additions and 233 deletions

View file

@ -97,8 +97,7 @@ sub new {
return $class->_new(
$args{polygon}, # required
$args{role}, # required
$args{height} // -1,
$args{flow_spacing} // -1,
$args{mm3_per_mm} // -1,
);
}
@ -108,8 +107,7 @@ sub clone {
return (ref $self)->_new(
$args{polygon} // $self->polygon,
$args{role} // $self->role,
$args{height} // $self->height,
$args{flow_spacing} // $self->flow_spacing,
$args{mm3_per_mm} // $self->mm3_per_mm,
);
}
@ -129,8 +127,7 @@ sub new {
return $class->_new(
$args{polyline}, # required
$args{role}, # required
$args{height} // -1,
$args{flow_spacing} // -1,
$args{mm3_per_mm} // -1,
);
}
@ -140,8 +137,7 @@ sub clone {
return (ref $self)->_new(
$args{polyline} // $self->polyline,
$args{role} // $self->role,
$args{height} // $self->height,
$args{flow_spacing} // $self->flow_spacing,
$args{mm3_per_mm} // $self->mm3_per_mm,
);
}

View file

@ -116,8 +116,7 @@ ExtrusionLoop::split_at_index(int index) const
ExtrusionPath* path = new ExtrusionPath();
path->polyline = *poly;
path->role = this->role;
path->height = this->height;
path->flow_spacing = this->flow_spacing;
path->mm3_per_mm = this->mm3_per_mm;
delete poly;
return path;

View file

@ -31,8 +31,7 @@ class ExtrusionEntity
virtual ExtrusionEntity* clone() const = 0;
virtual ~ExtrusionEntity() {};
ExtrusionRole role;
double height; // vertical thickness of the extrusion expressed in mm
double flow_spacing;
double mm3_per_mm; // mm^3 of plastic per mm of linear head motion
virtual void reverse() = 0;
virtual Point* first_point() const = 0;
virtual Point* last_point() const = 0;

View file

@ -241,6 +241,7 @@ class PrintConfigDef
Options["fill_pattern"].tooltip = "Fill pattern for general low-density infill.";
Options["fill_pattern"].cli = "fill-pattern=s";
Options["fill_pattern"].scope = "object";
Options["fill_pattern"].enum_keys_map = ConfigOptionEnum<InfillPattern>::get_enum_values();
Options["fill_pattern"].enum_values.push_back("rectilinear");
Options["fill_pattern"].enum_values.push_back("line");
Options["fill_pattern"].enum_values.push_back("concentric");
@ -320,6 +321,7 @@ class PrintConfigDef
Options["gcode_flavor"].label = "G-code flavor";
Options["gcode_flavor"].tooltip = "Some G/M-code commands, including temperature control and others, are not universal. Set this option to your printer's firmware to get a compatible output. The \"No extrusion\" flavor prevents Slic3r from exporting any extrusion value at all.";
Options["gcode_flavor"].cli = "gcode-flavor=s";
Options["gcode_flavor"].enum_keys_map = ConfigOptionEnum<GCodeFlavor>::get_enum_values();
Options["gcode_flavor"].enum_values.push_back("reprap");
Options["gcode_flavor"].enum_values.push_back("teacup");
Options["gcode_flavor"].enum_values.push_back("makerware");
@ -613,6 +615,7 @@ class PrintConfigDef
Options["solid_fill_pattern"].tooltip = "Fill pattern for top/bottom infill.";
Options["solid_fill_pattern"].cli = "solid-fill-pattern=s";
Options["solid_fill_pattern"].scope = "object";
Options["solid_fill_pattern"].enum_keys_map = ConfigOptionEnum<InfillPattern>::get_enum_values();
Options["solid_fill_pattern"].enum_values.push_back("rectilinear");
Options["solid_fill_pattern"].enum_values.push_back("concentric");
Options["solid_fill_pattern"].enum_values.push_back("hilbertcurve");

View file

@ -15,6 +15,7 @@ my $points = [
my $path = Slic3r::ExtrusionPath->new(
polyline => Slic3r::Polyline->new(@$points),
role => Slic3r::ExtrusionPath::EXTR_ROLE_EXTERNAL_PERIMETER,
mm3_per_mm => 1,
);
isa_ok $path->polyline, 'Slic3r::Polyline::Ref', 'path polyline';
is_deeply $path->polyline->pp, $points, 'path points roundtrip';

View file

@ -16,6 +16,7 @@ my $square = [
my $loop = Slic3r::ExtrusionLoop->new(
polygon => Slic3r::Polygon->new(@$square),
role => Slic3r::ExtrusionPath::EXTR_ROLE_EXTERNAL_PERIMETER,
mm3_per_mm => 1,
);
isa_ok $loop->polygon, 'Slic3r::Polygon::Ref', 'loop polygon';
is_deeply $loop->polygon->pp, $square, 'polygon points roundtrip';

View file

@ -15,11 +15,13 @@ my $points = [
my $path = Slic3r::ExtrusionPath->new(
polyline => Slic3r::Polyline->new(@$points),
role => Slic3r::ExtrusionPath::EXTR_ROLE_EXTERNAL_PERIMETER,
mm3_per_mm => 1,
);
my $loop = Slic3r::ExtrusionLoop->new(
polygon => Slic3r::Polygon->new(@$points),
role => Slic3r::ExtrusionPath::EXTR_ROLE_FILL,
mm3_per_mm => 1,
);
my $collection = Slic3r::ExtrusionPath::Collection->new($path);
@ -49,7 +51,7 @@ is scalar(@{$collection->[1]}), 1, 'appended collection was duplicated';
{
my $collection = Slic3r::ExtrusionPath::Collection->new(
map Slic3r::ExtrusionPath->new(polyline => $_, role => 0),
map Slic3r::ExtrusionPath->new(polyline => $_, role => 0, mm3_per_mm => 1),
Slic3r::Polyline->new([0,15], [0,18], [0,20]),
Slic3r::Polyline->new([0,10], [0,8], [0,5]),
);
@ -65,7 +67,7 @@ is scalar(@{$collection->[1]}), 1, 'appended collection was duplicated';
{
my $collection = Slic3r::ExtrusionPath::Collection->new(
map Slic3r::ExtrusionPath->new(polyline => $_, role => 0),
map Slic3r::ExtrusionPath->new(polyline => $_, role => 0, mm3_per_mm => 1),
Slic3r::Polyline->new([15,0], [10,0], [4,0]),
Slic3r::Polyline->new([10,5], [15,5], [20,5]),
);

View file

@ -4,7 +4,7 @@ use strict;
use warnings;
use Slic3r::XS;
use Test::More tests => 79;
use Test::More tests => 82;
foreach my $config (Slic3r::Config->new, Slic3r::Config::Full->new) {
$config->set('layer_height', 0.3);
@ -49,6 +49,9 @@ foreach my $config (Slic3r::Config->new, Slic3r::Config::Full->new) {
$config->set_deserialize('gcode_flavor', 'mach3');
is $config->get('gcode_flavor'), 'mach3', 'deserialize enum';
$config->set_deserialize('fill_pattern', 'line');
is $config->get('fill_pattern'), 'line', 'deserialize enum';
$config->set('extruder_offset', [[10,20],[30,45]]);
is_deeply $config->get('extruder_offset'), [[10,20],[30,45]], 'set/get points';
is $config->serialize('extruder_offset'), '10x20,30x45', 'serialize points';
@ -106,4 +109,14 @@ foreach my $config (Slic3r::Config->new, Slic3r::Config::Full->new) {
is $config2->get('perimeters'), Slic3r::Config::print_config_def()->{perimeters}{default}, 'apply_static and print_config_def';
}
{
my $config = Slic3r::Config->new;
$config->set('fill_pattern', 'line');
my $config2 = Slic3r::Config->new;
$config2->set('fill_pattern', 'hilbertcurve');
is $config->get('fill_pattern'), 'line', 'no interferences between DynamicConfig objects';
}
__END__

View file

@ -19,7 +19,7 @@
double get_abs_value(t_config_option_key opt_key, double ratio_over);
void apply(DynamicPrintConfig* other)
%code{% THIS->apply(*other, true); %};
void apply_static(PrintConfig* other)
void apply_static(FullPrintConfig* other)
%code{% THIS->apply(*other, true); %};
std::vector<std::string> get_keys()
%code{% THIS->keys(&RETVAL); %};

View file

@ -28,18 +28,16 @@
%{
ExtrusionLoop*
_new(CLASS, polygon_sv, role, height, flow_spacing)
_new(CLASS, polygon_sv, role, mm3_per_mm)
char* CLASS;
SV* polygon_sv;
ExtrusionRole role;
double height;
double flow_spacing;
double mm3_per_mm;
CODE:
RETVAL = new ExtrusionLoop ();
RETVAL->polygon.from_SV_check(polygon_sv);
RETVAL->role = role;
RETVAL->height = height;
RETVAL->flow_spacing = flow_spacing;
RETVAL->mm3_per_mm = mm3_per_mm;
OUTPUT:
RETVAL
@ -66,22 +64,12 @@ ExtrusionLoop::role(...)
RETVAL
double
ExtrusionLoop::height(...)
ExtrusionLoop::mm3_per_mm(...)
CODE:
if (items > 1) {
THIS->height = (double)SvNV(ST(1));
THIS->mm3_per_mm = (double)SvNV(ST(1));
}
RETVAL = THIS->height;
OUTPUT:
RETVAL
double
ExtrusionLoop::flow_spacing(...)
CODE:
if (items > 1) {
THIS->flow_spacing = (double)SvNV(ST(1));
}
RETVAL = THIS->flow_spacing;
RETVAL = THIS->mm3_per_mm;
OUTPUT:
RETVAL

View file

@ -33,18 +33,16 @@
%{
ExtrusionPath*
_new(CLASS, polyline_sv, role, height, flow_spacing)
_new(CLASS, polyline_sv, role, mm3_per_mm)
char* CLASS;
SV* polyline_sv;
ExtrusionRole role;
double height;
double flow_spacing;
double mm3_per_mm;
CODE:
RETVAL = new ExtrusionPath ();
RETVAL->polyline.from_SV_check(polyline_sv);
RETVAL->role = role;
RETVAL->height = height;
RETVAL->flow_spacing = flow_spacing;
RETVAL->mm3_per_mm = mm3_per_mm;
OUTPUT:
RETVAL
@ -71,22 +69,12 @@ ExtrusionPath::role(...)
RETVAL
double
ExtrusionPath::height(...)
ExtrusionPath::mm3_per_mm(...)
CODE:
if (items > 1) {
THIS->height = (double)SvNV(ST(1));
THIS->mm3_per_mm = (double)SvNV(ST(1));
}
RETVAL = THIS->height;
OUTPUT:
RETVAL
double
ExtrusionPath::flow_spacing(...)
CODE:
if (items > 1) {
THIS->flow_spacing = (double)SvNV(ST(1));
}
RETVAL = THIS->flow_spacing;
RETVAL = THIS->mm3_per_mm;
OUTPUT:
RETVAL