Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CURA-12081 Scarf seam #2137

Merged
merged 36 commits into from
Oct 4, 2024
Merged
Show file tree
Hide file tree
Changes from 31 commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
0d3439f
Add z-height to infill plugin
EmJay276 Jul 3, 2024
fd0dbea
Merge branch 'refs/heads/plugin_z_height' into PR_plugin_z_height
Aug 7, 2024
8d2bd2b
Make GCodePath use 3D points so that they can have individual Z offsets
wawanbreton Aug 20, 2024
cf3d3f9
Remove unused communication methods
wawanbreton Aug 20, 2024
636a6af
Send 3D points to the front-end so that we can display Z changes
wawanbreton Aug 21, 2024
7bbbbf7
Create a scarf seam depending on the given settings
wawanbreton Aug 22, 2024
8522069
Fix scarf seam for small walls
wawanbreton Aug 22, 2024
026557b
Applied clang-format.
wawanbreton Aug 22, 2024
fb36ac4
Scarf seam calculation optimization
wawanbreton Aug 22, 2024
5a184f3
Gradual flow calculation optimization
wawanbreton Aug 22, 2024
816d3fe
Fix scarf seam after optimization
wawanbreton Aug 22, 2024
86eabfb
Fix comment
wawanbreton Aug 22, 2024
2ff17e6
Retrieve scarf settings more consistently
wawanbreton Aug 22, 2024
9d2f285
Apply acceleration after seam
wawanbreton Aug 23, 2024
fd1e268
Refactor wall line splitting
wawanbreton Aug 23, 2024
cf3ece9
Apply deceleration when ending an outer wall print
wawanbreton Aug 23, 2024
6fc32c1
Add code documentation
wawanbreton Aug 23, 2024
e184deb
Fix edge cases with small models
wawanbreton Aug 23, 2024
4ce478b
Merge branch 'main' into CURA-12081_scarf-seam
wawanbreton Aug 23, 2024
19fa63c
Fix GCode display issue
wawanbreton Aug 23, 2024
3428bf8
Fix MacOS build
wawanbreton Aug 23, 2024
008ff2a
Fix MacOS build
wawanbreton Aug 23, 2024
4ab56b5
Merge branch 'main' into CURA-12081_scarf-seam
rburema Sep 24, 2024
969c312
Remove dead code and fix tests.
rburema Sep 24, 2024
132ab14
The 'spiralize' variable was missing.
rburema Sep 24, 2024
4fdee03
Merge remote-tracking branch 'emjay/PR_plugin_z_height' into CURA-120…
rburema Sep 25, 2024
348929e
Rename 'Splitted' to 'Split'
rburema Sep 25, 2024
e7ab2d1
Fix coasting for 'split-up' paths.
rburema Sep 25, 2024
5608352
Coast less if the next ('split') path(s) are already 'coasted away'.
rburema Sep 25, 2024
5e365b0
Applied clang-format.
rburema Sep 25, 2024
8c46f31
Disable scarf for initial layer (protects the buildplate).
rburema Sep 25, 2024
5024ded
Review: Better whitespace in comment.
rburema Oct 1, 2024
23c45a0
Make comment more clear for the new add-split-wall function.
rburema Oct 1, 2024
ae8c06c
Merge remote-tracking branch 'origin/main' into CURA-12081_scarf-seam
rburema Oct 1, 2024
54609c8
Use specific grpc definitions
wawanbreton Oct 3, 2024
5cfb461
Revert "Use specific grpc definitions"
HellAholic Oct 4, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,6 @@ set(engine_SRCS # Except main.cpp.
src/utils/ListPolyIt.cpp
src/utils/Matrix4x3D.cpp
src/utils/MinimumSpanningTree.cpp
src/utils/Point3LL.cpp
src/utils/PolygonConnector.cpp
src/utils/PolygonsPointIndex.cpp
src/utils/PolygonsSegmentIndex.cpp
Expand All @@ -157,6 +156,8 @@ set(engine_SRCS # Except main.cpp.
src/utils/VoxelUtils.cpp
src/utils/MixedPolylineStitcher.cpp

src/geometry/Point2LL.cpp
src/geometry/Point3LL.cpp
src/geometry/Polygon.cpp
src/geometry/Shape.cpp
src/geometry/PointsSet.cpp
Expand Down
2 changes: 1 addition & 1 deletion include/ExtruderPlan.h
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ class ExtruderPlan
/*!
* @return distance between p0 and p1 as well as the time spend on the segment
*/
std::pair<double, double> getPointToPointTime(const Point2LL& p0, const Point2LL& p1, const GCodePath& path);
std::pair<double, double> getPointToPointTime(const Point3LL& p0, const Point3LL& p1, const GCodePath& path);

/*!
* Compute naive time estimates (without accounting for slow down at corners etc.) and naive material estimates.
Expand Down
2 changes: 1 addition & 1 deletion include/GCodePathConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ struct GCodePathConfig
{
static constexpr double FAN_SPEED_DEFAULT = -1.0;

coord_t z_offset{}; //<! vertical offset from 'full' layer height
coord_t z_offset{}; //<! vertical offset from 'full' layer height, to be applied to the whole path
PrintFeatureType type{}; //!< name of the feature type
coord_t line_width{}; //!< width of the line extruded
coord_t layer_thickness{}; //!< current layer height in micron
Expand Down
6 changes: 5 additions & 1 deletion include/InsetOrderOptimizer.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@ class InsetOrderOptimizer
const ZSeamConfig& z_seam_config,
const std::vector<VariableWidthLines>& paths,
const Point2LL& model_center_point,
const Shape& disallowed_areas_for_seams = {});
const Shape& disallowed_areas_for_seams = {},
const bool scarf_seam = false,
const bool smooth_speed = false);

/*!
* Adds the insets to the given layer plan.
Expand Down Expand Up @@ -110,6 +112,8 @@ class InsetOrderOptimizer
const LayerIndex layer_nr_;
const Point2LL model_center_point_; // Center of the model (= all meshes) axis-aligned bounding-box.
Shape disallowed_areas_for_seams_;
const bool scarf_seam_;
const bool smooth_speed_;

std::vector<std::vector<const Polygon*>> inset_polys_; // vector of vectors holding the inset polygons
Shape retraction_region_; // After printing an outer wall, move into this region so that retractions do not leave visible blobs. Calculated lazily if needed (see
Expand Down
145 changes: 134 additions & 11 deletions include/LayerPlan.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,14 @@ class LayerPlan : public NoCopy
#endif

public:
// 'AdjustCoasting'; because split-up paths from the same extruder (with no travel moves between them) should count as the same path w.r.t. coasting.
enum class AdjustCoasting
{
AsNormal,
CoastEntirePath,
ContinueCoasting
};

const PathConfigStorage configs_storage_; //!< The line configs for this layer for each feature type
const coord_t z_;
coord_t final_travel_z_;
Expand Down Expand Up @@ -360,14 +368,15 @@ class LayerPlan : public NoCopy
* \param fan_speed Fan speed override for this path.
*/
void addExtrusionMove(
const Point2LL p,
const Point3LL& p,
const GCodePathConfig& config,
const SpaceFillType space_fill_type,
const Ratio& flow = 1.0_r,
const Ratio width_factor = 1.0_r,
const bool spiralize = false,
const Ratio speed_factor = 1.0_r,
const double fan_speed = GCodePathConfig::FAN_SPEED_DEFAULT);
const double fan_speed = GCodePathConfig::FAN_SPEED_DEFAULT,
const bool travel_to_z = true);

/*!
* Add polygon to the gcode starting at vertex \p startIdx
Expand Down Expand Up @@ -452,8 +461,8 @@ class LayerPlan : public NoCopy
* the first bridge segment.
*/
void addWallLine(
const Point2LL& p0,
const Point2LL& p1,
const Point3LL& p0,
const Point3LL& p1,
const Settings& settings,
const GCodePathConfig& default_config,
const GCodePathConfig& roofing_config,
Expand All @@ -462,7 +471,8 @@ class LayerPlan : public NoCopy
const Ratio width_factor,
double& non_bridge_line_volume,
Ratio speed_factor,
double distance_to_bridge_start);
double distance_to_bridge_start,
const bool travel_to_z = true);

