Make tests happy

This commit is contained in:
Alessandro Ranellucci 2015-07-02 14:29:20 +02:00
parent 5571144c0e
commit b14290b9f6
10 changed files with 19 additions and 14 deletions

View File

@ -6,7 +6,8 @@ use parent qw(Exporter);
our @EXPORT_OK = qw(EXTR_ROLE_PERIMETER EXTR_ROLE_EXTERNAL_PERIMETER EXTR_ROLE_OVERHANG_PERIMETER our @EXPORT_OK = qw(EXTR_ROLE_PERIMETER EXTR_ROLE_EXTERNAL_PERIMETER EXTR_ROLE_OVERHANG_PERIMETER
EXTR_ROLE_FILL EXTR_ROLE_SOLIDFILL EXTR_ROLE_TOPSOLIDFILL EXTR_ROLE_GAPFILL EXTR_ROLE_BRIDGE EXTR_ROLE_FILL EXTR_ROLE_SOLIDFILL EXTR_ROLE_TOPSOLIDFILL EXTR_ROLE_GAPFILL EXTR_ROLE_BRIDGE
EXTR_ROLE_SKIRT EXTR_ROLE_SUPPORTMATERIAL EXTR_ROLE_SUPPORTMATERIAL_INTERFACE); EXTR_ROLE_SKIRT EXTR_ROLE_SUPPORTMATERIAL EXTR_ROLE_SUPPORTMATERIAL_INTERFACE
EXTR_ROLE_NONE);
our %EXPORT_TAGS = (roles => \@EXPORT_OK); our %EXPORT_TAGS = (roles => \@EXPORT_OK);
1; 1;

View File

