Commit 88a8017b authored by Philip Trettner's avatar Philip Trettner
Browse files

more assertions

parent 49cfa35a
......@@ -100,6 +100,7 @@ void Mesh::alloc_primitives(int vertices, int faces, int halfedges)
void Mesh::permute_vertices(std::vector<int> const& p)
{
POLYMESH_ASSERT(detail::is_valid_permutation(p));
POLYMESH_ASSERT(int(p.size()) == mVerticesSize);
// calculate transpositions
auto ts = detail::transpositions_of(p);
......@@ -121,6 +122,7 @@ void Mesh::permute_vertices(std::vector<int> const& p)
void Mesh::permute_faces(std::vector<int> const& p)
{
POLYMESH_ASSERT(detail::is_valid_permutation(p));
POLYMESH_ASSERT(int(p.size()) == mFacesSize);
// calculate transpositions
auto ts = detail::transpositions_of(p);
......@@ -142,6 +144,7 @@ void Mesh::permute_faces(std::vector<int> const& p)
void Mesh::permute_edges(std::vector<int> const& p)
{
POLYMESH_ASSERT(detail::is_valid_permutation(p));
POLYMESH_ASSERT(int(p.size() * 2) == mHalfedgesSize);
std::vector<int> hp(p.size() * 2);
for (auto i = 0u; i < p.size(); ++i)
......
......@@ -299,7 +299,12 @@ bool low_level_api_base<MeshT>::can_add_face(const halfedge_handle* half_loop, i
if (vcnt < 3)
return false; // too few vertices
// TODO: check duplicated vertices
// check duplicated vertices
// TODO: a bit more performant
for (auto i = 0; i < vcnt; ++i)
for (auto j = i + 1; j < vcnt; ++j)
if (to_vertex_of(half_loop[i]) == to_vertex_of(half_loop[j]))
return false;
// ensure that half-edges are adjacent at each vertex
for (auto i = 0; i < vcnt; ++i)
......@@ -329,7 +334,12 @@ bool low_level_api_base<MeshT>::can_add_face(const halfedge_index* half_loop, in
if (vcnt < 3)
return false; // too few vertices
// TODO: check duplicated vertices
// check duplicated vertices
// TODO: a bit more performant
for (auto i = 0; i < vcnt; ++i)
for (auto j = i + 1; j < vcnt; ++j)
if (to_vertex_of(half_loop[i]) == to_vertex_of(half_loop[j]))
return false;
// ensure that half-edges are adjacent at each vertex
for (auto i = 0; i < vcnt; ++i)
......
......@@ -1001,7 +1001,7 @@ inline void low_level_api_mutable::halfedge_rotate_prev(halfedge_index h) const
{
POLYMESH_ASSERT(m.handle_of(h).prev().prev().prev() != h && "does not work for triangles");
POLYMESH_ASSERT(!m.handle_of(h).edge().is_boundary() && "does not work on boundaries");
POLYMESH_ASSERT(m.handle_of(h).vertex_from().adjacent_vertices().size() > 2 && "does not work on valence <= 2 vertices");
POLYMESH_ASSERT(m.handle_of(h).vertex_to().adjacent_vertices().size() > 2 && "does not work on valence <= 2 vertices");
auto h0 = h;
auto h1 = opposite(h);
......
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