Skip to content

Commit f85cbab

Browse files
committed
fix(SolidMesh): add safety count in propage around edge
1 parent be410e1 commit f85cbab

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/geode/mesh/core/solid_mesh.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,8 @@ namespace
163163
{
164164
geode::PolyhedraAroundEdge result;
165165
const auto first_polyhedron = facet.polyhedron_id;
166+
geode::index_t safety_count{ 0 };
167+
constexpr geode::index_t MAX_SAFETY_COUNT{ 1000 };
166168
do
167169
{
168170
if( const auto adj = solid.polyhedron_adjacent_facet( facet ) )
@@ -188,7 +190,16 @@ namespace
188190
{
189191
return std::make_tuple( std::move( result ), false );
190192
}
191-
} while( facet.polyhedron_id != first_polyhedron );
193+
} while( facet.polyhedron_id != first_polyhedron
194+
&& safety_count < MAX_SAFETY_COUNT );
195+
OPENGEODE_EXCEPTION( safety_count < MAX_SAFETY_COUNT,
196+
"[SolidMesh::propagate_around_edge] Too many polyhedra "
197+
"around edge ",
198+
edge_vertices[0], " ", edge_vertices[1], " (",
199+
solid.point( edge_vertices[0] ).string(), " ",
200+
solid.point( edge_vertices[1] ).string(),
201+
"). This is probably related to a bug in the polyhedron "
202+
"adjacencies." );
192203
return std::make_tuple( std::move( result ), true );
193204
}
194205

0 commit comments

Comments
 (0)