Skip to content

Commit 57cd44e

Browse files
committed
Merge remote-tracking branch 'origin/CURA-12833_improve-bridge-lines-direction' into CURA-12361_add-skin-support
2 parents baf8a1c + e1fb57a commit 57cd44e

File tree

3 files changed

+21
-13
lines changed

3 files changed

+21
-13
lines changed

include/FffGcodeWriter.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -592,6 +592,7 @@ class FffGcodeWriter : public NoCopy
592592
* minimise travel moves (``false``).
593593
* \param[out] added_something Whether this function added anything to the layer plan
594594
* \param fan_speed fan speed override for this skin area
595+
* \param forced_small_area_width A specific value to be used for small_area_width when generating the infill, or nullopt to use the normal value
595596
*/
596597
void processSkinPrintFeature(
597598
const SliceDataStorage& storage,
@@ -607,7 +608,8 @@ class FffGcodeWriter : public NoCopy
607608
const LinesOrderingMethod ordering,
608609
const bool is_roofing_flooring,
609610
bool& added_something,
610-
double fan_speed = GCodePathConfig::FAN_SPEED_DEFAULT) const;
611+
double fan_speed = GCodePathConfig::FAN_SPEED_DEFAULT,
612+
std::optional<coord_t> forced_small_area_width = std::nullopt) const;
611613

612614
/*!
613615
* see if we can avoid printing a lines or zig zag style skin part in multiple segments by moving to

src/FffGcodeWriter.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3235,6 +3235,7 @@ void FffGcodeWriter::processTopBottom(
32353235
const bool bridge_enable_more_layers = bridge_settings_enabled && mesh.settings.get<bool>("bridge_enable_more_layers");
32363236
const Ratio support_threshold = bridge_settings_enabled ? mesh.settings.get<Ratio>("bridge_skin_support_threshold") : 0.0_r;
32373237
const size_t bottom_layers = mesh.settings.get<size_t>("bottom_layers");
3238+
std::optional<coord_t> forced_small_area_width;
32383239

32393240
// if support is enabled, consider the support outlines so we don't generate bridges over support
32403241

@@ -3292,6 +3293,7 @@ void FffGcodeWriter::processTopBottom(
32923293
break;
32933294
}
32943295
}
3296+
forced_small_area_width = 0;
32953297
pattern = EFillMethod::LINES; // force lines pattern when bridging
32963298
if (bridge_settings_enabled)
32973299
{
@@ -3391,7 +3393,8 @@ void FffGcodeWriter::processTopBottom(
33913393
ordering,
33923394
is_roofing_flooring,
33933395
added_something,
3394-
fan_speed);
3396+
fan_speed,
3397+
forced_small_area_width);
33953398
}
33963399

33973400
void FffGcodeWriter::processSkinPrintFeature(
@@ -3408,7 +3411,8 @@ void FffGcodeWriter::processSkinPrintFeature(
34083411
const LinesOrderingMethod ordering,
34093412
const bool is_roofing_flooring,
34103413
bool& added_something,
3411-
double fan_speed) const
3414+
double fan_speed,
3415+
std::optional<coord_t> forced_small_area_width) const
34123416
{
34133417
Shape skin_polygons;
34143418
OpenLinesSet skin_lines;
@@ -3431,7 +3435,8 @@ void FffGcodeWriter::processSkinPrintFeature(
34313435
constexpr coord_t pocket_size = 0;
34323436
const bool small_areas_on_surface = mesh.settings.get<bool>("small_skin_on_surface");
34333437
const coord_t line_width = config.getLineWidth();
3434-
const coord_t small_area_width = (small_areas_on_surface || ! is_roofing_flooring) ? mesh.settings.get<coord_t>("small_skin_width") : line_width / 4;
3438+
const coord_t small_area_width
3439+
= forced_small_area_width.value_or((small_areas_on_surface || ! is_roofing_flooring) ? mesh.settings.get<coord_t>("small_skin_width") : line_width / 4);
34353440
const auto& current_layer = mesh.layers[gcode_layer.getLayerNr()];
34363441
const auto& exposed_to_air = current_layer.top_surface.areas.unionPolygons(current_layer.bottom_surface);
34373442

src/bridge/bridge.cpp

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ std::vector<coord_t> shapeLineIntersections(const coord_t line_y, const Transfor
6161
*
6262
* The score is based on the following criteria:
6363
* - Properly bridging segments, i.e. between two supported areas, add their length to the score
64-
* - Hanging segments, i.e. supported on one side but not the other (or not at all), subtract their length to the score
65-
* - Segments that lie on a supported area are not accounted for */
64+
* - Hanging segments, i.e. supported on one side but not the other (or not at all), subtract their length from the score
65+
* - Segments that lie on a supported area substract part of their length from the score */
6666
coord_t evaluateBridgeLine(const coord_t line_y, const TransformedShape& transformed_skin_area, const TransformedShape& transformed_supported_area)
6767
{
6868
// Calculate intersections with skin outline to see which segments should actually be printed
@@ -154,8 +154,7 @@ coord_t evaluateBridgeLine(const coord_t line_y, const TransformedShape& transfo
154154

155155
const bool leaving_skin = next_intersection_is_skin_area && ! next_inside_skin_area;
156156
const bool reaching_supported = next_intersection_is_supported_area && next_inside_supported_area;
157-
bool add_bridging_segment = false;
158-
bool add_hanging_segment = false;
157+
double add_segment_score_weight = 0.0;
159158

160159
switch (bridge_status)
161160
{
@@ -165,31 +164,33 @@ coord_t evaluateBridgeLine(const coord_t line_y, const TransformedShape& transfo
165164

166165
case BridgeStatus::Supported:
167166
bridge_status = leaving_skin ? BridgeStatus::Outside : BridgeStatus::Anchored;
167+
// Negatively account for fully supported lines to avoid lonely line parts over the supported areas
168+
add_segment_score_weight = -0.1;
168169
break;
169170

170171
case BridgeStatus::Hanging:
171-
add_hanging_segment = true;
172+
add_segment_score_weight = -1.0;
172173
bridge_status = reaching_supported ? BridgeStatus::Supported : BridgeStatus::Outside;
173174
break;
174175

175176
case BridgeStatus::Anchored:
176177
if (reaching_supported)
177178
{
178-
add_bridging_segment = true;
179+
add_segment_score_weight = 1.0;
179180
bridge_status = BridgeStatus::Supported;
180181
}
181182
else if (leaving_skin)
182183
{
183-
add_hanging_segment = true;
184+
add_segment_score_weight = -1.0;
184185
bridge_status = BridgeStatus::Outside;
185186
}
186187
break;
187188
}
188189

189-
if (add_bridging_segment || add_hanging_segment)
190+
if (add_segment_score_weight != 0.0)
190191
{
191192
const coord_t segment_length = next_intersection - last_position;
192-
segment_score += add_bridging_segment ? segment_length : -segment_length;
193+
segment_score += std::llrint(segment_length * add_segment_score_weight);
193194
}
194195

195196
last_position = next_intersection;

0 commit comments

Comments
 (0)