Commit 85f96d09 authored by Philip Trettner's avatar Philip Trettner
Browse files

added some additional safeguards for adding faces

parent a3d2f2aa
......@@ -774,6 +774,7 @@ face_handle face_collection<iterator>::add(std::vector<halfedge_index> const& ha
template <class iterator>
face_handle face_collection<iterator>::add(vertex_handle v0, vertex_handle v1, vertex_handle v2) const
{
POLYMESH_ASSERT(v0.is_valid() && v1.is_valid() && v2.is_valid());
halfedge_index hs[3] = {
low_level_api(this->m).add_or_get_halfedge(v2.idx, v0.idx), //
low_level_api(this->m).add_or_get_halfedge(v0.idx, v1.idx), //
......@@ -785,6 +786,7 @@ face_handle face_collection<iterator>::add(vertex_handle v0, vertex_handle v1, v
template <class iterator>
face_handle face_collection<iterator>::add(vertex_handle v0, vertex_handle v1, vertex_handle v2, vertex_handle v3) const
{
POLYMESH_ASSERT(v0.is_valid() && v1.is_valid() && v2.is_valid() && v3.is_valid());
halfedge_index hs[4] = {
low_level_api(this->m).add_or_get_halfedge(v3.idx, v0.idx), //
low_level_api(this->m).add_or_get_halfedge(v0.idx, v1.idx), //
......@@ -797,6 +799,7 @@ face_handle face_collection<iterator>::add(vertex_handle v0, vertex_handle v1, v
template <class iterator>
face_handle face_collection<iterator>::add(halfedge_handle h0, halfedge_handle h1, halfedge_handle h2) const
{
POLYMESH_ASSERT(h0.is_valid() && h1.is_valid() && h2.is_valid());
halfedge_index hs[3] = {h0.idx, h1.idx, h2.idx};
return this->m->handle_of(low_level_api(this->m).add_face(hs, 3));
}
......@@ -804,6 +807,7 @@ face_handle face_collection<iterator>::add(halfedge_handle h0, halfedge_handle h
template <class iterator>
face_handle face_collection<iterator>::add(halfedge_handle h0, halfedge_handle h1, halfedge_handle h2, halfedge_handle h3) const
{
POLYMESH_ASSERT(h0.is_valid() && h1.is_valid() && h2.is_valid() && h3.is_valid());
halfedge_index hs[4] = {h0.idx, h1.idx, h2.idx, h3.idx};
return this->m->handle_of(low_level_api(this->m).add_face(hs, 4));
}
......@@ -814,7 +818,10 @@ face_handle face_collection<iterator>::add(const vertex_handle (&v_handles)[N])
{
halfedge_index hs[N];
for (auto i = 0u; i < N; ++i)
{
POLYMESH_ASSERT(v_handles[i].is_valid());
hs[i] = low_level_api(this->m).add_or_get_halfedge(v_handles[(i + N - 1) % N].idx, v_handles[i].idx);
}
return this->m->handle_of(low_level_api(this->m).add_face(hs, N));
}
......@@ -824,7 +831,10 @@ face_handle face_collection<iterator>::add(const halfedge_handle (&half_loop)[N]
{
halfedge_index hs[N];
for (auto i = 0u; i < N; ++i)
{
POLYMESH_ASSERT(half_loop[i].is_valid());
hs[i] = half_loop[i].idx;
}
return this->m->handle_of(low_level_api(this->m).add_face(hs, N));
}
......
Supports Markdown
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