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:
authorVojtech Bubnik <bubnikv@gmail.com>2021-01-28 20:59:53 +0300
committerVojtech Bubnik <bubnikv@gmail.com>2021-06-21 15:03:04 +0300
commit9a71d6deb98f81a7838975726807a30a406e2799 (patch)
treeb571b59ac742bbd0b114162584eb75b0872eaa2c
parent02f97e10a5249dc291e0fc301aa8877852c06461 (diff)
Fix of #4654 #5122 #5668 #5811 #5895
Fixing model import of models with nearly degenerate triangles, which degenerate after transformation (translation or rotation). There was certainly a bug in PrusaSlicer, however this bug was triggered mostly by the ASCII STL files generated by OpenSCAD, likely due to insufficient number of decimal digits when saving an ASCII STL, see [openscad/openscad] STL export should contain single precision floats (#2651)
-rw-r--r--src/libslic3r/PrintObject.cpp22
1 files changed, 14 insertions, 8 deletions
diff --git a/src/libslic3r/PrintObject.cpp b/src/libslic3r/PrintObject.cpp
index 99b4130f4..ed17676e0 100644
--- a/src/libslic3r/PrintObject.cpp
+++ b/src/libslic3r/PrintObject.cpp
@@ -2139,6 +2139,16 @@ std::vector<ExPolygons> PrintObject::slice_support_volumes(const ModelVolumeType
return this->slice_volumes(zs, SlicingMode::Regular, volumes);
}
+//FIXME The admesh repair function may break the face connectivity, rather refresh it here as the slicing code relies on it.
+static void fix_mesh_connectivity(TriangleMesh &mesh)
+{
+ auto nr_degenerated = mesh.stl.stats.degenerate_facets;
+ stl_check_facets_exact(&mesh.stl);
+ if (nr_degenerated != mesh.stl.stats.degenerate_facets)
+ // stl_check_facets_exact() removed some newly degenerated faces. Some faces could become degenerate after some mesh transformation.
+ stl_generate_shared_vertices(&mesh.stl, mesh.its);
+}
+
std::vector<ExPolygons> PrintObject::slice_volumes(
const std::vector<float> &z,
SlicingMode mode, size_t slicing_mode_normal_below_layer, SlicingMode mode_below,
@@ -2151,10 +2161,8 @@ std::vector<ExPolygons> PrintObject::slice_volumes(
TriangleMesh mesh(volumes.front()->mesh());
mesh.transform(volumes.front()->get_matrix(), true);
assert(mesh.repaired);
- if (volumes.size() == 1 && mesh.repaired) {
- //FIXME The admesh repair function may break the face connectivity, rather refresh it here as the slicing code relies on it.
- stl_check_facets_exact(&mesh.stl);
- }
+ if (volumes.size() == 1 && mesh.repaired)
+ fix_mesh_connectivity(mesh);
for (size_t idx_volume = 1; idx_volume < volumes.size(); ++ idx_volume) {
const ModelVolume &model_volume = *volumes[idx_volume];
TriangleMesh vol_mesh(model_volume.mesh());
@@ -2187,10 +2195,8 @@ std::vector<ExPolygons> PrintObject::slice_volume(const std::vector<float> &z, S
//FIXME better to split the mesh into separate shells, perform slicing over each shell separately and then to use a Boolean operation to merge them.
TriangleMesh mesh(volume.mesh());
mesh.transform(volume.get_matrix(), true);
- if (mesh.repaired) {
- //FIXME The admesh repair function may break the face connectivity, rather refresh it here as the slicing code relies on it.
- stl_check_facets_exact(&mesh.stl);
- }
+ if (mesh.repaired)
+ fix_mesh_connectivity(mesh);
if (mesh.stl.stats.number_of_facets > 0) {
mesh.transform(m_trafo, true);
// apply XY shift