Skip to content

Commit cd6e224

Browse files
committed
fix(repair_manifold): Fixed missing attribute update on vertices added during non manifold repair.
1 parent e333402 commit cd6e224

File tree

2 files changed

+26
-16
lines changed

2 files changed

+26
-16
lines changed

src/geode/mesh/helpers/detail/solid_mesh_validity_fix.cpp

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424
#include <geode/mesh/helpers/detail/solid_mesh_validity_fix.hpp>
2525

26+
#include <geode/basic/attribute_manager.hpp>
2627
#include <geode/basic/uuid.hpp>
2728

2829
#include <geode/geometry/point.hpp>
@@ -51,10 +52,12 @@ namespace geode
5152
}
5253
}
5354
GenericMapping< index_t > vertex_mappings;
54-
for( const auto v : Range{ mesh.nb_vertices() } )
55+
for( const auto vertex_id : Range{ mesh.nb_vertices() } )
5556
{
56-
auto polyhedra_around = mesh.polyhedra_around_vertex( v );
57-
const auto& polyhedron_vertices = polyhedra_around_vertices[v];
57+
auto polyhedra_around =
58+
mesh.polyhedra_around_vertex( vertex_id );
59+
const auto& polyhedron_vertices =
60+
polyhedra_around_vertices[vertex_id];
5861
auto nb_polyhedra_around = polyhedra_around.size();
5962
if( nb_polyhedra_around == polyhedron_vertices.size() )
6063
{
@@ -68,20 +71,23 @@ namespace geode
6871
total_polyhedra.emplace_back( std::move( polyhedron ) );
6972
}
7073
const auto new_vertex_id =
71-
builder.create_point( mesh.point( v ) );
72-
builder.replace_vertex( v, new_vertex_id );
74+
builder.create_point( mesh.point( vertex_id ) );
75+
mesh.vertex_attribute_manager().copy_attribute_value(
76+
vertex_id, new_vertex_id );
77+
builder.replace_vertex( vertex_id, new_vertex_id );
7378
for( const auto& polyhedron_vertex : polyhedron_vertices )
7479
{
7580
if( absl::c_find( total_polyhedra, polyhedron_vertex )
7681
== total_polyhedra.end() )
7782
{
7883
builder.associate_polyhedron_vertex_to_vertex(
79-
polyhedron_vertex, v );
84+
polyhedron_vertex, vertex_id );
8085
break;
8186
}
8287
}
83-
vertex_mappings.map( v, new_vertex_id );
84-
polyhedra_around = mesh.polyhedra_around_vertex( v );
88+
vertex_mappings.map( vertex_id, new_vertex_id );
89+
polyhedra_around =
90+
mesh.polyhedra_around_vertex( vertex_id );
8591
nb_polyhedra_around += polyhedra_around.size();
8692
}
8793
}

src/geode/mesh/helpers/detail/surface_mesh_validity_fix.cpp

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424
#include <geode/model/helpers/detail/surface_mesh_validity_fix.hpp>
2525

26+
#include <geode/basic/attribute_manager.hpp>
2627
#include <geode/basic/uuid.hpp>
2728

2829
#include <geode/geometry/point.hpp>
@@ -53,10 +54,11 @@ namespace geode
5354
}
5455
}
5556
GenericMapping< index_t > vertex_mappings;
56-
for( const auto v : Range{ mesh.nb_vertices() } )
57+
for( const auto vertex_id : Range{ mesh.nb_vertices() } )
5758
{
58-
auto polygons_around = mesh.polygons_around_vertex( v );
59-
const auto& polygon_vertices = polygons_around_vertices[v];
59+
auto polygons_around = mesh.polygons_around_vertex( vertex_id );
60+
const auto& polygon_vertices =
61+
polygons_around_vertices[vertex_id];
6062
auto nb_polygons_around = polygons_around.size();
6163
if( nb_polygons_around == polygon_vertices.size() )
6264
{
@@ -71,20 +73,22 @@ namespace geode
7173
total_polygons.emplace_back( std::move( polygon ) );
7274
}
7375
const auto new_vertex_id =
74-
builder.create_point( mesh.point( v ) );
75-
builder.replace_vertex( v, new_vertex_id );
76+
builder.create_point( mesh.point( vertex_id ) );
77+
mesh.vertex_attribute_manager().copy_attribute_value(
78+
vertex_id, new_vertex_id );
79+
builder.replace_vertex( vertex_id, new_vertex_id );
7680
for( const auto& polygon_vertex : polygon_vertices )
7781
{
7882
if( absl::c_find( total_polygons, polygon_vertex )
7983
== total_polygons.end() )
8084
{
8185
builder.associate_polygon_vertex_to_vertex(
82-
polygon_vertex, v );
86+
polygon_vertex, vertex_id );
8387
break;
8488
}
8589
}
86-
vertex_mappings.map( v, new_vertex_id );
87-
polygons_around = mesh.polygons_around_vertex( v );
90+
vertex_mappings.map( vertex_id, new_vertex_id );
91+
polygons_around = mesh.polygons_around_vertex( vertex_id );
8892
nb_polygons_around += polygons_around.size();
8993
}
9094
}

0 commit comments

Comments
 (0)