@ -306,7 +306,7 @@ sub travel_to {
my $travel = Slic3r::Polyline->new($self->last_pos, $point); my $travel = Slic3r::Polyline->new($self->last_pos, $point);
# check whether a straight travel move would need retraction # check whether a straight travel move would need retraction
my $needs_retraction = $self->needs_retraction($travel, $role); my $needs_retraction = $self->needs_retraction($travel, $role // EXTR_ROLE_NONE);
# if a retraction would be needed, try to use avoid_crossing_perimeters to plan a # if a retraction would be needed, try to use avoid_crossing_perimeters to plan a
# multi-hop travel path inside the configuration space # multi-hop travel path inside the configuration space
@ -316,7 +316,7 @@ sub travel_to {
$travel = $self->avoid_crossing_perimeters->travel_to($self, $point); $travel = $self->avoid_crossing_perimeters->travel_to($self, $point);
# check again whether the new travel path still needs a retraction # check again whether the new travel path still needs a retraction
$needs_retraction = $self->needs_retraction($travel, $role); $needs_retraction = $self->needs_retraction($travel, $role // EXTR_ROLE_NONE);
} }
# Re-allow avoid_crossing_perimeters for the next travel moves # Re-allow avoid_crossing_perimeters for the next travel moves

View File

@ -355,7 +355,7 @@ sub _traverse_loops {
# there's only one contour loop). # there's only one contour loop).
$loop_role = EXTRL_ROLE_CONTOUR_INTERNAL_PERIMETER; $loop_role = EXTRL_ROLE_CONTOUR_INTERNAL_PERIMETER;
} else { } else {
$loop_role = EXTR_ROLE_PERIMETER; $loop_role = EXTRL_ROLE_DEFAULT;
} }
# detect overhanging/bridging perimeters # detect overhanging/bridging perimeters

View File

@ -329,13 +329,16 @@ use Slic3r::Test;
scalar(@$expolygons), 'expected number of collections'; scalar(@$expolygons), 'expected number of collections';
ok !defined(first { !$_->isa('Slic3r::ExtrusionPath::Collection') } @{$g->loops}), ok !defined(first { !$_->isa('Slic3r::ExtrusionPath::Collection') } @{$g->loops}),
'everything is returned as collections'; 'everything is returned as collections';
is scalar(map @$_, @{$g->loops}),
my $flattened_loops = $g->loops->flatten;
my @loops = @$flattened_loops;
is scalar(@loops),
$expected{total}, 'expected number of loops'; $expected{total}, 'expected number of loops';
is scalar(grep $_->role == EXTR_ROLE_EXTERNAL_PERIMETER, map @$_, map @$_, @{$g->loops}), is scalar(grep $_->role == EXTR_ROLE_EXTERNAL_PERIMETER, map @$_, @loops),
$expected{external}, 'expected number of external loops'; $expected{external}, 'expected number of external loops';
is scalar(grep $_->role == EXTRL_ROLE_CONTOUR_INTERNAL_PERIMETER, map @$_, @{$g->loops}), is scalar(grep $_->role == EXTRL_ROLE_CONTOUR_INTERNAL_PERIMETER, @loops),
$expected{cinternal}, 'expected number of internal contour loops'; $expected{cinternal}, 'expected number of internal contour loops';
is scalar(grep $_->polygon->is_counter_clockwise, map @$_, @{$g->loops}), is scalar(grep $_->polygon->is_counter_clockwise, @loops),
$expected{ccw}, 'expected number of ccw loops'; $expected{ccw}, 'expected number of ccw loops';
return $g; return $g;

View File

@ -13,6 +13,7 @@ class Extruder;
/* Each ExtrusionRole value identifies a distinct set of { extruder, speed } */ /* Each ExtrusionRole value identifies a distinct set of { extruder, speed } */
enum ExtrusionRole { enum ExtrusionRole {
erNone,
erPerimeter, erPerimeter,
erExternalPerimeter, erExternalPerimeter,
erOverhangPerimeter, erOverhangPerimeter,

View File

@ -156,7 +156,7 @@ REGISTER_CLASS(Wipe, "GCode::Wipe");
GCode::GCode() GCode::GCode()
: enable_loop_clipping(true), enable_cooling_markers(false), layer_count(0), : enable_loop_clipping(true), enable_cooling_markers(false), layer_count(0),
layer_index(-1), first_layer(false), elapsed_time(0), volumetric_speed(0), layer_index(-1), first_layer(false), elapsed_time(0), volumetric_speed(0),
_last_pos_defined(false) _last_pos_defined(false), layer(NULL), placeholder_parser(NULL)
{ {
} }
@ -224,7 +224,7 @@ GCode::needs_retraction(const Polyline &travel, ExtrusionRole role)
if (role == erSupportMaterial) { if (role == erSupportMaterial) {
SupportLayer* support_layer = dynamic_cast<SupportLayer*>(this->layer); SupportLayer* support_layer = dynamic_cast<SupportLayer*>(this->layer);
if (support_layer->support_islands.contains(travel)) { if (support_layer != NULL && support_layer->support_islands.contains(travel)) {
// skip retraction if this is a travel move inside a support material island // skip retraction if this is a travel move inside a support material island
return false; return false;
} }

View File

@ -87,7 +87,7 @@ class GCode {
void apply_print_config(const PrintConfig &print_config); void apply_print_config(const PrintConfig &print_config);
void set_origin(const Pointf &pointf); void set_origin(const Pointf &pointf);
std::string preamble(); std::string preamble();
bool needs_retraction(const Polyline &travel, ExtrusionRole role); bool needs_retraction(const Polyline &travel, ExtrusionRole role = erNone);
std::string retract(bool toolchange = false); std::string retract(bool toolchange = false);
std::string unretract(); std::string unretract();
Pointf point_to_gcode(const Point &point); Pointf point_to_gcode(const Point &point);

View File

@ -38,9 +38,8 @@ ExtrusionLoop::arrayref()
CODE: CODE:
AV* av = newAV(); AV* av = newAV();
av_fill(av, THIS->paths.size()-1); av_fill(av, THIS->paths.size()-1);
int i = 0;
for (ExtrusionPaths::iterator it = THIS->paths.begin(); it != THIS->paths.end(); ++it) { for (ExtrusionPaths::iterator it = THIS->paths.begin(); it != THIS->paths.end(); ++it) {
av_store(av, i++, perl_to_SV_ref(*it)); av_store(av, it - THIS->paths.begin(), perl_to_SV_ref(*it));
} }
RETVAL = newRV_noinc((SV*)av); RETVAL = newRV_noinc((SV*)av);
OUTPUT: OUTPUT:

View File

@ -133,6 +133,7 @@ ExtrusionPath::subtract_expolygons(ExPolygonCollection* collection)
IV IV
_constant() _constant()
ALIAS: ALIAS:
EXTR_ROLE_NONE = erNone
EXTR_ROLE_PERIMETER = erPerimeter EXTR_ROLE_PERIMETER = erPerimeter
EXTR_ROLE_EXTERNAL_PERIMETER = erExternalPerimeter EXTR_ROLE_EXTERNAL_PERIMETER = erExternalPerimeter
EXTR_ROLE_OVERHANG_PERIMETER = erOverhangPerimeter EXTR_ROLE_OVERHANG_PERIMETER = erOverhangPerimeter

View File

@ -152,7 +152,7 @@
void set_origin(Pointf* pointf) void set_origin(Pointf* pointf)
%code{% THIS->set_origin(*pointf); %}; %code{% THIS->set_origin(*pointf); %};
std::string preamble(); std::string preamble();
bool needs_retraction(Polyline* travel, ExtrusionRole role) bool needs_retraction(Polyline* travel, ExtrusionRole role = erNone)
%code{% RETVAL = THIS->needs_retraction(*travel, role); %}; %code{% RETVAL = THIS->needs_retraction(*travel, role); %};
std::string retract(bool toolchange = false); std::string retract(bool toolchange = false);
std::string unretract(); std::string unretract();