Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/Ultimaker/CuraEngine.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGhostkeeper <rubend@tutanota.com>2021-10-25 19:26:50 +0300
committerRemco Burema <r.burema@ultimaker.com>2021-10-26 12:04:26 +0300
commitd903df6d3e51b9abfc62f8c0fb95e451caa2a95c (patch)
tree1a3302cc305ec88362007fa78e9e4c78357b9d85 /src
parent44ea69928f88d24482432cc192b5949a1712a7fd (diff)
Make number of layers depend on slicing tolerance setting
This is how much space we make for layers. The actual number of generated layers can still be different. I've seen some cases where the actual number of layers was clearly wrong. Contributes to issue CURA-8614.
Diffstat (limited to 'src')
-rw-r--r--src/FffPolygonGenerator.cpp20
-rw-r--r--src/utils/math.h12
2 files changed, 30 insertions, 2 deletions
diff --git a/src/FffPolygonGenerator.cpp b/src/FffPolygonGenerator.cpp
index e8db143f4..82a3f82aa 100644
--- a/src/FffPolygonGenerator.cpp
+++ b/src/FffPolygonGenerator.cpp
@@ -132,7 +132,25 @@ bool FffPolygonGenerator::sliceModel(MeshGroup* meshgroup, TimeKeeper& timeKeepe
}
else
{
- slice_layer_count = round_divide_signed(storage.model_max.z - initial_layer_thickness, layer_thickness) + 1;
+ //Find highest layer count according to each mesh's settings.
+ for(const Mesh& mesh : meshgroup->meshes)
+ {
+ switch(mesh.settings.get<SlicingTolerance>("slicing_tolerance"))
+ {
+ case SlicingTolerance::MIDDLE:
+ slice_layer_count = std::max(slice_layer_count, int(round_divide_signed(storage.model_max.z - initial_layer_thickness, layer_thickness) + 1));
+ break;
+ case SlicingTolerance::EXCLUSIVE:
+ slice_layer_count = std::max(slice_layer_count, int(floor_divide_signed(storage.model_max.z - initial_layer_thickness, layer_thickness) + 1));
+ break;
+ case SlicingTolerance::INCLUSIVE:
+ slice_layer_count = std::max(slice_layer_count, int(ceil_divide_signed(storage.model_max.z - initial_layer_thickness, layer_thickness) + 1));
+ break;
+ default:
+ logError("Unknown slicing tolerance. Did you forget to add a case here?");
+ return false;
+ }
+ }
}
// Model is shallower than layer_height_0, so not even the first layer is sliced. Return an empty model then.
diff --git a/src/utils/math.h b/src/utils/math.h
index 1d36dc34f..031243738 100644
--- a/src/utils/math.h
+++ b/src/utils/math.h
@@ -1,4 +1,6 @@
-/** Copyright (C) 2016 Ultimaker - Released under terms of the AGPLv3 License */
+//Copyright (c) 2021 Ultimaker B.V.
+//CuraEngine is released under the terms of the AGPLv3 or higher.
+
#ifndef UTILS_MATH_H
#define UTILS_MATH_H
@@ -22,6 +24,14 @@ inline unsigned int round_divide_signed(int dividend, int divisor) //!< Return d
const int abs_div = std::abs(divisor);
return (dividend * divisor > 0 ? 1 : -1) * ((std::abs(dividend) + abs_div / 2) / abs_div);
}
+inline unsigned int ceil_divide_signed(int dividend, int divisor) //!< Return dividend divided by divisor rounded up towards positive infinity.
+{
+ return (dividend / divisor) + (dividend * divisor > 0 ? 1 : 0);
+}
+inline unsigned int floor_divide_signed(int dividend, int divisor) //!< Return dividend divided by divisor rounded down towards negative infinity.
+{
+ return (dividend / divisor) + (dividend * divisor > 0 ? 0 : -1);
+}
inline unsigned int round_divide(unsigned int dividend, unsigned int divisor) //!< Return dividend divided by divisor rounded to the nearest integer
{
return (dividend + divisor / 2) / divisor;