diff --git a/bindings/python/src/inspection/inspection.cpp b/bindings/python/src/inspection/inspection.cpp index 6321e26d..514f4642 100644 --- a/bindings/python/src/inspection/inspection.cpp +++ b/bindings/python/src/inspection/inspection.cpp @@ -79,6 +79,12 @@ namespace pybind11 { }; + template < typename Key, typename Value > + struct type_caster< absl::linked_hash_map< Key, Value > > + : map_caster< absl::linked_hash_map< Key, Value >, Key, Value > + { + }; + template < typename Type, size_t dimension > struct type_caster< absl::InlinedVector< Type, dimension > > : list_caster< absl::InlinedVector< Type, dimension >, Type > diff --git a/include/geode/inspector/inspection/information.hpp b/include/geode/inspector/inspection/information.hpp index c4eb8ced..549514b1 100644 --- a/include/geode/inspector/inspection/information.hpp +++ b/include/geode/inspector/inspection/information.hpp @@ -26,7 +26,7 @@ #include #include -#include +#include #include #include @@ -94,8 +94,8 @@ namespace geode "Default inspection issue message. This message " "should have been overriden." }; - std::vector< IssueType > issues_{}; - std::vector< std::string > messages_{}; + std::vector< IssueType > issues_; + std::vector< std::string > messages_; }; template < typename IssueType > @@ -150,7 +150,7 @@ namespace geode return message; } - [[nodiscard]] const absl::flat_hash_map< uuid, + [[nodiscard]] const absl::linked_hash_map< uuid, InspectionIssues< IssueType > >& issues_map() const { @@ -162,6 +162,7 @@ namespace geode "Default inspection issue message. This message " "should have been overriden." }; - absl::flat_hash_map< uuid, InspectionIssues< IssueType > > issues_map_; + absl::linked_hash_map< uuid, InspectionIssues< IssueType > > + issues_map_; }; } // namespace geode \ No newline at end of file diff --git a/src/geode/inspector/inspection/criterion/manifold/brep_meshes_manifold.cpp b/src/geode/inspector/inspection/criterion/manifold/brep_meshes_manifold.cpp index 0a5c3ccf..8f35aa8e 100644 --- a/src/geode/inspector/inspection/criterion/manifold/brep_meshes_manifold.cpp +++ b/src/geode/inspector/inspection/criterion/manifold/brep_meshes_manifold.cpp @@ -93,7 +93,7 @@ namespace geode : public internal::ComponentMeshesManifold< BRep > { public: - Impl( const BRep& brep ) + explicit Impl( const BRep& brep ) : internal::ComponentMeshesManifold< BRep >( brep ) { } @@ -156,7 +156,7 @@ namespace geode InspectionIssues< BRepNonManifoldEdge >& issues ) const { using Edge = detail::VertexCycle< std::array< index_t, 2 > >; - absl::flat_hash_map< Edge, std::vector< uuid > > edges; + absl::linked_hash_map< Edge, std::vector< uuid > > edges; for( const auto& surface : model().active_surfaces() ) { const auto& mesh = surface.mesh(); @@ -171,16 +171,16 @@ namespace geode { continue; } - const auto v0 = model().unique_vertex( + const auto vertex0 = model().unique_vertex( { surface.component_id(), vertices[edge_id] } ); - const auto v1 = + const auto vertex1 = model().unique_vertex( { surface.component_id(), vertices[edge_id == vertices.size() - 1 ? 0 : edge_id + 1] } ); const auto info = edges.try_emplace( - Edge{ std::array< index_t, 2 >{ v0, v1 } }, - std::vector< uuid >{ surface.id() } ); + Edge{ std::array{ vertex0, vertex1 } }, + std::vector{ surface.id() } ); if( !info.second ) { info.first->second.push_back( surface.id() ); @@ -220,7 +220,7 @@ namespace geode { continue; } - std::array< index_t, 2 > edge_unique_vertices; + std::array< index_t, 2 > edge_unique_vertices{ NO_ID, NO_ID }; for( const auto edge_vertex : LRange{ 2 } ) { edge_unique_vertices[edge_vertex] = @@ -276,7 +276,7 @@ namespace geode } private: - bool several_cmvs_on_one_vertex( + [[nodiscard]] bool several_cmvs_on_one_vertex( absl::Span< const index_t > unique_vertices ) const { std::vector< uuid > surfaces; diff --git a/src/geode/inspector/inspection/criterion/manifold/solid_facet_manifold.cpp b/src/geode/inspector/inspection/criterion/manifold/solid_facet_manifold.cpp index 72338ff9..23e16818 100644 --- a/src/geode/inspector/inspection/criterion/manifold/solid_facet_manifold.cpp +++ b/src/geode/inspector/inspection/criterion/manifold/solid_facet_manifold.cpp @@ -23,8 +23,8 @@ #include -#include #include +#include #include #include @@ -37,11 +37,11 @@ namespace using Facet = geode::detail::VertexCycle< geode::PolyhedronFacetVertices >; template < geode::index_t dimension > - absl::flat_hash_map< Facet, geode::index_t > + [[nodiscard]] absl::linked_hash_map< Facet, geode::index_t > facets_to_nb_adjacent_polyhedra( const geode::SolidMesh< dimension >& mesh ) { - absl::flat_hash_map< Facet, geode::index_t > + absl::linked_hash_map< Facet, geode::index_t > nb_polyhedra_adjacent_to_facets; for( const auto polyhedron_id : geode::Range{ mesh.nb_polyhedra() } ) { @@ -67,9 +67,9 @@ namespace geode class SolidMeshFacetManifold< dimension >::Impl { public: - Impl( const SolidMesh< dimension >& mesh ) : mesh_( mesh ) {} + explicit Impl( const SolidMesh< dimension >& mesh ) : mesh_( mesh ) {} - bool mesh_facets_are_manifold() const + [[nodiscard]] bool mesh_facets_are_manifold() const { const auto nb_polyhedra_adjacent_to_facets = facets_to_nb_adjacent_polyhedra( mesh_ ); @@ -84,7 +84,8 @@ namespace geode return true; } - InspectionIssues< PolyhedronFacetVertices > non_manifold_facets() const + [[nodiscard]] InspectionIssues< PolyhedronFacetVertices > + non_manifold_facets() const { const auto nb_polyhedra_adjacent_to_facets = facets_to_nb_adjacent_polyhedra( mesh_ ); diff --git a/src/geode/inspector/inspection/criterion/manifold/surface_edge_manifold.cpp b/src/geode/inspector/inspection/criterion/manifold/surface_edge_manifold.cpp index 8619daff..233f0c63 100644 --- a/src/geode/inspector/inspection/criterion/manifold/surface_edge_manifold.cpp +++ b/src/geode/inspector/inspection/criterion/manifold/surface_edge_manifold.cpp @@ -36,10 +36,11 @@ namespace using Edge = geode::detail::VertexCycle< std::array< geode::index_t, 2 > >; template < geode::index_t dimension > - absl::flat_hash_map< Edge, std::pair< geode::local_index_t, bool > > + [[nodiscard]] absl::linked_hash_map< Edge, + std::pair< geode::local_index_t, bool > > edge_to_polygons_around( const geode::SurfaceMesh< dimension >& mesh ) { - absl::flat_hash_map< Edge, std::pair< geode::local_index_t, bool > > + absl::linked_hash_map< Edge, std::pair< geode::local_index_t, bool > > polygons_around_edges; for( const auto polygon_id : geode::Range{ mesh.nb_polygons() } ) { @@ -76,9 +77,9 @@ namespace geode class SurfaceMeshEdgeManifold< dimension >::Impl { public: - Impl( const SurfaceMesh< dimension >& mesh ) : mesh_( mesh ) {} + explicit Impl( const SurfaceMesh< dimension >& mesh ) : mesh_( mesh ) {} - bool mesh_edges_are_manifold() const + [[nodiscard]] bool mesh_edges_are_manifold() const { for( const auto& edge : edge_to_polygons_around( mesh_ ) ) { @@ -95,7 +96,8 @@ namespace geode return true; } - InspectionIssues< std::array< index_t, 2 > > non_manifold_edges() const + [[nodiscard]] InspectionIssues< std::array< index_t, 2 > > + non_manifold_edges() const { InspectionIssues< std::array< index_t, 2 > > non_manifold_edges{ "non manifold edges"