No tests were covering randomize-start, which was not working anymore after recent ExtrusionLoop refactoring. #2028
This commit is contained in:
parent
47940a712d
commit
69002b8ea2
@ -2,4 +2,11 @@ package Slic3r::ExtrusionLoop;
|
|||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
|
|
||||||
|
use parent qw(Exporter);
|
||||||
|
|
||||||
|
our @EXPORT_OK = qw(EXTRL_ROLE_DEFAULT EXTRL_ROLE_EXTERNAL_PERIMETER
|
||||||
|
EXTRL_ROLE_CONTOUR_INTERNAL_PERIMETER);
|
||||||
|
our %EXPORT_TAGS = (roles => \@EXPORT_OK);
|
||||||
|
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
@ -4,10 +4,9 @@ use warnings;
|
|||||||
|
|
||||||
use parent qw(Exporter);
|
use parent qw(Exporter);
|
||||||
|
|
||||||
our @EXPORT_OK = qw(EXTR_ROLE_PERIMETER EXTR_ROLE_EXTERNAL_PERIMETER
|
our @EXPORT_OK = qw(EXTR_ROLE_PERIMETER EXTR_ROLE_EXTERNAL_PERIMETER EXTR_ROLE_OVERHANG_PERIMETER
|
||||||
EXTR_ROLE_CONTOUR_INTERNAL_PERIMETER EXTR_ROLE_OVERHANG_PERIMETER
|
|
||||||
EXTR_ROLE_FILL EXTR_ROLE_SOLIDFILL EXTR_ROLE_TOPSOLIDFILL EXTR_ROLE_BRIDGE
|
EXTR_ROLE_FILL EXTR_ROLE_SOLIDFILL EXTR_ROLE_TOPSOLIDFILL EXTR_ROLE_BRIDGE
|
||||||
EXTR_ROLE_INTERNALBRIDGE EXTR_ROLE_SKIRT EXTR_ROLE_SUPPORTMATERIAL EXTR_ROLE_GAPFILL);
|
EXTR_ROLE_SKIRT EXTR_ROLE_SUPPORTMATERIAL EXTR_ROLE_GAPFILL);
|
||||||
our %EXPORT_TAGS = (roles => \@EXPORT_OK);
|
our %EXPORT_TAGS = (roles => \@EXPORT_OK);
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
@ -230,9 +230,7 @@ sub make_fill {
|
|||||||
$collection->append(
|
$collection->append(
|
||||||
map Slic3r::ExtrusionPath->new(
|
map Slic3r::ExtrusionPath->new(
|
||||||
polyline => $_,
|
polyline => $_,
|
||||||
role => ($surface->surface_type == S_TYPE_INTERNALBRIDGE
|
role => ($is_bridge
|
||||||
? EXTR_ROLE_INTERNALBRIDGE
|
|
||||||
: $is_bridge
|
|
||||||
? EXTR_ROLE_BRIDGE
|
? EXTR_ROLE_BRIDGE
|
||||||
: $is_solid
|
: $is_solid
|
||||||
? (($surface->surface_type == S_TYPE_TOP) ? EXTR_ROLE_TOPSOLIDFILL : EXTR_ROLE_SOLIDFILL)
|
? (($surface->surface_type == S_TYPE_TOP) ? EXTR_ROLE_TOPSOLIDFILL : EXTR_ROLE_SOLIDFILL)
|
||||||
|
@ -2,6 +2,7 @@ package Slic3r::GCode;
|
|||||||
use Moo;
|
use Moo;
|
||||||
|
|
||||||
use List::Util qw(min max first);
|
use List::Util qw(min max first);
|
||||||
|
use Slic3r::ExtrusionLoop ':roles';
|
||||||
use Slic3r::ExtrusionPath ':roles';
|
use Slic3r::ExtrusionPath ':roles';
|
||||||
use Slic3r::Flow ':roles';
|
use Slic3r::Flow ':roles';
|
||||||
use Slic3r::Geometry qw(epsilon scale unscale scaled_epsilon points_coincide PI X Y B);
|
use Slic3r::Geometry qw(epsilon scale unscale scaled_epsilon points_coincide PI X Y B);
|
||||||
@ -76,12 +77,10 @@ my %role_speeds = (
|
|||||||
&EXTR_ROLE_PERIMETER => 'perimeter',
|
&EXTR_ROLE_PERIMETER => 'perimeter',
|
||||||
&EXTR_ROLE_EXTERNAL_PERIMETER => 'external_perimeter',
|
&EXTR_ROLE_EXTERNAL_PERIMETER => 'external_perimeter',
|
||||||
&EXTR_ROLE_OVERHANG_PERIMETER => 'bridge',
|
&EXTR_ROLE_OVERHANG_PERIMETER => 'bridge',
|
||||||
&EXTR_ROLE_CONTOUR_INTERNAL_PERIMETER => 'perimeter',
|
|
||||||
&EXTR_ROLE_FILL => 'infill',
|
&EXTR_ROLE_FILL => 'infill',
|
||||||
&EXTR_ROLE_SOLIDFILL => 'solid_infill',
|
&EXTR_ROLE_SOLIDFILL => 'solid_infill',
|
||||||
&EXTR_ROLE_TOPSOLIDFILL => 'top_solid_infill',
|
&EXTR_ROLE_TOPSOLIDFILL => 'top_solid_infill',
|
||||||
&EXTR_ROLE_BRIDGE => 'bridge',
|
&EXTR_ROLE_BRIDGE => 'bridge',
|
||||||
&EXTR_ROLE_INTERNALBRIDGE => 'bridge',
|
|
||||||
&EXTR_ROLE_SKIRT => 'perimeter',
|
&EXTR_ROLE_SKIRT => 'perimeter',
|
||||||
&EXTR_ROLE_GAPFILL => 'gap_fill',
|
&EXTR_ROLE_GAPFILL => 'gap_fill',
|
||||||
);
|
);
|
||||||
@ -217,7 +216,7 @@ sub extrude_loop {
|
|||||||
# find the point of the loop that is closest to the current extruder position
|
# find the point of the loop that is closest to the current extruder position
|
||||||
# or randomize if requested
|
# or randomize if requested
|
||||||
my $last_pos = $self->last_pos;
|
my $last_pos = $self->last_pos;
|
||||||
if ($self->print_config->randomize_start && $loop->role == EXTR_ROLE_CONTOUR_INTERNAL_PERIMETER) {
|
if ($self->print_config->randomize_start && $loop->role == EXTRL_ROLE_CONTOUR_INTERNAL_PERIMETER) {
|
||||||
$last_pos = Slic3r::Point->new(scale $self->print_config->print_center->[X], scale $self->print_config->bed_size->[Y]);
|
$last_pos = Slic3r::Point->new(scale $self->print_config->print_center->[X], scale $self->print_config->bed_size->[Y]);
|
||||||
$last_pos->rotate(rand(2*PI), $self->print_config->print_center);
|
$last_pos->rotate(rand(2*PI), $self->print_config->print_center);
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@ package Slic3r::Layer::Region;
|
|||||||
use Moo;
|
use Moo;
|
||||||
|
|
||||||
use List::Util qw(sum first);
|
use List::Util qw(sum first);
|
||||||
|
use Slic3r::ExtrusionLoop ':roles';
|
||||||
use Slic3r::ExtrusionPath ':roles';
|
use Slic3r::ExtrusionPath ':roles';
|
||||||
use Slic3r::Flow ':roles';
|
use Slic3r::Flow ':roles';
|
||||||
use Slic3r::Geometry qw(PI A B scale unscale chained_path points_coincide);
|
use Slic3r::Geometry qw(PI A B scale unscale chained_path points_coincide);
|
||||||
@ -257,13 +258,15 @@ sub make_perimeters {
|
|||||||
foreach my $polynode (@$polynodes) {
|
foreach my $polynode (@$polynodes) {
|
||||||
my $polygon = ($polynode->{outer} // $polynode->{hole})->clone;
|
my $polygon = ($polynode->{outer} // $polynode->{hole})->clone;
|
||||||
|
|
||||||
my $role = EXTR_ROLE_PERIMETER;
|
my $role = EXTR_ROLE_PERIMETER;
|
||||||
|
my $loop_role = EXTRL_ROLE_DEFAULT;
|
||||||
if ($is_contour ? $depth == 0 : !@{ $polynode->{children} }) {
|
if ($is_contour ? $depth == 0 : !@{ $polynode->{children} }) {
|
||||||
# external perimeters are root level in case of contours
|
# external perimeters are root level in case of contours
|
||||||
# and items with no children in case of holes
|
# and items with no children in case of holes
|
||||||
$role = EXTR_ROLE_EXTERNAL_PERIMETER;
|
$role = EXTR_ROLE_EXTERNAL_PERIMETER;
|
||||||
|
$loop_role = EXTRL_ROLE_EXTERNAL_PERIMETER;
|
||||||
} elsif ($depth == 1 && $is_contour) {
|
} elsif ($depth == 1 && $is_contour) {
|
||||||
$role = EXTR_ROLE_CONTOUR_INTERNAL_PERIMETER;
|
$loop_role = EXTRL_ROLE_CONTOUR_INTERNAL_PERIMETER;
|
||||||
}
|
}
|
||||||
|
|
||||||
# detect overhanging/bridging perimeters
|
# detect overhanging/bridging perimeters
|
||||||
@ -309,6 +312,7 @@ sub make_perimeters {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
my $loop = Slic3r::ExtrusionLoop->new_from_paths(@paths);
|
my $loop = Slic3r::ExtrusionLoop->new_from_paths(@paths);
|
||||||
|
$loop->role($loop_role);
|
||||||
|
|
||||||
# return ccw contours and cw holes
|
# return ccw contours and cw holes
|
||||||
# GCode.pm will convert all of them to ccw, but it needs to know
|
# GCode.pm will convert all of them to ccw, but it needs to know
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
use Test::More tests => 9;
|
use Test::More tests => 10;
|
||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
|
|
||||||
@ -265,4 +265,11 @@ use Slic3r::Test;
|
|||||||
'overhangs printed with bridge speed';
|
'overhangs printed with bridge speed';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
my $config = Slic3r::Config->new_from_defaults;
|
||||||
|
$config->set('randomize_start', 1);
|
||||||
|
my $print = Slic3r::Test::init_print('20mm_cube', config => $config);
|
||||||
|
ok Slic3r::Test::gcode($print), 'successful generation of G-code with randomize_start option';
|
||||||
|
}
|
||||||
|
|
||||||
__END__
|
__END__
|
||||||
|
@ -72,23 +72,21 @@ ExtrusionPath::is_perimeter() const
|
|||||||
{
|
{
|
||||||
return this->role == erPerimeter
|
return this->role == erPerimeter
|
||||||
|| this->role == erExternalPerimeter
|
|| this->role == erExternalPerimeter
|
||||||
|| this->role == erOverhangPerimeter
|
|| this->role == erOverhangPerimeter;
|
||||||
|| this->role == erContourInternalPerimeter;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
ExtrusionPath::is_fill() const
|
ExtrusionPath::is_fill() const
|
||||||
{
|
{
|
||||||
return this->role == erFill
|
return this->role == erInternalInfill
|
||||||
|| this->role == erSolidFill
|
|| this->role == erSolidInfill
|
||||||
|| this->role == erTopSolidFill;
|
|| this->role == erTopSolidInfill;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
ExtrusionPath::is_bridge() const
|
ExtrusionPath::is_bridge() const
|
||||||
{
|
{
|
||||||
return this->role == erBridge
|
return this->role == erBridgeInfill
|
||||||
|| this->role == erInternalBridge
|
|
||||||
|| this->role == erOverhangPerimeter;
|
|| this->role == erOverhangPerimeter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,19 +11,25 @@ class ExPolygonCollection;
|
|||||||
class ExtrusionEntityCollection;
|
class ExtrusionEntityCollection;
|
||||||
class Extruder;
|
class Extruder;
|
||||||
|
|
||||||
|
/* Each ExtrusionRole value identifies a distinct set of { extruder, speed } */
|
||||||
enum ExtrusionRole {
|
enum ExtrusionRole {
|
||||||
erPerimeter,
|
erPerimeter,
|
||||||
erExternalPerimeter,
|
erExternalPerimeter,
|
||||||
erOverhangPerimeter,
|
erOverhangPerimeter,
|
||||||
erContourInternalPerimeter,
|
erInternalInfill,
|
||||||
erFill,
|
erSolidInfill,
|
||||||
erSolidFill,
|
erTopSolidInfill,
|
||||||
erTopSolidFill,
|
erBridgeInfill,
|
||||||
erBridge,
|
erGapFill,
|
||||||
erInternalBridge,
|
|
||||||
erSkirt,
|
erSkirt,
|
||||||
erSupportMaterial,
|
erSupportMaterial,
|
||||||
erGapFill,
|
};
|
||||||
|
|
||||||
|
/* Special flags describing loop */
|
||||||
|
enum ExtrusionLoopRole {
|
||||||
|
elrDefault,
|
||||||
|
elrExternalPerimeter,
|
||||||
|
elrContourInternalPerimeter,
|
||||||
};
|
};
|
||||||
|
|
||||||
class ExtrusionEntity
|
class ExtrusionEntity
|
||||||
@ -47,7 +53,7 @@ class ExtrusionPath : public ExtrusionEntity
|
|||||||
float width;
|
float width;
|
||||||
float height;
|
float height;
|
||||||
|
|
||||||
ExtrusionPath() : mm3_per_mm(-1), width(-1), height(-1) {};
|
ExtrusionPath(ExtrusionRole role) : role(role), mm3_per_mm(-1), width(-1), height(-1) {};
|
||||||
ExtrusionPath* clone() const;
|
ExtrusionPath* clone() const;
|
||||||
void reverse();
|
void reverse();
|
||||||
Point first_point() const;
|
Point first_point() const;
|
||||||
@ -74,7 +80,9 @@ class ExtrusionLoop : public ExtrusionEntity
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ExtrusionPaths paths;
|
ExtrusionPaths paths;
|
||||||
|
ExtrusionLoopRole role;
|
||||||
|
|
||||||
|
ExtrusionLoop(ExtrusionLoopRole role = elrDefault) : role(role) {};
|
||||||
operator Polygon() const;
|
operator Polygon() const;
|
||||||
ExtrusionLoop* clone() const;
|
ExtrusionLoop* clone() const;
|
||||||
bool make_clockwise();
|
bool make_clockwise();
|
||||||
|
@ -41,5 +41,31 @@ ExtrusionLoop::arrayref()
|
|||||||
OUTPUT:
|
OUTPUT:
|
||||||
RETVAL
|
RETVAL
|
||||||
|
|
||||||
|
ExtrusionLoopRole
|
||||||
|
ExtrusionLoop::role(...)
|
||||||
|
CODE:
|
||||||
|
if (items > 1) {
|
||||||
|
THIS->role = (ExtrusionLoopRole)SvUV(ST(1));
|
||||||
|
}
|
||||||
|
RETVAL = THIS->role;
|
||||||
|
OUTPUT:
|
||||||
|
RETVAL
|
||||||
|
|
||||||
%}
|
%}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
%package{Slic3r::ExtrusionLoop};
|
||||||
|
%{
|
||||||
|
|
||||||
|
IV
|
||||||
|
_constant()
|
||||||
|
ALIAS:
|
||||||
|
EXTRL_ROLE_DEFAULT = elrDefault
|
||||||
|
EXTRL_ROLE_EXTERNAL_PERIMETER = elrExternalPerimeter
|
||||||
|
EXTRL_ROLE_CONTOUR_INTERNAL_PERIMETER = erInternalInfill
|
||||||
|
PROTOTYPE:
|
||||||
|
CODE:
|
||||||
|
RETVAL = ix;
|
||||||
|
OUTPUT: RETVAL
|
||||||
|
|
||||||
|
%}
|
||||||
|
@ -39,9 +39,8 @@ _new(CLASS, polyline_sv, role, mm3_per_mm, width, height)
|
|||||||
float width;
|
float width;
|
||||||
float height;
|
float height;
|
||||||
CODE:
|
CODE:
|
||||||
RETVAL = new ExtrusionPath ();
|
RETVAL = new ExtrusionPath (role);
|
||||||
RETVAL->polyline.from_SV_check(polyline_sv);
|
RETVAL->polyline.from_SV_check(polyline_sv);
|
||||||
RETVAL->role = role;
|
|
||||||
RETVAL->mm3_per_mm = mm3_per_mm;
|
RETVAL->mm3_per_mm = mm3_per_mm;
|
||||||
RETVAL->width = width;
|
RETVAL->width = width;
|
||||||
RETVAL->height = height;
|
RETVAL->height = height;
|
||||||
@ -135,15 +134,13 @@ _constant()
|
|||||||
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
|
||||||
EXTR_ROLE_CONTOUR_INTERNAL_PERIMETER = erContourInternalPerimeter
|
EXTR_ROLE_FILL = erInternalInfill
|
||||||
EXTR_ROLE_FILL = erFill
|
EXTR_ROLE_SOLIDFILL = erSolidInfill
|
||||||
EXTR_ROLE_SOLIDFILL = erSolidFill
|
EXTR_ROLE_TOPSOLIDFILL = erTopSolidInfill
|
||||||
EXTR_ROLE_TOPSOLIDFILL = erTopSolidFill
|
EXTR_ROLE_BRIDGE = erBridgeInfill
|
||||||
EXTR_ROLE_BRIDGE = erBridge
|
EXTR_ROLE_GAPFILL = erGapFill
|
||||||
EXTR_ROLE_INTERNALBRIDGE = erInternalBridge
|
|
||||||
EXTR_ROLE_SKIRT = erSkirt
|
EXTR_ROLE_SKIRT = erSkirt
|
||||||
EXTR_ROLE_SUPPORTMATERIAL = erSupportMaterial
|
EXTR_ROLE_SUPPORTMATERIAL = erSupportMaterial
|
||||||
EXTR_ROLE_GAPFILL = erGapFill
|
|
||||||
PROTOTYPE:
|
PROTOTYPE:
|
||||||
CODE:
|
CODE:
|
||||||
RETVAL = ix;
|
RETVAL = ix;
|
||||||
|
@ -111,6 +111,7 @@ Ref<ModelInstance> O_OBJECT_SLIC3R_T
|
|||||||
Clone<ModelInstance> O_OBJECT_SLIC3R_T
|
Clone<ModelInstance> O_OBJECT_SLIC3R_T
|
||||||
|
|
||||||
|
|
||||||
|
ExtrusionLoopRole T_UV
|
||||||
ExtrusionRole T_UV
|
ExtrusionRole T_UV
|
||||||
FlowRole T_UV
|
FlowRole T_UV
|
||||||
PrintStep T_UV
|
PrintStep T_UV
|
||||||
|
@ -112,6 +112,12 @@
|
|||||||
$CVar = (SurfaceType)SvUV($PerlVar);
|
$CVar = (SurfaceType)SvUV($PerlVar);
|
||||||
%};
|
%};
|
||||||
};
|
};
|
||||||
|
%typemap{ExtrusionLoopRole}{parsed}{
|
||||||
|
%cpp_type{ExtrusionLoopRole};
|
||||||
|
%precall_code{%
|
||||||
|
$CVar = (ExtrusionLoopRole)SvUV($PerlVar);
|
||||||
|
%};
|
||||||
|
};
|
||||||
%typemap{ExtrusionRole}{parsed}{
|
%typemap{ExtrusionRole}{parsed}{
|
||||||
%cpp_type{ExtrusionRole};
|
%cpp_type{ExtrusionRole};
|
||||||
%precall_code{%
|
%precall_code{%
|
||||||
|
Loading…
Reference in New Issue
Block a user