Skip to content

Commit 2dfdece

Browse files
committed
fix(MeshesBuilder): fix copy of information in meshes builder
1 parent e79de32 commit 2dfdece

File tree

2 files changed

+49
-24
lines changed

2 files changed

+49
-24
lines changed

src/geode/mesh/builder/solid_mesh_builder.cpp

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,19 @@ namespace
251251
}
252252
builder.create_polyhedron( vertices, facets );
253253
}
254+
for( const auto v : geode::Range{ solid.nb_vertices() } )
255+
{
256+
const auto polyhedron = solid.polyhedron_around_vertex( v );
257+
if( !polyhedron )
258+
{
259+
builder.disassociate_polyhedron_vertex_to_vertex( v );
260+
}
261+
else
262+
{
263+
builder.associate_polyhedron_vertex_to_vertex(
264+
polyhedron.value(), v );
265+
}
266+
}
254267
}
255268

256269
template < geode::index_t dimension >
@@ -392,43 +405,42 @@ namespace geode
392405

393406
template < index_t dimension >
394407
void SolidMeshBuilder< dimension >::set_polyhedron_vertex(
395-
const PolyhedronVertex& polyhedron_vertex, index_t vertex_id )
408+
const PolyhedronVertex& polyhedron_vertex, index_t new_vertex_id )
396409
{
397-
const auto polyhedron_vertex_id =
410+
const auto old_vertex_id =
398411
solid_mesh_.polyhedron_vertex( polyhedron_vertex );
399-
if( polyhedron_vertex_id == vertex_id )
412+
if( old_vertex_id == new_vertex_id )
400413
{
401414
return;
402415
}
403-
if( polyhedron_vertex_id != NO_ID )
416+
if( old_vertex_id != NO_ID )
404417
{
405418
const auto polyhedron_around =
406-
solid_mesh_.polyhedron_around_vertex( polyhedron_vertex_id );
419+
solid_mesh_.polyhedron_around_vertex( old_vertex_id );
407420
if( polyhedron_around == polyhedron_vertex )
408421
{
409422
const auto& polyhedra_around =
410-
solid_mesh_.polyhedra_around_vertex( polyhedron_vertex_id );
423+
solid_mesh_.polyhedra_around_vertex( old_vertex_id );
411424
if( polyhedra_around.size() < 2 )
412425
{
413-
disassociate_polyhedron_vertex_to_vertex(
414-
polyhedron_vertex_id );
426+
disassociate_polyhedron_vertex_to_vertex( old_vertex_id );
415427
}
416428
else
417429
{
418430
associate_polyhedron_vertex_to_vertex(
419-
polyhedra_around[1], polyhedron_vertex_id );
431+
polyhedra_around[1], new_vertex_id );
420432
}
421433
}
422-
reset_polyhedra_around_vertex( polyhedron_vertex_id );
434+
reset_polyhedra_around_vertex( old_vertex_id );
423435
}
424436

425437
if( solid_mesh_.are_edges_enabled()
426438
|| solid_mesh_.are_facets_enabled() )
427439
{
428440
update_edge_and_facet(
429-
solid_mesh_, *this, polyhedron_vertex, vertex_id );
441+
solid_mesh_, *this, polyhedron_vertex, new_vertex_id );
430442
}
431-
update_polyhedron_vertex( polyhedron_vertex, vertex_id );
443+
update_polyhedron_vertex( polyhedron_vertex, new_vertex_id );
432444
}
433445

434446
template < index_t dimension >

src/geode/mesh/builder/surface_mesh_builder.cpp

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,19 @@ namespace
281281
}
282282
builder.create_polygon( vertices );
283283
}
284+
for( const auto v : geode::Range{ surface.nb_vertices() } )
285+
{
286+
const auto polygon = surface.polygon_around_vertex( v );
287+
if( !polygon )
288+
{
289+
builder.disassociate_polygon_vertex_to_vertex( v );
290+
}
291+
else
292+
{
293+
builder.associate_polygon_vertex_to_vertex(
294+
polygon.value(), v );
295+
}
296+
}
284297
}
285298

286299
template < geode::index_t dimension >
@@ -405,41 +418,41 @@ namespace geode
405418

406419
template < index_t dimension >
407420
void SurfaceMeshBuilder< dimension >::set_polygon_vertex(
408-
const PolygonVertex& polygon_vertex, index_t vertex_id )
421+
const PolygonVertex& polygon_vertex, index_t new_vertex_id )
409422
{
410-
const auto polygon_vertex_id =
423+
const auto old_vertex_id =
411424
surface_mesh_.polygon_vertex( polygon_vertex );
412-
if( polygon_vertex_id == vertex_id )
425+
if( old_vertex_id == new_vertex_id )
413426
{
414427
return;
415428
}
416-
if( polygon_vertex_id != NO_ID )
429+
if( old_vertex_id != NO_ID )
417430
{
418431
const auto polygon_around =
419-
surface_mesh_.polygon_around_vertex( polygon_vertex_id );
432+
surface_mesh_.polygon_around_vertex( old_vertex_id );
420433
if( polygon_around == polygon_vertex )
421434
{
422435
const auto& polygons_around =
423-
surface_mesh_.polygons_around_vertex( polygon_vertex_id );
436+
surface_mesh_.polygons_around_vertex( old_vertex_id );
424437
if( polygons_around.size() < 2 )
425438
{
426-
disassociate_polygon_vertex_to_vertex( polygon_vertex_id );
439+
disassociate_polygon_vertex_to_vertex( old_vertex_id );
427440
}
428441
else
429442
{
430443
associate_polygon_vertex_to_vertex(
431-
polygons_around[1], polygon_vertex_id );
444+
polygons_around[1], new_vertex_id );
432445
}
433446
}
434-
reset_polygons_around_vertex( polygon_vertex_id );
447+
reset_polygons_around_vertex( old_vertex_id );
435448
}
436449

437450
if( surface_mesh_.are_edges_enabled() )
438451
{
439-
update_edge( surface_mesh_, *this, polygon_vertex,
440-
polygon_vertex_id, vertex_id );
452+
update_edge( surface_mesh_, *this, polygon_vertex, old_vertex_id,
453+
new_vertex_id );
441454
}
442-
update_polygon_vertex( polygon_vertex, vertex_id );
455+
update_polygon_vertex( polygon_vertex, new_vertex_id );
443456
}
444457

445458
template < index_t dimension >

0 commit comments

Comments
 (0)