Skip to content

Commit 354def5

Browse files
committed
feat(BRepBlocksTopology): adding boundary surface inspection test
1 parent c86caaf commit 354def5

File tree

2 files changed

+76
-0
lines changed

2 files changed

+76
-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+
"uuid of boundary Surface that is actually not a boundary one."
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: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,67 @@
4242

4343
#include <geode/inspector/topology/internal/topology_helpers.hpp>
4444

45+
namespace
46+
{
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_other_block_boundary_surf(
60+
const geode::Line3D& line,
61+
const geode::BRep& brep,
62+
const std::vector< geode::uuid >& block_boundary_uuids,
63+
const geode::uuid& bsurf_uuid )
64+
{
65+
for( const auto& incident_surface : brep.incidences( line ) )
66+
{
67+
if( incident_surface.id() == bsurf_uuid )
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+
std::vector< geode::uuid > inspect_boundary_surfaces(
81+
const geode::BRep& brep )
82+
{
83+
std::vector< geode::uuid > wrong_boundary_surfaces;
84+
for( const auto& block : brep.blocks() )
85+
{
86+
const auto block_boundary_uuids =
87+
block_boundary_surfaces( brep, block );
88+
for( const auto& bsurf_uuid : block_boundary_uuids )
89+
{
90+
const auto& surface = brep.surface( bsurf_uuid );
91+
for( const auto& line : brep.boundaries( surface ) )
92+
{
93+
if( is_line_incident_to_other_block_boundary_surf(
94+
line, brep, block_boundary_uuids, bsurf_uuid ) )
95+
{
96+
continue;
97+
}
98+
wrong_boundary_surfaces.push_back( bsurf_uuid );
99+
break;
100+
}
101+
}
102+
}
103+
return wrong_boundary_surfaces;
104+
}
105+
} // namespace
45106
namespace
46107
{
47108
template < typename Condition >
@@ -66,6 +127,11 @@ namespace geode
66127
std::string BRepBlocksTopologyInspectionResult::string() const
67128
{
68129
std::string message;
130+
if( wrong_block_boundary_surface.nb_issues() != 0 )
131+
{
132+
absl::StrAppend(
133+
&message, wrong_block_boundary_surface.string(), "\n" );
134+
}
69135
if( blocks_not_meshed.nb_issues() != 0 )
70136
{
71137
absl::StrAppend( &message, blocks_not_meshed.string(), "\n" );
@@ -371,6 +437,13 @@ namespace geode
371437
.add_issue( unique_vertex_id, problem_message.value() );
372438
}
373439
}
440+
for( const auto wrong_bsurf : inspect_boundary_surfaces( brep_ ) )
441+
{
442+
result.wrong_block_boundary_surface.add_issue( wrong_bsurf,
443+
absl::StrCat( "Boundary surface ", wrong_bsurf.string(),
444+
" contains a line not incident to "
445+
"any other block boundary surface." ) );
446+
}
374447
return result;
375448
}
376449
} // namespace geode

0 commit comments

Comments
 (0)