4444
4545namespace
4646{
47+ std::vector< geode::uuid > block_boundary_surfaces (
48+ const geode::BRep& brep, const geode::Block3D& block )
49+ {
50+ std::vector< geode::uuid > block_boundary_uuids;
51+ block_boundary_uuids.reserve ( brep.nb_boundaries ( block.id () ) );
52+ for ( const auto & boundary_surface : brep.boundaries ( block ) )
53+ {
54+ block_boundary_uuids.push_back ( boundary_surface.id () );
55+ }
56+ return block_boundary_uuids;
57+ }
58+
59+ bool is_line_incident_to_another_block_boundary_surface (
60+ const geode::Line3D& line,
61+ const geode::BRep& brep,
62+ absl::Span< const geode::uuid > block_boundary_uuids,
63+ const geode::uuid& boundary_surface_id )
64+ {
65+ for ( const auto & incident_surface : brep.incidences ( line ) )
66+ {
67+ if ( incident_surface.id () == boundary_surface_id )
68+ {
69+ continue ;
70+ }
71+ if ( absl::c_find ( block_boundary_uuids, incident_surface.id () )
72+ != block_boundary_uuids.end () )
73+ {
74+ return true ;
75+ }
76+ }
77+ return false ;
78+ }
79+
80+ bool surface_should_not_be_boundary_to_block ( const geode::uuid& bsurf_uuid,
81+ const geode::BRep& brep,
82+ const std::vector< geode::uuid >& block_boundary_uuids )
83+ {
84+ const auto & surface = brep.surface ( bsurf_uuid );
85+ for ( const auto & line : brep.boundaries ( surface ) )
86+ {
87+ if ( is_line_incident_to_another_block_boundary_surface (
88+ line, brep, block_boundary_uuids, bsurf_uuid ) )
89+ {
90+ continue ;
91+ }
92+ return true ;
93+ }
94+ return false ;
95+ }
96+
4797 template < typename Condition >
4898 geode::index_t count_cmvs (
4999 absl::Span< const geode::ComponentMeshVertex > cmvs,
@@ -66,6 +116,11 @@ namespace geode
66116 std::string BRepBlocksTopologyInspectionResult::string () const
67117 {
68118 std::string message;
119+ if ( wrong_block_boundary_surface.nb_issues () != 0 )
120+ {
121+ absl::StrAppend (
122+ &message, wrong_block_boundary_surface.string (), " \n " );
123+ }
69124 if ( blocks_not_meshed.nb_issues () != 0 )
70125 {
71126 absl::StrAppend ( &message, blocks_not_meshed.string (), " \n " );
@@ -371,6 +426,25 @@ namespace geode
371426 .add_issue ( unique_vertex_id, problem_message.value () );
372427 }
373428 }
429+ for ( const auto & block : brep_.blocks () )
430+ {
431+ const auto block_boundary_uuids =
432+ block_boundary_surfaces ( brep_, block );
433+ for ( const auto & bsurf_uuid : block_boundary_uuids )
434+ {
435+ if ( surface_should_not_be_boundary_to_block (
436+ bsurf_uuid, brep_, block_boundary_uuids ) )
437+ {
438+ result.wrong_block_boundary_surface .add_issue ( bsurf_uuid,
439+ absl::StrCat ( " Surface " , bsurf_uuid.string (),
440+ " should not be boundary of Block " ,
441+ block.id ().string (),
442+ " : it has a boundary line not incident to any "
443+ " other block "
444+ " boundary surface." ) );
445+ }
446+ }
447+ }
374448 return result;
375449 }
376450} // namespace geode
0 commit comments