Skip to content

Commit

Permalink
Fix support for cradle being placed to far up if the cradle is roof.
Browse files Browse the repository at this point in the history
  • Loading branch information
ThomasRahm committed Sep 18, 2024
1 parent 06c6488 commit 340e70f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/TreeSupportCradle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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(
Expand Down
25 changes: 16 additions & 9 deletions src/support.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<TreeSupportCradleLine*> cradle_line_opt = cradle->getCradleLineOfIndex(overhang.cradle_layer_idx_, overhang.cradle_line_idx_);
Expand All @@ -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<std::mutex> 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)
Expand Down

0 comments on commit 340e70f

Please sign in to comment.