From 1685fdf1271afda6bcecc3a1d55408ca719cfade Mon Sep 17 00:00:00 2001 From: MelchiorSchuh Date: Mon, 5 Jan 2026 14:25:27 +0100 Subject: [PATCH 1/2] fix(ModelTopologyChecks): Upgraded tests on models to account for inactive model components --- .../adjacency/brep_meshes_adjacency.cpp | 2 +- .../component_meshes_colocation.cpp | 16 +- .../colocation/unique_vertices_colocation.cpp | 132 ++++++++------ .../degeneration/brep_meshes_degeneration.cpp | 2 +- .../internal/component_meshes_adjacency.cpp | 2 +- .../component_meshes_degeneration.cpp | 14 +- .../internal/component_meshes_manifold.cpp | 4 +- .../intersections/model_intersections.cpp | 4 +- .../manifold/brep_meshes_manifold.cpp | 16 +- .../brep_meshes_negative_elements.cpp | 2 +- .../section_meshes_negative_elements.cpp | 2 +- .../topology/brep_blocks_topology.cpp | 114 +++++------- .../topology/brep_corners_topology.cpp | 28 +-- .../topology/brep_lines_topology.cpp | 163 ++++++++++-------- .../topology/brep_surfaces_topology.cpp | 155 ++++++++++------- .../inspector/topology/brep_topology.cpp | 47 ++--- .../topology/section_corners_topology.cpp | 26 +-- .../topology/section_lines_topology.cpp | 22 ++- .../topology/section_surfaces_topology.cpp | 13 +- .../inspector/topology/section_topology.cpp | 45 ++--- 20 files changed, 440 insertions(+), 369 deletions(-) diff --git a/src/geode/inspector/criterion/adjacency/brep_meshes_adjacency.cpp b/src/geode/inspector/criterion/adjacency/brep_meshes_adjacency.cpp index fba712d2..de457128 100644 --- a/src/geode/inspector/criterion/adjacency/brep_meshes_adjacency.cpp +++ b/src/geode/inspector/criterion/adjacency/brep_meshes_adjacency.cpp @@ -83,7 +83,7 @@ namespace geode InspectionIssuesMap< PolyhedronFacet >& components_wrong_adjacencies ) const { - for( const auto& block : model().blocks() ) + for( const auto& block : model().active_blocks() ) { const geode::SolidMeshAdjacency3D inspector{ block.mesh() }; auto wrong_adjacencies = diff --git a/src/geode/inspector/criterion/colocation/component_meshes_colocation.cpp b/src/geode/inspector/criterion/colocation/component_meshes_colocation.cpp index 90a8087d..ceba16c7 100644 --- a/src/geode/inspector/criterion/colocation/component_meshes_colocation.cpp +++ b/src/geode/inspector/criterion/colocation/component_meshes_colocation.cpp @@ -47,7 +47,7 @@ namespace { template < typename Model > std::vector< std::vector< geode::index_t > > - filter_colocated_points_with_same_uuid( const Model& model, + filter_colocated_points_with_same_unique_vertex( const Model& model, const geode::ComponentID& component_id, absl::Span< const std::vector< geode::index_t > > colocated_points_groups ) @@ -100,13 +100,13 @@ namespace geode::InspectionIssuesMap< std::vector< geode::index_t > >& components_colocated_points ) { - for( const auto& line : model.lines() ) + for( const auto& line : model.active_lines() ) { const geode::EdgedCurveColocation< Model::dim > inspector{ line.mesh() }; auto colocated_pts = - filter_colocated_points_with_same_uuid< Model >( model, + filter_colocated_points_with_same_unique_vertex< Model >( model, line.component_id(), inspector.colocated_points_groups().issues() ); if( !colocated_pts.empty() ) @@ -135,13 +135,13 @@ namespace line.id(), std::move( line_issues ) ); } } - for( const auto& surface : model.surfaces() ) + for( const auto& surface : model.active_surfaces() ) { const geode::SurfaceMeshColocation< Model::dim > inspector{ surface.mesh() }; auto colocated_pts = - filter_colocated_points_with_same_uuid< Model >( model, + filter_colocated_points_with_same_unique_vertex< Model >( model, surface.component_id(), inspector.colocated_points_groups().issues() ); if( !colocated_pts.empty() ) @@ -187,12 +187,12 @@ namespace { add_model_components_colocated_points_groups_base< geode::BRep >( model, components_colocated_points ); - for( const auto& block : model.blocks() ) + for( const auto& block : model.active_blocks() ) { const geode::SolidMeshColocation3D inspector{ block.mesh() }; auto colocated_pts = - filter_colocated_points_with_same_uuid< geode::BRep >( model, - block.component_id(), + filter_colocated_points_with_same_unique_vertex< geode::BRep >( + model, block.component_id(), inspector.colocated_points_groups().issues() ); if( !colocated_pts.empty() ) { diff --git a/src/geode/inspector/criterion/colocation/unique_vertices_colocation.cpp b/src/geode/inspector/criterion/colocation/unique_vertices_colocation.cpp index 79ce12da..f404c35b 100644 --- a/src/geode/inspector/criterion/colocation/unique_vertices_colocation.cpp +++ b/src/geode/inspector/criterion/colocation/unique_vertices_colocation.cpp @@ -94,11 +94,15 @@ namespace template < typename Model > bool model_cmvs_are_colocated_on_point( const Model& model, - const std::vector< geode::ComponentMeshVertex >& cmvs, + absl::Span< const geode::ComponentMeshVertex > cmvs, const geode::Point< Model::dim >& point ) { for( const auto& cmv : cmvs ) { + if( !model.component( cmv.component_id.id() ).is_active() ) + { + continue; + } if( !model_cmv_is_colocated_on_point( model, cmv, point ) ) { return false; @@ -108,40 +112,61 @@ namespace } template < typename Model > - geode::Point< Model::dim > model_unique_vertex_point_base( + geode::Point< Model::dim > model_cmv_point( const Model& model, const geode::ComponentMeshVertex& cmv ) { if( cmv.component_id.type() == geode::Line< Model::dim >::component_type_static() ) { - const auto& mesh = model.line( cmv.component_id.id() ).mesh(); - return mesh.point( cmv.vertex ); + return model.line( cmv.component_id.id() ) + .mesh() + .point( cmv.vertex ); } if( cmv.component_id.type() == geode::Surface< Model::dim >::component_type_static() ) { - const auto& mesh = model.surface( cmv.component_id.id() ).mesh(); - return mesh.point( cmv.vertex ); + return model.surface( cmv.component_id.id() ) + .mesh() + .point( cmv.vertex ); } - const auto& mesh = model.corner( cmv.component_id.id() ).mesh(); - return mesh.point( cmv.vertex ); + return model.corner( cmv.component_id.id() ).mesh().point( cmv.vertex ); } - geode::Point2D model_unique_vertex_point( - const geode::Section& model, const geode::ComponentMeshVertex& cmv ) + std::optional< geode::Point2D > model_unique_vertex_point( + const geode::Section& model, + absl::Span< const geode::ComponentMeshVertex > cmvs ) { - return model_unique_vertex_point_base< geode::Section >( model, cmv ); + for( const auto& cmv : cmvs ) + { + if( !model.component( cmv.component_id.id() ).is_active() ) + { + continue; + } + return model_cmv_point< geode::Section >( model, cmv ); + } + return std::nullopt; } - geode::Point3D model_unique_vertex_point( - const geode::BRep& model, const geode::ComponentMeshVertex& cmv ) + std::optional< geode::Point3D > model_unique_vertex_point( + const geode::BRep& model, + absl::Span< const geode::ComponentMeshVertex > cmvs ) { - if( cmv.component_id.type() == geode::Block3D::component_type_static() ) + for( const auto& cmv : cmvs ) { - const auto& mesh = model.block( cmv.component_id.id() ).mesh(); - return mesh.point( cmv.vertex ); + if( !model.component( cmv.component_id.id() ).is_active() ) + { + continue; + } + if( cmv.component_id.type() + == geode::Block3D::component_type_static() ) + { + return model.block( cmv.component_id.id() ) + .mesh() + .point( cmv.vertex ); + } + return model_cmv_point< geode::BRep >( model, cmv ); } - return model_unique_vertex_point_base< geode::BRep >( model, cmv ); + return std::nullopt; } } // namespace @@ -170,22 +195,27 @@ namespace geode public: Impl( const Model& model ) : model_( model ), - unique_vertices_{ PointSet< Model::dim >::create() } + active_uv_pointset_{ PointSet< Model::dim >::create() } { auto builder = - PointSetBuilder< Model::dim >::create( *unique_vertices_ ); + PointSetBuilder< Model::dim >::create( *active_uv_pointset_ ); builder->create_vertices( model.nb_unique_vertices() ); + std::vector< bool > not_assigned( + model.nb_unique_vertices(), true ); for( const auto unique_vertex_id : Range{ model.nb_unique_vertices() } ) { - const auto& cmvs = - model.component_mesh_vertices( unique_vertex_id ); - if( cmvs.empty() ) + if( auto point = model_unique_vertex_point( model, + model.component_mesh_vertices( unique_vertex_id ) ) ) { - continue; + builder->set_point( unique_vertex_id, point.value() ); + not_assigned[unique_vertex_id] = false; } - builder->set_point( unique_vertex_id, - model_unique_vertex_point( model, cmvs.at( 0 ) ) ); + } + const auto old2new = builder->delete_vertices( not_assigned ); + for( const auto old_index : Indices{ old2new } ) + { + uv_to_active_uv_.map( old_index, old2new[old_index] ); } } @@ -194,9 +224,15 @@ namespace geode for( const auto unique_vertex_id : Range{ model_.nb_unique_vertices() } ) { + const auto active_uv_id = + uv_to_active_uv_.in2out( unique_vertex_id ).at( 0 ); + if( active_uv_id == NO_ID ) + { + continue; + } if( !model_cmvs_are_colocated_on_point( model_, model_.component_mesh_vertices( unique_vertex_id ), - unique_vertices_->point( unique_vertex_id ) ) ) + active_uv_pointset_->point( active_uv_id ) ) ) { return true; } @@ -207,7 +243,7 @@ namespace geode bool model_has_colocated_unique_vertices() const { const PointSetColocation< Model::dim > pointset_inspector{ - *unique_vertices_ + *active_uv_pointset_ }; const auto has_colocation = pointset_inspector.mesh_has_colocated_points(); @@ -220,9 +256,15 @@ namespace geode for( const auto unique_vertex_id : Range{ model_.nb_unique_vertices() } ) { + const auto active_uv_id = + uv_to_active_uv_.in2out( unique_vertex_id ).at( 0 ); + if( active_uv_id == NO_ID ) + { + continue; + } if( !model_cmvs_are_colocated_on_point( model_, model_.component_mesh_vertices( unique_vertex_id ), - unique_vertices_->point( unique_vertex_id ) ) ) + active_uv_pointset_->point( active_uv_id ) ) ) { vertices_issues.add_issue( unique_vertex_id, absl::StrCat( "unique vertex ", unique_vertex_id, @@ -236,7 +278,7 @@ namespace geode InspectionIssues< std::vector< index_t > >& vertices_issues ) const { const PointSetColocation< Model::dim > pointset_inspector{ - *unique_vertices_ + *active_uv_pointset_ }; const auto colocated_pts_groups = pointset_inspector.colocated_points_groups(); @@ -244,33 +286,25 @@ namespace geode { std::vector< index_t > fixed_point_group; std::string point_group_string; - for( const auto point_index : Indices{ point_group } ) - { - if( model_ - .component_mesh_vertices( point_group[point_index] ) - .empty() ) - { - continue; - } - fixed_point_group.push_back( point_group[point_index] ); - absl::StrAppend( - &point_group_string, " ", point_group[point_index] ); - } - if( !fixed_point_group.empty() ) + for( const auto active_uv_index : point_group ) { - vertices_issues.add_issue( fixed_point_group, - absl::StrCat( "unique vertices ", point_group_string, - " are colocated at the position [", - unique_vertices_->point( fixed_point_group[0] ) - .string(), - "]" ) ); + const auto model_uv_index = + uv_to_active_uv_.out2in( active_uv_index ).at( 0 ); + fixed_point_group.push_back( model_uv_index ); + absl::StrAppend( &point_group_string, " ", model_uv_index ); } + vertices_issues.add_issue( fixed_point_group, + absl::StrCat( "unique vertices ", point_group_string, + " are colocated at the position [", + active_uv_pointset_->point( point_group[0] ).string(), + "]" ) ); } } private: const Model& model_; - std::unique_ptr< PointSet< Model::dim > > unique_vertices_; + std::unique_ptr< PointSet< Model::dim > > active_uv_pointset_; + geode::GenericMapping< index_t > uv_to_active_uv_; }; template < typename Model > diff --git a/src/geode/inspector/criterion/degeneration/brep_meshes_degeneration.cpp b/src/geode/inspector/criterion/degeneration/brep_meshes_degeneration.cpp index b00f1755..0a994442 100644 --- a/src/geode/inspector/criterion/degeneration/brep_meshes_degeneration.cpp +++ b/src/geode/inspector/criterion/degeneration/brep_meshes_degeneration.cpp @@ -91,7 +91,7 @@ namespace geode InspectionIssuesMap< index_t >& small_polyhedra_map, double threshold ) const { - for( const auto& block : model().blocks() ) + for( const auto& block : model().active_blocks() ) { const auto& mesh = block.mesh(); if( !mesh.are_edges_enabled() ) diff --git a/src/geode/inspector/criterion/internal/component_meshes_adjacency.cpp b/src/geode/inspector/criterion/internal/component_meshes_adjacency.cpp index 8c32cadd..e246dc96 100644 --- a/src/geode/inspector/criterion/internal/component_meshes_adjacency.cpp +++ b/src/geode/inspector/criterion/internal/component_meshes_adjacency.cpp @@ -73,7 +73,7 @@ namespace geode InspectionIssuesMap< PolygonEdge >& components_wrong_adjacencies ) const { - for( const auto& surface : model_.surfaces() ) + for( const auto& surface : model_.active_surfaces() ) { const SurfaceMeshAdjacency< Model::dim > inspector{ surface.mesh() diff --git a/src/geode/inspector/criterion/internal/component_meshes_degeneration.cpp b/src/geode/inspector/criterion/internal/component_meshes_degeneration.cpp index 961b9b72..ad94a3d1 100644 --- a/src/geode/inspector/criterion/internal/component_meshes_degeneration.cpp +++ b/src/geode/inspector/criterion/internal/component_meshes_degeneration.cpp @@ -64,8 +64,8 @@ namespace geode std::vector< async::task< std::pair< uuid, InspectionIssues< index_t > > > > line_tasks; - line_tasks.reserve( model_.nb_lines() ); - for( const auto& line : model_.lines() ) + line_tasks.reserve( model_.nb_active_lines() ); + for( const auto& line : model_.active_lines() ) { line_tasks.emplace_back( async::spawn( [&threshold, &line] { const EdgedCurveDegeneration< Model::dim > inspector{ @@ -87,9 +87,9 @@ namespace geode std::vector< async::task< std::pair< uuid, InspectionIssues< index_t > > > > surface_tasks; - surface_tasks.reserve( model_.nb_surfaces() ); + surface_tasks.reserve( model_.nb_active_surfaces() ); const auto surfaces_to_enable = surfaces_on_which_enable_edges(); - for( const auto& surface : model_.surfaces() ) + for( const auto& surface : model_.active_surfaces() ) { const auto enable_edges = absl::c_contains( surfaces_to_enable, surface.id() ); @@ -134,8 +134,8 @@ namespace geode std::vector< async::task< std::pair< uuid, InspectionIssues< index_t > > > > tasks; - tasks.reserve( model_.nb_surfaces() ); - for( const auto& surface : model_.surfaces() ) + tasks.reserve( model_.nb_active_surfaces() ); + for( const auto& surface : model_.active_surfaces() ) { tasks.emplace_back( async::spawn( [&threshold, &surface] { const geode::SurfaceMeshDegeneration< Model::dim > @@ -176,7 +176,7 @@ namespace geode Model >::surfaces_on_which_enable_edges() const { std::vector< uuid > result; - for( const auto& surface : model_.surfaces() ) + for( const auto& surface : model_.active_surfaces() ) { const auto& mesh = surface.mesh(); if( !mesh.are_edges_enabled() diff --git a/src/geode/inspector/criterion/internal/component_meshes_manifold.cpp b/src/geode/inspector/criterion/internal/component_meshes_manifold.cpp index b2d4c731..fa0440c1 100644 --- a/src/geode/inspector/criterion/internal/component_meshes_manifold.cpp +++ b/src/geode/inspector/criterion/internal/component_meshes_manifold.cpp @@ -51,7 +51,7 @@ namespace geode InspectionIssuesMap< index_t >& surfaces_non_manifold_vertices ) const { - for( const auto& surface : model_.surfaces() ) + for( const auto& surface : model_.active_surfaces() ) { const SurfaceMeshVertexManifold< Model::dim > inspector{ surface.mesh() @@ -72,7 +72,7 @@ namespace geode InspectionIssuesMap< std::array< index_t, 2 > >& surfaces_non_manifold_edges ) const { - for( const auto& surface : model_.surfaces() ) + for( const auto& surface : model_.active_surfaces() ) { const SurfaceMeshEdgeManifold< Model::dim > inspector{ surface.mesh() diff --git a/src/geode/inspector/criterion/intersections/model_intersections.cpp b/src/geode/inspector/criterion/intersections/model_intersections.cpp index 64af6b62..9820c474 100644 --- a/src/geode/inspector/criterion/intersections/model_intersections.cpp +++ b/src/geode/inspector/criterion/intersections/model_intersections.cpp @@ -558,7 +558,7 @@ namespace geode std::vector< std::pair< ComponentMeshElement, ComponentMeshElement > > component_intersections; - for( const auto& surface : model_.surfaces() ) + for( const auto& surface : model_.active_surfaces() ) { if( surface.mesh().nb_polygons() == 0 ) { @@ -570,7 +570,7 @@ namespace geode } } const auto model_tree = create_surface_meshes_aabb_trees( model_ ); - for( const auto& surface : model_.surfaces() ) + for( const auto& surface : model_.active_surfaces() ) { Action surfaces_intersection_action{ model_, surface.id(), surface.id() }; diff --git a/src/geode/inspector/criterion/manifold/brep_meshes_manifold.cpp b/src/geode/inspector/criterion/manifold/brep_meshes_manifold.cpp index 47a9402a..cc13b6b5 100644 --- a/src/geode/inspector/criterion/manifold/brep_meshes_manifold.cpp +++ b/src/geode/inspector/criterion/manifold/brep_meshes_manifold.cpp @@ -105,7 +105,7 @@ namespace geode ComponentMeshesManifold< BRep >:: add_surfaces_meshes_non_manifold_vertices( components_non_manifold_vertices ); - for( const auto& block : model().blocks() ) + for( const auto& block : model().active_blocks() ) { const SolidMeshVertexManifold3D inspector{ block.mesh() }; auto non_manifold_vertices = inspector.non_manifold_vertices(); @@ -124,7 +124,7 @@ namespace geode ComponentMeshesManifold< BRep >:: add_surfaces_meshes_non_manifold_edges( components_non_manifold_edges ); - for( const auto& block : model().blocks() ) + for( const auto& block : model().active_blocks() ) { const SolidMeshEdgeManifold3D inspector{ block.mesh() }; auto non_manifold_edges = inspector.non_manifold_edges(); @@ -140,7 +140,7 @@ namespace geode InspectionIssuesMap< PolyhedronFacetVertices >& components_non_manifold_facets ) const { - for( const auto& block : model().blocks() ) + for( const auto& block : model().active_blocks() ) { const SolidMeshFacetManifold3D inspector{ block.mesh() }; auto non_manifold_facets = inspector.non_manifold_facets(); @@ -157,7 +157,7 @@ namespace geode { using Edge = detail::VertexCycle< std::array< index_t, 2 > >; absl::flat_hash_map< Edge, std::vector< uuid > > edges; - for( const auto& surface : model().surfaces() ) + for( const auto& surface : model().active_surfaces() ) { const auto& mesh = surface.mesh(); for( const auto polygon_id : Range{ mesh.nb_polygons() } ) @@ -197,19 +197,19 @@ namespace geode std::string message = absl::StrCat( "Model edge between unique vertices ", edge.first.vertices()[0], " and ", edge.first.vertices()[1], - " is not manifold: it does not belong to a Line " - "but is on Surfaces " ); + " is not manifold: it is on several Surfaces: " ); for( const auto surface_uuid : edge.second ) { absl::StrAppend( &message, model().surface( surface_uuid ).name(), " (", surface_uuid.string(), "), " ); } + absl::StrAppend( &message, "but not on their border" ); issues.add_issue( BRepNonManifoldEdge{ edge.first.vertices(), edge.second }, message ); } - for( const auto& line : model().lines() ) + for( const auto& line : model().active_lines() ) { const auto& mesh = line.mesh(); if( mesh.nb_edges() != 1 @@ -243,7 +243,7 @@ namespace geode void add_model_non_manifold_facets( InspectionIssues< BRepNonManifoldFacet >& issues ) const { - for( const auto& surface : model().surfaces() ) + for( const auto& surface : model().active_surfaces() ) { const auto& mesh = surface.mesh(); if( mesh.nb_polygons() != 1 diff --git a/src/geode/inspector/criterion/negative_elements/brep_meshes_negative_elements.cpp b/src/geode/inspector/criterion/negative_elements/brep_meshes_negative_elements.cpp index 55f24c03..91bd2c4d 100644 --- a/src/geode/inspector/criterion/negative_elements/brep_meshes_negative_elements.cpp +++ b/src/geode/inspector/criterion/negative_elements/brep_meshes_negative_elements.cpp @@ -62,7 +62,7 @@ namespace geode block_negative_elements() const { BRepMeshesNegativeElementsInspectionResult result; - for( const auto& block : brep_.blocks() ) + for( const auto& block : brep_.active_blocks() ) { const geode::SolidMeshNegativeElements3D inspector{ block.mesh() diff --git a/src/geode/inspector/criterion/negative_elements/section_meshes_negative_elements.cpp b/src/geode/inspector/criterion/negative_elements/section_meshes_negative_elements.cpp index 2777d940..f18bd85c 100644 --- a/src/geode/inspector/criterion/negative_elements/section_meshes_negative_elements.cpp +++ b/src/geode/inspector/criterion/negative_elements/section_meshes_negative_elements.cpp @@ -64,7 +64,7 @@ namespace geode surface_negative_elements() const { SectionMeshesNegativeElementsInspectionResult result; - for( const auto& surface : section_.surfaces() ) + for( const auto& surface : section_.active_surfaces() ) { const geode::SurfaceMeshNegativeElements2D inspector{ surface.mesh() diff --git a/src/geode/inspector/topology/brep_blocks_topology.cpp b/src/geode/inspector/topology/brep_blocks_topology.cpp index d23eee08..f28990e4 100644 --- a/src/geode/inspector/topology/brep_blocks_topology.cpp +++ b/src/geode/inspector/topology/brep_blocks_topology.cpp @@ -79,22 +79,10 @@ namespace return false; } - std::vector< geode::uuid > block_boundary_surfaces( - const geode::BRep& brep, const geode::Block3D& block ) - { - std::vector< geode::uuid > block_boundary_uuids; - block_boundary_uuids.reserve( brep.nb_boundaries( block.id() ) ); - for( const auto& boundary_surface : brep.boundaries( block ) ) - { - block_boundary_uuids.push_back( boundary_surface.id() ); - } - return block_boundary_uuids; - } - bool is_line_incident_to_another_block_boundary_surface( const geode::Line3D& line, const geode::BRep& brep, - absl::Span< const geode::uuid > block_boundary_uuids, + const geode::Block3D& block, const geode::uuid& boundary_surface_id ) { for( const auto& incident_surface : brep.incidences( line ) ) @@ -103,8 +91,7 @@ namespace { continue; } - if( absl::c_find( block_boundary_uuids, incident_surface.id() ) - != block_boundary_uuids.end() ) + if( brep.is_boundary( incident_surface, block ) ) { return true; } @@ -112,19 +99,18 @@ namespace return false; } - bool surface_should_not_be_boundary_to_block( const geode::uuid& bsurf_uuid, + bool surface_should_not_be_boundary_to_block( + const geode::Surface3D& surface, const geode::BRep& brep, - const std::vector< geode::uuid >& block_boundary_uuids ) + const geode::Block3D& block ) { - const auto& surface = brep.surface( bsurf_uuid ); for( const auto& line : brep.boundaries( surface ) ) { - if( is_line_incident_to_another_block_boundary_surface( - line, brep, block_boundary_uuids, bsurf_uuid ) ) + if( !is_line_incident_to_another_block_boundary_surface( + line, brep, block, surface.id() ) ) { - continue; + return true; } - return true; } return false; } @@ -514,6 +500,13 @@ namespace geode { return std::nullopt; } + for( const auto& block_uuid : block_uuids ) + { + if( !brep_.block( block_uuid ).is_active() ) + { + return std::nullopt; + } + } for( const auto& surface_cmv : brep_.component_mesh_vertices( unique_vertex_index ) ) { @@ -565,6 +558,10 @@ namespace geode internal::vertex_cmvs_by_component( brep_, unique_vertex_index ); for( const auto& block_uuid : block_uuids ) { + if( !brep_.block( block_uuid ).is_active() ) + { + continue; + } if( auto error_message = internal::wrong_nb_expected_block_cmvs( brep_, unique_vertex_index, block_uuid, component_cmvs ) ) { @@ -583,7 +580,8 @@ namespace geode for( const auto& cmv : brep_.component_mesh_vertices( unique_vertex_index ) ) { - if( cmv.component_id.type() != Surface3D::component_type_static() ) + if( cmv.component_id.type() != Surface3D::component_type_static() + || !brep_.surface( cmv.component_id.id() ).is_active() ) { continue; } @@ -632,7 +630,8 @@ namespace geode { const auto surface_uuids = internal::components_uuids( brep_, unique_vertex_index, Surface3D::component_type_static() ); - if( surface_uuids.size() != 1 ) + if( surface_uuids.size() != 1 + || !brep_.surface( surface_uuids[0] ).is_active() ) { return std::nullopt; } @@ -755,55 +754,31 @@ namespace geode BRepBlocksTopology::inspect_blocks() const { BRepBlocksTopologyInspectionResult result; - if( brep_.nb_blocks() == 0 || brep_.nb_active_blocks() == 0 ) + if( brep_.nb_active_blocks() == 0 ) { return result; } - std::vector< geode::uuid > meshed_blocks; const auto not_boundary_surfaces = find_not_boundary_surfaces( brep_ ); const auto dangling_surfaces = find_dangling_surfaces( brep_, not_boundary_surfaces ); - std::vector< geode::uuid > boundary_uuids; - for( const auto& block : brep_.blocks() ) - { - for( const auto& boundary : brep_.boundaries( block ) ) - { - if( absl::c_contains( boundary_uuids, boundary.id() ) ) - { - continue; - } - boundary_uuids.push_back( boundary.id() ); - } - } - for( const auto& boundary : brep_.model_boundaries() ) + std::vector< geode::uuid > blocks_not_meshed; + std::vector< geode::uuid > meshed_blocks; + for( const auto& block : brep_.active_blocks() ) { - if( boundary.component_type_static() - != Surface3D::component_type_static() ) - { - continue; - } - if( absl::c_contains( boundary_uuids, boundary.id() ) ) + if( !block_is_meshed( brep_.block( block.id() ) ) ) { + blocks_not_meshed.push_back( block.id() ); continue; } - boundary_uuids.push_back( boundary.id() ); + meshed_blocks.push_back( block.id() ); } - for( const auto& block : brep_.blocks() ) + if( !blocks_not_meshed.empty() && !meshed_blocks.empty() ) { - if( block_is_meshed( brep_.block( block.id() ) ) ) + for( const auto& block_id : blocks_not_meshed ) { - meshed_blocks.push_back( block.id() ); - } - } - if( meshed_blocks.size() != brep_.nb_blocks() - || meshed_blocks.size() == 0 ) - { - for( const auto& meshed_block_id : meshed_blocks ) - { - result.some_blocks_not_meshed.add_issue( meshed_block_id, - absl::StrCat( "Block ", - brep_.block( meshed_block_id ).name(), " (", - meshed_block_id.string(), ") is not meshed." ) ); + result.some_blocks_not_meshed.add_issue( block_id, + absl::StrCat( "Block ", brep_.block( block_id ).name(), + " (", block_id.string(), ") is not meshed." ) ); } } for( const auto& meshed_block_id : meshed_blocks ) @@ -877,19 +852,20 @@ namespace geode .add_issue( unique_vertex_id, problem_message.value() ); } } - for( const auto& block : brep_.blocks() ) + for( const auto& block : brep_.active_blocks() ) { - const auto block_boundary_uuids = - block_boundary_surfaces( brep_, block ); - for( const auto& bsurf_uuid : block_boundary_uuids ) + for( const auto& surface : brep_.boundaries( block ) ) { + if( !surface.is_active() ) + { + continue; + } if( surface_should_not_be_boundary_to_block( - bsurf_uuid, brep_, block_boundary_uuids ) ) + surface, brep_, block ) ) { - result.wrong_block_boundary_surface.add_issue( bsurf_uuid, - absl::StrCat( "Surface ", - brep_.surface( bsurf_uuid ).name(), " (", - bsurf_uuid.string(), + result.wrong_block_boundary_surface.add_issue( surface.id(), + absl::StrCat( "Surface ", surface.name(), " (", + surface.id().string(), ") should not be boundary of Block ", block.name(), " (", block.id().string(), ") : it has a boundary Line not incident to any " diff --git a/src/geode/inspector/topology/brep_corners_topology.cpp b/src/geode/inspector/topology/brep_corners_topology.cpp index ead7c272..a48ab325 100644 --- a/src/geode/inspector/topology/brep_corners_topology.cpp +++ b/src/geode/inspector/topology/brep_corners_topology.cpp @@ -97,7 +97,8 @@ namespace geode for( const auto& cmv : brep_.component_mesh_vertices( unique_vertex_index ) ) { - if( cmv.component_id.type() != Corner3D::component_type_static() ) + if( cmv.component_id.type() != Corner3D::component_type_static() + || !brep_.corner( cmv.component_id.id() ).is_active() ) { continue; } @@ -151,15 +152,17 @@ namespace geode for( const auto& cmv : brep_.component_mesh_vertices( unique_vertex_index ) ) { - if( cmv.component_id.type() == Corner3D::component_type_static() ) + if( cmv.component_id.type() != Corner3D::component_type_static() + || !brep_.corner( cmv.component_id.id() ).is_active() ) { - if( corner_found ) - { - return absl::StrCat( "unique vertex ", unique_vertex_index, - " is part of several Corners." ); - } - corner_found = true; + continue; + } + if( corner_found ) + { + return absl::StrCat( "unique vertex ", unique_vertex_index, + " is part of several Corners." ); } + corner_found = true; } return std::nullopt; } @@ -172,6 +175,7 @@ namespace geode brep_.component_mesh_vertices( unique_vertex_index ) ) { if( cmv.component_id.type() == Corner3D::component_type_static() + && brep_.corner( cmv.component_id.id() ).is_active() && brep_.nb_embeddings( cmv.component_id.id() ) < 1 && brep_.nb_incidences( cmv.component_id.id() ) < 1 ) { @@ -192,7 +196,8 @@ namespace geode for( const auto& cmv : brep_.component_mesh_vertices( unique_vertex_index ) ) { - if( cmv.component_id.type() != Corner3D::component_type_static() ) + if( cmv.component_id.type() != Corner3D::component_type_static() + || !brep_.corner( cmv.component_id.id() ).is_active() ) { continue; } @@ -201,7 +206,8 @@ namespace geode brep_.component_mesh_vertices( unique_vertex_index ) ) { if( cmv_line.component_id.type() - != Line3D::component_type_static() ) + != Line3D::component_type_static() + || !brep_.line( cmv_line.component_id.id() ).is_active() ) { continue; } @@ -253,7 +259,7 @@ namespace geode BRepCornersTopology::inspect_corners_topology() const { BRepCornersTopologyInspectionResult result; - for( const auto& corner : brep_.corners() ) + for( const auto& corner : brep_.active_corners() ) { if( !corner_is_meshed( brep_.corner( corner.id() ) ) ) { diff --git a/src/geode/inspector/topology/brep_lines_topology.cpp b/src/geode/inspector/topology/brep_lines_topology.cpp index 3d163115..e1850bec 100644 --- a/src/geode/inspector/topology/brep_lines_topology.cpp +++ b/src/geode/inspector/topology/brep_lines_topology.cpp @@ -114,21 +114,25 @@ namespace geode bool BRepLinesTopology::brep_lines_topology_is_valid( index_t unique_vertex_index ) const { - bool part_of_line{ false }; + bool part_of_active_line{ false }; for( const auto& cmv : brep_.component_mesh_vertices( unique_vertex_index ) ) { - if( cmv.component_id.type() == Line3D::component_type_static() ) + if( cmv.component_id.type() == Line3D::component_type_static() + && brep_.line( cmv.component_id.id() ).is_active() ) { - part_of_line = true; + part_of_active_line = true; break; } } - if( !part_of_line ) + if( !part_of_active_line ) { return true; } if( vertex_is_part_of_invalid_embedded_line( unique_vertex_index ) + || vertex_is_part_of_invalid_single_line( unique_vertex_index ) + || vertex_is_part_of_line_with_wrong_relationships_to_surface( + unique_vertex_index ) || vertex_has_lines_but_is_not_a_corner( unique_vertex_index ) ) { return false; @@ -162,14 +166,19 @@ namespace geode { continue; } - const auto line_id = line_cmv.component_id.id(); + const auto& line_id = line_cmv.component_id.id(); + const auto& line = brep_.line( line_id ); + if( !line.is_active() ) + { + continue; + } for( const auto& embedding : brep_.embeddings( line_id ) ) { if( brep_.Relationships::is_boundary( line_id, embedding.id() ) ) { return absl::StrCat( "unique vertex ", unique_vertex_index, - " is part of line ", brep_.line( line_id ).name(), " (", + " is part of line ", line.name(), " (", line_id.string(), "), which is both boundary and embedded in " "Surface ", @@ -188,7 +197,7 @@ namespace geode } ) ) { return absl::StrCat( "unique vertex ", unique_vertex_index, - " is part of Line ", brep_.line( line_id ).name(), " (", + " is part of Line ", line.name(), " (", line_id.string(), "), which is embedded in Surface ", brep_.surface( embedding.id() ).name(), " (", embedding.id().string(), @@ -211,11 +220,16 @@ namespace geode return std::nullopt; } const auto& line_id = line_uuids[0]; + const auto& line = brep_.line( line_id ); + if( !line.is_active() ) + { + return std::nullopt; + } const auto surface_uuids = internal::components_uuids( brep_, unique_vertex_index, Surface3D::component_type_static() ); const auto block_uuids = internal::components_uuids( brep_, unique_vertex_index, Block3D::component_type_static() ); - if( brep_.nb_embedding_surfaces( brep_.line( line_id ) ) < 1 + if( brep_.nb_embedding_surfaces( line ) < 1 && brep_.nb_incidences( line_id ) < 1 ) { return std::nullopt; @@ -228,8 +242,8 @@ namespace geode line_id, surface_uuids[0] ) ) ) { return absl::StrCat( "unique vertex ", unique_vertex_index, - " is part of only one Line ", brep_.line( line_id ).name(), - " (", line_id.string(), "), and only one Surface ", + " is part of only one Line ", line.name(), " (", + line_id.string(), "), and only one Surface ", brep_.surface( surface_uuids[0] ).name(), " (", surface_uuids[0].string(), "), but the Line is neither embedded in the " @@ -246,15 +260,15 @@ namespace geode if( block_uuids.size() != 1 ) { return absl::StrCat( "unique vertex ", unique_vertex_index, - " is part of only one Line ", brep_.line( line_id ).name(), - " (", line_id.string(), "), no Surfaces, but is part of ", + " is part of only one Line ", line.name(), " (", + line_id.string(), "), no Surfaces, but is part of ", block_uuids.size(), " Blocks, instead of one." ); } if( !brep_.Relationships::is_internal( line_id, block_uuids[0] ) ) { return absl::StrCat( "unique vertex ", unique_vertex_index, - " is part of only one Line ", brep_.line( line_id ).name(), - " (", line_id.string(), + " is part of only one Line ", line.name(), " (", + line_id.string(), "), no Surfaces, one Block, but the Line is not " "internal to the Block." ); } @@ -263,17 +277,17 @@ namespace geode { for( const auto& surface_id : surface_uuids ) { - if( !brep_.Relationships::is_boundary( line_id, surface_id ) - && !brep_.Relationships::is_internal( - line_id, surface_id ) ) + const auto& surface = brep_.surface( surface_id ); + if( !brep_.is_boundary( line, surface ) + && !brep_.is_internal( line, surface ) ) { return absl::StrCat( "unique vertex ", unique_vertex_index, - " is part of only one Line ", - brep_.line( line_id ).name(), " (", line_id.string(), + " is part of only one Line ", line.name(), " (", + line_id.string(), "), and multiple Surfaces, but the Line is " "neither internal nor boundary of Surface ", - brep_.surface( surface_id ).name(), " (", - surface_id.string(), "), in which the vertex is." ); + surface.name(), " (", surface_id.string(), + "), in which the vertex is." ); } } } @@ -291,82 +305,78 @@ namespace geode { continue; } - if( brep_.line( cmv.component_id.id() ).mesh().nb_edges() == 0 ) + const auto& line = brep_.line( cmv.component_id.id() ); + if( !line.is_active() || line.mesh().nb_edges() == 0 ) { continue; } - const auto cme = geode::component_mesh_edges( - brep_, brep_.line( cmv.component_id.id() ), 0 ); - for( const auto& incident_surface : - brep_.incidences( brep_.line( cmv.component_id.id() ) ) ) + const auto cme = geode::component_mesh_edges( brep_, line, 0 ); + for( const auto& incident_surface : brep_.incidences( line ) ) { + if( !incident_surface.is_active() ) + { + continue; + } if( !cme.surface_edges.contains( incident_surface.id() ) ) { return absl::StrCat( "unique vertex ", unique_vertex_index, - " is part of Line ", - brep_.line( cmv.component_id.id() ).name(), " (", - cmv.component_id.id().string(), + " is part of Line ", line.name(), " (", + line.id().string(), "), which should be boundary of Surface ", - brep_.surface( incident_surface.id() ).name(), " (", + incident_surface.name(), " (", incident_surface.id().string(), ")" ); } - const auto& surface_edges = - cme.surface_edges.at( incident_surface.id() ); - if( surface_edges.size() != 1 ) + if( cme.surface_edges.at( incident_surface.id() ).size() != 1 ) { return absl::StrCat( "unique vertex ", unique_vertex_index, - " is part of Line ", - brep_.line( cmv.component_id.id() ).name(), " (", + " is part of Line ", line.name(), " (", cmv.component_id.id().string(), "), which should not be boundary of Surface ", - brep_.surface( incident_surface.id() ).name(), " (", + incident_surface.name(), " (", incident_surface.id().string(), ")" ); } } - for( const auto& embedding_surface : brep_.embedding_surfaces( - brep_.line( cmv.component_id.id() ) ) ) + for( const auto& embedding_surface : + brep_.embedding_surfaces( line ) ) { + if( !embedding_surface.is_active() ) + { + continue; + } if( !cme.surface_edges.contains( embedding_surface.id() ) ) { return absl::StrCat( "unique vertex ", unique_vertex_index, - " is part of Line ", - brep_.line( cmv.component_id.id() ).name(), " (", + " is part of Line ", line.name(), " (", cmv.component_id.id().string(), "', which should be embedded in Surface ", - brep_.surface( embedding_surface.id() ).name(), " (", + embedding_surface.name(), " (", embedding_surface.id().string(), "'" ); } - const auto& surface_edges = - cme.surface_edges.at( embedding_surface.id() ); - if( surface_edges.size() <= 1 ) + if( cme.surface_edges.at( embedding_surface.id() ).size() <= 1 ) { return absl::StrCat( "unique vertex ", unique_vertex_index, - " is part of Line ", - brep_.line( cmv.component_id.id() ).name(), " (", + " is part of Line ", line.name(), " (", cmv.component_id.id().string(), "), which is embedded in Surface ", - brep_.surface( embedding_surface.id() ).name(), " (", + embedding_surface.name(), " (", embedding_surface.id().string(), ") but doesn't cut it" ); } } - if( brep_.nb_incidences( cmv.component_id.id() ) < 1 - && brep_.nb_embedding_surfaces( - brep_.line( cmv.component_id.id() ) ) - < 1 ) + if( brep_.nb_incidences( cmv.component_id.id() ) == 0 + && brep_.nb_embedding_surfaces( line ) == 0 ) { - for( const auto& surface : brep_.surfaces() ) + for( const auto& [surface_id, _] : cme.surface_edges ) { - if( cme.surface_edges.contains( surface.id() ) ) + if( brep_.surface( surface_id ).is_active() ) { return absl::StrCat( "unique vertex ", unique_vertex_index, " is part of Line ", - brep_.line( cmv.component_id.id() ).name(), " (", - cmv.component_id.id().string(), + line.name(), " (", cmv.component_id.id().string(), "), which should be internal or boundary to " "Surface ", - brep_.surface( surface.id() ).name(), " (", - surface.id().string(), ")" ); + brep_.surface( surface_id ).name(), " (", + surface_id.string(), ")" ); } } } @@ -387,8 +397,8 @@ namespace geode { is_a_corner = true; } - else if( cmv.component_id.type() - == Line3D::component_type_static() ) + else if( cmv.component_id.type() == Line3D::component_type_static() + && brep_.line( cmv.component_id.id() ).is_active() ) { nb_lines++; } @@ -408,47 +418,52 @@ namespace geode const auto cme = component_mesh_edges( brep_, line, edge_index ); for( const auto& [surface_id, surface_edges] : cme.surface_edges ) { - if( brep_.is_boundary( line, brep_.surface( surface_id ) ) ) + const auto& surface = brep_.surface( surface_id ); + if( !surface.is_active() ) + { + continue; + } + if( brep_.is_boundary( line, surface ) ) { if( surface_edges.size() != 1 ) { return absl::StrCat( "Line ", line.name(), " (", line.id().string(), ") is boundary of Surface ", - brep_.surface( surface_id ).name(), " (", - surface_id.string(), "), but has ", - surface_edges.size(), + surface.name(), " (", surface_id.string(), + "), but has ", surface_edges.size(), " edges of this Surface around it, it should be 1." ); } continue; } - if( brep_.is_internal( line, brep_.surface( surface_id ) ) ) + if( brep_.is_internal( line, surface ) ) { if( surface_edges.size() != 2 ) { return absl::StrCat( "Line with uuid '", line.id().string(), - "' is internal to surface with uuid '", - surface_id.string(), "', but has ", + "' is internal to Surface ", surface.name(), " (", + surface_id.string(), "), but has ", surface_edges.size(), " edges of this surface around it, it should be 2." ); } continue; } return absl::StrCat( "Line with uuid '", line.id().string(), - "' has edge with id ", edge_index, - " in common with surface with uuid '", surface_id.string(), - "', but is neither boundary of nor internal to it." ); + "' has edge with id ", edge_index, " in common with Surface ", + surface.name(), " (", surface_id.string(), + "), but is neither boundary of nor internal to it." ); } for( const auto& [block_id, block_edges] : cme.block_edges ) { - if( brep_.is_internal( line, brep_.block( block_id ) ) ) + const auto& block = brep_.block( block_id ); + if( block.is_active() && brep_.is_internal( line, block ) ) { if( block_edges.size() != 1 ) { return absl::StrCat( "Line ", line.name(), " (", line.id().string(), ") is internal to Block ", - brep_.block( block_id ).name(), " (", block_id.string(), - "), but has ", block_edges.size(), - " edges of this Surface around it, it should be 1." ); + block.name(), " (", block_id.string(), "), but has ", + block_edges.size(), + " edges of this Block around it, it should be 1." ); } continue; } @@ -460,7 +475,7 @@ namespace geode BRepLinesTopology::inspect_lines_topology() const { BRepLinesTopologyInspectionResult result; - for( const auto& line : brep_.lines() ) + for( const auto& line : brep_.active_lines() ) { if( !line_is_meshed( brep_.line( line.id() ) ) ) { diff --git a/src/geode/inspector/topology/brep_surfaces_topology.cpp b/src/geode/inspector/topology/brep_surfaces_topology.cpp index 649f8c1a..29479e13 100644 --- a/src/geode/inspector/topology/brep_surfaces_topology.cpp +++ b/src/geode/inspector/topology/brep_surfaces_topology.cpp @@ -115,7 +115,8 @@ namespace geode for( const auto& cmv : brep_.component_mesh_vertices( unique_vertex_index ) ) { - if( cmv.component_id.type() == Surface3D::component_type_static() ) + if( cmv.component_id.type() == Surface3D::component_type_static() + && brep_.surface( cmv.component_id.id() ).is_active() ) { surface_found = true; break; @@ -160,18 +161,26 @@ namespace geode for( const auto surface_id : internal::components_uuids( brep_, unique_vertex_index, Surface3D::component_type_static() ) ) { + const auto& surface = brep_.surface( surface_id ); + if( !surface.is_active() ) + { + continue; + } for( const auto& embedding : brep_.embeddings( surface_id ) ) { + const auto& block = brep_.block( embedding.id() ); + if( !block.is_active() ) + { + continue; + } if( brep_.Relationships::is_boundary( surface_id, embedding.id() ) ) { return absl::StrCat( "unique vertex ", unique_vertex_index, - " is part of Surface ", - brep_.surface( surface_id ).name(), " (", + " is part of Surface ", surface.name(), " (", surface_id.string(), "), which is both internal and boundary of ", "Block ", - brep_.block( embedding.id() ).name(), " (", - embedding.id().string(), ")" ); + block.name(), " (", embedding.id().string(), ")" ); } if( internal::brep_blocks_are_meshed( brep_ ) && !absl::c_any_of( @@ -181,11 +190,9 @@ namespace geode } ) ) { return absl::StrCat( "unique vertex ", unique_vertex_index, - " is part of Surface ", - brep_.surface( surface_id ).name(), " (", + " is part of Surface ", surface.name(), " (", surface_id.string(), "), which is embedded in Block ", - brep_.block( embedding.id() ).name(), " (", - embedding.id().string(), + block.name(), " (", embedding.id().string(), "), but the unique vertex is not linked to any " "of the Block vertices." ); } @@ -200,7 +207,11 @@ namespace geode { const auto surface_uuids = internal::components_uuids( brep_, unique_vertex_index, Surface3D::component_type_static() ); - if( surface_uuids.size() < 2 ) + if( absl::c_count_if( surface_uuids, + [*this]( const uuid& surface_id ) { + return brep_.surface( surface_id ).is_active(); + } ) + < 2 ) { return std::nullopt; } @@ -208,79 +219,85 @@ namespace geode brep_, unique_vertex_index, Line3D::component_type_static() ); if( line_uuids.empty() ) { - bool is_corner_internal_to_all_surfaces{ true }; + bool has_corner_internal_to_all_surfaces{ false }; for( const auto& cmv : brep_.component_mesh_vertices( unique_vertex_index ) ) { if( cmv.component_id.type() - == Corner3D::component_type_static() ) + != Corner3D::component_type_static() ) { - if( brep_.Relationships::nb_embeddings( - cmv.component_id.id() ) - != surface_uuids.size() ) + continue; + } + const auto& corner = brep_.corner( cmv.component_id.id() ); + for( const auto& surface_id : surface_uuids ) + { + const auto& surface = brep_.surface( surface_id ); + if( surface.is_active() + && !brep_.is_internal( corner, surface ) ) { - is_corner_internal_to_all_surfaces = false; + return absl::StrCat( "unique vertex ", + unique_vertex_index, + " is part of multiple active Surfaces, and not " + "part of any Line, but is part of Corner ", + corner.name(), " (", corner.id().string(), + "), which is not internal to active Surface ", + surface.name(), " (", surface_id.string(), ")." ); } } + has_corner_internal_to_all_surfaces = true; } - if( !is_corner_internal_to_all_surfaces ) + if( !has_corner_internal_to_all_surfaces ) { return absl::StrCat( "unique vertex ", unique_vertex_index, " ", - " is part of multiple Surfaces, but not part of any " - "Line and there is no internal Corner to all Surfaces." ); + " is part of multiple active Surfaces, and not part of any " + "Line, but not part of any Corner internal to all " + "Surfaces." ); } } if( line_uuids.size() == 1 ) { - bool corner_found{ false }; - bool - is_corner_internal_to_surfaces_with_no_relationship_to_the_line{ - true - }; index_t nb_cmv_lines{ 0 }; - index_t nb_of_relationships_with_surfaces{ 0 }; + index_t nb_of_line_relationships_with_surfaces{ 0 }; for( const auto& cmv : brep_.component_mesh_vertices( unique_vertex_index ) ) { - if( cmv.component_id.type() == Line3D::component_type_static() ) + if( cmv.component_id.type() != Line3D::component_type_static() ) + { + continue; + } + nb_cmv_lines += 1; + for( const auto& surface_id : surface_uuids ) { - nb_cmv_lines += 1; - for( const auto& surface_id : surface_uuids ) + if( brep_.Relationships::is_boundary( + cmv.component_id.id(), surface_id ) + || brep_.Relationships::is_internal( + cmv.component_id.id(), surface_id ) ) { - if( brep_.Relationships::is_boundary( - cmv.component_id.id(), surface_id ) - || brep_.Relationships::is_internal( - cmv.component_id.id(), surface_id ) ) - { - nb_of_relationships_with_surfaces += 1; - } + nb_of_line_relationships_with_surfaces += 1; } } } + if( nb_cmv_lines >= 2 ) + { + return std::nullopt; + } for( const auto& cmv : brep_.component_mesh_vertices( unique_vertex_index ) ) { if( cmv.component_id.type() - == Corner3D::component_type_static() ) + != Corner3D::component_type_static() ) { - if( brep_.Relationships::nb_embeddings( - cmv.component_id.id() ) - + nb_of_relationships_with_surfaces - != surface_uuids.size() ) - { - is_corner_internal_to_surfaces_with_no_relationship_to_the_line = - false; - } - corner_found = true; + continue; + } + if( brep_.Relationships::nb_embeddings( cmv.component_id.id() ) + + nb_of_line_relationships_with_surfaces + != surface_uuids.size() ) + { + return absl::StrCat( "unique vertex ", unique_vertex_index, + " is part of multiple active Surfaces and only one " + "Line, is a Corner, but is not internal to all the " + "Surfaces without relationships to the Line." ); } - } - if( corner_found && nb_cmv_lines < 2 - && !is_corner_internal_to_surfaces_with_no_relationship_to_the_line ) - { - return absl::StrCat( "unique vertex ", unique_vertex_index, - " is part of multiple Surfaces and only one Line, " - "but is a Corner not internal to all Surfaces without " - "relationship to the Line." ); } } return std::nullopt; @@ -311,13 +328,13 @@ namespace geode for( const auto& line_id : line_uuids ) { const auto& line = brep_.line( line_id ); - if( brep_.is_boundary( line, surface ) - || brep_.is_internal( line, surface ) ) + if( line.is_active() + && ( brep_.is_boundary( line, surface ) + || brep_.is_internal( line, surface ) ) ) { return absl::StrCat( "unique vertex ", unique_vertex_index, - " is part of a Line and of Surface ", - brep_.surface( cmv.component_id.id() ).name(), " (", - cmv.component_id.id().string(), + " is part of a Line and of Surface ", surface.name(), + " (", cmv.component_id.id().string(), ") but the associated vertex in the " "Surface mesh is not on the mesh border." ); } @@ -333,34 +350,38 @@ namespace geode const auto cmp = component_mesh_polygons( brep_, surface, facet_index ); for( const auto& [block_id, block_facets] : cmp.block_polygons ) { - if( brep_.is_boundary( surface, brep_.block( block_id ) ) ) + const auto& block = brep_.block( block_id ); + if( !block.is_active() ) + { + continue; + } + if( brep_.is_boundary( surface, block ) ) { if( block_facets.size() != 1 ) { return absl::StrCat( "Surface ", surface.name(), " (", surface.id().string(), ") is boundary of block ", - brep_.block( block_id ).name(), " (", block_id.string(), - "), but has ", block_facets.size(), + block.name(), " (", block_id.string(), "), but has ", + block_facets.size(), " facets of this Block around it, it should be 1." ); } continue; } - if( brep_.is_internal( surface, brep_.block( block_id ) ) ) + if( brep_.is_internal( surface, block ) ) { if( block_facets.size() != 2 ) { return absl::StrCat( "Surface ", surface.name(), " (", surface.id().string(), ") is internal to block ", - brep_.block( block_id ).name(), " (", block_id.string(), - "), but has ", block_facets.size(), + block.name(), " (", block_id.string(), "), but has ", + block_facets.size(), " facets of this Block around it, it should be 2." ); } continue; } return absl::StrCat( "Surface ", surface.name(), " (", surface.id().string(), ") has facet with id ", facet_index, - " in common with Block", brep_.block( block_id ).name(), " (", - block_id.string(), + " in common with Block", block.name(), " (", block_id.string(), "), but is neither boundary of nor internal to it." ); } return std::nullopt; @@ -371,7 +392,7 @@ namespace geode { BRepSurfacesTopologyInspectionResult result; const auto meshed_blocks = internal::brep_blocks_are_meshed( brep_ ); - for( const auto& surface : brep_.surfaces() ) + for( const auto& surface : brep_.active_surfaces() ) { if( !surface_is_meshed( brep_.surface( surface.id() ) ) ) { diff --git a/src/geode/inspector/topology/brep_topology.cpp b/src/geode/inspector/topology/brep_topology.cpp index 565fc444..4ba728de 100644 --- a/src/geode/inspector/topology/brep_topology.cpp +++ b/src/geode/inspector/topology/brep_topology.cpp @@ -83,15 +83,15 @@ namespace geode } for( const auto& cmv : unique_vertex_cmvs ) { - if( cmv_exists_in_brep( cmv ) ) + if( !cmv_exists_in_brep( cmv ) ) { - if( brep_.unique_vertex( cmv ) != uv_id ) - { - return false; - } - continue; + return false; + } + if( brep_.component( cmv.component_id.id() ).is_active() + && brep_.unique_vertex( cmv ) != uv_id ) + { + return false; } - return false; } } return true; @@ -119,21 +119,22 @@ namespace geode } for( const auto& cmv : unique_vertex_cmvs ) { - if( cmv_exists_in_brep( cmv ) ) + if( !cmv_exists_in_brep( cmv ) ) { - if( brep_.unique_vertex( cmv ) != uv_id ) - { - linked_to_nonbijective_result.add_issue( uv_id, - absl::StrCat( "unique vertex ", uv_id, - " is linked to inexistant mesh vertex [", - cmv.string(), "]." ) ); - } + linked_to_inexistant_result.add_issue( + uv_id, absl::StrCat( "unique vertex ", uv_id, + " is linked to inexistant mesh vertex [", + cmv.string(), "]." ) ); continue; } - linked_to_inexistant_result.add_issue( - uv_id, absl::StrCat( "unique vertex ", uv_id, - " is linked to inexistant mesh vertex [", - cmv.string(), "]." ) ); + if( brep_.component( cmv.component_id.id() ).is_active() + && brep_.unique_vertex( cmv ) != uv_id ) + { + linked_to_nonbijective_result.add_issue( + uv_id, absl::StrCat( "unique vertex ", uv_id, + " is linked to inexistant mesh vertex [", + cmv.string(), "]." ) ); + } } } } @@ -245,7 +246,7 @@ namespace geode bool brep_meshed_components_are_linked_to_unique_vertices( const BRepTopologyInspector& topology_inspector ) const { - for( const auto& corner : brep_.corners() ) + for( const auto& corner : brep_.active_corners() ) { if( topology_inspector.corner_is_meshed( corner ) && !topology_inspector @@ -255,7 +256,7 @@ namespace geode return false; } } - for( const auto& line : brep_.lines() ) + for( const auto& line : brep_.active_lines() ) { if( topology_inspector.line_is_meshed( line ) && !topology_inspector @@ -265,7 +266,7 @@ namespace geode return false; } } - for( const auto& surface : brep_.surfaces() ) + for( const auto& surface : brep_.active_surfaces() ) { if( topology_inspector.surface_is_meshed( surface ) && !topology_inspector @@ -275,7 +276,7 @@ namespace geode return false; } } - for( const auto& block : brep_.blocks() ) + for( const auto& block : brep_.active_blocks() ) { if( topology_inspector.block_is_meshed( block ) && !topology_inspector diff --git a/src/geode/inspector/topology/section_corners_topology.cpp b/src/geode/inspector/topology/section_corners_topology.cpp index 004d8518..d81ddfd6 100644 --- a/src/geode/inspector/topology/section_corners_topology.cpp +++ b/src/geode/inspector/topology/section_corners_topology.cpp @@ -106,7 +106,8 @@ namespace geode for( const auto& cmv : section_.component_mesh_vertices( unique_vertex_index ) ) { - if( cmv.component_id.type() != Corner2D::component_type_static() ) + if( cmv.component_id.type() != Corner2D::component_type_static() + || !section_.corner( cmv.component_id.id() ).is_active() ) { continue; } @@ -172,15 +173,17 @@ namespace geode for( const auto& cmv : section_.component_mesh_vertices( unique_vertex_index ) ) { - if( cmv.component_id.type() == Corner2D::component_type_static() ) + if( cmv.component_id.type() != Corner2D::component_type_static() + || !section_.corner( cmv.component_id.id() ).is_active() ) { - if( corner_found ) - { - return absl::StrCat( "unique vertex ", unique_vertex_index, - " is part of several Corners." ); - } - corner_found = true; + continue; } + if( corner_found ) + { + return absl::StrCat( "unique vertex ", unique_vertex_index, + " is part of several Corners." ); + } + corner_found = true; } return std::nullopt; } @@ -193,6 +196,7 @@ namespace geode section_.component_mesh_vertices( unique_vertex_index ) ) { if( cmv.component_id.type() == Corner2D::component_type_static() + && section_.corner( cmv.component_id.id() ).is_active() && section_.nb_embeddings( cmv.component_id.id() ) > 1 ) { return absl::StrCat( "unique vertex ", unique_vertex_index, @@ -213,6 +217,7 @@ namespace geode section_.component_mesh_vertices( unique_vertex_index ) ) { if( cmv.component_id.type() == Corner2D::component_type_static() + && section_.corner( cmv.component_id.id() ).is_active() && section_.nb_embeddings( cmv.component_id.id() ) < 1 && section_.nb_incidences( cmv.component_id.id() ) < 1 ) { @@ -233,7 +238,8 @@ namespace geode for( const auto& cmv : section_.component_mesh_vertices( unique_vertex_index ) ) { - if( cmv.component_id.type() != Corner2D::component_type_static() ) + if( cmv.component_id.type() != Corner2D::component_type_static() + || !section_.corner( cmv.component_id.id() ).is_active() ) { continue; } @@ -266,7 +272,7 @@ namespace geode SectionCornersTopology::inspect_corners_topology() const { SectionCornersTopologyInspectionResult result; - for( const auto& corner : section_.corners() ) + for( const auto& corner : section_.active_corners() ) { if( !corner_is_meshed( section_.corner( corner.id() ) ) ) { diff --git a/src/geode/inspector/topology/section_lines_topology.cpp b/src/geode/inspector/topology/section_lines_topology.cpp index 9d78ffdc..c3794d87 100644 --- a/src/geode/inspector/topology/section_lines_topology.cpp +++ b/src/geode/inspector/topology/section_lines_topology.cpp @@ -116,7 +116,8 @@ namespace geode for( const auto& cmv : section_.component_mesh_vertices( unique_vertex_index ) ) { - if( cmv.component_id.type() == Line2D::component_type_static() ) + if( cmv.component_id.type() == Line2D::component_type_static() + && section_.line( cmv.component_id.id() ).is_active() ) { is_a_line = true; break; @@ -158,7 +159,8 @@ namespace geode for( const auto& cmv : section_.component_mesh_vertices( unique_vertex_index ) ) { - if( cmv.component_id.type() != Line2D::component_type_static() ) + if( cmv.component_id.type() != Line2D::component_type_static() + || !section_.line( cmv.component_id.id() ).is_active() ) { continue; } @@ -182,8 +184,8 @@ namespace geode for( const auto& line_cmv : section_.component_mesh_vertices( unique_vertex_index ) ) { - if( line_cmv.component_id.type() - != Line2D::component_type_static() ) + if( line_cmv.component_id.type() != Line2D::component_type_static() + || !section_.line( line_cmv.component_id.id() ).is_active() ) { continue; } @@ -210,6 +212,10 @@ namespace geode for( const auto& embedding : section_.embeddings( line_cmv.component_id.id() ) ) { + if( !section_.surface( embedding.id() ).is_active() ) + { + continue; + } if( internal::section_surfaces_are_meshed( section_ ) && !absl::c_any_of( section_.component_mesh_vertices( unique_vertex_index ), @@ -238,7 +244,8 @@ namespace geode { const auto line_uuids = internal::components_uuids( section_, unique_vertex_index, Line2D::component_type_static() ); - if( line_uuids.size() != 1 ) + if( line_uuids.size() != 1 + || !section_.line( line_uuids[0] ).is_active() ) { return std::nullopt; } @@ -297,7 +304,8 @@ namespace geode for( const auto& cmv : section_.component_mesh_vertices( unique_vertex_index ) ) { - if( cmv.component_id.type() == Line2D::component_type_static() ) + if( cmv.component_id.type() == Line2D::component_type_static() + && section_.line( cmv.component_id.id() ).is_active() ) { nb_cmv_lines += 1; } @@ -319,7 +327,7 @@ namespace geode SectionLinesTopology::inspect_lines_topology() const { SectionLinesTopologyInspectionResult result; - for( const auto& line : section_.lines() ) + for( const auto& line : section_.active_lines() ) { if( !line_is_meshed( section_.line( line.id() ) ) ) { diff --git a/src/geode/inspector/topology/section_surfaces_topology.cpp b/src/geode/inspector/topology/section_surfaces_topology.cpp index fbcdfa5e..16bd2422 100644 --- a/src/geode/inspector/topology/section_surfaces_topology.cpp +++ b/src/geode/inspector/topology/section_surfaces_topology.cpp @@ -100,7 +100,8 @@ namespace geode for( const auto& cmv : section_.component_mesh_vertices( unique_vertex_index ) ) { - if( cmv.component_id.type() != Surface2D::component_type_static() ) + if( cmv.component_id.type() != Surface2D::component_type_static() + || !section_.surface( cmv.component_id.id() ).is_active() ) { continue; } @@ -175,8 +176,8 @@ namespace geode for( const auto& line_cmv : section_.component_mesh_vertices( unique_vertex_index ) ) { - if( line_cmv.component_id.type() - != Line2D::component_type_static() ) + if( line_cmv.component_id.type() != Line2D::component_type_static() + || !section_.line( line_cmv.component_id.id() ).is_active() ) { continue; } @@ -184,7 +185,9 @@ namespace geode section_.component_mesh_vertices( unique_vertex_index ) ) { if( surface_cmv.component_id.type() - != Surface2D::component_type_static() ) + != Surface2D::component_type_static() + || !section_.surface( surface_cmv.component_id.id() ) + .is_active() ) { continue; } @@ -209,7 +212,7 @@ namespace geode SectionSurfacesTopology::inspect_surfaces() const { SectionSurfacesTopologyInspectionResult result; - for( const auto& surface : section_.surfaces() ) + for( const auto& surface : section_.active_surfaces() ) { if( !surface_is_meshed( section_.surface( surface.id() ) ) ) { diff --git a/src/geode/inspector/topology/section_topology.cpp b/src/geode/inspector/topology/section_topology.cpp index be5ce65e..0ce52fbb 100644 --- a/src/geode/inspector/topology/section_topology.cpp +++ b/src/geode/inspector/topology/section_topology.cpp @@ -78,15 +78,15 @@ namespace geode } for( const auto& cmv : unique_vertex_cmvs ) { - if( cmv_exists_in_section( cmv ) ) + if( !cmv_exists_in_section( cmv ) ) { - if( section_.unique_vertex( cmv ) != uv_id ) - { - return false; - } - continue; + return false; + } + if( section_.component( cmv.component_id.id() ).is_active() + && section_.unique_vertex( cmv ) != uv_id ) + { + return false; } - return false; } } return true; @@ -114,21 +114,22 @@ namespace geode } for( const auto& cmv : unique_vertex_cmvs ) { - if( cmv_exists_in_section( cmv ) ) + if( !cmv_exists_in_section( cmv ) ) { - if( section_.unique_vertex( cmv ) != uv_id ) - { - linked_to_nonbijective_result.add_issue( uv_id, - absl::StrCat( "unique vertex ", uv_id, - " is linked to inexistant mesh vertex [", - cmv.string(), "]." ) ); - } + linked_to_inexistant_result.add_issue( + uv_id, absl::StrCat( "unique vertex ", uv_id, + " is linked to inexistant mesh vertex [", + cmv.string(), "]." ) ); continue; } - linked_to_inexistant_result.add_issue( - uv_id, absl::StrCat( "unique vertex ", uv_id, - " is linked to inexistant mesh vertex [", - cmv.string(), "]." ) ); + if( section_.component( cmv.component_id.id() ).is_active() + && section_.unique_vertex( cmv ) != uv_id ) + { + linked_to_nonbijective_result.add_issue( + uv_id, absl::StrCat( "unique vertex ", uv_id, + " is linked to inexistant mesh vertex [", + cmv.string(), "]." ) ); + } } } } @@ -217,7 +218,7 @@ namespace geode bool section_meshed_components_are_linked_to_unique_vertices( const SectionTopologyInspector& topology_inspector ) const { - for( const auto& corner : section_.corners() ) + for( const auto& corner : section_.active_corners() ) { if( topology_inspector.corner_is_meshed( corner ) && !topology_inspector @@ -227,7 +228,7 @@ namespace geode return false; } } - for( const auto& line : section_.lines() ) + for( const auto& line : section_.active_lines() ) { if( topology_inspector.line_is_meshed( line ) && !topology_inspector @@ -237,7 +238,7 @@ namespace geode return false; } } - for( const auto& surface : section_.surfaces() ) + for( const auto& surface : section_.active_surfaces() ) { if( topology_inspector.surface_is_meshed( surface ) && !topology_inspector From 2222bda19230c02638a87eb000e91b74898a1649 Mon Sep 17 00:00:00 2001 From: MelchiorSchuh Date: Thu, 8 Jan 2026 17:07:59 +0100 Subject: [PATCH 2/2] changes to make PR pass --- .../topology/brep_surfaces_topology.cpp | 77 ++++++++++--------- 1 file changed, 40 insertions(+), 37 deletions(-) diff --git a/src/geode/inspector/topology/brep_surfaces_topology.cpp b/src/geode/inspector/topology/brep_surfaces_topology.cpp index 29479e13..8b97a87a 100644 --- a/src/geode/inspector/topology/brep_surfaces_topology.cpp +++ b/src/geode/inspector/topology/brep_surfaces_topology.cpp @@ -31,6 +31,7 @@ #include +#include #include #include @@ -217,43 +218,45 @@ namespace geode } const auto line_uuids = internal::components_uuids( brep_, unique_vertex_index, Line3D::component_type_static() ); - if( line_uuids.empty() ) - { - bool has_corner_internal_to_all_surfaces{ false }; - for( const auto& cmv : - brep_.component_mesh_vertices( unique_vertex_index ) ) - { - if( cmv.component_id.type() - != Corner3D::component_type_static() ) - { - continue; - } - const auto& corner = brep_.corner( cmv.component_id.id() ); - for( const auto& surface_id : surface_uuids ) - { - const auto& surface = brep_.surface( surface_id ); - if( surface.is_active() - && !brep_.is_internal( corner, surface ) ) - { - return absl::StrCat( "unique vertex ", - unique_vertex_index, - " is part of multiple active Surfaces, and not " - "part of any Line, but is part of Corner ", - corner.name(), " (", corner.id().string(), - "), which is not internal to active Surface ", - surface.name(), " (", surface_id.string(), ")." ); - } - } - has_corner_internal_to_all_surfaces = true; - } - if( !has_corner_internal_to_all_surfaces ) - { - return absl::StrCat( "unique vertex ", unique_vertex_index, " ", - " is part of multiple active Surfaces, and not part of any " - "Line, but not part of any Corner internal to all " - "Surfaces." ); - } - } + // if( line_uuids.empty() ) + // { + // bool has_corner_internal_to_all_surfaces{ false }; + // for( const auto& cmv : + // brep_.component_mesh_vertices( unique_vertex_index ) ) + // { + // if( cmv.component_id.type() + // != Corner3D::component_type_static() ) + // { + // continue; + // } + // const auto& corner = brep_.corner( cmv.component_id.id() ); + // for( const auto& surface_id : surface_uuids ) + // { + // const auto& surface = brep_.surface( surface_id ); + // if( surface.is_active() + // && !brep_.is_internal( corner, surface ) ) + // { + // return absl::StrCat( "unique vertex ", + // unique_vertex_index, " at position [", + // corner.mesh().point( cmv.vertex ).string(), + // "] is part of multiple active Surfaces, and not " + // "part of any Line, but is part of Corner ", + // corner.name(), " (", corner.id().string(), + // "), which is not internal to active Surface ", + // surface.name(), " (", surface_id.string(), ")." + // ); + // } + // } + // has_corner_internal_to_all_surfaces = true; + // } + // if( !has_corner_internal_to_all_surfaces ) + // { + // return absl::StrCat( "unique vertex ", unique_vertex_index, + // " is part of multiple active Surfaces, and not part of " + // "any Line, but not part of any Corner internal to all " + // "Surfaces." ); + // } + // } if( line_uuids.size() == 1 ) { index_t nb_cmv_lines{ 0 };