From 340e70fc4ba4f89eb3af8dbe77601e949b06638f Mon Sep 17 00:00:00 2001 From: Thomas Rahm <67757218+ThomasRahm@users.noreply.github.com> Date: Wed, 18 Sep 2024 23:25:43 +0200 Subject: [PATCH] Fix support for cradle being placed to far up if the cradle is roof. --- src/TreeSupportCradle.cpp | 2 +- src/support.cpp | 25 ++++++++++++++++--------- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/src/TreeSupportCradle.cpp b/src/TreeSupportCradle.cpp index 422d2c9835..af214965f9 100644 --- a/src/TreeSupportCradle.cpp +++ b/src/TreeSupportCradle.cpp @@ -1065,7 +1065,6 @@ void SupportCradleGeneration::generateCradleLineAreasAndBase(const SliceDataStor for (auto roof_area_pair : roofs) { - Shape roof_area_before = roof_area_pair.first; Shape full_overhang_area = TreeSupportUtils::safeOffsetInc( roof_area_pair.first, roof_outset, @@ -1075,6 +1074,7 @@ void SupportCradleGeneration::generateCradleLineAreasAndBase(const SliceDataStor 1, support_line_width, &simplifyer); + Shape roof_area_before = full_overhang_area; for (LayerIndex dtt_roof = 0; dtt_roof <= support_roof_layers && layer_idx - dtt_roof >= 1; dtt_roof++) { const Shape forbidden_next = volumes_.getAvoidance( diff --git a/src/support.cpp b/src/support.cpp index 46e8ba49aa..3414fffa04 100644 --- a/src/support.cpp +++ b/src/support.cpp @@ -1046,14 +1046,19 @@ void AreaSupport::generateCradlesForMesh(SliceDataStorage& storage, size_t mesh_ for (size_t cradle_idx = 0; cradle_idx < cradle_data_mesh[layer_idx].size(); cradle_idx++) { TreeSupportCradle* cradle = cradle_data_mesh[layer_idx][cradle_idx]; - Shape overhang_outer_area; for (auto overhang_pair : cradle->overhang_) { + if(overhang_pair.second.empty()) + { + continue; + } + Shape overhang_area_regular; Point2LL center = cradle_data_mesh[layer_idx][cradle_idx]->getCenter(layer_idx); Polygon overhang_outer_area_part; bool includes_lines = false; for (OverhangInformation& overhang : overhang_pair.second) { + overhang_area_regular.push_back(overhang.overhang_); if (overhang.isCradleLine()) { std::optional cradle_line_opt = cradle->getCradleLineOfIndex(overhang.cradle_layer_idx_, overhang.cradle_line_idx_); @@ -1065,25 +1070,27 @@ void AreaSupport::generateCradlesForMesh(SliceDataStorage& storage, size_t mesh_ } else { - overhang_outer_area.push_back(overhang.overhang_); if (fractional_support_present) { support_layer_storage_fractional[overhang_pair.first + 1].push_back(overhang.overhang_); } } } - - overhang_outer_area.push_back(overhang_outer_area_part); - overhang_outer_area.makeConvex(); + Shape line_support; + line_support.push_back(overhang_outer_area_part); + line_support.makeConvex(); if (includes_lines) { bool large_base_roof = cradle->config_->large_cradle_base_ && cradle->config_->cradle_lines_roof_; - coord_t offset_distance = cradle->config_->cradle_line_width_ / 2 + (large_base_roof ? cradle->config_->cradle_support_base_area_radius_ : 0); - overhang_outer_area = overhang_outer_area.offset(offset_distance); + coord_t offset_distance = std::max(cradle->config_->cradle_line_width_ / 2, (large_base_roof ? cradle->config_->cradle_support_base_area_radius_ : 0)); + line_support = line_support.offset(offset_distance, ClipperLib::jtRound); } - overhang_outer_area = overhang_outer_area.difference(volumes.getCollision(0, overhang_pair.first, true)); + overhang_area_regular = overhang_area_regular.unionPolygons(line_support); + overhang_area_regular = overhang_area_regular.difference(volumes.getCollision(0, overhang_pair.first, true)); + std::lock_guard critical_section_cradle(critical_cradle_reserved_areas); - cradle_overhang_reserved_areas[overhang_pair.first].push_back(overhang_outer_area); + cradle_overhang_reserved_areas[overhang_pair.first].push_back(overhang_area_regular); + } for (auto [base_idx, base] : cradle_data_mesh[layer_idx][cradle_idx]->base_below_ | ranges::views::enumerate)