Skip to content

Commit 79b121c

Browse files
Merge pull request #119 from Geode-solutions/adding_block_inspection_bsurf_test
feat(BRepBlocksTopology): adding boundary surface inspection test
2 parents c86caaf + e60a7e8 commit 79b121c

File tree

4 files changed

+106
-0
lines changed

4 files changed

+106
-0
lines changed

include/geode/inspector/topology/brep_blocks_topology.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ namespace geode
4646
InspectionIssues< uuid > blocks_not_meshed{
4747
"uuids of Blocks without mesh."
4848
};
49+
InspectionIssues< uuid > wrong_block_boundary_surface{
50+
"uuids of surfaces boundary to a block when they should not."
51+
};
4952
InspectionIssuesMap< index_t > blocks_not_linked_to_a_unique_vertex{
5053
"Blocks with mesh vertices not linked to a unique vertex"
5154
};

src/geode/inspector/topology/brep_blocks_topology.cpp

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,56 @@
4444

4545
namespace
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
875 KB
Binary file not shown.

tests/inspector/test-brep.cpp

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -387,6 +387,34 @@ void check_model_D( bool string )
387387
nb_component_meshes_issues, " meshes problems instead of 0." );
388388
}
389389

390+
void check_wrong_bsurfaces_model()
391+
{
392+
const auto model_brep = geode::load_brep( absl::StrCat(
393+
geode::DATA_PATH, "wrong_boundary_surface_model.og_brep" ) );
394+
const geode::BRepInspector brep_inspector{ model_brep };
395+
const auto result = brep_inspector.inspect_brep();
396+
OPENGEODE_EXCEPTION(
397+
result.topology.blocks.wrong_block_boundary_surface.nb_issues() == 3,
398+
absl::StrCat(
399+
"[Test] Wrong number of wrong block boundary surfaces detected: "
400+
"should be 3, and it is ",
401+
result.topology.blocks.wrong_block_boundary_surface.nb_issues(),
402+
"." ) );
403+
std::vector< geode::uuid > wrong_bsurf{
404+
geode::uuid{ "00000000-78d4-4e10-8000-0000cb3a3a27" },
405+
geode::uuid{ "00000000-7a4e-4a1c-8000-00003732de1f" },
406+
geode::uuid{ "00000000-980f-49d4-8000-00002f79374e" }
407+
};
408+
for( const auto& issue :
409+
result.topology.blocks.wrong_block_boundary_surface.issues() )
410+
{
411+
OPENGEODE_EXCEPTION(
412+
absl::c_find( wrong_bsurf, issue ) != wrong_bsurf.end(),
413+
"[Test] Surface (", issue.string(),
414+
") is detected as a wrong boundary surface but is not one." );
415+
}
416+
}
417+
390418
int main()
391419
{
392420
try
@@ -396,6 +424,7 @@ int main()
396424
check_model_a1_valid( false );
397425
check_model_mss( false );
398426
check_model_D( false );
427+
check_wrong_bsurfaces_model();
399428
geode::Logger::info( "TEST SUCCESS" );
400429
return 0;
401430
}

0 commit comments

Comments
 (0)