diff --git a/src/geode/mesh/builder/solid_mesh_builder.cpp b/src/geode/mesh/builder/solid_mesh_builder.cpp index a71824c05..8034dbd62 100644 --- a/src/geode/mesh/builder/solid_mesh_builder.cpp +++ b/src/geode/mesh/builder/solid_mesh_builder.cpp @@ -251,6 +251,19 @@ namespace } builder.create_polyhedron( vertices, facets ); } + for( const auto v : geode::Range{ solid.nb_vertices() } ) + { + const auto polyhedron = solid.polyhedron_around_vertex( v ); + if( !polyhedron ) + { + builder.disassociate_polyhedron_vertex_to_vertex( v ); + } + else + { + builder.associate_polyhedron_vertex_to_vertex( + polyhedron.value(), v ); + } + } } template < geode::index_t dimension > @@ -392,43 +405,42 @@ namespace geode template < index_t dimension > void SolidMeshBuilder< dimension >::set_polyhedron_vertex( - const PolyhedronVertex& polyhedron_vertex, index_t vertex_id ) + const PolyhedronVertex& polyhedron_vertex, index_t new_vertex_id ) { - const auto polyhedron_vertex_id = + const auto old_vertex_id = solid_mesh_.polyhedron_vertex( polyhedron_vertex ); - if( polyhedron_vertex_id == vertex_id ) + if( old_vertex_id == new_vertex_id ) { return; } - if( polyhedron_vertex_id != NO_ID ) + if( old_vertex_id != NO_ID ) { const auto polyhedron_around = - solid_mesh_.polyhedron_around_vertex( polyhedron_vertex_id ); + solid_mesh_.polyhedron_around_vertex( old_vertex_id ); if( polyhedron_around == polyhedron_vertex ) { const auto& polyhedra_around = - solid_mesh_.polyhedra_around_vertex( polyhedron_vertex_id ); + solid_mesh_.polyhedra_around_vertex( old_vertex_id ); if( polyhedra_around.size() < 2 ) { - disassociate_polyhedron_vertex_to_vertex( - polyhedron_vertex_id ); + disassociate_polyhedron_vertex_to_vertex( old_vertex_id ); } else { associate_polyhedron_vertex_to_vertex( - polyhedra_around[1], polyhedron_vertex_id ); + polyhedra_around[1], new_vertex_id ); } } - reset_polyhedra_around_vertex( polyhedron_vertex_id ); + reset_polyhedra_around_vertex( old_vertex_id ); } if( solid_mesh_.are_edges_enabled() || solid_mesh_.are_facets_enabled() ) { update_edge_and_facet( - solid_mesh_, *this, polyhedron_vertex, vertex_id ); + solid_mesh_, *this, polyhedron_vertex, new_vertex_id ); } - update_polyhedron_vertex( polyhedron_vertex, vertex_id ); + update_polyhedron_vertex( polyhedron_vertex, new_vertex_id ); } template < index_t dimension > diff --git a/src/geode/mesh/builder/surface_mesh_builder.cpp b/src/geode/mesh/builder/surface_mesh_builder.cpp index da6f7e74c..d04929eb3 100644 --- a/src/geode/mesh/builder/surface_mesh_builder.cpp +++ b/src/geode/mesh/builder/surface_mesh_builder.cpp @@ -281,6 +281,19 @@ namespace } builder.create_polygon( vertices ); } + for( const auto v : geode::Range{ surface.nb_vertices() } ) + { + const auto polygon = surface.polygon_around_vertex( v ); + if( !polygon ) + { + builder.disassociate_polygon_vertex_to_vertex( v ); + } + else + { + builder.associate_polygon_vertex_to_vertex( + polygon.value(), v ); + } + } } template < geode::index_t dimension > @@ -405,41 +418,41 @@ namespace geode template < index_t dimension > void SurfaceMeshBuilder< dimension >::set_polygon_vertex( - const PolygonVertex& polygon_vertex, index_t vertex_id ) + const PolygonVertex& polygon_vertex, index_t new_vertex_id ) { - const auto polygon_vertex_id = + const auto old_vertex_id = surface_mesh_.polygon_vertex( polygon_vertex ); - if( polygon_vertex_id == vertex_id ) + if( old_vertex_id == new_vertex_id ) { return; } - if( polygon_vertex_id != NO_ID ) + if( old_vertex_id != NO_ID ) { const auto polygon_around = - surface_mesh_.polygon_around_vertex( polygon_vertex_id ); + surface_mesh_.polygon_around_vertex( old_vertex_id ); if( polygon_around == polygon_vertex ) { const auto& polygons_around = - surface_mesh_.polygons_around_vertex( polygon_vertex_id ); + surface_mesh_.polygons_around_vertex( old_vertex_id ); if( polygons_around.size() < 2 ) { - disassociate_polygon_vertex_to_vertex( polygon_vertex_id ); + disassociate_polygon_vertex_to_vertex( old_vertex_id ); } else { associate_polygon_vertex_to_vertex( - polygons_around[1], polygon_vertex_id ); + polygons_around[1], new_vertex_id ); } } - reset_polygons_around_vertex( polygon_vertex_id ); + reset_polygons_around_vertex( old_vertex_id ); } if( surface_mesh_.are_edges_enabled() ) { - update_edge( surface_mesh_, *this, polygon_vertex, - polygon_vertex_id, vertex_id ); + update_edge( surface_mesh_, *this, polygon_vertex, old_vertex_id, + new_vertex_id ); } - update_polygon_vertex( polygon_vertex, vertex_id ); + update_polygon_vertex( polygon_vertex, new_vertex_id ); } template < index_t dimension >