Skip to content

Commit

Permalink
Rename non_bridge_config with default_config
Browse files Browse the repository at this point in the history
`non_bridge_config` made sense previously since there were only two configs: `bridge_config` and `non_bridge_config`. Since we introduced a third one (`roofing_config`) the variable name didn't make much sense anymore.

CURA-11129
  • Loading branch information
casperlamboo committed Jan 26, 2024
1 parent 8298f8e commit d2e7260
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 44 deletions.
8 changes: 4 additions & 4 deletions include/InsetOrderOptimizer.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ class InsetOrderOptimizer
LayerPlan& gcode_layer,
const Settings& settings,
const int extruder_nr,
const GCodePathConfig& inset_0_non_bridge_config,
const GCodePathConfig& inset_X_non_bridge_config,
const GCodePathConfig& inset_0_default_config,
const GCodePathConfig& inset_X_default_config,
const GCodePathConfig& inset_0_roofing_config,
const GCodePathConfig& inset_X_roofing_config,
const GCodePathConfig& inset_0_bridge_config,
Expand Down Expand Up @@ -92,8 +92,8 @@ class InsetOrderOptimizer
LayerPlan& gcode_layer_;
const Settings& settings_;
const size_t extruder_nr_;
const GCodePathConfig& inset_0_non_bridge_config_;
const GCodePathConfig& inset_X_non_bridge_config_;
const GCodePathConfig& inset_0_default_config_;
const GCodePathConfig& inset_X_default_config_;
const GCodePathConfig& inset_0_roofing_config_;
const GCodePathConfig& inset_X_roofing_config_;
const GCodePathConfig& inset_0_bridge_config_;
Expand Down
16 changes: 8 additions & 8 deletions include/LayerPlan.h
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ class LayerPlan : public NoCopy
* \param p1 The end vertex of the line.
* \param settings The settings which should apply to this line added to the
* layer plan.
* \param non_bridge_config The config with which to print the wall lines
* \param default_config The config with which to print the wall lines
* that are not spanning a bridge.
* \param bridge_config The config with which to print the wall lines that
* are spanning a bridge.
Expand All @@ -421,7 +421,7 @@ class LayerPlan : public NoCopy
const Point2LL& p0,
const Point2LL& p1,
const Settings& settings,
const GCodePathConfig& non_bridge_config,
const GCodePathConfig& default_config,
const GCodePathConfig& roofing_config,
const GCodePathConfig& bridge_config,
double flow,
Expand All @@ -435,7 +435,7 @@ class LayerPlan : public NoCopy
* \param wall The vertices of the wall to add.
* \param start_idx The index of the starting vertex to start at.
* \param settings The settings which should apply to this wall added to the layer plan.
* \param non_bridge_config The config with which to print the wall lines
* \param default_config The config with which to print the wall lines
* that are not spanning a bridge.
* \param bridge_config The config with which to print the wall lines that
* are spanning a bridge.
Expand All @@ -449,7 +449,7 @@ class LayerPlan : public NoCopy
ConstPolygonRef wall,
int start_idx,
const Settings& settings,
const GCodePathConfig& non_bridge_config,
const GCodePathConfig& default_config,
const GCodePathConfig& roofing_config,
const GCodePathConfig& bridge_config,
coord_t wall_0_wipe_dist,
Expand All @@ -461,7 +461,7 @@ class LayerPlan : public NoCopy
* \param wall The wall of type ExtrusionJunctions
* \param start_idx The index of the starting vertex to start at.
* \param mesh The current mesh being added to the layer plan.
* \param non_bridge_config The config with which to print the wall lines
* \param default_config The config with which to print the wall lines
* that are not spanning a bridge.
* \param bridge_config The config with which to print the wall lines that
* are spanning a bridge
Expand All @@ -479,7 +479,7 @@ class LayerPlan : public NoCopy
const ExtrusionLine& wall,
int start_idx,
const Settings& settings,
const GCodePathConfig& non_bridge_config,
const GCodePathConfig& default_config,
const GCodePathConfig& roofing_config,
const GCodePathConfig& bridge_config,
coord_t wall_0_wipe_dist,
Expand All @@ -501,7 +501,7 @@ class LayerPlan : public NoCopy
* Add walls (polygons) to the gcode with optimized order.
* \param walls The walls
* \param settings The settings which should apply to these walls added to the layer plan.
* \param non_bridge_config The config with which to print the wall lines that are not spanning a bridge
* \param default_config The config with which to print the wall lines that are not spanning a bridge
* \param bridge_config The config with which to print the wall lines that are spanning a bridge
* \param z_seam_config Optional configuration for z-seam
* \param wall_0_wipe_dist The distance to travel along each wall after it has been laid down, in order to wipe the start and end of the wall together
Expand All @@ -512,7 +512,7 @@ class LayerPlan : public NoCopy
void addWalls(
const Polygons& walls,
const Settings& settings,
const GCodePathConfig& non_bridge_config,
const GCodePathConfig& default_config,
const GCodePathConfig& roofing_config,
const GCodePathConfig& bridge_config,
const ZSeamConfig& z_seam_config = ZSeamConfig(),
Expand Down
12 changes: 6 additions & 6 deletions src/InsetOrderOptimizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ InsetOrderOptimizer::InsetOrderOptimizer(
LayerPlan& gcode_layer,
const Settings& settings,
const int extruder_nr,
const GCodePathConfig& inset_0_non_bridge_config,
const GCodePathConfig& inset_X_non_bridge_config,
const GCodePathConfig& inset_0_default_config,
const GCodePathConfig& inset_X_default_config,
const GCodePathConfig& inset_0_roofing_config,
const GCodePathConfig& inset_X_roofing_config,
const GCodePathConfig& inset_0_bridge_config,
Expand All @@ -56,8 +56,8 @@ InsetOrderOptimizer::InsetOrderOptimizer(
, gcode_layer_(gcode_layer)
, settings_(settings)
, extruder_nr_(extruder_nr)
, inset_0_non_bridge_config_(inset_0_non_bridge_config)
, inset_X_non_bridge_config_(inset_X_non_bridge_config)
, inset_0_default_config_(inset_0_default_config)
, inset_X_default_config_(inset_X_default_config)
, inset_0_roofing_config_(inset_0_roofing_config)
, inset_X_roofing_config_(inset_X_roofing_config)
, inset_0_bridge_config_(inset_0_bridge_config)
Expand Down Expand Up @@ -124,7 +124,7 @@ bool InsetOrderOptimizer::addToLayer()

const bool is_outer_wall = path.vertices_->inset_idx_ == 0; // or thin wall 'gap filler'
const bool is_gap_filler = path.vertices_->is_odd_;
const GCodePathConfig& non_bridge_config = is_outer_wall ? inset_0_non_bridge_config_ : inset_X_non_bridge_config_;
const GCodePathConfig& default_config = is_outer_wall ? inset_0_default_config_ : inset_X_default_config_;
const GCodePathConfig& roofing_config = is_outer_wall ? inset_0_roofing_config_ : inset_X_roofing_config_;
const GCodePathConfig& bridge_config = is_outer_wall ? inset_0_bridge_config_ : inset_X_bridge_config_;
const coord_t wipe_dist = is_outer_wall && ! is_gap_filler ? wall_0_wipe_dist_ : wall_x_wipe_dist_;
Expand All @@ -137,7 +137,7 @@ bool InsetOrderOptimizer::addToLayer()
const bool linked_path = ! path.is_closed_;

gcode_layer_.setIsInside(true); // Going to print walls, which are always inside.
gcode_layer_.addWall(*path.vertices_, start_index, settings_, non_bridge_config, roofing_config, bridge_config, wipe_dist, flow, retract_before, path.is_closed_, backwards, linked_path);
gcode_layer_.addWall(*path.vertices_, start_index, settings_, default_config, roofing_config, bridge_config, wipe_dist, flow, retract_before, path.is_closed_, backwards, linked_path);
added_something = true;
}
return added_something;
Expand Down
52 changes: 26 additions & 26 deletions src/LayerPlan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -648,7 +648,7 @@ void LayerPlan::addWallLine(
const Point2LL& p0,
const Point2LL& p1,
const Settings& settings,
const GCodePathConfig& non_bridge_config,
const GCodePathConfig& default_config,
const GCodePathConfig& roofing_config,
const GCodePathConfig& bridge_config,
double flow,
Expand Down Expand Up @@ -695,7 +695,7 @@ void LayerPlan::addWallLine(
// speed_flow_factor approximates how the extrusion rate alters between the non-bridge wall line and the following bridge wall line
// if the extrusion rates are the same, its value will be 1, if the bridge config extrusion rate is < the non-bridge config extrusion rate, the value is < 1

const Ratio speed_flow_factor((bridge_config.getSpeed() * bridge_config.getFlowRatio()) / (non_bridge_config.getSpeed() * non_bridge_config.getFlowRatio()));
const Ratio speed_flow_factor((bridge_config.getSpeed() * bridge_config.getFlowRatio()) / (default_config.getSpeed() * default_config.getFlowRatio()));

// coast distance is proportional to distance, speed and flow of non-bridge segments just printed and is throttled by speed_flow_factor
const double coast_dist = std::min(non_bridge_line_volume, max_non_bridge_line_volume) * (1 - speed_flow_factor) * bridge_wall_coast / 40;
Expand All @@ -714,7 +714,7 @@ void LayerPlan::addWallLine(
// segment is longer than coast distance so extrude using non-bridge config to start of coast
addExtrusionMove(
segment_end + coast_dist * (cur_point - segment_end) / len,
non_bridge_config,
default_config,
SpaceFillType::Polygons,
segment_flow,
width_factor,
Expand All @@ -723,14 +723,14 @@ void LayerPlan::addWallLine(
}
// then coast to start of bridge segment
constexpr Ratio no_flow = 0.0_r; // Coasting has no flow rate.
addExtrusionMove(segment_end, non_bridge_config, SpaceFillType::Polygons, no_flow, width_factor, spiralize, speed_factor);
addExtrusionMove(segment_end, default_config, SpaceFillType::Polygons, no_flow, width_factor, spiralize, speed_factor);
}
else
{
// no coasting required, just normal segment using non-bridge config
addExtrusionMove(
segment_end,
non_bridge_config,
default_config,
SpaceFillType::Polygons,
segment_flow,
width_factor,
Expand All @@ -745,14 +745,14 @@ void LayerPlan::addWallLine(
// no coasting required, just normal segment using non-bridge config
addExtrusionMove(
segment_end,
non_bridge_config,
default_config,
SpaceFillType::Polygons,
segment_flow,
width_factor,
spiralize,
(overhang_mask_.empty() || (! overhang_mask_.inside(p0, true) && ! overhang_mask_.inside(p1, true))) ? speed_factor : overhang_speed_factor);
}
non_bridge_line_volume += vSize(cur_point - segment_end) * segment_flow * width_factor * speed_factor * non_bridge_config.getSpeed();
non_bridge_line_volume += vSize(cur_point - segment_end) * segment_flow * width_factor * speed_factor * default_config.getSpeed();
cur_point = segment_end;
speed_factor = 1 - (1 - speed_factor) * acceleration_factor;
if (speed_factor >= 0.9)
Expand All @@ -765,7 +765,7 @@ void LayerPlan::addWallLine(

const auto use_roofing_config = [&]() -> bool
{
if (roofing_config == non_bridge_config)
if (roofing_config == default_config)
{
// if the roofing config and normal config are the same any way there is no need to check what part of the line segment
return false;
Expand All @@ -778,9 +778,9 @@ void LayerPlan::addWallLine(
// The line segment is wholly or partially in the roofing area. The line is intersected
// with the roofing area into line segments. Each line segment left in this intersection
// will be printed using the roofing config, all removed segments will be printed using
// the non_bridge_config. Since the original line segment was straight we can simply print
// the default_config. Since the original line segment was straight we can simply print
// to the first and last point of the intersected line segments alternating between
// roofing and non_bridge_config's.
// roofing and default_config's.
Polygons line_polys;
line_polys.addLine(p0, p1);
constexpr bool restitch = false; // only a single line doesn't need stitching
Expand All @@ -804,7 +804,7 @@ void LayerPlan::addWallLine(
}
std::sort(has_area_above_poly_lines.begin(), has_area_above_poly_lines.end(), [&](auto& a, auto& b) { return vSize2(a.front() - p0) < vSize2(b.front() - p0); });

// add intersected line segments, alternating between roofing and non_bridge_config
// add intersected line segments, alternating between roofing and default_config
for (const auto& line_poly : has_area_above_poly_lines)
{
// This is only relevant for the very fist iteration of the loop
Expand All @@ -814,7 +814,7 @@ void LayerPlan::addWallLine(
addExtrusionMove(line_poly.front(), roofing_config, SpaceFillType::Polygons, flow, width_factor, spiralize, 1.0_r);
}

addExtrusionMove(line_poly.back(), non_bridge_config, SpaceFillType::Polygons, flow, width_factor, spiralize, 1.0_r);
addExtrusionMove(line_poly.back(), default_config, SpaceFillType::Polygons, flow, width_factor, spiralize, 1.0_r);
}

// if the last point is not yet at p1 then add a move to p1
Expand All @@ -829,7 +829,7 @@ void LayerPlan::addWallLine(
// no bridges required
addExtrusionMove(
p1,
non_bridge_config,
default_config,
SpaceFillType::Polygons,
flow,
width_factor,
Expand Down Expand Up @@ -879,7 +879,7 @@ void LayerPlan::addWallLine(
b1 = bridge[0];
}

// extrude using non_bridge_config to the start of the next bridge segment
// extrude using default_config to the start of the next bridge segment

addNonBridgeLine(b0);

Expand All @@ -895,7 +895,7 @@ void LayerPlan::addWallLine(
non_bridge_line_volume = 0;
cur_point = b1;
// after a bridge segment, start slow and accelerate to avoid under-extrusion due to extruder lag
speed_factor = std::max(std::min(Ratio(bridge_config.getSpeed() / non_bridge_config.getSpeed()), 1.0_r), 0.5_r);
speed_factor = std::max(std::min(Ratio(bridge_config.getSpeed() / default_config.getSpeed()), 1.0_r), 0.5_r);
}
}
else
Expand All @@ -909,7 +909,7 @@ void LayerPlan::addWallLine(
line_polys.remove(nearest);
}

// if we haven't yet reached p1, fill the gap with non_bridge_config line
// if we haven't yet reached p1, fill the gap with default_config line
addNonBridgeLine(p1);
}
else if (bridge_wall_mask_.inside(p0, true) && vSize(p0 - p1) >= min_bridge_line_len)
Expand All @@ -930,7 +930,7 @@ void LayerPlan::addWall(
ConstPolygonRef wall,
int start_idx,
const Settings& settings,
const GCodePathConfig& non_bridge_config,
const GCodePathConfig& default_config,
const GCodePathConfig& roofing_config,
const GCodePathConfig& bridge_config,
coord_t wall_0_wipe_dist,
Expand All @@ -945,7 +945,7 @@ void LayerPlan::addWall(

constexpr size_t dummy_perimeter_id = 0; // <-- Here, don't care about which perimeter any more.
const coord_t nominal_line_width
= non_bridge_config
= default_config
.getLineWidth(); // <-- The line width which it's 'supposed to' be will be used to adjust the flow ratio each time, this'll give a flow-ratio-multiplier of 1.

ExtrusionLine ewall;
Expand All @@ -960,14 +960,14 @@ void LayerPlan::addWall(
constexpr bool is_closed = true;
constexpr bool is_reversed = false;
constexpr bool is_linked_path = false;
addWall(ewall, start_idx, settings, non_bridge_config, roofing_config, bridge_config, wall_0_wipe_dist, flow_ratio, always_retract, is_closed, is_reversed, is_linked_path);
addWall(ewall, start_idx, settings, default_config, roofing_config, bridge_config, wall_0_wipe_dist, flow_ratio, always_retract, is_closed, is_reversed, is_linked_path);
}

void LayerPlan::addWall(
const ExtrusionLine& wall,
int start_idx,
const Settings& settings,
const GCodePathConfig& non_bridge_config,
const GCodePathConfig& default_config,
const GCodePathConfig& roofing_config,
const GCodePathConfig& bridge_config,
coord_t wall_0_wipe_dist,
Expand All @@ -994,7 +994,7 @@ void LayerPlan::addWall(
const coord_t min_bridge_line_len = settings.get<coord_t>("bridge_wall_min_length");

const Ratio nominal_line_width_multiplier{
1.0 / Ratio{ static_cast<Ratio::value_type>(non_bridge_config.getLineWidth()) }
1.0 / Ratio{ static_cast<Ratio::value_type>(default_config.getLineWidth()) }
}; // we multiply the flow with the actual wanted line width (for that junction), and then multiply with this

// helper function to calculate the distance from the start of the current wall line to the first bridge segment
Expand Down Expand Up @@ -1083,7 +1083,7 @@ void LayerPlan::addWall(
const bool is_small_feature = (small_feature_max_length > 0) && (layer_nr_ == 0 || wall.inset_idx_ == 0) && cura::shorterThan(wall, small_feature_max_length);
Ratio small_feature_speed_factor = settings.get<Ratio>((layer_nr_ == 0) ? "small_feature_speed_factor_0" : "small_feature_speed_factor");
const Velocity min_speed = fan_speed_layer_time_settings_per_extruder_[getLastPlannedExtruderTrain()->extruder_nr_].cool_min_speed;
small_feature_speed_factor = std::max((double)small_feature_speed_factor, (double)(min_speed / non_bridge_config.getSpeed()));
small_feature_speed_factor = std::max((double)small_feature_speed_factor, (double)(min_speed / default_config.getSpeed()));
const coord_t max_area_deviation = std::max(settings.get<int>("meshfix_maximum_extrusion_area_deviation"), 1); // Square micrometres!
const coord_t max_resolution = std::max(settings.get<coord_t>("meshfix_maximum_resolution"), coord_t(1));

Expand Down Expand Up @@ -1145,7 +1145,7 @@ void LayerPlan::addWall(
constexpr bool spiralize = false;
addExtrusionMove(
destination,
non_bridge_config,
default_config,
SpaceFillType::Polygons,
flow_ratio,
line_width * nominal_line_width_multiplier,
Expand All @@ -1159,7 +1159,7 @@ void LayerPlan::addWall(
origin,
destination,
settings,
non_bridge_config,
default_config,
roofing_config,
bridge_config,
flow_ratio,
Expand Down Expand Up @@ -1234,7 +1234,7 @@ void LayerPlan::addInfillWall(const ExtrusionLine& wall, const GCodePathConfig&
void LayerPlan::addWalls(
const Polygons& walls,
const Settings& settings,
const GCodePathConfig& non_bridge_config,
const GCodePathConfig& default_config,
const GCodePathConfig& roofing_config,
const GCodePathConfig& bridge_config,
const ZSeamConfig& z_seam_config,
Expand All @@ -1251,7 +1251,7 @@ void LayerPlan::addWalls(
orderOptimizer.optimize();
for (const PathOrdering<ConstPolygonPointer>& path : orderOptimizer.paths_)
{
addWall(**path.vertices_, path.start_vertex_, settings, non_bridge_config, roofing_config, bridge_config, wall_0_wipe_dist, flow_ratio, always_retract);
addWall(**path.vertices_, path.start_vertex_, settings, default_config, roofing_config, bridge_config, wall_0_wipe_dist, flow_ratio, always_retract);
}
}

Expand Down

0 comments on commit d2e7260

Please sign in to comment.