Inlined Surface::any_internal_contains / any_bottom_contains

This commit is contained in:
bubnikv 2017-07-10 13:15:36 +02:00
parent 7c1350d007
commit 41f50b246c
6 changed files with 23 additions and 61 deletions

View File

@ -1928,8 +1928,7 @@ std::string GCode::travel_to(const Point &point, ExtrusionRole role, std::string
return gcode;
}
bool
GCode::needs_retraction(const Polyline &travel, ExtrusionRole role)
bool GCode::needs_retraction(const Polyline &travel, ExtrusionRole role)
{
if (travel.length() < scale_(EXTRUDER_CONFIG(retract_before_travel))) {
// skip retraction if the move is shorter than the configured threshold
@ -1946,14 +1945,12 @@ GCode::needs_retraction(const Polyline &travel, ExtrusionRole role)
return false;
}
if (m_config.only_retract_when_crossing_perimeters && m_layer != nullptr) {
if (m_config.fill_density.value > 0
&& m_layer->any_internal_region_slice_contains(travel)) {
/* skip retraction if travel is contained in an internal slice *and*
internal infill is enabled (so that stringing is entirely not visible) */
return false;
}
}
if (m_config.only_retract_when_crossing_perimeters && m_layer != nullptr &&
m_config.fill_density.value > 0 && m_layer->any_internal_region_slice_contains(travel))
// Skip retraction if travel is contained in an internal slice *and*
// internal infill is enabled (so that stringing is entirely not visible).
//FIXME any_internal_region_slice_contains() is potentionally very slow, it shall test for the bounding boxes first.
return false;
// retract if only_retract_when_crossing_perimeters is disabled or doesn't apply
return true;

View File

@ -70,27 +70,6 @@ void Layer::merge_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<Polyline>(const Polyline &item) const;
template <class T>
bool Layer::any_bottom_region_slice_contains(const T &item) const
{
FOREACH_LAYERREGION(this, layerm) {
if ((*layerm)->slices.any_bottom_contains(item)) return true;
}
return false;
}
template bool Layer::any_bottom_region_slice_contains<Polyline>(const Polyline &item) const;
// Here the perimeters are created cummulatively for all layer regions sharing the same parameters influencing the perimeters.
// The perimeter paths and the thin fills (ExtrusionEntityCollection) are assigned to the first compatible layer region.
// The resulting fill surface is split back among the originating regions.

View File

@ -115,8 +115,14 @@ public:
void make_slices();
void merge_slices();
template <class T> bool any_internal_region_slice_contains(const T &item) const;
template <class T> bool any_bottom_region_slice_contains(const T &item) const;
template <class T> bool any_internal_region_slice_contains(const T &item) const {
for (const LayerRegion *layerm : this->regions) if (layerm->slices.any_internal_contains(item)) return true;
return false;
}
template <class T> bool any_bottom_region_slice_contains(const T &item) const {
for (const LayerRegion *layerm : this->regions) if (layerm->slices.any_bottom_contains(item)) return true;
return false;
}
void make_perimeters();
void make_fills();

View File

@ -54,28 +54,6 @@ 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<Polyline>(const Polyline &item) const;
template <class T>
bool
SurfaceCollection::any_bottom_contains(const T &item) const
{
for (Surfaces::const_iterator surface = this->surfaces.begin(); surface != this->surfaces.end(); ++surface) {
if (surface->is_bottom() && surface->expolygon.contains(item)) return true;
}
return false;
}
template bool SurfaceCollection::any_bottom_contains<Polyline>(const Polyline &item) const;
SurfacesPtr
SurfaceCollection::filter_by_type(const SurfaceType type)
{

View File

@ -19,8 +19,14 @@ public:
operator ExPolygons() const;
void simplify(double tolerance);
void group(std::vector<SurfacesPtr> *retval);
template <class T> bool any_internal_contains(const T &item) const;
template <class T> bool any_bottom_contains(const T &item) const;
template <class T> bool any_internal_contains(const T &item) const {
for (const Surface &surface : this->surfaces) if (surface.is_internal() && surface.expolygon.contains(item)) return true;
return false;
}
template <class T> bool any_bottom_contains(const T &item) const {
for (const Surface &surface : this->surfaces) if (surface.is_bottom() && surface.expolygon.contains(item)) return true;
return false;
}
SurfacesPtr filter_by_type(const SurfaceType type);
SurfacesPtr filter_by_types(const SurfaceType *types, int ntypes);
void keep_type(const SurfaceType type);

View File

@ -87,10 +87,6 @@
void make_slices();
void merge_slices();
bool any_internal_region_slice_contains_polyline(Polyline* polyline)
%code%{ RETVAL = THIS->any_internal_region_slice_contains(*polyline); %};
bool any_bottom_region_slice_contains_polyline(Polyline* polyline)
%code%{ RETVAL = THIS->any_bottom_region_slice_contains(*polyline); %};
void make_perimeters();
void make_fills();