@@ -298,60 +298,52 @@ namespace geode
298
298
}
299
299
const auto cme = geode::component_mesh_edges (
300
300
brep_, brep_.line ( cmv.component_id .id () ), 0 );
301
- if ( brep_.nb_incidences ( cmv.component_id .id () ) >= 1 )
301
+ for ( const auto & incident_surface :
302
+ brep_.incidences ( brep_.line ( cmv.component_id .id () ) ) )
302
303
{
303
- for ( const auto & incident_surface :
304
- brep_.incidences ( brep_.line ( cmv.component_id .id () ) ) )
304
+ if ( !cme.surface_edges .contains ( incident_surface.id () ) )
305
305
{
306
- if ( !cme.surface_edges .contains ( incident_surface.id () ) )
307
- {
308
- return absl::StrCat ( " Unique vertex with index " ,
309
- unique_vertex_index, " is part of line with uuid '" ,
310
- cmv.component_id .id ().string (),
311
- " ', which should be boundary of "
312
- " surface with uuid '" ,
313
- incident_surface.id ().string () );
314
- }
315
- const auto & surface_edges =
316
- cme.surface_edges .at ( incident_surface.id () );
317
- if ( surface_edges.size () != 1 )
318
- {
319
- return absl::StrCat ( " Unique vertex with index " ,
320
- unique_vertex_index, " is part of line with uuid '" ,
321
- cmv.component_id .id ().string (),
322
- " ', which should not be boundary of "
323
- " surface with uuid '" ,
324
- incident_surface.id ().string () );
325
- }
306
+ return absl::StrCat ( " Unique vertex with index " ,
307
+ unique_vertex_index, " is part of line with uuid '" ,
308
+ cmv.component_id .id ().string (),
309
+ " ', which should be boundary of "
310
+ " surface with uuid '" ,
311
+ incident_surface.id ().string () );
312
+ }
313
+ const auto & surface_edges =
314
+ cme.surface_edges .at ( incident_surface.id () );
315
+ if ( surface_edges.size () != 1 )
316
+ {
317
+ return absl::StrCat ( " Unique vertex with index " ,
318
+ unique_vertex_index, " is part of line with uuid '" ,
319
+ cmv.component_id .id ().string (),
320
+ " ', which should not be boundary of "
321
+ " surface with uuid '" ,
322
+ incident_surface.id ().string () );
326
323
}
327
324
}
328
- if ( brep_.nb_embedding_surfaces (
329
- brep_.line ( cmv.component_id .id () ) )
330
- >= 1 )
325
+ for ( const auto & embedding_surface : brep_.embedding_surfaces (
326
+ brep_.line ( cmv.component_id .id () ) ) )
331
327
{
332
- for ( const auto & embedding_surface : brep_.embedding_surfaces (
333
- brep_.line ( cmv.component_id .id () ) ) )
328
+ if ( !cme.surface_edges .contains ( embedding_surface.id () ) )
334
329
{
335
- if ( !cme.surface_edges .contains ( embedding_surface.id () ) )
336
- {
337
- return absl::StrCat ( " Unique vertex with index " ,
338
- unique_vertex_index, " is part of line with uuid '" ,
339
- cmv.component_id .id ().string (),
340
- " ', which should not be embedded in "
341
- " surface with uuid '" ,
342
- embedding_surface.id ().string () );
343
- }
344
- const auto & surface_edges =
345
- cme.surface_edges .at ( embedding_surface.id () );
346
- if ( surface_edges.size () <= 1 )
347
- {
348
- return absl::StrCat ( " Unique vertex with index " ,
349
- unique_vertex_index, " is part of line with uuid '" ,
350
- cmv.component_id .id ().string (),
351
- " ', which should not be embedded in "
352
- " surface with uuid '" ,
353
- embedding_surface.id ().string () );
354
- }
330
+ return absl::StrCat ( " Unique vertex with index " ,
331
+ unique_vertex_index, " is part of line with uuid '" ,
332
+ cmv.component_id .id ().string (),
333
+ " ', which should not be embedded in "
334
+ " surface with uuid '" ,
335
+ embedding_surface.id ().string () );
336
+ }
337
+ const auto & surface_edges =
338
+ cme.surface_edges .at ( embedding_surface.id () );
339
+ if ( surface_edges.size () <= 1 )
340
+ {
341
+ return absl::StrCat ( " Unique vertex with index " ,
342
+ unique_vertex_index, " is part of line with uuid '" ,
343
+ cmv.component_id .id ().string (),
344
+ " ', which should not be embedded in "
345
+ " surface with uuid '" ,
346
+ embedding_surface.id ().string () );
355
347
}
356
348
}
357
349
if ( brep_.nb_incidences ( cmv.component_id .id () ) < 1
@@ -404,6 +396,59 @@ namespace geode
404
396
return std::nullopt;
405
397
}
406
398
399
+ std::optional< std::string >
400
+ BRepLinesTopology::line_edge_has_wrong_component_edges_around (
401
+ const Line3D& line, const index_t edge_index ) const
402
+ {
403
+ const auto cme = component_mesh_edges ( brep_, line, edge_index );
404
+ for ( const auto & [surface_id, surface_edges] : cme.surface_edges )
405
+ {
406
+ if ( brep_.is_boundary ( line, brep_.surface ( surface_id ) ) )
407
+ {
408
+ if ( surface_edges.size () != 1 )
409
+ {
410
+ return absl::StrCat ( " Line with uuid '" , line.id ().string (),
411
+ " ' is boundary of surface with uuid '" ,
412
+ surface_id.string (), " ', but has " ,
413
+ surface_edges.size (),
414
+ " edges of this surface around it, it should be 1." );
415
+ }
416
+ continue ;
417
+ }
418
+ if ( brep_.is_internal ( line, brep_.surface ( surface_id ) ) )
419
+ {
420
+ if ( surface_edges.size () != 2 )
421
+ {
422
+ return absl::StrCat ( " Line with uuid '" , line.id ().string (),
423
+ " ' is internal to surface with uuid '" ,
424
+ surface_id.string (), " ', but has " ,
425
+ surface_edges.size (),
426
+ " edges of this surface around it, it should be 2." );
427
+ }
428
+ continue ;
429
+ }
430
+ return absl::StrCat ( " Line with uuid '" , line.id ().string (),
431
+ " ' has edge with id " , edge_index,
432
+ " in common with surface with uuid '" , surface_id.string (),
433
+ " ', but is neither boundary of nor internal to it." );
434
+ }
435
+ for ( const auto & [block_id, block_edges] : cme.block_edges )
436
+ {
437
+ if ( brep_.is_internal ( line, brep_.block ( block_id ) ) )
438
+ {
439
+ if ( block_edges.size () != 1 )
440
+ {
441
+ return absl::StrCat ( " Line with uuid '" , line.id ().string (),
442
+ " ' is internal to block with uuid '" , block_id.string (),
443
+ " ', but has " , block_edges.size (),
444
+ " edges of this surface around it, it should be 1." );
445
+ }
446
+ continue ;
447
+ }
448
+ }
449
+ return std::nullopt;
450
+ }
451
+
407
452
BRepLinesTopologyInspectionResult
408
453
BRepLinesTopology::inspect_lines_topology () const
409
454
{
@@ -427,6 +472,24 @@ namespace geode
427
472
result.lines_not_linked_to_a_unique_vertex .add_issues_to_map (
428
473
line.id (), std::move ( line_result ) );
429
474
}
475
+ InspectionIssues< index_t > line_edges_with_wrong_cme{ absl::StrCat (
476
+ " Line " , line.id ().string () ) };
477
+ for ( const auto edge_id : Range{ line.mesh ().nb_edges () } )
478
+ {
479
+ if ( const auto problem_message =
480
+ line_edge_has_wrong_component_edges_around (
481
+ line, edge_id ) )
482
+ {
483
+ line_edges_with_wrong_cme.add_issue (
484
+ edge_id, problem_message.value () );
485
+ }
486
+ }
487
+ if ( line_edges_with_wrong_cme.nb_issues () != 0 )
488
+ {
489
+ result.line_edges_with_wrong_component_edges_around
490
+ .add_issues_to_map (
491
+ line.id (), std::move ( line_edges_with_wrong_cme ) );
492
+ }
430
493
}
431
494
for ( const auto unique_vertex_id : Range{ brep_.nb_unique_vertices () } )
432
495
{
0 commit comments