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);
|
||||
|
||||
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);
|
||||
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@ use warnings;
|
|||
use File::Basename qw(basename fileparse);
|
||||
use File::Spec;
|
||||
use List::Util qw(min max first sum);
|
||||
use Slic3r::ExtrusionLoop ':roles';
|
||||
use Slic3r::ExtrusionPath ':roles';
|
||||
use Slic3r::Flow ':roles';
|
||||
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--) {
|
||||
$distance += scale $spacing;
|
||||
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(
|
||||
polyline => Slic3r::Polygon->new(@$loop)->split_at_first_point,
|
||||
role => EXTR_ROLE_SKIRT,
|
||||
|
@ -281,7 +282,9 @@ sub make_skirt {
|
|||
width => $flow->width,
|
||||
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) {
|
||||
$extruded_length[$extruder_idx] ||= 0;
|
||||
|
|
|
@ -31,6 +31,7 @@ enum ExtrusionRole {
|
|||
enum ExtrusionLoopRole {
|
||||
elrDefault,
|
||||
elrContourInternalPerimeter,
|
||||
elrSkirt,
|
||||
};
|
||||
|
||||
class ExtrusionEntity
|
||||
|
|
|
@ -316,12 +316,15 @@ GCode::extrude(ExtrusionLoop loop, std::string description, double speed)
|
|||
// extrude all loops ccw
|
||||
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
|
||||
// or randomize if requested
|
||||
Point last_pos = this->last_pos();
|
||||
if (this->config.spiral_vase) {
|
||||
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();
|
||||
|
||||
// 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;
|
||||
if (this->config.seam_position == spNearest) {
|
||||
if (seam_position == spNearest) {
|
||||
if (candidates.empty()) candidates = polygon.points;
|
||||
last_pos.nearest_point(candidates, &point);
|
||||
|
||||
|
@ -382,7 +385,7 @@ GCode::extrude(ExtrusionLoop loop, std::string description, double speed)
|
|||
}
|
||||
if (this->layer != NULL)
|
||||
this->_seam_position[this->layer->object()] = point;
|
||||
} else if (this->config.seam_position == spRandom) {
|
||||
} else if (seam_position == spRandom) {
|
||||
if (loop.role == elrContourInternalPerimeter) {
|
||||
Polygon polygon = loop.polygon();
|
||||
Point centroid = polygon.centroid();
|
||||
|
|
|
@ -66,6 +66,7 @@ _constant()
|
|||
ALIAS:
|
||||
EXTRL_ROLE_DEFAULT = elrDefault
|
||||
EXTRL_ROLE_CONTOUR_INTERNAL_PERIMETER = elrContourInternalPerimeter
|
||||
EXTRL_ROLE_SKIRT = elrSkirt
|
||||
PROTOTYPE:
|
||||
CODE:
|
||||
RETVAL = ix;
|
||||
|
|
Loading…
Reference in a new issue