Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix tree support related crash that occurs if there are no overhangs #2028

Merged
merged 3 commits into from
Feb 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion include/TreeSupport.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,9 @@ class TreeSupport
*
* \param storage[in] Background storage to access meshes.
* \param currently_processing_meshes[in] Indexes of all meshes that are processed in this iteration
* \return Uppermost layer precalculated. -1 if no layer were precalculated as no overhang is present.
*/
void precalculate(const SliceDataStorage& storage, std::vector<size_t> currently_processing_meshes);
LayerIndex precalculate(const SliceDataStorage& storage, std::vector<size_t> currently_processing_meshes);


/*!
Expand Down
6 changes: 3 additions & 3 deletions src/TreeModelVolumes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1084,7 +1084,6 @@ void TreeModelVolumes::calculateAvoidanceToModel(const std::deque<RadiusLayerPai
{
return;
}
getPlaceableAreas(radius, max_required_layer); // ensuring Placeableareas are calculated
const coord_t offset_speed = slow ? max_move_slow_ : max_move_;
const coord_t max_step_move = std::max(1.9 * radius, current_min_xy_dist_ * 1.9);
Polygons latest_avoidance;
Expand All @@ -1100,12 +1099,13 @@ void TreeModelVolumes::calculateAvoidanceToModel(const std::deque<RadiusLayerPai
: critical_avoidance_cache_to_model_));
start_layer = 1 + getMaxCalculatedLayer(radius, slow ? avoidance_cache_to_model_slow_ : holefree ? avoidance_cache_hole_to_model_ : avoidance_cache_to_model_);
}
start_layer = std::max(start_layer, LayerIndex(1));
if (start_layer > max_required_layer)
{
spdlog::debug("Requested calculation for value already calculated ?");
spdlog::debug("Requested calculation for value already calculated or max_required_layer is 0?");
return;
}
start_layer = std::max(start_layer, LayerIndex(1));
getPlaceableAreas(radius, max_required_layer); // ensuring Placeable Areas are calculated
latest_avoidance
= getAvoidance(radius, start_layer - 1, type, true, true); // minDist as the delta was already added, also avoidance for layer 0 will return the collision.

Expand Down
17 changes: 13 additions & 4 deletions src/TreeSupport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,12 @@ void TreeSupport::generateSupportAreas(SliceDataStorage& storage)
exclude);

// ### Precalculate avoidances, collision etc.
precalculate(storage, processing.second);
const LayerIndex max_required_layer = precalculate(storage, processing.second);
if(max_required_layer < 0)
{
spdlog::info("Support tree mesh group {} does not have any overhang. Skipping tree support generation for this support tree mesh group.",counter + 1);
continue; //If there is no overhang to support, skip these meshes
}
const auto t_precalc = std::chrono::high_resolution_clock::now();

// ### Place tips of the support tree
Expand Down Expand Up @@ -208,10 +213,10 @@ void TreeSupport::generateSupportAreas(SliceDataStorage& storage)
storage.support.generated = true;
}

void TreeSupport::precalculate(const SliceDataStorage& storage, std::vector<size_t> currently_processing_meshes)
LayerIndex TreeSupport::precalculate(const SliceDataStorage& storage, std::vector<size_t> currently_processing_meshes)
{
// Calculate top most layer that is relevant for support.
LayerIndex max_layer = 0;
LayerIndex max_layer = -1;
for (size_t mesh_idx : currently_processing_meshes)
{
const SliceMeshStorage& mesh = *storage.meshes[mesh_idx];
Expand Down Expand Up @@ -240,7 +245,11 @@ void TreeSupport::precalculate(const SliceDataStorage& storage, std::vector<size
}

// ### The actual precalculation happens in TreeModelVolumes.
volumes_.precalculate(max_layer);
if(max_layer >= 0)
{
volumes_.precalculate(max_layer);
}
return max_layer;
}


Expand Down
Loading