From 7398ec67ab5471c722f11b09ccf9111e7e23cffc Mon Sep 17 00:00:00 2001 From: Francois Bonneau Date: Tue, 28 Oct 2025 14:17:34 +0100 Subject: [PATCH 1/3] fix(Error Message): add component name in error message --- src/geode/mesh/core/solid_mesh.cpp | 15 +++++++---- src/geode/mesh/core/surface_mesh.cpp | 9 ++++--- .../helpers/repair_polygon_orientations.cpp | 27 ++++++++++++++----- 3 files changed, 36 insertions(+), 15 deletions(-) diff --git a/src/geode/mesh/core/solid_mesh.cpp b/src/geode/mesh/core/solid_mesh.cpp index 7a5ec2c99..f975fd030 100644 --- a/src/geode/mesh/core/solid_mesh.cpp +++ b/src/geode/mesh/core/solid_mesh.cpp @@ -193,7 +193,8 @@ namespace } while( facet.polyhedron_id != first_polyhedron && safety_count < MAX_SAFETY_COUNT ); OPENGEODE_EXCEPTION( safety_count < MAX_SAFETY_COUNT, - "[SolidMesh::propagate_around_edge] Too many polyhedra " + "[SolidMesh::propagate_around_edge] Solid: ", solid.name(), + " - Too many polyhedra " "around edge ", edge_vertices[0], " ", edge_vertices[1], " (", solid.point( edge_vertices[0] ).string(), " ", @@ -298,7 +299,9 @@ namespace } } OPENGEODE_EXCEPTION( safety_count < MAX_SAFETY_COUNT, - "[SolidMesh::compute_polyhedra_around_vertex] Too many polyhedra " + "[SolidMesh::compute_polyhedra_around_vertex] Solid: ", + solid.name(), + " Too many polyhedra " "around vertex ", vertex_id, " (", solid.point( vertex_id ).string(), "). This is probably related to a bug in the polyhedra " @@ -424,12 +427,14 @@ namespace geode public: explicit Impl( SolidMesh& solid ) - : polyhedron_around_vertex_( solid.vertex_attribute_manager() + : polyhedron_around_vertex_( + solid.vertex_attribute_manager() .template find_or_create_attribute< VariableAttribute, PolyhedronVertex >( "polyhedron_around_vertex", PolyhedronVertex{}, { false, false, false } ) ), - polyhedra_around_vertex_( solid.vertex_attribute_manager() + polyhedra_around_vertex_( + solid.vertex_attribute_manager() .template find_or_create_attribute< VariableAttribute, CachedPolyhedra >( POLYHEDRA_AROUND_VERTEX_NAME, CachedPolyhedra{}, @@ -1335,7 +1340,7 @@ namespace geode { facet_vertices.push_back( vertices[polyhedron_facet_vertex_id( { facet, v } ) - .vertex_id] ); + .vertex_id] ); } } return facets_vertices; diff --git a/src/geode/mesh/core/surface_mesh.cpp b/src/geode/mesh/core/surface_mesh.cpp index 9d1f57e71..a2d45b5aa 100644 --- a/src/geode/mesh/core/surface_mesh.cpp +++ b/src/geode/mesh/core/surface_mesh.cpp @@ -181,7 +181,8 @@ namespace } } OPENGEODE_EXCEPTION( safety_count < MAX_SAFETY_COUNT, - "[SurfaceMesh::polygons_around_vertex] Too many polygons " + "[SurfaceMesh::polygons_around_vertex] Surface: ", mesh.name(), + " Too many polygons " "around vertex ", vertex_id, " (", mesh.point( vertex_id ).string(), "). This is probably related to a bug in the polygon " @@ -249,12 +250,14 @@ namespace geode public: Impl( SurfaceMesh& surface ) - : polygon_around_vertex_( surface.vertex_attribute_manager() + : polygon_around_vertex_( + surface.vertex_attribute_manager() .template find_or_create_attribute< VariableAttribute, PolygonVertex >( "polygon_around_vertex", PolygonVertex{}, { false, false, false } ) ), - polygons_around_vertex_( surface.vertex_attribute_manager() + polygons_around_vertex_( + surface.vertex_attribute_manager() .template find_or_create_attribute< VariableAttribute, CachedPolygons >( POLYGONS_AROUND_VERTEX_NAME, CachedPolygons{}, diff --git a/src/geode/mesh/helpers/repair_polygon_orientations.cpp b/src/geode/mesh/helpers/repair_polygon_orientations.cpp index ca1604687..28dfe83a2 100644 --- a/src/geode/mesh/helpers/repair_polygon_orientations.cpp +++ b/src/geode/mesh/helpers/repair_polygon_orientations.cpp @@ -51,16 +51,29 @@ namespace absl::FixedArray< geode::index_t > compute_bad_oriented_polygons() { - absl::FixedArray< bool > visited( mesh_.nb_polygons(), false ); - for( const auto p : geode::Range{ mesh_.nb_polygons() } ) + try { - if( visited[p] ) + absl::FixedArray< bool > visited( mesh_.nb_polygons(), false ); + for( const auto p : geode::Range{ mesh_.nb_polygons() } ) { - continue; + if( visited[p] ) + { + continue; + } + queue_.emplace( p ); + visited[p] = true; + process_polygon_queue( visited ); } - queue_.emplace( p ); - visited[p] = true; - process_polygon_queue( visited ); + } + catch( geode::OpenGeodeException& e ) + { + const auto msg = + absl::StrCat( "Surface ", mesh_.name(), " - ", e.what() ); + throw( geode::OpenGeodeException( msg ) ); + } + catch( ... ) + { + throw; } return get_bad_oriented_polygons(); } From 61fdb6e0235feec0445addbabe9c9cbec22e8346 Mon Sep 17 00:00:00 2001 From: francoisbonneau <24669995+francoisbonneau@users.noreply.github.com> Date: Tue, 28 Oct 2025 13:23:45 +0000 Subject: [PATCH 2/3] Apply prepare changes --- src/geode/mesh/core/solid_mesh.cpp | 8 +++----- src/geode/mesh/core/surface_mesh.cpp | 6 ++---- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/src/geode/mesh/core/solid_mesh.cpp b/src/geode/mesh/core/solid_mesh.cpp index f975fd030..e56f45dc9 100644 --- a/src/geode/mesh/core/solid_mesh.cpp +++ b/src/geode/mesh/core/solid_mesh.cpp @@ -427,14 +427,12 @@ namespace geode public: explicit Impl( SolidMesh& solid ) - : polyhedron_around_vertex_( - solid.vertex_attribute_manager() + : polyhedron_around_vertex_( solid.vertex_attribute_manager() .template find_or_create_attribute< VariableAttribute, PolyhedronVertex >( "polyhedron_around_vertex", PolyhedronVertex{}, { false, false, false } ) ), - polyhedra_around_vertex_( - solid.vertex_attribute_manager() + polyhedra_around_vertex_( solid.vertex_attribute_manager() .template find_or_create_attribute< VariableAttribute, CachedPolyhedra >( POLYHEDRA_AROUND_VERTEX_NAME, CachedPolyhedra{}, @@ -1340,7 +1338,7 @@ namespace geode { facet_vertices.push_back( vertices[polyhedron_facet_vertex_id( { facet, v } ) - .vertex_id] ); + .vertex_id] ); } } return facets_vertices; diff --git a/src/geode/mesh/core/surface_mesh.cpp b/src/geode/mesh/core/surface_mesh.cpp index a2d45b5aa..2f36ca886 100644 --- a/src/geode/mesh/core/surface_mesh.cpp +++ b/src/geode/mesh/core/surface_mesh.cpp @@ -250,14 +250,12 @@ namespace geode public: Impl( SurfaceMesh& surface ) - : polygon_around_vertex_( - surface.vertex_attribute_manager() + : polygon_around_vertex_( surface.vertex_attribute_manager() .template find_or_create_attribute< VariableAttribute, PolygonVertex >( "polygon_around_vertex", PolygonVertex{}, { false, false, false } ) ), - polygons_around_vertex_( - surface.vertex_attribute_manager() + polygons_around_vertex_( surface.vertex_attribute_manager() .template find_or_create_attribute< VariableAttribute, CachedPolygons >( POLYGONS_AROUND_VERTEX_NAME, CachedPolygons{}, From a30ebe44fb6c85450fc858f13855f208c59df268 Mon Sep 17 00:00:00 2001 From: Francois Bonneau Date: Mon, 3 Nov 2025 09:31:49 +0100 Subject: [PATCH 3/3] PA review --- src/geode/mesh/core/solid_mesh.cpp | 18 +++++++----------- src/geode/mesh/core/surface_mesh.cpp | 7 +++---- .../helpers/repair_polygon_orientations.cpp | 4 ++-- 3 files changed, 12 insertions(+), 17 deletions(-) diff --git a/src/geode/mesh/core/solid_mesh.cpp b/src/geode/mesh/core/solid_mesh.cpp index e56f45dc9..14af89c88 100644 --- a/src/geode/mesh/core/solid_mesh.cpp +++ b/src/geode/mesh/core/solid_mesh.cpp @@ -193,12 +193,10 @@ namespace } while( facet.polyhedron_id != first_polyhedron && safety_count < MAX_SAFETY_COUNT ); OPENGEODE_EXCEPTION( safety_count < MAX_SAFETY_COUNT, - "[SolidMesh::propagate_around_edge] Solid: ", solid.name(), - " - Too many polyhedra " - "around edge ", - edge_vertices[0], " ", edge_vertices[1], " (", - solid.point( edge_vertices[0] ).string(), " ", - solid.point( edge_vertices[1] ).string(), + "[SolidMesh::propagate_around_edge] Solid ", solid.name(), + ": too many polyhedra around edge ", edge_vertices[0], " ", + edge_vertices[1], " (", solid.point( edge_vertices[0] ).string(), + " ", solid.point( edge_vertices[1] ).string(), "). This is probably related to a bug in the polyhedron " "adjacencies." ); return std::make_tuple( std::move( result ), true ); @@ -299,11 +297,9 @@ namespace } } OPENGEODE_EXCEPTION( safety_count < MAX_SAFETY_COUNT, - "[SolidMesh::compute_polyhedra_around_vertex] Solid: ", - solid.name(), - " Too many polyhedra " - "around vertex ", - vertex_id, " (", solid.point( vertex_id ).string(), + "[SolidMesh::compute_polyhedra_around_vertex] Solid ", solid.name(), + ": Too many polyhedra around vertex ", vertex_id, " (", + solid.point( vertex_id ).string(), "). This is probably related to a bug in the polyhedra " "adjacencies." ); return result; diff --git a/src/geode/mesh/core/surface_mesh.cpp b/src/geode/mesh/core/surface_mesh.cpp index 2f36ca886..5e677a68e 100644 --- a/src/geode/mesh/core/surface_mesh.cpp +++ b/src/geode/mesh/core/surface_mesh.cpp @@ -181,10 +181,9 @@ namespace } } OPENGEODE_EXCEPTION( safety_count < MAX_SAFETY_COUNT, - "[SurfaceMesh::polygons_around_vertex] Surface: ", mesh.name(), - " Too many polygons " - "around vertex ", - vertex_id, " (", mesh.point( vertex_id ).string(), + "[SurfaceMesh::polygons_around_vertex] Surface ", mesh.name(), + ": Too many polygons around vertex ", vertex_id, " (", + mesh.point( vertex_id ).string(), "). This is probably related to a bug in the polygon " "adjacencies." ); return result; diff --git a/src/geode/mesh/helpers/repair_polygon_orientations.cpp b/src/geode/mesh/helpers/repair_polygon_orientations.cpp index 28dfe83a2..337044168 100644 --- a/src/geode/mesh/helpers/repair_polygon_orientations.cpp +++ b/src/geode/mesh/helpers/repair_polygon_orientations.cpp @@ -68,8 +68,8 @@ namespace catch( geode::OpenGeodeException& e ) { const auto msg = - absl::StrCat( "Surface ", mesh_.name(), " - ", e.what() ); - throw( geode::OpenGeodeException( msg ) ); + absl::StrCat( "Surface ", mesh_.name(), ": ", e.what() ); + throw geode::OpenGeodeException( msg ); } catch( ... ) {