Commit 078e541c authored by Philip Trettner's avatar Philip Trettner
Browse files

next crash fix

parent d445e9d6
Pipeline #17187 passed with stage
in 4 minutes and 54 seconds
polymesh @ a9f10730
Subproject commit b7ee88d6a832faccbd38a1b568c0467644111e2d
Subproject commit a9f10730da832facca272aac08d79b7a84ad6439
......@@ -114,3 +114,99 @@ TEST_CASE("triangulate_naive crash")
c.add_line(p0, p1);
}*/
}
TEST_CASE("triangulate_naive crash 2")
{
auto m = pm::Mesh();
std::vector<pm::vertex_index> vertices;
for (int i = 0; i < 9; ++i)
vertices.push_back(m.vertices().add());
std::vector<pm::vertex_index> vs;
vs.push_back(vertices[1]);
vs.push_back(vertices[2]);
vs.push_back(vertices[3]);
vs.push_back(vertices[0]);
m.faces().add(vs);
vs.clear();
vs.push_back(vertices[4]);
vs.push_back(vertices[5]);
vs.push_back(vertices[2]);
vs.push_back(vertices[1]);
m.faces().add(vs);
vs.clear();
vs.push_back(vertices[6]);
vs.push_back(vertices[3]);
vs.push_back(vertices[2]);
vs.push_back(vertices[5]);
m.faces().add(vs);
vs.clear();
vs.push_back(vertices[0]);
vs.push_back(vertices[3]);
vs.push_back(vertices[6]);
vs.push_back(vertices[7]);
m.faces().add(vs);
vs.clear();
vs.push_back(vertices[8]);
vs.push_back(vertices[7]);
vs.push_back(vertices[6]);
vs.push_back(vertices[5]);
vs.push_back(vertices[4]);
m.faces().add(vs);
vs.clear();
vs.push_back(vertices[7]);
vs.push_back(vertices[8]);
vs.push_back(vertices[4]);
vs.push_back(vertices[1]);
vs.push_back(vertices[0]);
m.faces().add(vs);
vs.clear();
pm::triangulate_naive(m);
/*
{
auto is_inner_valence2 = [](pm::vertex_handle v) { return !v.is_boundary() && valence(v) == 2; };
std::vector<pm::vertex_handle> vs;
for (auto f : m.faces())
{
vs.clear();
f.vertices().into_vector(vs);
if (vs.size() <= 3)
continue;
// find non-valence 2
auto si = 0;
for (auto i = 0u; i < vs.size(); ++i)
{
if (!is_inner_valence2(vs[i]))
{
si = i;
break;
}
}
POLYMESH_ASSERT(!is_inner_valence2(vs[si]) && "could not find start vertex (second vertex must not be inner valence 2)");
si--; // make sure v1 is never valence 2
if (si < 0)
si += int(vs.size());
// remove
m.faces().remove(f);
// triangulate
std::cout << "triangulate " << int(f) << std::endl;
for (auto i = 2u; i < vs.size(); ++i)
{
auto v0 = vs[si];
auto v1 = vs[(si + i - 1) % vs.size()];
auto v2 = vs[(si + i) % vs.size()];
std::cout << int(v0) << " " << int(v1) << " " << int(v2) << std::endl;
for (auto v : {v0, v1, v2})
std::cout << " is inner val 2: " << is_inner_valence2(v) << " (boundary " << v.is_boundary() << ", valence: " << valence(v)
<< ")" << std::endl;
m.faces().add(v0, v1, v2);
}
}
}*/
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment