Skip to content

Commit

Permalink
Proof-of-concept: fractional support z-distance.
Browse files Browse the repository at this point in the history
Instead of half-height layers in each area that could potentially be affected by non-layer-height modulo support z distance, actually calculate the proper z-offset that is needed for the fractional layer.

Proof of concept mostly in the sense that the quality of the code added may not reflect our standards, and would also be missing functionality (for instance; what if we print without support-interface, or tree-support at all).

part of CURA-11041, which is the proof-of-concept for CURA-10407
  • Loading branch information
rburema committed Sep 21, 2023
1 parent b621644 commit a07fb92
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
12 changes: 7 additions & 5 deletions src/FffGcodeWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2287,7 +2287,7 @@ bool FffGcodeWriter::processInsets(
if (mesh_group_settings.get<bool>("support_enable"))
{
const coord_t z_distance_top = mesh.settings.get<coord_t>("support_top_distance");
const size_t z_distance_top_layers = round_up_divide(z_distance_top, layer_height) + 1;
const size_t z_distance_top_layers = round_up_divide(z_distance_top, layer_height); // Previously '... +1', but now there is an extra fractional layer on top.
const int support_layer_nr = gcode_layer.getLayerNr() - z_distance_top_layers;

if (support_layer_nr > 0)
Expand Down Expand Up @@ -2596,7 +2596,7 @@ void FffGcodeWriter::processTopBottom(
{
const coord_t layer_height = mesh_config.inset0_config.getLayerThickness();
const coord_t z_distance_top = mesh.settings.get<coord_t>("support_top_distance");
const size_t z_distance_top_layers = round_up_divide(z_distance_top, layer_height) + 1;
const size_t z_distance_top_layers = round_up_divide(z_distance_top, layer_height); // Previously '... +1', but now there is an extra fractional layer on top.
support_layer_nr = layer_nr - z_distance_top_layers;
}

Expand Down Expand Up @@ -3327,7 +3327,9 @@ bool FffGcodeWriter::addSupportRoofsToGCode(const SliceDataStorage& storage, Lay
support_roof_line_distance *= roof_extruder.settings.get<Ratio>("initial_layer_line_width_factor");
}

const auto half_layer_height = Application::getInstance().current_slice->scene.current_mesh_group->settings.get<coord_t>("layer_height") / 2;
const auto layer_height = Application::getInstance().current_slice->scene.current_mesh_group->settings.get<coord_t>("layer_height");
const auto support_top_distance = Application::getInstance().current_slice->scene.current_mesh_group->settings.get<coord_t>("support_top_distance");
const coord_t leftover_support_distance = support_top_distance % layer_height;

auto infill_outlines = { support_layer.support_roof.difference(support_layer.support_fractional_roof_top), support_layer.support_fractional_roof_top };
auto current_roof_config = gcode_layer.configs_storage.support_roof_config; // copy!
Expand Down Expand Up @@ -3417,8 +3419,8 @@ bool FffGcodeWriter::addSupportRoofsToGCode(const SliceDataStorage& storage, Lay
gcode_layer.configs_storage.support_roof_config,
(pattern == EFillMethod::ZIG_ZAG) ? SpaceFillType::PolyLines : SpaceFillType::Lines);

current_roof_config.z_offset = -half_layer_height;
current_roof_config.flow /= 2.0;
current_roof_config.z_offset = -leftover_support_distance;
current_roof_config.flow *= Ratio(layer_height - leftover_support_distance, layer_height);
}
return generated_something;
}
Expand Down
6 changes: 3 additions & 3 deletions src/support.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -794,7 +794,7 @@ void AreaSupport::generateOverhangAreasForMesh(SliceDataStorage& storage, SliceM
// Don't generate overhang areas if the Z distance is higher than the objects we're generating support for.
const coord_t layer_height = Application::getInstance().current_slice->scene.current_mesh_group->settings.get<coord_t>("layer_height");
const coord_t z_distance_top = mesh.settings.get<coord_t>("support_top_distance");
const size_t z_distance_top_layers = round_up_divide(z_distance_top, layer_height) + 1; // Support must always be 1 layer below overhang.
const size_t z_distance_top_layers = round_up_divide(z_distance_top, layer_height); // Previously '... +1', but now there is an extra fractional layer on top.
if (z_distance_top_layers + 1 > storage.print_layer_count)
{
return;
Expand Down Expand Up @@ -1059,7 +1059,7 @@ void AreaSupport::generateSupportAreasForMesh(
// early out
const coord_t layer_thickness = mesh_group_settings.get<coord_t>("layer_height");
const coord_t z_distance_top = ((mesh.settings.get<bool>("support_roof_enable")) ? roof_settings : infill_settings).get<coord_t>("support_top_distance");
const size_t layer_z_distance_top = round_up_divide(z_distance_top, layer_thickness) + 1; // support must always be 1 layer below overhang
const size_t layer_z_distance_top = round_up_divide(z_distance_top, layer_thickness); // Previously '... +1', but now there is an extra fractional layer on top.
if (layer_z_distance_top + 1 > layer_count)
{
return;
Expand Down Expand Up @@ -1805,7 +1805,7 @@ void AreaSupport::generateSupportRoof(SliceDataStorage& storage, const SliceMesh
const double minimum_roof_area = mesh.settings.get<double>("minimum_roof_area");

std::vector<SupportLayer>& support_layers = storage.support.supportLayers;
for (LayerIndex layer_idx = static_cast<int>(support_layers.size() - z_distance_top) - 1; layer_idx >= 0; --layer_idx)
for (LayerIndex layer_idx = static_cast<int>(support_layers.size() - z_distance_top); layer_idx >= 0; --layer_idx)
{
const LayerIndex top_layer_idx_above{
std::min(LayerIndex{ support_layers.size() - 1 }, LayerIndex{ layer_idx + roof_layer_count + z_distance_top })
Expand Down

0 comments on commit a07fb92

Please sign in to comment.