/*!
* Add a wall to the g-code starting at vertex \p start_idx
Expand All @@ -481,7 +491,7 @@ class LayerPlan : public NoCopy
*/
void addWall(
const Polygon& wall,
int start_idx,
size_t start_idx,
const Settings& settings,
const GCodePathConfig& default_config,
const GCodePathConfig& roofing_config,
Expand Down Expand Up @@ -513,7 +523,7 @@ class LayerPlan : public NoCopy
*/
void addWall(
const ExtrusionLine& wall,
int start_idx,
size_t start_idx,
const Settings& settings,
const GCodePathConfig& default_config,
const GCodePathConfig& roofing_config,
Expand All @@ -523,7 +533,9 @@ class LayerPlan : public NoCopy
bool always_retract,
const bool is_closed,
const bool is_reversed,
const bool is_linked_path);
const bool is_linked_path,
const bool scarf_seam = false,
const bool smooth_speed = false);

/*!
* Add an infill wall to the g-code
Expand Down Expand Up @@ -676,7 +688,7 @@ class LayerPlan : public NoCopy
* \return The index of the first supported vertex - if no vertices are supported, start_idx is returned
*/
template<typename T>
unsigned locateFirstSupportedVertex(const T& wall, const unsigned start_idx) const
size_t locateFirstSupportedVertex(const T& wall, const size_t start_idx) const
{
if (bridge_wall_mask_.empty() && seam_overhang_mask_.empty())
{
Expand All @@ -685,7 +697,7 @@ class LayerPlan : public NoCopy

const auto air_below = bridge_wall_mask_.unionPolygons(seam_overhang_mask_);

unsigned curr_idx = start_idx;
size_t curr_idx = start_idx;

while (true)
{
Expand Down Expand Up @@ -736,14 +748,17 @@ class LayerPlan : public NoCopy
* \param path_idx The index into LayerPlan::paths for the next path to be
* written to GCode.
* \param layer_thickness The height of the current layer.
* \param insertTempOnTime A function that inserts temperature changes at a given time.
* \param coasting_adjust Paths can be split up, so we need to know when to continue coasting from last, or even coast the entire path.
* \return Whether any GCode has been written for the path.
*/
bool writePathWithCoasting(
GCodeExport& gcode,
const size_t extruder_plan_idx,
const size_t path_idx,
const coord_t layer_thickness,
const std::function<void(const double, const int64_t)> insertTempOnTime);
const std::function<void(const double, const int64_t)> insertTempOnTime,
const std::pair<AdjustCoasting, double> coasting_adjust);

/*!
* Applying speed corrections for minimal layer times and determine the fanSpeed.
Expand Down Expand Up @@ -820,6 +835,114 @@ class LayerPlan : public NoCopy
const coord_t wipe_dist,
const Ratio flow_ratio,
const double fan_speed);

/*!
* @brief Send a GCodePath line to the communication object, applying proper Z offsets
* @param path The path to be sent
* @param position The start position (which is not included in the path points)
* @param extrude_speed The actual used extrusion speed
*/
void sendLineTo(const GCodePath& path, const Point3LL& position, const double extrude_speed);

/*!
* @brief Write a travel move and properly apply the various Z offsets
* @param gcode The actual GCode exporter
* @param position The position to move to. The Z coordinate is an offset to the current layer position
* @param speed The actual used speed
* @param path_z_offset The global path Z offset to be applied
* @note This function is to be used when dealing with 3D coordinates. If you have 2D coordinates, just call gcode.writeTravel()
*/
void writeTravelRelativeZ(GCodeExport& gcode, const Point3LL& position, const Velocity& speed, const coord_t path_z_offset);

/*!
* \brief Write an extrusion move and properly apply the various Z offsets
* \param gcode The actual GCode exporter
* \param position The position to move to. The Z coordinate is an offset to the current layer position
* \param speed The actual used speed
* \param path_z_offset The global path Z offset to be applied
* \param extrusion_mm3_per_mm The desired flow rate
* \param feature The current feature being printed
* \param update_extrusion_offset whether to update the extrusion offset to match the current flow rate
*/
void writeExtrusionRelativeZ(
GCodeExport& gcode,
const Point3LL& position,
const Velocity& speed,
const coord_t path_z_offset,
double extrusion_mm3_per_mm,
PrintFeatureType feature,
bool update_extrusion_offset = false);

/*!
* \brief Add a wall to the gcode with optimized order
rburema marked this conversation as resolved.
Show resolved Hide resolved
* \param wall The full wall to be added
* \param wall_length The pre-calculated full wall length
* \param start_idx The index of the point where to start printing the wall
* \param direction The direction along which to print the wall, which should be 1 or -1
* \param max_index The last index to be used when iterating over the wall segments
* \param settings The settings which should apply to this wall added to the layer plan
* \param default_config The config with which to print the wall lines that are not spanning a bridge or are exposed to air
* \param roofing_config The config with which to print the wall lines that are exposed to air
* \param bridge_config The config with which to print the wall lines that are spanning a bridge
* \param flow_ratio The ratio with which to multiply the extrusion amount
* \param line_width_ratio The line width ratio to be applied
* \param non_bridge_line_volume A pseudo-volume that is derived from the print speed and flow of the non-bridge lines that have preceded this lin
* \param min_bridge_line_len The minimum line width to allow an extrusion move to be processed as a bridge move
* \param always_retract Whether to force a retraction when moving to the start of the polygon (used for outer walls)
* \param is_small_feature Indicates whether the wall is so small that it should be processed differently
* \param small_feature_speed_factor The speed factor to be applied to small feature walls
* \param max_area_deviation The maximum allowed area deviation to split a segment into pieces
* \param max_resolution The maximum resolution to split a segment into pieces
* \param scarf_seam_length The length of the scarf joint seam, which may be 0 if there is none
* \param scarf_seam_start_ratio The ratio of the line thickness to start the scarf seam with
* \param scarf_split_distance The maximum length of a segment to apply the scarf seam gradient, longer segments will be splitted
* \param scarf_max_z_offset The maximum Z offset te be applied at the lowest position of the scarf seam
* \param speed_split_distance The maximum length of a segment to apply the acceleration/deceleration gradient, longer segments will be splitted
* \param start_speed_ratio The ratio of the top speed to be applied when starting the segment, then accelerate gradually to full speed
* \param accelerate_length The pre-calculated length of the acceleration phase
* \param end_speed_ratio The ratio of the top speed to be applied when finishing a segment
* \param decelerate_length The pre-calculated length of the deceleration phase
* \param is_scarf_closure Indicates whether this function is called to make the scarf closure (overlap over the first scarf pass) or
* the normal first pass of the wall
rburema marked this conversation as resolved.
Show resolved Hide resolved
*/
void addSplitWall(
const ExtrusionLine& wall,
const coord_t wall_length,
size_t start_idx,
const int direction,
const size_t max_index,
const Settings& settings,
const GCodePathConfig& default_config,
const GCodePathConfig& roofing_config,
const GCodePathConfig& bridge_config,
const double flow_ratio,
const Ratio line_width_ratio,
double& non_bridge_line_volume,
const coord_t min_bridge_line_len,
const bool always_retract,
const bool is_small_feature,
Ratio small_feature_speed_factor,
const coord_t max_area_deviation,
const auto max_resolution,
const auto scarf_seam_length,
const auto scarf_seam_start_ratio,
const auto scarf_split_distance,
const coord_t scarf_max_z_offset,
const coord_t speed_split_distance,
const Ratio start_speed_ratio,
const coord_t accelerate_length,
const Ratio end_speed_ratio,
const coord_t decelerate_length,
const bool is_scarf_closure);

/*!
* \brief Helper function to calculate the distance from the start of the current wall line to the first bridge segment
* \param wall The currently processed wall
* \param current_index The index of the currently processed point
* \param min_bridge_line_len The minimum line width to allow an extrusion move to be processed as a bridge move
* \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;
};

} // namespace cura
Expand Down
40 changes: 5 additions & 35 deletions include/communication/ArcusCommunication.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ class ArcusCommunication : public Communication
* This may indicate the starting position (or any other jump in the path).
* \param position The current position to start the next line at.
*/
void sendCurrentPosition(const Point2LL& position) override;
void sendCurrentPosition(const Point3LL& position) override;

/*
* \brief Sends a message to indicate that all the slicing is done.
Expand All @@ -113,7 +113,7 @@ class ArcusCommunication : public Communication
* visualisation of the layer.
*
* This will be called after all the polygons and lines of this layer are
* sent via sendPolygons, sendPolygon and sendLineTo. This will flush all
* sent via sendLineTo. This will flush all
* visualised data for one layer in one go.
* \param layer_nr The layer that was completed.
* \param z The z-coordinate of the top side of the layer.
Expand All @@ -132,7 +132,7 @@ class ArcusCommunication : public Communication
* \param line_thickness The thickness (in the Z direction) of the line.
* \param velocity The velocity of printing this polygon.
*/
void sendLineTo(const PrintFeatureType& type, const Point2LL& to, const coord_t& line_width, const coord_t& line_thickness, const Velocity& velocity) override;
void sendLineTo(const PrintFeatureType& type, const Point3LL& to, const coord_t& line_width, const coord_t& line_thickness, const Velocity& velocity) override;

/*
* \brief Send the sliced layer data to the front-end after the optimisation
Expand All @@ -142,34 +142,6 @@ class ArcusCommunication : public Communication
*/
void sendOptimizedLayerData() override;

/*
* \brief Send a polygon to the front-end to display in layer view.
*
* The polygons are not actually flushed until ``sendLayerComplete`` is
* called.
* \param type The type of print feature the polygon represents (infill,
* wall, support, etc).
* \param polygon The shape to visualise.
* \param line_width The width of the lines in this polygon.
* \param line_thickness The thickness (in the Z direction) of the polygon.
* \param velocity The velocity of printing this polygon.
*/
void sendPolygon(const PrintFeatureType& type, const Polygon& polygon, const coord_t& line_width, const coord_t& line_thickness, const Velocity& velocity) override;

/*
* \brief Send polygons to the front-end to display in layer view.
*
* The polygons may not actually be flushed until ``sendLayerComplete`` is
* called.
* \param type The type of print feature the polygons represent (infill,
* wall, support, etc).
* \param polygons The shapes to visualise.
* \param line_width The width of the lines in these polygons.
* \param line_thickness The thickness (in the Z direction) of the polygons.
* \param velocity The velocity of printing these polygons.
*/
void sendPolygons(const PrintFeatureType& type, const Shape& polygons, const coord_t& line_width, const coord_t& line_thickness, const Velocity& velocity) override;

/*
* \brief Send an estimate of how long the print would take and how much
* material it would use.
Expand All @@ -182,15 +154,13 @@ class ArcusCommunication : public Communication
void sendProgress(double progress) const override;

/*
* \brief Set which extruder is being used for the following calls to
* ``sendPolygon``, ``sendPolygons`` and ``sendLineTo``.
* \brief Set which extruder is being used for the following calls to ``sendLineTo``.
* \param extruder The new extruder to send data for.
*/
void setExtruderForSend(const ExtruderTrain& extruder) override;

/*
* \brief Set which layer is being used for the following calls to
* ``sendPolygon``, ``sendPolygons`` and ``sendLineTo``.
* \brief Set which layer is being used for the following calls to ``sendLineTo``.
* \param layer_nr The index of the layer to send data for. This is zero-
* indexed but may be negative for raft layers.
*/
Expand Down
Loading
Loading