Limit "Only retract when crossing perimeters" so that retraction is triggered also when crossing the boundaries of a single region. #2298
This commit is contained in:
parent
80c38b0113
commit
c8596c5c58
8 changed files with 47 additions and 4 deletions
|
@ -344,8 +344,7 @@ 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
|
||||
&& $self->layer->slices->contains_line($travel)
|
||||
&& (!$self->layer->has_upper_layer || $self->layer->upper_layer->slices->contains_line($travel)))
|
||||
&& $self->layer->any_internal_region_slice_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.
|
||||
|
@ -608,8 +607,7 @@ sub _plan {
|
|||
# if the path is not contained in a single island we need to 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));
|
||||
|| !$gcodegen->layer->any_internal_region_slice_contains_polyline($travel);
|
||||
|
||||
# append the actual path and return
|
||||
# use G1 because we rely on paths being straight (G0 may make round paths)
|
||||
|
|
|
@ -120,6 +120,18 @@ Layer::make_slices()
|
|||
}
|
||||
}
|
||||
|
||||
template <class T>
|
||||
bool
|
||||
Layer::any_internal_region_slice_contains(const T &item) const
|
||||
{
|
||||
FOREACH_LAYERREGION(this, layerm) {
|
||||
if ((*layerm)->slices.any_internal_contains(item)) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
template bool Layer::any_internal_region_slice_contains<Line>(const Line &item) const;
|
||||
template bool Layer::any_internal_region_slice_contains<Polyline>(const Polyline &item) const;
|
||||
|
||||
|
||||
#ifdef SLIC3RXS
|
||||
REGISTER_CLASS(Layer, "Layer");
|
||||
|
|
|
@ -90,6 +90,7 @@ class Layer {
|
|||
LayerRegion* add_region(PrintRegion* print_region);
|
||||
|
||||
void make_slices();
|
||||
template <class T> bool any_internal_region_slice_contains(const T &item) const;
|
||||
|
||||
protected:
|
||||
int _id; // sequential number of layer, 0-based
|
||||
|
|
|
@ -26,6 +26,15 @@ Surface::is_external() const
|
|||
|| this->surface_type == stBottomBridge;
|
||||
}
|
||||
|
||||
bool
|
||||
Surface::is_internal() const
|
||||
{
|
||||
return this->surface_type == stInternal
|
||||
|| this->surface_type == stInternalBridge
|
||||
|| this->surface_type == stInternalSolid
|
||||
|| this->surface_type == stInternalVoid;
|
||||
}
|
||||
|
||||
bool
|
||||
Surface::is_bottom() const
|
||||
{
|
||||
|
|
|
@ -24,6 +24,7 @@ class Surface
|
|||
double area() const;
|
||||
bool is_solid() const;
|
||||
bool is_external() const;
|
||||
bool is_internal() const;
|
||||
bool is_bottom() const;
|
||||
bool is_bridge() const;
|
||||
|
||||
|
|
|
@ -68,6 +68,18 @@ SurfaceCollection::group(std::vector<SurfacesPtr> *retval)
|
|||
}
|
||||
}
|
||||
|
||||
template <class T>
|
||||
bool
|
||||
SurfaceCollection::any_internal_contains(const T &item) const
|
||||
{
|
||||
for (Surfaces::const_iterator surface = this->surfaces.begin(); surface != this->surfaces.end(); ++surface) {
|
||||
if (surface->is_internal() && surface->expolygon.contains(item)) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
template bool SurfaceCollection::any_internal_contains<Line>(const Line &item) const;
|
||||
template bool SurfaceCollection::any_internal_contains<Polyline>(const Polyline &item) const;
|
||||
|
||||
#ifdef SLIC3RXS
|
||||
REGISTER_CLASS(SurfaceCollection, "Surface::Collection");
|
||||
#endif
|
||||
|
|
|
@ -15,6 +15,7 @@ class SurfaceCollection
|
|||
operator ExPolygons() const;
|
||||
void simplify(double tolerance);
|
||||
void group(std::vector<SurfacesPtr> *retval);
|
||||
template <class T> bool any_internal_contains(const T &item) const;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -69,6 +69,10 @@
|
|||
%code%{ RETVAL = (int)(intptr_t)THIS; %};
|
||||
|
||||
void make_slices();
|
||||
bool any_internal_region_slice_contains_line(Line* line)
|
||||
%code%{ RETVAL = THIS->any_internal_region_slice_contains(*line); %};
|
||||
bool any_internal_region_slice_contains_polyline(Polyline* polyline)
|
||||
%code%{ RETVAL = THIS->any_internal_region_slice_contains(*polyline); %};
|
||||
};
|
||||
|
||||
%name{Slic3r::Layer::Support} class SupportLayer {
|
||||
|
@ -114,4 +118,9 @@
|
|||
|
||||
Ref<ExPolygonCollection> slices()
|
||||
%code%{ RETVAL = &THIS->slices; %};
|
||||
|
||||
bool any_internal_region_slice_contains_line(Line* line)
|
||||
%code%{ RETVAL = THIS->any_internal_region_slice_contains(*line); %};
|
||||
bool any_internal_region_slice_contains_polyline(Polyline* polyline)
|
||||
%code%{ RETVAL = THIS->any_internal_region_slice_contains(*polyline); %};
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue