diff --git a/include/LayerPlan.h b/include/LayerPlan.h index 0b5f632489..75eac440ea 100644 --- a/include/LayerPlan.h +++ b/include/LayerPlan.h @@ -942,6 +942,13 @@ class LayerPlan : public NoCopy * \return The distance from the start of the current wall line to the first bridge segment */ coord_t computeDistanceToBridgeStart(const ExtrusionLine& wall, const size_t current_index, const coord_t min_bridge_line_len) const; + + /*! + * \brief Calculates whether the given segment is to be treated as overhanging + * \param p0 The start point of the segment + * \param p1 The end point of the segment + */ + bool segmentIsOnOverhang(const Point3LL& p0, const Point3LL& p1) const; }; } // namespace cura diff --git a/src/LayerPlan.cpp b/src/LayerPlan.cpp index 8f6c12317c..a821d01f4a 100644 --- a/src/LayerPlan.cpp +++ b/src/LayerPlan.cpp @@ -743,8 +743,7 @@ void LayerPlan::addWallLine( segment_flow, width_factor, spiralize, - (overhang_mask_.empty() || (! overhang_mask_.inside(p0.toPoint2LL(), true) && ! overhang_mask_.inside(p1.toPoint2LL(), true))) ? speed_factor - : overhang_speed_factor, + segmentIsOnOverhang(p0, p1) ? overhang_speed_factor : speed_factor, GCodePathConfig::FAN_SPEED_DEFAULT, travel_to_z); } @@ -761,8 +760,7 @@ void LayerPlan::addWallLine( segment_flow, width_factor, spiralize, - (overhang_mask_.empty() || (! overhang_mask_.inside(p0.toPoint2LL(), true) && ! overhang_mask_.inside(p1.toPoint2LL(), true))) ? speed_factor - : overhang_speed_factor, + segmentIsOnOverhang(p0, p1) ? overhang_speed_factor : speed_factor, GCodePathConfig::FAN_SPEED_DEFAULT, travel_to_z); } @@ -867,7 +865,7 @@ void LayerPlan::addWallLine( flow, width_factor, spiralize, - (overhang_mask_.empty() || (! overhang_mask_.inside(p0.toPoint2LL(), true) && ! overhang_mask_.inside(p1.toPoint2LL(), true))) ? speed_factor : overhang_speed_factor, + segmentIsOnOverhang(p0, p1) ? overhang_speed_factor : 1.0_r, GCodePathConfig::FAN_SPEED_DEFAULT, travel_to_z); } @@ -1725,6 +1723,13 @@ void LayerPlan::addLinesInGivenOrder( } } +bool LayerPlan::segmentIsOnOverhang(const Point3LL& p0, const Point3LL& p1) const +{ + const OpenPolyline segment{ p0.toPoint2LL(), p1.toPoint2LL() }; + const OpenLinesSet intersected_lines = overhang_mask_.intersection(OpenLinesSet{ segment }); + return ! intersected_lines.empty() && (static_cast(intersected_lines.length()) / segment.length()) > 0.5; +} + void LayerPlan::sendLineTo(const GCodePath& path, const Point3LL& position, const double extrude_speed) { Application::getInstance().communication_->sendLineTo(