From ae23adff104710bd584511501c71e72ca1291dcd Mon Sep 17 00:00:00 2001 From: tamasmeszaros Date: Fri, 13 May 2022 12:26:03 +0200 Subject: [PATCH] Fix crash on windows Fix crash on windows - 2nd try --- src/libslic3r/BranchingTree/PointCloud.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/libslic3r/BranchingTree/PointCloud.cpp b/src/libslic3r/BranchingTree/PointCloud.cpp index a4855ee53..14ce4f63c 100644 --- a/src/libslic3r/BranchingTree/PointCloud.cpp +++ b/src/libslic3r/BranchingTree/PointCloud.cpp @@ -42,8 +42,7 @@ void to_eigen_mesh(const indexed_triangle_set &its, V.row(i) = its.vertices[i].cast(); } -std::vector sample_mesh(const indexed_triangle_set &its, - double radius) +std::vector sample_mesh(const indexed_triangle_set &its, double radius) { std::vector ret; @@ -68,7 +67,17 @@ std::vector sample_mesh(const indexed_triangle_set &its, ret.reserve(size_t(N)); for (int i = 0; i < FI.size(); i++) { - Vec3i face = its.indices[FI(i)]; + int face_id = FI(i); + + if (face_id < 0 || face_id >= int(its.indices.size())) + continue; + + Vec3i face = its.indices[face_id]; + + if (face(0) >= int(its.vertices.size()) || + face(1) >= int(its.vertices.size()) || + face(2) >= int(its.vertices.size())) + continue; Vec3f c = B.row(i)(0) * its.vertices[face(0)] + B.row(i)(1) * its.vertices[face(1)] +