Fixed a crash in the modified butterfly subdivider with vertices with valance larger than 30.

This commit is contained in:
Jan Möbius
2021-02-16 13:13:15 +01:00
parent 6aebeef889
commit 0031513835
3 changed files with 33 additions and 0 deletions

View File

@@ -179,6 +179,17 @@ protected:
///TODO:Implement fixed positions
// Compute the maximal vertex valence in the mesh
unsigned int maxValence = 0;
for ( auto vertex : _m.vertices() ) {
maxValence = std::max(maxValence,_m.valence(vertex));
}
// We pre initialized with 30. If it's larger, we update the weights
if (maxValence >= 30) {
init_weights( maxValence + 1 );
}
// Do _n subdivisions
for (size_t i=0; i < _n; ++i)
{

Binary file not shown.

View File

@@ -1027,6 +1027,28 @@ TEST_F(OpenMeshSubdividerUniform_Triangle, Modified_Butterfly) {
TEST_F(OpenMeshSubdividerUniform_Triangle, Modified_Butterfly_cylinder) {
mesh_.clear();
OpenMesh::IO::read_mesh(mesh_, "cylinder.om");
// Initialize subdivider
OpenMesh::Subdivider::Uniform::ModifiedButterflyT<Mesh> butter;
// Check setup
EXPECT_EQ(66u, mesh_.n_vertices() ) << "Wrong number of vertices";
EXPECT_EQ(128u, mesh_.n_faces() ) << "Wrong number of faces";
// Execute 3 subdivision steps
butter( mesh_,3,true );
// Check setup
EXPECT_EQ(4098u, mesh_.n_vertices() ) << "Wrong number of vertices after subdivision with loop";
EXPECT_EQ(8192u, mesh_.n_faces() ) << "Wrong number of faces after subdivision with loop";
}
TEST_F(OpenMeshSubdividerUniform_Triangle, Modified_Butterfly_delete_vertex) {
for (bool collect_garbage : { false, true })