Skip to content

Commit 938f9ae

Browse files
committed
move computation of dangling surfaces to speed inspection process
1 parent 773bd91 commit 938f9ae

File tree

2 files changed

+42
-34
lines changed

2 files changed

+42
-34
lines changed

include/geode/inspector/topology/brep_blocks_topology.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,8 @@ namespace geode
139139
[[nodiscard]] std::optional< std::string >
140140
vertex_is_part_of_surface_with_wrong_relationships_to_block(
141141
index_t unique_vertex_index,
142-
absl::Span< const uuid > not_boundaries_surfaces ) const;
142+
absl::Span< const uuid > not_boundaries_surfaces,
143+
absl::Span< const uuid > dangling_surface ) const;
143144

144145
[[nodiscard]] std::optional< std::string >
145146
vertex_is_part_of_invalid_single_surface(

src/geode/inspector/topology/brep_blocks_topology.cpp

Lines changed: 40 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,33 @@ namespace
261261
return not_boundaries_surfaces;
262262
}
263263

264+
std::vector< geode::uuid > find_dangling_surfaces( const geode::BRep& brep,
265+
absl::Span< const geode::uuid > not_boundary_surfaces )
266+
{
267+
std::vector< geode::uuid > dangling_surfaces;
268+
for( const auto& surface_id : not_boundary_surfaces )
269+
{
270+
const auto& surface_mesh = brep.surface( surface_id ).mesh();
271+
const auto polygon_barycenter =
272+
surface_mesh.polygon_barycenter( 0 );
273+
bool is_dangling{ true };
274+
for( const auto& block : brep.blocks() )
275+
{
276+
if( geode::is_point_inside_block(
277+
brep, block, polygon_barycenter ) )
278+
{
279+
is_dangling = false;
280+
break;
281+
}
282+
}
283+
if( is_dangling )
284+
{
285+
dangling_surfaces.push_back( surface_id );
286+
}
287+
}
288+
return dangling_surfaces;
289+
}
290+
264291
bool verify_blocks_boundaries(
265292
const geode::BRep& brep, const geode::Block3D& block )
266293
{
@@ -888,7 +915,8 @@ namespace geode
888915
std::optional< std::string > BRepBlocksTopology::
889916
vertex_is_part_of_surface_with_wrong_relationships_to_block(
890917
index_t unique_vertex_index,
891-
absl::Span< const uuid > not_boundary_surfaces ) const
918+
absl::Span< const uuid > not_boundary_surfaces,
919+
absl::Span< const uuid > dangling_surface ) const
892920
{
893921
for( const auto& cmv :
894922
brep_.component_mesh_vertices( unique_vertex_index ) )
@@ -909,48 +937,24 @@ namespace geode
909937
if( brep_.nb_embeddings( cmv.component_id.id() ) >= 1
910938
&& brep_.nb_incidences( cmv.component_id.id() ) < 1
911939
&& !absl::c_contains(
912-
not_boundary_surfaces, cmv.component_id.id() ) )
940+
not_boundary_surfaces, cmv.component_id.id() )
941+
&& absl::c_contains( dangling_surface, cmv.component_id.id() ) )
913942
{
914943
return absl::StrCat( "Unique vertex with index ",
915944
unique_vertex_index, " is part of surface with uuid '",
916945
cmv.component_id.id().string(),
917946
"', which should not be embedded in any block." );
918947
}
919-
if( brep_.nb_embeddings( cmv.component_id.id() ) < 1
920-
&& brep_.nb_incidences( cmv.component_id.id() ) < 1
948+
if( brep_.nb_incidences( cmv.component_id.id() ) < 1
949+
&& brep_.nb_embeddings( cmv.component_id.id() ) < 1
921950
&& !absl::c_contains(
922-
not_boundary_surfaces, cmv.component_id.id() ) )
951+
dangling_surface, cmv.component_id.id() ) )
923952
{
924953
return absl::StrCat( "Unique vertex with index ",
925954
unique_vertex_index, " is part of surface with uuid '",
926955
cmv.component_id.id().string(),
927-
"', which should be boundary of a block." );
928-
}
929-
if( brep_.nb_incidences( cmv.component_id.id() ) < 1
930-
&& brep_.nb_embeddings( cmv.component_id.id() ) < 1 )
931-
{
932-
const auto& surface_mesh =
933-
brep_.surface( cmv.component_id.id() ).mesh();
934-
const auto polygon_barycenter =
935-
surface_mesh.polygon_barycenter( 0 );
936-
bool is_dangling{ true };
937-
for( const auto& block : brep_.blocks() )
938-
{
939-
if( geode::is_point_inside_block(
940-
brep_, block, polygon_barycenter ) )
941-
{
942-
is_dangling = false;
943-
break;
944-
}
945-
}
946-
if( !is_dangling )
947-
{
948-
return absl::StrCat( "Unique vertex with index ",
949-
unique_vertex_index, " is part of surface with uuid '",
950-
cmv.component_id.id().string(),
951-
"', which is not internal to "
952-
"a block while it should be." );
953-
}
956+
"', which is not internal to "
957+
"a block while it should be." );
954958
}
955959
}
956960
return std::nullopt;
@@ -1091,6 +1095,8 @@ namespace geode
10911095
BRepBlocksTopologyInspectionResult result;
10921096
std::vector< geode::uuid > meshed_blocks;
10931097
const auto not_boundary_surfaces = find_not_boundary_surfaces( brep_ );
1098+
const auto dangling_surfaces =
1099+
find_dangling_surfaces( brep_, not_boundary_surfaces );
10941100
std::vector< geode::uuid > boundary_uuids;
10951101
for( const auto& block : brep_.blocks() )
10961102
{
@@ -1201,7 +1207,8 @@ namespace geode
12011207
}
12021208
if( const auto problem_message =
12031209
vertex_is_part_of_surface_with_wrong_relationships_to_block(
1204-
unique_vertex_id, not_boundary_surfaces ) )
1210+
unique_vertex_id, not_boundary_surfaces,
1211+
dangling_surfaces ) )
12051212
{
12061213
result
12071214
.unique_vertices_linked_to_surface_with_wrong_relationship_to_blocks

0 commit comments

Comments
 (0)