Skip to content

Commit 212a4be

Browse files
authored
CURA-12996 Fix flooring areas being generated when disabled (#2302)
2 parents cd70a6e + e49466b commit 212a4be

2 files changed

Lines changed: 41 additions & 7 deletions

File tree

include/skin.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,13 @@ class SkinInfillAreaComputation
120120
*/
121121
void applySkinExpansion(const Shape& original_outline, Shape& upskin, Shape& downskin);
122122

123+
/*!
124+
* Allow small gaps in infill areas to grow over infill areas. This helps keeping the skin areas consistent.
125+
* @param skin[in, out] The skin area to be possibly expanded
126+
* @param infill[in, out] The infill area to be possibly shrunk
127+
*/
128+
void applySkinFillSmallInfillGaps(Shape& skin, Shape& infill) const;
129+
123130
/*!
124131
* Generate infill of a given part
125132
* \param[in,out] part The part where the wall information (input) is retrieved and

src/skin.cpp

Lines changed: 34 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,9 @@ void SkinInfillAreaComputation::generateSkinAndInfillAreas(SliceLayerPart& part)
151151
skin.removeSmallAreas(MIN_AREA_SIZE);
152152
// Create infill area irrespective if the infill is to be generated or not(would be used for bridging).
153153
part.infill_area = part.inner_area.difference(skin);
154+
155+
applySkinFillSmallInfillGaps(skin, part.infill_area);
156+
154157
if (process_infill_)
155158
{ // process infill when infill density > 0
156159
// or when other infill meshes want to modify this infill
@@ -308,6 +311,22 @@ void SkinInfillAreaComputation::applySkinExpansion(const Shape& original_outline
308311
}
309312
}
310313

314+
void SkinInfillAreaComputation::applySkinFillSmallInfillGaps(Shape& skin, Shape& infill) const
315+
{
316+
// First do an opening to close the small gaps within the skin
317+
const coord_t opening_offset = skin_line_width_ * 2;
318+
const Shape opened_skin = skin.offset(opening_offset).offset(-opening_offset - EPSILON);
319+
320+
// Now extract the filled gaps by removing the initial skin
321+
const Shape filled_areas = opened_skin.difference(skin);
322+
// Only keep the filled gaps that overlap infill areas
323+
const Shape filled_areas_over_infill = filled_areas.intersection(infill).offset(EPSILON);
324+
325+
// Expand skin and shrink infill with the filled gaps
326+
skin = skin.unionPolygons(filled_areas_over_infill);
327+
infill = infill.difference(filled_areas_over_infill);
328+
}
329+
311330
/*
312331
* This function is executed in a parallel region based on layer_nr.
313332
* When modifying make sure any changes does not introduce data races.
@@ -329,24 +348,32 @@ void SkinInfillAreaComputation::generateInfill(SliceLayerPart& part)
329348
void SkinInfillAreaComputation::generateSkinRoofingFlooringFill(SliceLayerPart& part)
330349
{
331350
const size_t roofing_layer_count = std::min(mesh_.settings.get<size_t>("roofing_layer_count"), mesh_.settings.get<size_t>("top_layers"));
351+
const bool has_roofing = roofing_layer_count > 0;
332352
const size_t flooring_layer_count = std::min(mesh_.settings.get<size_t>("flooring_layer_count"), mesh_.settings.get<size_t>("bottom_layers"));
353+
const bool has_flooring = flooring_layer_count > 0;
333354
const coord_t skin_overlap = mesh_.settings.get<coord_t>("skin_overlap_mm");
334355
const coord_t roofing_expansion = mesh_.settings.get<coord_t>("roofing_expansion");
335356

336-
constexpr coord_t epsilon = 5;
337357
const SliceDataStorage slice_data;
338358
const Shape build_plate = slice_data.getRawMachineBorder();
339359

340-
const Shape filled_area_above = generateFilledAreaAbove(part, roofing_layer_count);
341-
const Shape filled_area_below = generateFilledAreaBelow(part, flooring_layer_count).value_or(build_plate.offset(epsilon));
360+
const Shape filled_area_above = has_roofing ? generateFilledAreaAbove(part, roofing_layer_count) : build_plate;
361+
const Shape filled_area_below = has_flooring ? (generateFilledAreaBelow(part, flooring_layer_count).value_or(build_plate)) : build_plate;
342362

343363
for (SkinPart& skin_part : part.skin_parts)
344364
{
345-
const Shape below_inside = skin_part.outline.intersection(filled_area_below);
346-
const Shape above_inside = skin_part.outline.intersection(filled_area_above);
365+
if (has_roofing)
366+
{
367+
const Shape below_inside = skin_part.outline.intersection(filled_area_below);
368+
skin_part.roofing_fill = below_inside.difference(filled_area_above).offset(roofing_expansion).intersection(below_inside);
369+
}
370+
371+
if (has_flooring)
372+
{
373+
const Shape above_inside = skin_part.outline.intersection(filled_area_above);
374+
skin_part.flooring_fill = above_inside.difference(filled_area_below);
375+
}
347376

348-
skin_part.roofing_fill = below_inside.difference(filled_area_above).offset(roofing_expansion).intersection(below_inside);
349-
skin_part.flooring_fill = above_inside.difference(filled_area_below);
350377
skin_part.skin_fill = skin_part.outline.difference(skin_part.roofing_fill).intersection(filled_area_below);
351378

352379
// We remove offsets areas from roofing and flooring anywhere they overlap with skin_fill.

0 commit comments

Comments
 (0)