Skip to content

Commit

Permalink
(From code review.) Small refactors and add documentation.
Browse files Browse the repository at this point in the history
done as part of CURA-10407
  • Loading branch information
rburema committed Oct 25, 2023
1 parent 01a5b35 commit 98fc849
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 12 deletions.
2 changes: 1 addition & 1 deletion include/GCodePathConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ namespace cura
*/
struct GCodePathConfig
{
coord_t z_offset{};
coord_t z_offset{}; //<! vertical offset from 'full' layer height
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
7 changes: 4 additions & 3 deletions include/LayerPlan.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,15 +110,16 @@ class LayerPlan : public NoCopy
*
* \param config The config used for the path returned
* \param space_fill_type The type of space filling which this path employs
* \param z_offset (optional) Vertical offset w.r.t current layer height, defaults to 0
* \param flow (optional) A ratio for the extrusion speed
* \param spiralize Whether to gradually increase the z while printing. (Note that this path may be part of a sequence of spiralized paths, forming one polygon)
* \param speed_factor (optional) a factor which the speed will be multiplied by.
* \return A path with the given config which is now the last path in LayerPlan::paths
*/
GCodePath* getLatestPathWithConfig(
const GCodePathConfig& config,
const coord_t z_offset,
const SpaceFillType space_fill_type,
const coord_t z_offset = 0,
const Ratio flow = 1.0_r,
const Ratio width_factor = 1.0_r,
const bool spiralize = false,
Expand Down Expand Up @@ -282,7 +283,7 @@ class LayerPlan : public NoCopy
* \param p The point to travel to.
* \param force_retract Whether to force a retraction to occur.
*/
GCodePath& addTravel(const Point p, const bool force_retract = false, const coord_t z_offset = 0);
GCodePath& addTravel(const Point& p, const bool force_retract = false, const coord_t z_offset = 0);

/*!
* Add a travel path to a certain point and retract if needed.
Expand All @@ -292,7 +293,7 @@ class LayerPlan : public NoCopy
* \param p The point to travel to
* \param path (optional) The travel path to which to add the point \p p
*/
GCodePath& addTravel_simple(const Point p, GCodePath* path = nullptr);
GCodePath& addTravel_simple(const Point& p, GCodePath* path = nullptr);

/*!
* Plan a prime blob at the current location.
Expand Down
2 changes: 1 addition & 1 deletion include/SupportInfillPart.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class SupportInfillPart
std::vector<VariableWidthLines> wall_toolpaths; //!< Any walls go here, not in the areas, where they could be combined vertically (don't combine walls). Binned by inset_idx.

coord_t custom_line_distance;
bool use_fractional_config;
bool use_fractional_config; //!< Request to use the configuration used to fill a partial layer height here, instead of the normal full layer height configuration.

SupportInfillPart(const PolygonsPart& outline, coord_t support_line_width, bool use_fractional_config, int inset_count_to_generate = 0, coord_t custom_line_distance = 0);

Expand Down
2 changes: 1 addition & 1 deletion include/pathPlanning/GCodePath.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ namespace cura
*/
struct GCodePath
{
coord_t z_offset{};
coord_t z_offset{}; //<! vertical offset from 'full' layer height
GCodePathConfig config{}; //!< The configuration settings of the path.
std::shared_ptr<const SliceMeshStorage> mesh; //!< Which mesh this path belongs to, if any. If it's not part of any mesh, the mesh should be nullptr;
SpaceFillType space_fill_type{}; //!< The type of space filling of which this path is a part
Expand Down
12 changes: 6 additions & 6 deletions src/LayerPlan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ constexpr int MINIMUM_SQUARED_LINE_LENGTH = MINIMUM_LINE_LENGTH * MINIMUM_LINE_L

GCodePath* LayerPlan::getLatestPathWithConfig(
const GCodePathConfig& config,
const coord_t z_offset,
const SpaceFillType space_fill_type,
const coord_t z_offset,
const Ratio flow,
const Ratio width_factor,
const bool spiralize,
Expand Down Expand Up @@ -329,14 +329,14 @@ std::optional<std::pair<Point, bool>> LayerPlan::getFirstTravelDestinationState(
return ret;
}

GCodePath& LayerPlan::addTravel(const Point p, const bool force_retract, const coord_t z_offset)
GCodePath& LayerPlan::addTravel(const Point& p, const bool force_retract, const coord_t z_offset)
{
const GCodePathConfig& travel_config = configs_storage.travel_config_per_extruder[getExtruder()];

const RetractionConfig& retraction_config
= current_mesh ? current_mesh->retraction_wipe_config.retraction_config : storage.retraction_wipe_config_per_extruder[getExtruder()].retraction_config;

GCodePath* path = getLatestPathWithConfig(travel_config, z_offset, SpaceFillType::None);
GCodePath* path = getLatestPathWithConfig(travel_config, SpaceFillType::None, z_offset);

bool combed = false;

Expand Down Expand Up @@ -481,7 +481,7 @@ GCodePath& LayerPlan::addTravel(const Point p, const bool force_retract, const c
return ret;
}

GCodePath& LayerPlan::addTravel_simple(const Point p, GCodePath* path)
GCodePath& LayerPlan::addTravel_simple(const Point& p, GCodePath* path)
{
bool is_first_travel_of_layer = ! static_cast<bool>(last_planned_position);
if (is_first_travel_of_layer)
Expand All @@ -491,7 +491,7 @@ GCodePath& LayerPlan::addTravel_simple(const Point p, GCodePath* path)
}
if (path == nullptr)
{
path = getLatestPathWithConfig(configs_storage.travel_config_per_extruder[getExtruder()], 0, SpaceFillType::None);
path = getLatestPathWithConfig(configs_storage.travel_config_per_extruder[getExtruder()], SpaceFillType::None);
}
path->points.push_back(p);
last_planned_position = p;
Expand All @@ -518,7 +518,7 @@ void LayerPlan::addExtrusionMove(
const Ratio speed_factor,
const double fan_speed)
{
GCodePath* path = getLatestPathWithConfig(config, config.z_offset, space_fill_type, flow, width_factor, spiralize, speed_factor);
GCodePath* path = getLatestPathWithConfig(config, space_fill_type, config.z_offset, flow, width_factor, spiralize, speed_factor);
path->points.push_back(p);
path->setFanSpeed(fan_speed);
if (! static_cast<bool>(first_extrusion_acc_jerk))
Expand Down

0 comments on commit 98fc849

Please sign in to comment.