Skip to content

Commit

Permalink
Fix crashes caused by tree support. (#2002)
Browse files Browse the repository at this point in the history
  • Loading branch information
rburema authored Jan 17, 2024
2 parents 9f9f9bf + cbd35ab commit b3ac3c3
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
3 changes: 3 additions & 0 deletions include/TreeSupportElement.h
Original file line number Diff line number Diff line change
Expand Up @@ -415,9 +415,11 @@ struct TreeSupportElement
}
}
}

void setToBuildplateForAllParents(bool new_value)
{
to_buildplate_ = new_value;
to_model_gracious_ |= new_value;
std::vector<TreeSupportElement*> grandparents{ parents_ };
while (! grandparents.empty())
{
Expand All @@ -426,6 +428,7 @@ struct TreeSupportElement
{
next_parents.insert(next_parents.end(), grandparent->parents_.begin(), grandparent->parents_.end());
grandparent->to_buildplate_ = new_value;
grandparent->to_model_gracious_ |= new_value; // If we set to_buildplate to true, update to_model_gracious
}
grandparents = next_parents;
}
Expand Down
12 changes: 10 additions & 2 deletions src/TreeSupport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1651,7 +1651,7 @@ void TreeSupport::generateBranchAreas(
}

std::vector<Polygons> linear_inserts(linear_data.size());
const size_t progress_inserts_check_interval = linear_data.size() / progress_report_steps;
const size_t progress_inserts_check_interval = std::max(linear_data.size() / progress_report_steps,size_t(1));

std::mutex critical_sections;
cura::parallel_for<size_t>(
Expand Down Expand Up @@ -1926,7 +1926,9 @@ void TreeSupport::dropNonGraciousAreas(
TreeSupportElement* elem = linear_data[idx].second;
bool non_gracious_model_contact
= ! elem->to_model_gracious_
&& ! inverse_tree_order.count(elem); // If an element has no child, it connects to whatever is below as no support further down for it will exist.
&& ! inverse_tree_order.count(elem)
&& linear_data[idx].first > 0
&& ! elem->to_buildplate_; // If an element has no child, it connects to whatever is below as no support further down for it will exist.
if (non_gracious_model_contact)
{
Polygons rest_support = layer_tree_polygons[linear_data[idx].first][elem].intersection(volumes_.getAccumulatedPlaceable0(linear_data[idx].first));
Expand Down Expand Up @@ -2221,7 +2223,13 @@ void TreeSupport::finalizeInterfaceAndSupportAreas(std::vector<Polygons>& suppor
storage.support.supportLayers[layer_idx].support_bottom = storage.support.supportLayers[layer_idx].support_bottom.unionPolygons(floor_layer);
support_layer_storage[layer_idx] = support_layer_storage[layer_idx].difference(floor_layer.offset(10)); // Subtract the support floor from the normal support.
}
});

cura::parallel_for<coord_t>(
0,
support_layer_storage.size(),
[&](const LayerIndex layer_idx)
{
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);
Expand Down

0 comments on commit b3ac3c3

Please sign in to comment.