Skip to content

Commit

Permalink
Merge branch 'main' into PluginGcodeModifyPatches
Browse files Browse the repository at this point in the history
  • Loading branch information
jellespijker authored Feb 16, 2024
2 parents 4b66fec + db1231e commit 210a58c
Show file tree
Hide file tree
Showing 9 changed files with 55 additions and 16 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
12 changes: 9 additions & 3 deletions src/FffGcodeWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1643,7 +1643,10 @@ void FffGcodeWriter::addMeshLayerToGCode_meshSurfaceMode(const SliceMeshStorage&
Polygons polygons;
for (const SliceLayerPart& part : layer->parts)
{
polygons.add(part.outline);
if (! part.outline.empty())
{
polygons.add(part.outline);
}
}

polygons = Simplify(mesh.settings).polygon(polygons);
Expand Down Expand Up @@ -1707,7 +1710,10 @@ void FffGcodeWriter::addMeshLayerToGCode(
{
part_order_optimizer.addPolygon(&part);
}
part_order_optimizer.optimize(false);
if (part_order_optimizer.vertices_to_paths_.size() > 1)
{
part_order_optimizer.optimize(false);
}
for (const PathOrdering<const SliceLayerPart*>& path : part_order_optimizer.paths_)
{
addMeshPartToGCode(storage, mesh, extruder_nr, mesh_config, *path.vertices_, gcode_layer);
Expand Down Expand Up @@ -2581,7 +2587,7 @@ bool FffGcodeWriter::processInsets(

const auto roofing_mask = [&]() -> Polygons
{
const size_t roofing_layer_count = mesh.settings.get<size_t>("top_layers");
const size_t roofing_layer_count = std::min(mesh.settings.get<size_t>("roofing_layer_count"), mesh.settings.get<size_t>("top_layers"));

auto roofing_mask = storage.getMachineBorder(mesh.settings.get<ExtruderTrain&>("wall_0_extruder_nr").extruder_nr_);

Expand Down
10 changes: 7 additions & 3 deletions src/FffPolygonGenerator.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2023 UltiMaker
// Copyright (c) 2024 UltiMaker
// CuraEngine is released under the terms of the AGPLv3 or higher

#include <algorithm>
Expand Down Expand Up @@ -568,7 +568,7 @@ void FffPolygonGenerator::processInfillMesh(SliceDataStorage& storage, const siz
// they have to be polylines, because they might break up further when doing the cutting
for (SliceLayerPart& part : layer.parts)
{
for (PolygonRef poly : part.outline)
for (const PolygonRef& poly : part.outline)
{
layer.openPolyLines.add(poly);
layer.openPolyLines.back().add(layer.openPolyLines.back()[0]); // add the segment which closes the polygon
Expand Down Expand Up @@ -640,8 +640,12 @@ void FffPolygonGenerator::processInfillMesh(SliceDataStorage& storage, const siz
}

layer.parts.clear();
for (PolygonsPart& part : new_parts)
for (const PolygonsPart& part : new_parts)
{
if (part.empty())
{
continue;
}
layer.parts.emplace_back();
layer.parts.back().outline = part;
layer.parts.back().boundaryBox.calculate(part);
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
8 changes: 8 additions & 0 deletions src/layerPart.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ void createLayerWithParts(const Settings& settings, SliceLayer& storageLayer, Sl
result.reserve(layer->polygons.size());
for (const PolygonRef poly : layer->polygons)
{
if (poly.empty())
{
continue;
}
result.emplace_back();
result.back().add(poly);
}
Expand All @@ -63,6 +67,10 @@ void createLayerWithParts(const Settings& settings, SliceLayer& storageLayer, Sl
for (auto& part : result)
{
storageLayer.parts.emplace_back();
if (part.empty())
{
continue;
}
storageLayer.parts.back().outline = part;
storageLayer.parts.back().boundaryBox.calculate(storageLayer.parts.back().outline);
if (storageLayer.parts.back().outline.empty())
Expand Down
6 changes: 5 additions & 1 deletion src/skin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,12 @@ void SkinInfillAreaComputation::generateSkinAndInfillAreas(SliceLayerPart& part)
generateInfill(part);
}

for (PolygonsPart& skin_area_part : skin.splitIntoParts())
for (const PolygonsPart& skin_area_part : skin.splitIntoParts())
{
if (skin_area_part.empty())
{
continue;
}
part.skin_parts.emplace_back();
part.skin_parts.back().outline = skin_area_part;
}
Expand Down
5 changes: 4 additions & 1 deletion src/sliceDataStorage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -740,7 +740,10 @@ void SupportLayer::excludeAreasFromSupportInfillAreas(const Polygons& exclude_po
{
const size_t remove_idx = to_remove_part_indices.back();
to_remove_part_indices.pop_back();

if (support_infill_parts.empty())
{
continue;
}
if (remove_idx < support_infill_parts.size() - 1)
{ // move last element to the to-be-removed element so that we can erase the last place in the vector
support_infill_parts[remove_idx] = std::move(support_infill_parts.back());
Expand Down
4 changes: 4 additions & 0 deletions src/support.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1491,6 +1491,10 @@ void AreaSupport::detectOverhangPoints(const SliceDataStorage& storage, SliceMes

for (const SliceLayerPart& part : layer.parts)
{
if (part.outline.empty())
{
continue;
}
if (part.outline.outerPolygon().area() >= max_tower_supported_area)
{
// area is too big for support towers, should be supported by normal overhang detection
Expand Down

0 comments on commit 210a58c

Please sign in to comment.