Skip to content

Commit

Permalink
Fix tree support related crash that occurs if there are no overhangs (U…
Browse files Browse the repository at this point in the history
  • Loading branch information
saumyaj3 authored Feb 15, 2024
2 parents 3e76b8a + 1a60a38 commit b343d88
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 8 deletions.
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

0 comments on commit b343d88

Please sign in to comment.