From 303aebc27eb8f9c16278208833e56103ec199c01 Mon Sep 17 00:00:00 2001 From: Christopher Lackner Date: Tue, 26 Nov 2019 17:08:21 +0100 Subject: [PATCH] throw on meshing failure --- libsrc/csg/python_csg.cpp | 4 +++- libsrc/geom2d/python_geom2d.cpp | 4 +++- libsrc/occ/python_occ.cpp | 4 +++- libsrc/stlgeom/python_stl.cpp | 5 ++++- 4 files changed, 13 insertions(+), 4 deletions(-) diff --git a/libsrc/csg/python_csg.cpp b/libsrc/csg/python_csg.cpp index 11aae246..2f05a8db 100644 --- a/libsrc/csg/python_csg.cpp +++ b/libsrc/csg/python_csg.cpp @@ -707,7 +707,9 @@ However, when r = 0, the top part becomes a point(tip) and meshing fails! mesh->SetGeometry(geo); ng_geometry = geo; geo->FindIdenticSurfaces(1e-8 * geo->MaxSize()); - geo->GenerateMesh (mesh, mp); + auto result = geo->GenerateMesh (mesh, mp); + if(result != 0) + throw Exception("Meshing failed!"); return mesh; }, py::arg("mp") = nullptr, meshingparameter_description.c_str(), diff --git a/libsrc/geom2d/python_geom2d.cpp b/libsrc/geom2d/python_geom2d.cpp index 54f28ef1..fe25e4be 100644 --- a/libsrc/geom2d/python_geom2d.cpp +++ b/libsrc/geom2d/python_geom2d.cpp @@ -377,7 +377,9 @@ DLL_HEADER void ExportGeom2d(py::module &m) mesh->SetGeometry(self); SetGlobalMesh (mesh); ng_geometry = self; - self->GenerateMesh(mesh, mp); + auto result = self->GenerateMesh(mesh, mp); + if(result != 0) + throw Exception("Meshing failed!"); return mesh; }, py::arg("mp") = nullptr, py::call_guard(), diff --git a/libsrc/occ/python_occ.cpp b/libsrc/occ/python_occ.cpp index 07887466..837ecdb0 100644 --- a/libsrc/occ/python_occ.cpp +++ b/libsrc/occ/python_occ.cpp @@ -177,7 +177,9 @@ DLL_HEADER void ExportNgOCC(py::module &m) geo->SetOCCParameters(occparam); auto mesh = make_shared(); mesh->SetGeometry(geo); - geo->GenerateMesh(mesh, mp); + auto result = geo->GenerateMesh(mesh, mp); + if(result != 0) + throw Exception("Meshing failed!"); SetGlobalMesh(mesh); ng_geometry = geo; return mesh; diff --git a/libsrc/stlgeom/python_stl.cpp b/libsrc/stlgeom/python_stl.cpp index 104504bf..accfb8d6 100644 --- a/libsrc/stlgeom/python_stl.cpp +++ b/libsrc/stlgeom/python_stl.cpp @@ -205,7 +205,10 @@ DLL_HEADER void ExportSTL(py::module & m) mesh->SetGeometry(geo); ng_geometry = geo; SetGlobalMesh(mesh); - STLMeshingDummy(geo.get(), mesh, mp, stlparam); + auto result = STLMeshingDummy(geo.get(), mesh, mp, stlparam); + if(result != 0) + throw Exception("Meshing failed!"); + return mesh; }, py::arg("mp") = nullptr, py::call_guard(),