Skip to content

Commit ae38e60

Browse files
authored
CURA-12369 extra wipe move with spiralize (#2206)
2 parents 7465edd + 6ad3c80 commit ae38e60

File tree

4 files changed

+49
-39
lines changed

4 files changed

+49
-39
lines changed

include/LayerPlan.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -850,7 +850,7 @@ class LayerPlan : public NoCopy
850850
* @param position The start position (which is not included in the path points)
851851
* @param extrude_speed The actual used extrusion speed
852852
*/
853-
void sendLineTo(const GCodePath& path, const Point3LL& position, const double extrude_speed);
853+
void sendLineTo(const GCodePath& path, const Point3LL& position, const double extrude_speed, const std::optional<coord_t>& line_thickness = std::nullopt);
854854

855855
/*!
856856
* @brief Write a travel move and properly apply the various Z offsets

include/geometry/Point3LL.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class Point3LL
3636

3737
Point3LL(Point3LL&& point) = default;
3838
Point3LL(const Point3LL& point) = default;
39-
Point3LL(const Point2LL& point);
39+
Point3LL(const Point2LL& point, const coord_t z = 0);
4040

4141
Point3LL& operator=(const Point3LL& point) = default;
4242
Point3LL& operator=(Point3LL&& point) = default;

src/LayerPlan.cpp

Lines changed: 45 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -2174,13 +2174,13 @@ void LayerPlan::addLinesInGivenOrder(
21742174
}
21752175
}
21762176

2177-
void LayerPlan::sendLineTo(const GCodePath& path, const Point3LL& position, const double extrude_speed)
2177+
void LayerPlan::sendLineTo(const GCodePath& path, const Point3LL& position, const double extrude_speed, const std::optional<coord_t>& line_thickness)
21782178
{
21792179
Application::getInstance().communication_->sendLineTo(
21802180
path.config.type,
21812181
position + Point3LL(0, 0, z_ + path.z_offset),
21822182
path.getLineWidthForLayerView(),
2183-
path.config.getLayerThickness() + path.z_offset + position.z_,
2183+
line_thickness.value_or(path.config.getLayerThickness() + path.z_offset + position.z_),
21842184
extrude_speed);
21852185
}
21862186

@@ -2410,7 +2410,18 @@ void LayerPlan::spiralizeWallSlice(
24102410
}
24112411
// reduce number of paths created when polygon has many points by limiting precision of flow
24122412
constexpr bool no_spiralize = false;
2413-
addExtrusionMove(p, config, SpaceFillType::Polygons, ((int)(flow * 20)) / 20.0, width_factor, no_spiralize, speed_factor);
2413+
constexpr double fan_speed = GCodePathConfig::FAN_SPEED_DEFAULT;
2414+
constexpr bool travel_to_z = false;
2415+
addExtrusionMove(
2416+
Point3LL(p, layer_thickness_ / 2.0),
2417+
config,
2418+
SpaceFillType::Polygons,
2419+
((int)(flow * 20)) / 20.0,
2420+
width_factor,
2421+
no_spiralize,
2422+
speed_factor,
2423+
fan_speed,
2424+
travel_to_z);
24142425
}
24152426
}
24162427
}
@@ -3040,23 +3051,16 @@ void LayerPlan::writeGCode(GCodeExport& gcode)
30403051
if (! coasting) // not same as 'else', cause we might have changed [coasting] in the line above...
30413052
{ // normal path to gcode algorithm
30423053
Point3LL prev_point = gcode.getPosition();
3043-
for (unsigned int point_idx = 0; point_idx < path.points.size(); point_idx++)
3054+
for (const auto& pt : path.points)
30443055
{
3045-
const auto [_, time] = extruder_plan.getPointToPointTime(prev_point, path.points[point_idx], path);
3056+
const auto [_, time] = extruder_plan.getPointToPointTime(prev_point, pt, path);
30463057
insertTempOnTime(time, path_idx);
30473058

30483059
const double extrude_speed = speed * path.speed_back_pressure_factor;
3049-
writeExtrusionRelativeZ(
3050-
gcode,
3051-
path.points[point_idx],
3052-
extrude_speed,
3053-
path.z_offset,
3054-
path.getExtrusionMM3perMM(),
3055-
path.config.type,
3056-
update_extrusion_offset);
3057-
sendLineTo(path, path.points[point_idx], extrude_speed);
3060+
writeExtrusionRelativeZ(gcode, pt, extrude_speed, path.z_offset, path.getExtrusionMM3perMM(), path.config.type, update_extrusion_offset);
3061+
sendLineTo(path, pt, extrude_speed);
30583062

3059-
prev_point = path.points[point_idx];
3063+
prev_point = pt;
30603064
}
30613065
}
30623066
}
@@ -3078,38 +3082,43 @@ void LayerPlan::writeGCode(GCodeExport& gcode)
30783082

30793083
double length = 0.0;
30803084
p0 = gcode.getPositionXY();
3081-
for (; path_idx < paths.size() && paths[path_idx].spiralize; path_idx++)
3082-
{ // handle all consecutive spiralized paths > CHANGES path_idx!
3083-
GCodePath& spiral_path = paths[path_idx];
3084-
3085-
for (unsigned int point_idx = 0; point_idx < spiral_path.points.size(); point_idx++)
3085+
const auto writeSpiralPath = [&](const GCodePath& spiral_path, const bool end_layer) -> void
3086+
{
3087+
for (const auto& p1 : spiral_path.points)
30863088
{
3087-
const Point2LL p1 = spiral_path.points[point_idx].toPoint2LL();
3088-
length += vSizeMM(p0 - p1);
3089-
p0 = p1;
3089+
const Point2LL p1_2d = p1.toPoint2LL();
3090+
length += vSizeMM(p0 - p1_2d);
3091+
p0 = p1_2d;
30903092

3091-
const coord_t z_offset = std::round(layer_thickness_ * length / totalLength);
3093+
const coord_t z_offset = end_layer ? layer_thickness_ / 2 : std::round(layer_thickness_ * length / totalLength);
30923094
const double extrude_speed = speed * spiral_path.speed_back_pressure_factor;
30933095
writeExtrusionRelativeZ(
30943096
gcode,
3095-
spiral_path.points[point_idx],
3097+
p1,
30963098
extrude_speed,
30973099
path.z_offset + z_offset,
30983100
spiral_path.getExtrusionMM3perMM(),
30993101
spiral_path.config.type,
31003102
update_extrusion_offset);
3101-
sendLineTo(spiral_path, spiral_path.points[point_idx], extrude_speed);
3103+
sendLineTo(spiral_path, Point3LL(p1.x_, p1.y_, z_offset), extrude_speed, layer_thickness_);
31023104
}
3103-
// for layer display only - the loop finished at the seam vertex but as we started from
3104-
// the location of the previous layer's seam vertex the loop may have a gap if this layer's
3105-
// seam vertex is "behind" the previous layer's seam vertex. So output another line segment
3106-
// that joins this layer's seam vertex to the following vertex. If the layers have been blended
3107-
// then this can cause a visible ridge (on the screen, not on the print) because the first vertex
3108-
// would have been shifted in x/y to make it nearer to the previous layer outline but the seam
3109-
// vertex would not be shifted (as it's the last vertex in the sequence). The smoother the model,
3110-
// the less the vertices are shifted and the less obvious is the ridge. If the layer display
3111-
// really displayed a spiral rather than slices of a spiral, this would not be required.
3112-
sendLineTo(spiral_path, spiral_path.points[0], speed);
3105+
};
3106+
3107+
for (; path_idx < paths.size() && paths[path_idx].spiralize; path_idx++)
3108+
{ // handle all consecutive spiralized paths > CHANGES path_idx!
3109+
constexpr bool not_end_layer = false;
3110+
writeSpiralPath(paths[path_idx], not_end_layer);
3111+
}
3112+
3113+
if (path_idx < paths.size())
3114+
{
3115+
// Handle last path & exit.
3116+
constexpr bool end_layer = true;
3117+
for (; path_idx < paths.size(); path_idx++)
3118+
{
3119+
writeSpiralPath(paths[path_idx], end_layer);
3120+
}
3121+
break;
31133122
}
31143123
path_idx--; // the last path_idx didnt spiralize, so it's not part of the current spiralize path
31153124
}

src/geometry/Point3LL.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@
66
namespace cura
77
{
88

9-
Point3LL::Point3LL(const Point2LL& point)
9+
Point3LL::Point3LL(const Point2LL& point, const coord_t z)
1010
: x_(point.X)
1111
, y_(point.Y)
12+
, z_(z)
1213
{
1314
}
1415

0 commit comments

Comments
 (0)