@@ -257,7 +257,7 @@ namespace
257257 std::vector< geode::uuid > not_boundaries;
258258 auto graph = geode::Graph::create ();
259259 auto graph_builder = geode::GraphBuilder::create ( *graph );
260- geode::BijectiveMapping < geode::uuid, geode::index_t >
260+ geode::GenericMapping < geode::uuid, geode::index_t >
261261 line_uuids_to_graph_edges;
262262 geode::BijectiveMapping< geode::uuid, geode::index_t >
263263 corner_uuids_to_graph_vertices;
@@ -275,18 +275,29 @@ namespace
275275 for ( const auto & boundary_corner :
276276 brep.boundaries ( incident_line ) )
277277 {
278- if ( boundary_corner.id () == corner.id () )
279- {
280- continue ;
281- }
278+ // if( boundary_corner.id() == corner.id() )
279+ // {
280+ // continue;
281+ // }
282282 SDEBUG ( boundary_corner.id () );
283283 const auto boundary_corner_vertex =
284284 corner_uuids_to_graph_vertices.in2out (
285285 boundary_corner.id () );
286- if ( line_uuids_to_graph_edges.has_mapping_input (
287- incident_line.id () ) )
286+ // if( line_uuids_to_graph_edges.has_mapping_input(
287+ // incident_line.id() ) )
288+ // {
289+ // continue;
290+ // }
291+ if ( const auto existing_edge = graph->edge_from_vertices (
292+ boundary_corner_vertex, corner_vertex ) )
288293 {
289- continue ;
294+ if ( line_uuids_to_graph_edges
295+ .out2in ( existing_edge.value () )
296+ .at ( 0 )
297+ == incident_line.id () )
298+ {
299+ continue ;
300+ }
290301 }
291302 line_uuids_to_graph_edges.map ( incident_line.id (),
292303 graph_builder->create_edge (
@@ -298,51 +309,65 @@ namespace
298309 geode::save_graph ( *graph, " graph.og_grp" );
299310 while ( found_not_boundary_line )
300311 {
301- DEBUG ( " found_not_boundary_lines" );
302312 std::vector< bool > to_delete ( graph->nb_edges (), false );
303313 for ( const auto graph_vertex :
304314 geode::Range{ graph->nb_vertices () } )
305315 {
306- DEBUG ( graph->edges_around_vertex ( graph_vertex ).size () );
307- SDEBUG (
308- brep.corner ( corner_uuids_to_graph_vertices.out2in (
309- graph_vertex ) )
310- .mesh ()
311- .point ( 0 ) );
312- if ( graph->edges_around_vertex ( graph_vertex ).size () != 1 )
316+ if ( graph->edges_around_vertex ( graph_vertex ).empty () )
313317 {
314318 continue ;
315319 }
316- const auto line_id = line_uuids_to_graph_edges.out2in (
317- graph->edges_around_vertex ( graph_vertex )
318- .at ( 0 )
319- .edge_id );
320- DEBUG ( to_delete.size () );
321- DEBUG ( graph->edges_around_vertex ( graph_vertex ).size () );
322- DEBUG ( graph->edges_around_vertex ( graph_vertex )
323- .at ( 0 )
324- .edge_id );
320+ const auto line_id =
321+ line_uuids_to_graph_edges
322+ .out2in ( graph->edges_around_vertex ( graph_vertex )
323+ .at ( 0 )
324+ .edge_id )
325+ .at ( 0 );
326+ bool should_delete{ true };
327+ for ( const auto & edge_around :
328+ graph->edges_around_vertex ( graph_vertex ) )
329+ {
330+ if ( line_uuids_to_graph_edges.out2in ( edge_around.edge_id )
331+ .at ( 0 )
332+ != line_id )
333+ {
334+ should_delete = false ;
335+ break ;
336+ }
337+ }
338+ if ( !should_delete )
339+ {
340+ continue ;
341+ }
342+ if ( absl::c_contains ( not_boundaries, line_id ) )
343+ {
344+ continue ;
345+ }
346+ for ( const auto & edge :
347+ line_uuids_to_graph_edges.in2out ( line_id ) )
348+ {
349+ to_delete[edge] = true ;
350+ }
325351 not_boundaries.push_back ( line_id );
326- SDEBUG ( line_id );
327- to_delete[graph->edges_around_vertex ( graph_vertex )
328- .at ( 0 )
329- .edge_id ] = true ;
330352 }
331353 if ( !absl::c_contains ( to_delete, true ) )
332354 {
333355 found_not_boundary_line = false ;
334356 continue ;
335357 }
336358 const auto old2new = graph_builder->delete_edges ( to_delete );
337- geode::BijectiveMapping < geode::uuid, geode::index_t >
359+ geode::GenericMapping < geode::uuid, geode::index_t >
338360 new_line_uuids_to_graph_edges;
339- for ( const auto & [line_id, graph_edge ] :
361+ for ( const auto & [line_id, graph_edges ] :
340362 line_uuids_to_graph_edges.in2out_map () )
341363 {
342- if ( old2new. at ( graph_edge ) != geode::NO_ID )
364+ for ( const auto graph_edge : graph_edges )
343365 {
344- new_line_uuids_to_graph_edges.map (
345- line_id, old2new.at ( graph_edge ) );
366+ if ( old2new.at ( graph_edge ) != geode::NO_ID )
367+ {
368+ new_line_uuids_to_graph_edges.map (
369+ line_id, old2new.at ( graph_edge ) );
370+ }
346371 }
347372 }
348373 line_uuids_to_graph_edges = new_line_uuids_to_graph_edges;
0 commit comments