Skip to content

Commit 21c9e74

Browse files
authored
Merge pull request #4407 from roystgnr/actually_check_hull_integrity
Actually check hull integrity
2 parents f66cb98 + e015092 commit 21c9e74

3 files changed

Lines changed: 30 additions & 15 deletions

File tree

include/mesh/mesh_tet_interface.h

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -105,25 +105,28 @@ class MeshTetInterface
105105

106106
/**
107107
* This function checks the integrity of the current set of
108-
* elements in the Mesh to see if they comprise a hull,
109-
* that is:
108+
* elements in the Mesh to see if they comprise a topological
109+
* manifold that (if it's also geometrically valid) would define
110+
* valid hull for a tetrahedralized volume.
111+
* That is:
110112
* - If they are all TRI3 elements
111113
* - They all have non-nullptr neighbors
112114
*
113115
* \returns
114-
* - 0 if the mesh forms a valid hull
116+
* - 0 if the mesh forms a topologically valid hull
115117
* - 1 if a non-TRI3 element is found
116118
* - 2 if an element with a nullptr-neighbor is found
119+
* - 3 if the mesh is empty
117120
*/
118-
unsigned check_hull_integrity();
121+
[[nodiscard]] unsigned int check_hull_integrity();
119122

120123
/**
121-
* This function prints an informative message and
122-
* crashes based on the output of the check_hull_integrity()
123-
* function. It is a separate function so that you
124-
* can check hull integrity without crashing if you desire.
124+
* This function prints an informative message and throws an
125+
* exception based on the output of the check_hull_integrity()
126+
* function. It is a separate function so that you can check hull
127+
* integrity without exiting or catching an exception if desired.
125128
*/
126-
void process_hull_integrity_result(unsigned result);
129+
void process_hull_integrity_result(unsigned int result);
127130

128131
/**
129132
* Delete original convex hull elements from the Mesh

src/mesh/mesh_netgen_interface.C

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,8 @@ void NetGenMeshInterface::triangulate ()
127127
return;
128128
}
129129

130-
this->check_hull_integrity();
130+
auto integrity = this->check_hull_integrity();
131+
this->process_hull_integrity_result(integrity);
131132

132133
Ng_Meshing_Parameters params;
133134

src/mesh/mesh_tet_interface.C

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ BoundingBox MeshTetInterface::volume_to_surface_mesh(UnstructuredMesh & mesh)
335335
}
336336

337337

338-
unsigned MeshTetInterface::check_hull_integrity()
338+
unsigned int MeshTetInterface::check_hull_integrity()
339339
{
340340
// Check for easy return: if the Mesh is empty (i.e. if
341341
// somebody called triangulate_conformingDelaunayMesh on
@@ -371,17 +371,28 @@ unsigned MeshTetInterface::check_hull_integrity()
371371

372372
void MeshTetInterface::process_hull_integrity_result(unsigned result)
373373
{
374+
std::ostringstream err_msg;
375+
374376
if (result != 0)
375377
{
376-
libMesh::err << "Error! Conforming Delaunay mesh tetrahedralization requires a convex hull." << std::endl;
378+
err_msg << "Error! Conforming Delaunay mesh tetrahedralization requires a convex hull." << std::endl;
377379

378380
if (result==1)
379381
{
380-
libMesh::err << "Non-TRI3 elements were found in the input Mesh. ";
381-
libMesh::err << "A constrained Delaunay triangulation requires a convex hull of TRI3 elements." << std::endl;
382+
err_msg << "Non-TRI3 elements were found in the input Mesh. ";
383+
err_msg << "A constrained Delaunay tetrahedralization requires a convex hull of TRI3 elements." << std::endl;
382384
}
383385

384-
libmesh_error_msg("Consider calling TetGenMeshInterface::pointset_convexhull() followed by Mesh::find_neighbors() first.");
386+
if (result==2)
387+
{
388+
err_msg << "At least one triangle without three neighbors was found in the input Mesh. ";
389+
err_msg << "A constrained Delaunay tetrahedralization must be a triangular manifold without boundary." << std::endl;
390+
}
391+
392+
if (result==3)
393+
err_msg << "The input Mesh was empty!" << std::endl;
394+
395+
libmesh_error_msg(err_msg.str());
385396
}
386397
}
387398

0 commit comments

Comments
 (0)