Force the 'nearest' strategy for starting skirt loops
This commit is contained in:
parent
1a286fc906
commit
7c8b71012c
5 changed files with 14 additions and 6 deletions
|
@ -5,7 +5,7 @@ use warnings;
|
||||||
use parent qw(Exporter);
|
use parent qw(Exporter);
|
||||||
|
|
||||||
our @EXPORT_OK = qw(EXTRL_ROLE_DEFAULT
|
our @EXPORT_OK = qw(EXTRL_ROLE_DEFAULT
|
||||||
EXTRL_ROLE_CONTOUR_INTERNAL_PERIMETER);
|
EXTRL_ROLE_CONTOUR_INTERNAL_PERIMETER EXTRL_ROLE_SKIRT);
|
||||||
our %EXPORT_TAGS = (roles => \@EXPORT_OK);
|
our %EXPORT_TAGS = (roles => \@EXPORT_OK);
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,7 @@ use warnings;
|
||||||
use File::Basename qw(basename fileparse);
|
use File::Basename qw(basename fileparse);
|
||||||
use File::Spec;
|
use File::Spec;
|
||||||
use List::Util qw(min max first sum);
|
use List::Util qw(min max first sum);
|
||||||
|
use Slic3r::ExtrusionLoop ':roles';
|
||||||
use Slic3r::ExtrusionPath ':roles';
|
use Slic3r::ExtrusionPath ':roles';
|
||||||
use Slic3r::Flow ':roles';
|
use Slic3r::Flow ':roles';
|
||||||
use Slic3r::Geometry qw(X Y Z X1 Y1 X2 Y2 MIN MAX PI scale unscale convex_hull);
|
use Slic3r::Geometry qw(X Y Z X1 Y1 X2 Y2 MIN MAX PI scale unscale convex_hull);
|
||||||
|
@ -273,7 +274,7 @@ sub make_skirt {
|
||||||
for (my $i = $skirts; $i > 0; $i--) {
|
for (my $i = $skirts; $i > 0; $i--) {
|
||||||
$distance += scale $spacing;
|
$distance += scale $spacing;
|
||||||
my $loop = offset([$convex_hull], $distance, 1, JT_ROUND, scale(0.1))->[0];
|
my $loop = offset([$convex_hull], $distance, 1, JT_ROUND, scale(0.1))->[0];
|
||||||
$self->skirt->append(Slic3r::ExtrusionLoop->new_from_paths(
|
my $eloop = Slic3r::ExtrusionLoop->new_from_paths(
|
||||||
Slic3r::ExtrusionPath->new(
|
Slic3r::ExtrusionPath->new(
|
||||||
polyline => Slic3r::Polygon->new(@$loop)->split_at_first_point,
|
polyline => Slic3r::Polygon->new(@$loop)->split_at_first_point,
|
||||||
role => EXTR_ROLE_SKIRT,
|
role => EXTR_ROLE_SKIRT,
|
||||||
|
@ -281,7 +282,9 @@ sub make_skirt {
|
||||||
width => $flow->width,
|
width => $flow->width,
|
||||||
height => $first_layer_height, # this will be overridden at G-code export time
|
height => $first_layer_height, # this will be overridden at G-code export time
|
||||||
),
|
),
|
||||||
));
|
);
|
||||||
|
$eloop->role(EXTRL_ROLE_SKIRT);
|
||||||
|
$self->skirt->append($eloop);
|
||||||
|
|
||||||
if ($self->config->min_skirt_length > 0) {
|
if ($self->config->min_skirt_length > 0) {
|
||||||
$extruded_length[$extruder_idx] ||= 0;
|
$extruded_length[$extruder_idx] ||= 0;
|
||||||
|
|
|
@ -31,6 +31,7 @@ enum ExtrusionRole {
|
||||||
enum ExtrusionLoopRole {
|
enum ExtrusionLoopRole {
|
||||||
elrDefault,
|
elrDefault,
|
||||||
elrContourInternalPerimeter,
|
elrContourInternalPerimeter,
|
||||||
|
elrSkirt,
|
||||||
};
|
};
|
||||||
|
|
||||||
class ExtrusionEntity
|
class ExtrusionEntity
|
||||||
|
|
|
@ -316,12 +316,15 @@ GCode::extrude(ExtrusionLoop loop, std::string description, double speed)
|
||||||
// extrude all loops ccw
|
// extrude all loops ccw
|
||||||
bool was_clockwise = loop.make_counter_clockwise();
|
bool was_clockwise = loop.make_counter_clockwise();
|
||||||
|
|
||||||
|
SeamPosition seam_position = this->config.seam_position;
|
||||||
|
if (loop.role == elrSkirt) seam_position = spNearest;
|
||||||
|
|
||||||
// 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
|
||||||
Point last_pos = this->last_pos();
|
Point last_pos = this->last_pos();
|
||||||
if (this->config.spiral_vase) {
|
if (this->config.spiral_vase) {
|
||||||
loop.split_at(last_pos);
|
loop.split_at(last_pos);
|
||||||
} else if (this->config.seam_position == spNearest || this->config.seam_position == spAligned) {
|
} else if (seam_position == spNearest || seam_position == spAligned) {
|
||||||
const Polygon polygon = loop.polygon();
|
const Polygon polygon = loop.polygon();
|
||||||
|
|
||||||
// simplify polygon in order to skip false positives in concave/convex detection
|
// simplify polygon in order to skip false positives in concave/convex detection
|
||||||
|
@ -356,7 +359,7 @@ GCode::extrude(ExtrusionLoop loop, std::string description, double speed)
|
||||||
}
|
}
|
||||||
|
|
||||||
Point point;
|
Point point;
|
||||||
if (this->config.seam_position == spNearest) {
|
if (seam_position == spNearest) {
|
||||||
if (candidates.empty()) candidates = polygon.points;
|
if (candidates.empty()) candidates = polygon.points;
|
||||||
last_pos.nearest_point(candidates, &point);
|
last_pos.nearest_point(candidates, &point);
|
||||||
|
|
||||||
|
@ -382,7 +385,7 @@ GCode::extrude(ExtrusionLoop loop, std::string description, double speed)
|
||||||
}
|
}
|
||||||
if (this->layer != NULL)
|
if (this->layer != NULL)
|
||||||
this->_seam_position[this->layer->object()] = point;
|
this->_seam_position[this->layer->object()] = point;
|
||||||
} else if (this->config.seam_position == spRandom) {
|
} else if (seam_position == spRandom) {
|
||||||
if (loop.role == elrContourInternalPerimeter) {
|
if (loop.role == elrContourInternalPerimeter) {
|
||||||
Polygon polygon = loop.polygon();
|
Polygon polygon = loop.polygon();
|
||||||
Point centroid = polygon.centroid();
|
Point centroid = polygon.centroid();
|
||||||
|
|
|
@ -66,6 +66,7 @@ _constant()
|
||||||
ALIAS:
|
ALIAS:
|
||||||
EXTRL_ROLE_DEFAULT = elrDefault
|
EXTRL_ROLE_DEFAULT = elrDefault
|
||||||
EXTRL_ROLE_CONTOUR_INTERNAL_PERIMETER = elrContourInternalPerimeter
|
EXTRL_ROLE_CONTOUR_INTERNAL_PERIMETER = elrContourInternalPerimeter
|
||||||
|
EXTRL_ROLE_SKIRT = elrSkirt
|
||||||
PROTOTYPE:
|
PROTOTYPE:
|
||||||
CODE:
|
CODE:
|
||||||
RETVAL = ix;
|
RETVAL = ix;
|
||||||
|
|
Loading…
Add table
Reference in a new issue