From c4829338453691371fc089d0aaf2cb9271417415 Mon Sep 17 00:00:00 2001 From: bubnikv Date: Mon, 11 Mar 2019 17:18:38 +0100 Subject: [PATCH] Fixed a regression issue in the triangle mesh slicing code, where a broken contour was not glued together using the closest neighbors. --- src/admesh/connect.cpp | 4 ++-- src/libslic3r/Point.hpp | 2 +- src/libslic3r/SupportMaterial.cpp | 2 +- src/libslic3r/TriangleMesh.cpp | 5 +++-- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/admesh/connect.cpp b/src/admesh/connect.cpp index 166eec3302..5fc992b63f 100644 --- a/src/admesh/connect.cpp +++ b/src/admesh/connect.cpp @@ -293,8 +293,8 @@ static int stl_load_edge_nearby(stl_file *stl, stl_hash_edge *edge, stl_vertex * { // Index of a grid cell spaced by tolerance. typedef Eigen::Matrix Vec3i; - Vec3i vertex1 = (*a / tolerance).cast(); - Vec3i vertex2 = (*b / tolerance).cast(); + Vec3i vertex1 = ((*a - stl->stats.min) / tolerance).cast(); + Vec3i vertex2 = ((*b - stl->stats.min) / tolerance).cast(); static_assert(sizeof(Vec3i) == 12, "size of Vec3i incorrect"); if (vertex1 == vertex2) diff --git a/src/libslic3r/Point.hpp b/src/libslic3r/Point.hpp index a03e6f436a..6b35600cbd 100644 --- a/src/libslic3r/Point.hpp +++ b/src/libslic3r/Point.hpp @@ -224,7 +224,7 @@ public: const ValueType &value = it->second; const Vec2crd *pt2 = m_point_accessor(value); if (pt2 != nullptr) { - const double d2 = (pt - *pt2).squaredNorm(); + const double d2 = (pt - *pt2).cast().squaredNorm(); if (d2 < dist_min) { dist_min = d2; value_min = &value; diff --git a/src/libslic3r/SupportMaterial.cpp b/src/libslic3r/SupportMaterial.cpp index 8cdc0ebfd3..c1847fcd83 100644 --- a/src/libslic3r/SupportMaterial.cpp +++ b/src/libslic3r/SupportMaterial.cpp @@ -2850,7 +2850,7 @@ void modulate_extrusion_by_overlapping_layers( if (end_and_dist2.first == nullptr) { // New fragment connecting to pt_current was not found. // Verify that the last point found is close to the original end point of the unfragmented path. - //const double d2 = (pt_end - pt_current).squaredNorm(); + //const double d2 = (pt_end - pt_current).cast.squaredNorm(); //assert(d2 < coordf_t(search_radius * search_radius)); // End of the path. break; diff --git a/src/libslic3r/TriangleMesh.cpp b/src/libslic3r/TriangleMesh.cpp index f75bd7fa9d..855fe76443 100644 --- a/src/libslic3r/TriangleMesh.cpp +++ b/src/libslic3r/TriangleMesh.cpp @@ -620,8 +620,9 @@ void TriangleMesh::require_shared_vertices() for (int nbr_idx = 0; nbr_idx < 3; ++nbr_idx) { int nbr_face = this->stl.neighbors_start[facet_idx].neighbor[nbr_idx]; if (nbr_face != -1) { - assert(stl.v_indices[nbr_face].vertex[(nbr.which_vertex_not[nbr_idx] + 1) % 3] == vertices[(nbr_idx + 1) % 3]); - assert(stl.v_indices[nbr_face].vertex[(nbr.which_vertex_not[nbr_idx] + 2) % 3] == vertices[nbr_idx]); + assert( + (stl.v_indices[nbr_face].vertex[(nbr.which_vertex_not[nbr_idx] + 1) % 3] == vertices[(nbr_idx + 1) % 3] && stl.v_indices[nbr_face].vertex[(nbr.which_vertex_not[nbr_idx] + 2) % 3] == vertices[nbr_idx]) || + (stl.v_indices[nbr_face].vertex[(nbr.which_vertex_not[nbr_idx] + 2) % 3] == vertices[(nbr_idx + 1) % 3] && stl.v_indices[nbr_face].vertex[(nbr.which_vertex_not[nbr_idx] + 1) % 3] == vertices[nbr_idx])); } } }