2323
2424#include < geode/inspector/topology/private/brep_surfaces_topology_impl.h>
2525
26+ #include < geode/basic/algorithm.h>
2627#include < geode/basic/logger.h>
2728
2829#include < geode/mesh/core/solid_mesh.h>
@@ -38,16 +39,15 @@ namespace
3839{
3940 bool line_is_boundary_of_at_least_two_surfaces_or_one_embedding_surface (
4041 const geode::BRep& brep,
41- const geode::MeshComponentVertex& line ,
42- const std::vector< geode::MeshComponentVertex >& surfaces )
42+ const geode::uuid& line_uuid ,
43+ const std::vector< geode::uuid >& surface_uuids )
4344 {
4445 geode::local_index_t counter{ 0 };
45- for ( const auto & surface : surfaces )
46+ for ( const auto & surface_id : surface_uuids )
4647 {
47- if ( brep.Relationships ::is_boundary (
48- line.component_id .id (), surface.component_id .id () ) )
48+ if ( brep.Relationships ::is_boundary ( line_uuid, surface_id ) )
4949 {
50- if ( brep.nb_embeddings ( surface. component_id . id () ) > 0 )
50+ if ( brep.nb_embeddings ( surface_id ) > 0 )
5151 {
5252 return true ;
5353 }
@@ -72,6 +72,23 @@ namespace
7272 }
7373 return true ;
7474 }
75+
76+ std::vector< geode::uuid > brep_vertex_component_uuids (
77+ const geode::BRep& brep,
78+ geode::index_t unique_vertex_index,
79+ const geode::ComponentType& component_type )
80+ {
81+ const auto components =
82+ brep.mesh_component_vertices ( unique_vertex_index, component_type );
83+ std::vector< geode::uuid > component_uuids;
84+ component_uuids.reserve ( components.size () );
85+ for ( const auto & mcv : components )
86+ {
87+ component_uuids.push_back ( mcv.component_id .id () );
88+ }
89+ geode::sort_unique ( component_uuids );
90+ return component_uuids;
91+ }
7592} // namespace
7693
7794namespace geode
@@ -115,18 +132,18 @@ namespace geode
115132 vertex_is_part_of_not_boundary_nor_internal_surface (
116133 const index_t unique_vertex_index ) const
117134 {
118- for ( const auto surface : brep_. mesh_component_vertices (
135+ for ( const auto surface_id : brep_vertex_component_uuids ( brep_,
119136 unique_vertex_index, Surface3D::component_type_static () ) )
120137 {
121- if ( brep_.nb_embeddings ( surface. component_id . id () ) < 1
122- && brep_.nb_incidences ( surface. component_id . id () ) < 1 )
138+ if ( brep_.nb_embeddings ( surface_id ) < 1
139+ && brep_.nb_incidences ( surface_id ) < 1 )
123140 {
124141 if ( verbose_ )
125142 {
126143 Logger::info ( " Unique vertex with index " ,
127144 unique_vertex_index,
128145 " is part of surface with uuid '" ,
129- surface. component_id . id () .string (),
146+ surface_id .string (),
130147 " ', which is neither internal to a block nor a "
131148 " boundary of a block." );
132149 }
@@ -140,23 +157,22 @@ namespace geode
140157 vertex_is_part_of_surface_with_invalid_internal_topology (
141158 const index_t unique_vertex_index ) const
142159 {
143- for ( const auto surface : brep_. mesh_component_vertices (
160+ for ( const auto surface_id : brep_vertex_component_uuids ( brep_,
144161 unique_vertex_index, Surface3D::component_type_static () ) )
145162 {
146- const auto embeddings =
147- brep_.embeddings ( surface.component_id .id () );
163+ const auto embeddings = brep_.embeddings ( surface_id );
148164
149165 for ( const auto embedding : embeddings )
150166 {
151167 if ( brep_.Relationships ::is_boundary (
152- surface. component_id . id () , embedding.id () ) )
168+ surface_id , embedding.id () ) )
153169 {
154170 if ( verbose_ )
155171 {
156172 Logger::info ( " Unique vertex with index " ,
157173 unique_vertex_index,
158174 " is part of surface with uuid '" ,
159- surface. component_id . id () .string (),
175+ surface_id .string (),
160176 " ', which is both internal and boundary of "
161177 " block with uuid '" ,
162178 embedding.id ().string (), " '." );
@@ -171,16 +187,16 @@ namespace geode
171187 bool BRepSurfacesTopologyImpl::vertex_is_part_of_invalid_unique_surface (
172188 index_t unique_vertex_index ) const
173189 {
174- const auto surfaces = brep_. mesh_component_vertices (
190+ const auto surface_uuids = brep_vertex_component_uuids ( brep_,
175191 unique_vertex_index, Surface3D::component_type_static () );
176- if ( surfaces .size () != 1 )
192+ if ( surface_uuids .size () != 1 )
177193 {
178194 return false ;
179195 }
180- const auto & surface_id = surfaces [0 ]. component_id . id () ;
181- const auto blocks = brep_. mesh_component_vertices (
182- unique_vertex_index, Block3D::component_type_static () );
183- if ( blocks .size () > 2 )
196+ const auto & surface_id = surface_uuids [0 ];
197+ const auto block_uuids = brep_vertex_component_uuids (
198+ brep_, unique_vertex_index, Block3D::component_type_static () );
199+ if ( block_uuids .size () > 2 )
184200 {
185201 if ( verbose_ )
186202 {
@@ -195,7 +211,7 @@ namespace geode
195211 {
196212 if ( brep_blocks_are_meshed ( brep_ ) )
197213 {
198- if ( blocks .size () != 1 )
214+ if ( block_uuids .size () != 1 )
199215 {
200216 if ( verbose_ )
201217 {
@@ -207,7 +223,7 @@ namespace geode
207223 return true ;
208224 }
209225 else if ( !brep_.Relationships ::is_internal (
210- surface_id, blocks [0 ]. component_id . id () ) )
226+ surface_id, block_uuids [0 ] ) )
211227 {
212228 if ( verbose_ )
213229 {
@@ -223,10 +239,10 @@ namespace geode
223239 }
224240 else
225241 {
226- for ( const auto & block : blocks )
242+ for ( const auto & block_id : block_uuids )
227243 {
228244 if ( !brep_.Relationships ::is_boundary (
229- surface_id, block. component_id . id () ) )
245+ surface_id, block_id ) )
230246 {
231247 if ( verbose_ )
232248 {
@@ -236,7 +252,7 @@ namespace geode
236252 surface_id.string (),
237253 " ' which is not embedded, but not boundary "
238254 " either of block with uuid '" ,
239- block. component_id . id () .string (),
255+ block_id .string (),
240256 " ', in which the vertex is." );
241257 }
242258 return true ;
@@ -250,15 +266,15 @@ namespace geode
250266 vertex_is_part_of_invalid_multiple_surfaces (
251267 index_t unique_vertex_index ) const
252268 {
253- const auto surfaces = brep_. mesh_component_vertices (
269+ const auto surface_uuids = brep_vertex_component_uuids ( brep_,
254270 unique_vertex_index, Surface3D::component_type_static () );
255- if ( surfaces .size () < 2 )
271+ if ( surface_uuids .size () < 2 )
256272 {
257273 return false ;
258274 }
259- const auto lines = brep_. mesh_component_vertices (
260- unique_vertex_index, Line3D::component_type_static () );
261- if ( lines .empty () )
275+ const auto line_uuids = brep_vertex_component_uuids (
276+ brep_, unique_vertex_index, Line3D::component_type_static () );
277+ if ( line_uuids .empty () )
262278 {
263279 if ( verbose_ )
264280 {
@@ -269,7 +285,7 @@ namespace geode
269285 }
270286 return true ;
271287 }
272- if ( lines .size () == 1 )
288+ if ( line_uuids .size () == 1 )
273289 {
274290 if ( !brep_
275291 .mesh_component_vertices ( unique_vertex_index,
@@ -285,24 +301,22 @@ namespace geode
285301 }
286302 return true ;
287303 }
288- for ( const auto & surface : surfaces )
304+ for ( const auto & surface_id : surface_uuids )
289305 {
290306 if ( !brep_.Relationships ::is_boundary (
291- lines[0 ].component_id .id (),
292- surface.component_id .id () )
307+ line_uuids[0 ], surface_id )
293308 && !brep_.Relationships ::is_internal (
294- lines[0 ].component_id .id (),
295- surface.component_id .id () ) )
309+ line_uuids[0 ], surface_id ) )
296310 {
297311 if ( verbose_ )
298312 {
299313 Logger::info ( " Unique vertex with index " ,
300314 unique_vertex_index,
301315 " is part of multiple surfaces and only one "
302316 " line, with uuid'" ,
303- lines [0 ]. component_id . id () .string (),
317+ line_uuids [0 ].string (),
304318 " ', but surface with uuid '" ,
305- surface. component_id . id () .string (),
319+ surface_id .string (),
306320 " ', in which the vertex is, is neither "
307321 " incident nor embedding of the line." );
308322 }
@@ -312,19 +326,19 @@ namespace geode
312326 }
313327 else
314328 {
315- for ( const auto & line : lines )
329+ for ( const auto & line_id : line_uuids )
316330 {
317- if ( brep_.nb_embeddings ( line. component_id . id () ) < 1
331+ if ( brep_.nb_embeddings ( line_id ) < 1
318332 && !line_is_boundary_of_at_least_two_surfaces_or_one_embedding_surface (
319- brep_, line, surfaces ) )
333+ brep_, line_id, surface_uuids ) )
320334 {
321335 if ( verbose_ )
322336 {
323337 Logger::info ( " Unique vertex with index " ,
324338 unique_vertex_index,
325339 " is part of multiple surfaces and multiple "
326340 " lines, but line with uuid'" ,
327- lines[ 0 ]. component_id . id () .string (),
341+ line_id .string (),
328342 " ' is neither internal, nor a boundary of at "
329343 " least two surfaces or one embedding "
330344 " surface." );
0 commit comments