Skip to content

Commit

Permalink
Change segment overhanging calculation formula (#2144)
Browse files Browse the repository at this point in the history
  • Loading branch information
HellAholic authored Oct 10, 2024
2 parents 1cba802 + ac5f1af commit 5716bf0
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
7 changes: 7 additions & 0 deletions include/LayerPlan.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 10 additions & 5 deletions src/LayerPlan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -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);
}
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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<double>(intersected_lines.length()) / segment.length()) > 0.5;
}

void LayerPlan::sendLineTo(const GCodePath& path, const Point3LL& position, const double extrude_speed)
{
Application::getInstance().communication_->sendLineTo(
Expand Down

0 comments on commit 5716bf0

Please sign in to comment.