Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/supermerill/SuperSlicer.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/Slic3r/GCode.pm32
-rw-r--r--lib/Slic3r/Layer.pm12
-rw-r--r--xs/src/libslic3r/ExPolygonCollection.cpp18
-rw-r--r--xs/src/libslic3r/ExPolygonCollection.hpp4
-rw-r--r--xs/xsp/ExPolygonCollection.xsp4
-rw-r--r--xs/xsp/Layer.xsp10
6 files changed, 44 insertions, 36 deletions
diff --git a/lib/Slic3r/GCode.pm b/lib/Slic3r/GCode.pm
index 990f6215a..3afc2f5ce 100644
--- a/lib/Slic3r/GCode.pm
+++ b/lib/Slic3r/GCode.pm
@@ -25,8 +25,6 @@ has 'enable_cooling_markers' => (is =>'rw', default => sub {0});
has 'layer_count' => (is => 'ro');
has '_layer_index' => (is => 'rw', default => sub {-1}); # just a counter
has 'layer' => (is => 'rw');
-has '_layer_islands' => (is => 'rw');
-has '_upper_layer_islands' => (is => 'rw');
has '_seam_position' => (is => 'ro', default => sub { {} }); # $object => pos
has 'first_layer' => (is => 'rw', default => sub {0}); # this flag triggers first layer speeds
has 'elapsed_time' => (is => 'rw', default => sub {0} ); # seconds
@@ -84,8 +82,6 @@ sub change_layer {
$self->first_layer($layer->id == 0);
# avoid computing islands and overhangs if they're not needed
- $self->_layer_islands($layer->islands);
- $self->_upper_layer_islands($layer->upper_layer ? $layer->upper_layer->islands : []);
if ($self->config->avoid_crossing_perimeters) {
$self->avoid_crossing_perimeters->init_layer_mp(
union_ex([ map @$_, @{$layer->slices} ], 1),
@@ -351,9 +347,9 @@ sub travel_to {
if ($travel->length < scale $self->config->get_at('retract_before_travel', $self->writer->extruder->id)
|| ($self->config->only_retract_when_crossing_perimeters
&& $self->config->fill_density > 0
- && (first { $_->contains_line($travel) } @{$self->_upper_layer_islands})
- && (first { $_->contains_line($travel) } @{$self->_layer_islands}))
- || (defined $role && $role == EXTR_ROLE_SUPPORTMATERIAL && (first { $_->contains_line($travel) } @{$self->layer->support_islands}))
+ && $self->layer->slices->contains_line($travel)
+ && (!$self->layer->has_upper_layer || $self->layer->upper_layer->slices->contains_line($travel)))
+ || (defined $role && $role == EXTR_ROLE_SUPPORTMATERIAL && $self->layer->support_islands->contains_line($travel))
) {
# Just perform a straight travel move without any retraction.
$gcode .= $self->writer->travel_to_xy($self->point_to_gcode($point), $comment);
@@ -608,29 +604,19 @@ sub _plan {
my ($self, $gcodegen, $mp, $point, $comment) = @_;
my $gcode = "";
- my @travel = @{$mp->shortest_path($gcodegen->last_pos, $point)->lines};
+ my $travel = $mp->shortest_path($gcodegen->last_pos, $point);
# if the path is not contained in a single island we need to retract
- my $need_retract = !$gcodegen->config->only_retract_when_crossing_perimeters;
- if (!$need_retract) {
- $need_retract = 1;
- foreach my $island (@{$gcodegen->_upper_layer_islands}) {
- # discard the island if at any line is not enclosed in it
- next if first { !$island->contains_line($_) } @travel;
- # okay, this island encloses the full travel path
- $need_retract = 0;
- last;
- }
- }
-
- # perform the retraction
- $gcode .= $gcodegen->retract if $need_retract;
+ $gcode .= $gcodegen->retract
+ if !$gcodegen->config->only_retract_when_crossing_perimeters
+ || !$gcodegen->layer->slices->contains_polyline($travel)
+ || ($gcodegen->layer->has_upper_layer && !$gcodegen->layer->upper_layer->slices->contains_polyline($travel));
# append the actual path and return
# use G1 because we rely on paths being straight (G0 may make round paths)
$gcode .= join '',
map $gcodegen->writer->travel_to_xy($self->point_to_gcode($_->b), $comment),
- @travel;
+ @{$travel->lines};
return $gcode;
}
diff --git a/lib/Slic3r/Layer.pm b/lib/Slic3r/Layer.pm
index 463413b55..a3e72994e 100644
--- a/lib/Slic3r/Layer.pm
+++ b/lib/Slic3r/Layer.pm
@@ -16,12 +16,6 @@ sub config {
return $self->object->config;
}
-# the purpose of this method is to be overridden for ::Support layers
-sub islands {
- my $self = shift;
- return $self->slices;
-}
-
sub region {
my $self = shift;
my ($region_id) = @_;
@@ -120,12 +114,6 @@ sub make_perimeters {
}
package Slic3r::Layer::Support;
-
our @ISA = qw(Slic3r::Layer);
-sub islands {
- my $self = shift;
- return [ @{$self->slices}, @{$self->support_islands} ];
-}
-
1;
diff --git a/xs/src/libslic3r/ExPolygonCollection.cpp b/xs/src/libslic3r/ExPolygonCollection.cpp
index 3de86e7c6..181288c95 100644
--- a/xs/src/libslic3r/ExPolygonCollection.cpp
+++ b/xs/src/libslic3r/ExPolygonCollection.cpp
@@ -64,6 +64,24 @@ ExPolygonCollection::contains_point(const Point &point) const
return false;
}
+bool
+ExPolygonCollection::contains_line(const Line &line) const
+{
+ for (ExPolygons::const_iterator it = this->expolygons.begin(); it != this->expolygons.end(); ++it) {
+ if (it->contains_line(line)) return true;
+ }
+ return false;
+}
+
+bool
+ExPolygonCollection::contains_polyline(const Polyline &polyline) const
+{
+ for (ExPolygons::const_iterator it = this->expolygons.begin(); it != this->expolygons.end(); ++it) {
+ if (it->contains_polyline(polyline)) return true;
+ }
+ return false;
+}
+
void
ExPolygonCollection::simplify(double tolerance)
{
diff --git a/xs/src/libslic3r/ExPolygonCollection.hpp b/xs/src/libslic3r/ExPolygonCollection.hpp
index f6a27284f..07532ccf4 100644
--- a/xs/src/libslic3r/ExPolygonCollection.hpp
+++ b/xs/src/libslic3r/ExPolygonCollection.hpp
@@ -3,6 +3,8 @@
#include <myinit.h>
#include "ExPolygon.hpp"
+#include "Line.hpp"
+#include "Polyline.hpp"
namespace Slic3r {
@@ -23,6 +25,8 @@ class ExPolygonCollection
void translate(double x, double y);
void rotate(double angle, const Point &center);
bool contains_point(const Point &point) const;
+ bool contains_line(const Line &line) const;
+ bool contains_polyline(const Polyline &polyline) const;
void simplify(double tolerance);
void convex_hull(Polygon* hull) const;
};
diff --git a/xs/xsp/ExPolygonCollection.xsp b/xs/xsp/ExPolygonCollection.xsp
index a93b27dda..902494b34 100644
--- a/xs/xsp/ExPolygonCollection.xsp
+++ b/xs/xsp/ExPolygonCollection.xsp
@@ -19,6 +19,10 @@
%code{% RETVAL = THIS->expolygons.size(); %};
bool contains_point(Point* point)
%code{% RETVAL = THIS->contains_point(*point); %};
+ bool contains_line(Line* line)
+ %code{% RETVAL = THIS->contains_line(*line); %};
+ bool contains_polyline(Polyline* polyline)
+ %code{% RETVAL = THIS->contains_polyline(*polyline); %};
void simplify(double tolerance);
Polygons polygons()
%code{% RETVAL = *THIS; %};
diff --git a/xs/xsp/Layer.xsp b/xs/xsp/Layer.xsp
index 2d6ec99e2..e0f7e8a17 100644
--- a/xs/xsp/Layer.xsp
+++ b/xs/xsp/Layer.xsp
@@ -53,7 +53,11 @@
%code%{ THIS->upper_layer = layer; %};
void set_lower_layer(Layer *layer)
%code%{ THIS->lower_layer = layer; %};
-
+ bool has_upper_layer()
+ %code%{ RETVAL = (THIS->upper_layer != NULL); %};
+ bool has_lower_layer()
+ %code%{ RETVAL = (THIS->lower_layer != NULL); %};
+
size_t region_count();
Ref<LayerRegion> get_region(int idx);
Ref<LayerRegion> add_region(PrintRegion* print_region);
@@ -99,6 +103,10 @@
%code%{ THIS->upper_layer = layer; %};
void set_lower_layer(SupportLayer *layer)
%code%{ THIS->lower_layer = layer; %};
+ bool has_upper_layer()
+ %code%{ RETVAL = (THIS->upper_layer != NULL); %};
+ bool has_lower_layer()
+ %code%{ RETVAL = (THIS->lower_layer != NULL); %};
size_t region_count();
Ref<LayerRegion> get_region(int idx);