From 7fe7f33b80e9b9154be9e61cb8e10de001e8854b Mon Sep 17 00:00:00 2001 From: tamasmeszaros Date: Fri, 23 Nov 2018 10:28:26 +0100 Subject: [PATCH] Fix for crash when generating supports with empty input points --- src/libslic3r/SLA/SLASupportTree.cpp | 8 ++++---- src/libslic3r/SLA/SLASupportTreeIGL.cpp | 3 ++- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/libslic3r/SLA/SLASupportTree.cpp b/src/libslic3r/SLA/SLASupportTree.cpp index 27fa53236..c348113f4 100644 --- a/src/libslic3r/SLA/SLASupportTree.cpp +++ b/src/libslic3r/SLA/SLASupportTree.cpp @@ -929,6 +929,9 @@ bool SLASupportTree::generate(const PointSet &points, const SupportConfig &cfg, const Controller &ctl) { + // If there are no input points there is no point in doing anything + if(points.rows() == 0) return false; + PointSet filtered_points; // all valid support points PointSet head_positions; // support points with pinhead PointSet head_normals; // head normals @@ -1619,10 +1622,7 @@ bool SLASupportTree::generate(const PointSet &points, return pc == ABORT; } -SLASupportTree::SLASupportTree(): m_impl(new Impl()) -{ - -} +SLASupportTree::SLASupportTree(): m_impl(new Impl()) {} const TriangleMesh &SLASupportTree::merged_mesh() const { diff --git a/src/libslic3r/SLA/SLASupportTreeIGL.cpp b/src/libslic3r/SLA/SLASupportTreeIGL.cpp index 42799ffd0..ef00d8d86 100644 --- a/src/libslic3r/SLA/SLASupportTreeIGL.cpp +++ b/src/libslic3r/SLA/SLASupportTreeIGL.cpp @@ -84,6 +84,7 @@ size_t SpatIndex::size() const } PointSet normals(const PointSet& points, const EigenMesh3D& mesh) { + if(points.rows() == 0 || mesh.V.rows() == 0 || mesh.F.rows() == 0) return {}; #ifdef IGL_COMPATIBLE Eigen::VectorXd dists; Eigen::VectorXi I; @@ -108,7 +109,7 @@ PointSet normals(const PointSet& points, const EigenMesh3D& mesh) { } return ret; -#else +#else // TODO: do something on 32 bit windows return {}; #endif }