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

github.com/prusa3d/PrusaSlicer.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLukáš Hejl <hejl.lukas@gmail.com>2021-10-22 13:17:42 +0300
committerLukáš Hejl <hejl.lukas@gmail.com>2021-10-25 15:59:05 +0300
commit3d87904e66983f042d4a58ea7c1d68f035736769 (patch)
tree6eb970f8ea980c5fb542bf3513feefa3c3296bda
parent7c00905ec7a2fc00d8d3aff487b9028f54693744 (diff)
Fixed the bottom layer of multi-material painted objects sunken below the print bed (#7107).version_2.4.0-beta1
-rw-r--r--src/libslic3r/MultiMaterialSegmentation.cpp24
1 files changed, 23 insertions, 1 deletions
diff --git a/src/libslic3r/MultiMaterialSegmentation.cpp b/src/libslic3r/MultiMaterialSegmentation.cpp
index 86b3488b0..3220a1e02 100644
--- a/src/libslic3r/MultiMaterialSegmentation.cpp
+++ b/src/libslic3r/MultiMaterialSegmentation.cpp
@@ -1252,6 +1252,14 @@ static void cut_segmented_layers(const std::vector<ExPolygons>
BOOST_LOG_TRIVIAL(debug) << "MMU segmentation - cutting segmented layers in parallel - end";
}
+static bool is_volume_sinking(const indexed_triangle_set &its, const Transform3d &trafo)
+{
+ const Transform3f trafo_f = trafo.cast<float>();
+ for (const stl_vertex &vertex : its.vertices)
+ if ((trafo_f * vertex).z() < SINKING_Z_THRESHOLD) return true;
+ return false;
+}
+
//#define MMU_SEGMENTATION_DEBUG_TOP_BOTTOM
// Returns MMU segmentation of top and bottom layers based on painting in MMU segmentation gizmo
@@ -1298,7 +1306,21 @@ static inline std::vector<std::vector<ExPolygons>> mmu_segmentation_top_and_bott
#endif // MMU_SEGMENTATION_DEBUG_TOP_BOTTOM
if (! painted.indices.empty()) {
std::vector<Polygons> top, bottom;
- slice_mesh_slabs(painted, zs, volume_trafo, max_top_layers > 0 ? &top : nullptr, max_bottom_layers > 0 ? &bottom : nullptr, throw_on_cancel_callback);
+ if (!zs.empty() && is_volume_sinking(painted, volume_trafo)) {
+ std::vector<float> zs_sinking = {0.f};
+ Slic3r::append(zs_sinking, zs);
+ slice_mesh_slabs(painted, zs_sinking, volume_trafo, max_top_layers > 0 ? &top : nullptr, max_bottom_layers > 0 ? &bottom : nullptr, throw_on_cancel_callback);
+
+ MeshSlicingParams slicing_params;
+ slicing_params.trafo = volume_trafo;
+ Polygons bottom_slice = slice_mesh(painted, zs[0], slicing_params);
+
+ top.erase(top.begin());
+ bottom.erase(bottom.begin());
+
+ bottom[0] = union_(bottom[0], bottom_slice);
+ } else
+ slice_mesh_slabs(painted, zs, volume_trafo, max_top_layers > 0 ? &top : nullptr, max_bottom_layers > 0 ? &bottom : nullptr, throw_on_cancel_callback);
auto merge = [](std::vector<Polygons> &&src, std::vector<Polygons> &dst) {
auto it_src = find_if(src.begin(), src.end(), [](const Polygons &p){ return ! p.empty(); });
if (it_src != src.end()) {