diff --git a/include/TreeSupport.h b/include/TreeSupport.h index 6ad2a5fac4..b2b12e6531 100644 --- a/include/TreeSupport.h +++ b/include/TreeSupport.h @@ -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 currently_processing_meshes); + LayerIndex precalculate(const SliceDataStorage& storage, std::vector currently_processing_meshes); /*! diff --git a/src/TreeModelVolumes.cpp b/src/TreeModelVolumes.cpp index 7318061091..fa8fe4bedf 100644 --- a/src/TreeModelVolumes.cpp +++ b/src/TreeModelVolumes.cpp @@ -1084,7 +1084,6 @@ void TreeModelVolumes::calculateAvoidanceToModel(const std::deque 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. diff --git a/src/TreeSupport.cpp b/src/TreeSupport.cpp index 8985432a6a..d5b48ab758 100644 --- a/src/TreeSupport.cpp +++ b/src/TreeSupport.cpp @@ -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 @@ -208,10 +213,10 @@ void TreeSupport::generateSupportAreas(SliceDataStorage& storage) storage.support.generated = true; } -void TreeSupport::precalculate(const SliceDataStorage& storage, std::vector currently_processing_meshes) +LayerIndex TreeSupport::precalculate(const SliceDataStorage& storage, std::vector 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]; @@ -240,7 +245,11 @@ void TreeSupport::precalculate(const SliceDataStorage& storage, std::vector= 0) + { + volumes_.precalculate(max_layer); + } + return max_layer; }