Skip to content

Commit

Permalink
Consolidate duplicated code into 'fillInfillParts'.
Browse files Browse the repository at this point in the history
done as part of CURA-10407
  • Loading branch information
rburema committed Oct 17, 2023
1 parent 774cc0f commit 7c02094
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 40 deletions.
11 changes: 11 additions & 0 deletions include/sliceDataStorage.h
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,17 @@ class SupportLayer
* \param exclude_polygons_boundary_box The boundary box for the polygons to exclude
*/
void excludeAreasFromSupportInfillAreas(const Polygons& exclude_polygons, const AABB& exclude_polygons_boundary_box);

/* Fill up the infill parts for the support with the given support polygons. The support polygons will be split into parts. This also takes into account fractional-height support layers.
*
* \param layer_nr Current layer index.
* \param support_fill_per_layer All of the (infill) support (since the layer above might be needed).
* \param support_line_width Line width of the support extrusions.
* \param wall_line_count Wall-line count around the fill.
* \param grow_layer_above (optional, default to 0) In cases where support shrinks per layer up, an appropriate offset may be nescesary.
* \param unionAll (optional, default to false) Wether to 'union all' for the split into parts bit.
*/
void fillInfillParts(const LayerIndex layer_nr, const std::vector<Polygons>& support_fill_per_layer, const coord_t support_line_width, const coord_t wall_line_count, const coord_t grow_layer_above = 0, const bool unionAll = false);
};

class SupportStorage
Expand Down
15 changes: 2 additions & 13 deletions src/TreeSupport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2226,19 +2226,8 @@ void TreeSupport::finalizeInterfaceAndSupportAreas(std::vector<Polygons>& suppor
support_layer_storage[layer_idx] = support_layer_storage[layer_idx].difference(floor_layer.offset(10)); // Subtract the support floor from the normal support.
}

const Polygons support_layer_storage_above
= (layer_idx + 1) >= support_layer_storage.size() || layer_idx <= 0 ? Polygons() : support_layer_storage[layer_idx + 1].offset(config.maximum_move_distance);
const auto all_support_areas_in_layer
= { support_layer_storage[layer_idx].difference(support_layer_storage_above), support_layer_storage[layer_idx].intersection(support_layer_storage_above) };
bool use_fractional_config = true;
for (auto& support_areas : all_support_areas_in_layer)
{
for (auto& part : support_areas.splitIntoParts(true)) // Convert every part into a PolygonsPart for the support.
{
storage.support.supportLayers[layer_idx].support_infill_parts.emplace_back(part, config.support_line_width, use_fractional_config, config.support_wall_count);
}
use_fractional_config = false;
}
constexpr bool convert_every_part = true; // Convert every part into a PolygonsPart for the support.
storage.support.supportLayers[layer_idx].fillInfillParts(layer_idx, support_layer_storage, config.support_line_width, config.support_wall_count, config.maximum_move_distance, convert_every_part);

{
std::lock_guard<std::mutex> critical_section_progress(critical_sections);
Expand Down
15 changes: 1 addition & 14 deletions src/TreeSupportTipGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1164,20 +1164,7 @@ void TreeSupportTipGenerator::generateTips(
{
if (use_fake_roof)
{
const Polygons support_roof_drawn_above
= (layer_idx + 1) >= support_roof_drawn.size() || layer_idx <= 0 ? Polygons() : support_roof_drawn[layer_idx + 1].offset(config.maximum_move_distance);
const auto all_support_areas_in_layer
= { support_roof_drawn[layer_idx].difference(support_roof_drawn_above), support_roof_drawn[layer_idx].intersection(support_roof_drawn_above) };
bool use_fractional_config = true;
for (auto& support_areas : all_support_areas_in_layer)
{
for (const auto& part : support_areas.splitIntoParts())
{
storage.support.supportLayers[layer_idx]
.support_infill_parts.emplace_back(part, config.support_line_width, use_fractional_config, 0, support_roof_line_distance);
}
use_fractional_config = false;
}
storage.support.supportLayers[layer_idx].fillInfillParts(layer_idx, support_roof_drawn, config.support_line_width, support_roof_line_distance, config.maximum_move_distance);
placed_support_lines_support_areas[layer_idx].add(TreeSupportUtils::generateSupportInfillLines(
support_roof_drawn[layer_idx],
config,
Expand Down
16 changes: 16 additions & 0 deletions src/sliceDataStorage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -705,4 +705,20 @@ void SupportLayer::excludeAreasFromSupportInfillAreas(const Polygons& exclude_po
}
}

void SupportLayer::fillInfillParts(const LayerIndex layer_nr, const std::vector<Polygons>& support_fill_per_layer, const coord_t support_line_width, const coord_t wall_line_count, const coord_t grow_layer_above /*has default 0*/, const bool unionAll /*has default false*/)
{
const Polygons& support_this_layer = support_fill_per_layer[layer_nr];
const Polygons& support_layer_above = (layer_nr + 1) >= support_fill_per_layer.size() || layer_nr <= 0 ? Polygons() : support_fill_per_layer[layer_nr + 1].offset(grow_layer_above);
const auto all_support_areas_in_layer = { support_this_layer.difference(support_layer_above), support_this_layer.intersection(support_layer_above) };
bool use_fractional_config = true;
for (auto& support_areas : all_support_areas_in_layer)
{
for (const PolygonsPart& island_outline : support_areas.splitIntoParts(unionAll))
{
support_infill_parts.emplace_back(island_outline, support_line_width, use_fractional_config, wall_line_count);
}
use_fractional_config = false;
}
}

} // namespace cura
14 changes: 1 addition & 13 deletions src/support.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,19 +122,7 @@ void AreaSupport::splitGlobalSupportAreasIntoSupportInfillParts(
}
// We don't generate insets and infill area for the parts yet because later the skirt/brim and prime
// tower will remove themselves from the support, so the outlines of the parts can be changed.

const Polygons& global_support_areas_above
= (layer_nr + 1) >= global_support_areas_per_layer.size() || layer_nr <= 0 ? Polygons() : global_support_areas_per_layer[layer_nr + 1];
const auto all_support_areas_in_layer = { global_support_areas.difference(global_support_areas_above), global_support_areas.intersection(global_support_areas_above) };
bool use_fractional_config = true;
for (auto& support_areas : all_support_areas_in_layer)
{
for (const PolygonsPart& island_outline : support_areas.splitIntoParts())
{
storage.support.supportLayers[layer_nr].support_infill_parts.emplace_back(island_outline, support_line_width_here, use_fractional_config, wall_line_count_this_layer);
}
use_fractional_config = false;
}
storage.support.supportLayers[layer_nr].fillInfillParts(layer_nr, global_support_areas_per_layer, support_line_width_here, wall_line_count_this_layer);
}
}

Expand Down

0 comments on commit 7c02094

Please sign in to comment.