From 9892d1bc2ce3fb89f8fb39a4c715b81fbdd05cd1 Mon Sep 17 00:00:00 2001 From: Jeremy Hu Date: Thu, 29 Mar 2018 14:27:31 +0800 Subject: [PATCH] Make cgal no-crash when fail --- src/skeletontomesh.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/skeletontomesh.cpp b/src/skeletontomesh.cpp index b4ea76b3..886effab 100644 --- a/src/skeletontomesh.cpp +++ b/src/skeletontomesh.cpp @@ -30,6 +30,7 @@ #include #include #include +#include typedef CGAL::Exact_predicates_exact_constructions_kernel Kernel; typedef CGAL::Surface_mesh CgalMesh; @@ -297,6 +298,9 @@ void SkeletonToMesh::process() if (meshIds.size() > 0) { #if USE_EXTERNAL +# if USE_CGAL + CGAL::set_error_behaviour(CGAL::THROW_EXCEPTION); +# endif std::vector externalMeshs; for (size_t i = 0; i < meshIds.size(); i++) { int triangledMeshId = meshlite_triangulate(meshliteContext, meshIds[i]); @@ -308,7 +312,12 @@ void SkeletonToMesh::process() for (size_t i = 1; i < externalMeshs.size(); i++) { if (!mergedExternalMesh) break; - ExternalMesh *unionedExternalMesh = unionExternalMeshs(mergedExternalMesh, externalMeshs[i]); + ExternalMesh *unionedExternalMesh = NULL; + try { + unionedExternalMesh = unionExternalMeshs(mergedExternalMesh, externalMeshs[i]); + } catch (...) { + // ignore; + } delete mergedExternalMesh; delete externalMeshs[i]; mergedExternalMesh = unionedExternalMesh;