Commit 62677179 authored by Philip Trettner's avatar Philip Trettner
Browse files

made index::invalid a static member

parent db0273d9
......@@ -28,7 +28,7 @@ inline void remove_faces(Mesh& m)
// remove all faces from half-edges
for (auto h : m.halfedges())
ll.face_of(h) = face_index::invalid();
ll.face_of(h) = face_index::invalid;
}
inline void remove_edges_and_faces(Mesh& m)
......@@ -45,6 +45,6 @@ inline void remove_edges_and_faces(Mesh& m)
// remove all halfedges from vertices
for (auto v : m.vertices())
ll.outgoing_halfedge_of(v) = halfedge_index::invalid();
ll.outgoing_halfedge_of(v) = halfedge_index::invalid;
}
}
......@@ -22,7 +22,7 @@ struct primitive_index
bool is_valid() const { return value >= 0; }
bool is_invalid() const { return value < 0; }
static index_t invalid() { return {}; }
static const index_t invalid;
bool operator<(index_t const& rhs) const { return value < rhs.value; }
bool operator<=(index_t const& rhs) const { return value <= rhs.value; }
......@@ -56,6 +56,9 @@ struct primitive_index
AttrT const& operator[](attribute<AttrT> const* attr) const;
};
template <class tag>
const typename primitive<tag>::index primitive_index<tag>::invalid = {};
template <class tag>
struct primitive_handle
{
......
......@@ -82,7 +82,7 @@ inline face_handle edge_handle::faceB() const { return mesh->handle_of(low_level
inline face_handle vertex_handle::any_face() const
{
auto h = low_level_api(mesh).outgoing_halfedge_of(idx);
return mesh->handle_of(h.is_valid() ? low_level_api(mesh).face_of(h) : face_index::invalid());
return mesh->handle_of(h.is_valid() ? low_level_api(mesh).face_of(h) : face_index::invalid);
}
inline face_handle vertex_handle::any_valid_face() const
......@@ -90,7 +90,7 @@ inline face_handle vertex_handle::any_valid_face() const
for (auto f : faces())
if (f.is_valid())
return f;
return mesh->handle_of(face_index::invalid());
return mesh->handle_of(face_index::invalid);
}
inline halfedge_handle vertex_handle::any_outgoing_halfedge() const { return mesh->handle_of(low_level_api(mesh).outgoing_halfedge_of(idx)); }
......@@ -98,13 +98,13 @@ inline halfedge_handle vertex_handle::any_outgoing_halfedge() const { return mes
inline halfedge_handle vertex_handle::any_incoming_halfedge() const
{
auto h = low_level_api(mesh).outgoing_halfedge_of(idx);
return mesh->handle_of(h.is_valid() ? low_level_api(mesh).opposite(h) : halfedge_index::invalid());
return mesh->handle_of(h.is_valid() ? low_level_api(mesh).opposite(h) : halfedge_index::invalid);
}
inline edge_handle vertex_handle::any_edge() const
{
auto h = low_level_api(mesh).outgoing_halfedge_of(idx);
return mesh->handle_of(h.is_valid() ? low_level_api(mesh).edge_of(h) : edge_index::invalid());
return mesh->handle_of(h.is_valid() ? low_level_api(mesh).edge_of(h) : edge_index::invalid);
}
inline vertex_handle face_handle::any_vertex() const
......
......@@ -371,7 +371,7 @@ halfedge_index low_level_api_base<MeshT>::find_free_incident(halfedge_index in_b
he = opposite(next_halfedge_of(he));
} while (he != in_end);
return halfedge_index::invalid();
return halfedge_index::invalid;
}
template <class MeshT>
......@@ -386,7 +386,7 @@ halfedge_index low_level_api_base<MeshT>::find_halfedge(vertex_index from, verte
{
auto he_begin = outgoing_halfedge_of(from);
if (!he_begin.is_valid())
return halfedge_index::invalid(); // isolated vertex
return halfedge_index::invalid; // isolated vertex
auto he = he_begin;
do
......@@ -400,7 +400,7 @@ halfedge_index low_level_api_base<MeshT>::find_halfedge(vertex_index from, verte
} while (he != he_begin);
return halfedge_index::invalid(); // not found
return halfedge_index::invalid; // not found
}
template <class MeshT>
......
......@@ -290,7 +290,7 @@ inline void low_level_api_mutable::remove_face(face_index f_idx) const
POLYMESH_ASSERT(face_of(he) == f_idx);
// set half-edge face to invalid
face_of(he) = face_index::invalid();
face_of(he) = face_index::invalid;
// fix outgoing vertex half-edge
// (vertex correctly reports is_boundary)
......@@ -343,7 +343,7 @@ inline void low_level_api_mutable::remove_edge(edge_index e_idx) const
if (v_in_to_out == h_out)
{
if (hi_in_next == h_out) // v_in_to becomes isolated
v_in_to_out = halfedge_index::invalid();
v_in_to_out = halfedge_index::invalid;
else
v_in_to_out = hi_in_next;
}
......@@ -352,7 +352,7 @@ inline void low_level_api_mutable::remove_edge(edge_index e_idx) const
if (v_out_to_out == h_in)
{
if (hi_out_next == h_in) // v_out_to becomes isolated
v_out_to_out = halfedge_index::invalid();
v_out_to_out = halfedge_index::invalid;
else
v_out_to_out = hi_out_next;
}
......@@ -453,7 +453,7 @@ inline void low_level_api_mutable::set_removed(vertex_index idx) const
inline void low_level_api_mutable::set_removed(face_index idx) const
{
POLYMESH_ASSERT(!is_removed(idx) && "cannot remove an already removed entry");
halfedge_of(idx) = halfedge_index::invalid();
halfedge_of(idx) = halfedge_index::invalid;
// bookkeeping
m.mRemovedFaces++;
......@@ -463,8 +463,8 @@ inline void low_level_api_mutable::set_removed(face_index idx) const
inline void low_level_api_mutable::set_removed(edge_index idx) const
{
POLYMESH_ASSERT(!is_removed(idx) && "cannot remove an already removed entry");
to_vertex_of(halfedge_of(idx, 0)) = vertex_index::invalid();
to_vertex_of(halfedge_of(idx, 1)) = vertex_index::invalid();
to_vertex_of(halfedge_of(idx, 0)) = vertex_index::invalid;
to_vertex_of(halfedge_of(idx, 1)) = vertex_index::invalid;
// bookkeeping
m.mRemovedHalfedges++;
......
......@@ -74,7 +74,7 @@ inline vertex_index Mesh::alloc_vertex()
auto old_size = mVerticesSize;
auto capacity_changed = detail::alloc_back(mVerticesSize, mVerticesCapacity, mVertexToOutgoingHalfedge);
mVertexToOutgoingHalfedge[mVerticesSize - 1] = halfedge_index::invalid();
mVertexToOutgoingHalfedge[mVerticesSize - 1] = halfedge_index::invalid;
if (capacity_changed)
{
......@@ -92,7 +92,7 @@ inline face_index Mesh::alloc_face()
auto old_size = mFacesSize;
auto capacity_changed = detail::alloc_back(mFacesSize, mFacesCapacity, mFaceToHalfedge);
mFaceToHalfedge[mFacesSize - 1] = halfedge_index::invalid();
mFaceToHalfedge[mFacesSize - 1] = halfedge_index::invalid;
if (capacity_changed)
{
......@@ -114,10 +114,10 @@ inline edge_index Mesh::alloc_edge()
{
capacity_changed |= detail::alloc_back(mHalfedgesSize, mHalfedgesCapacity, //
mHalfedgeToFace, mHalfedgeToVertex, mHalfedgeToNextHalfedge, mHalfedgeToPrevHalfedge);
mHalfedgeToFace[mHalfedgesSize - 1] = face_index::invalid();
mHalfedgeToVertex[mHalfedgesSize - 1] = vertex_index::invalid();
mHalfedgeToNextHalfedge[mHalfedgesSize - 1] = halfedge_index::invalid();
mHalfedgeToPrevHalfedge[mHalfedgesSize - 1] = halfedge_index::invalid();
mHalfedgeToFace[mHalfedgesSize - 1] = face_index::invalid;
mHalfedgeToVertex[mHalfedgesSize - 1] = vertex_index::invalid;
mHalfedgeToNextHalfedge[mHalfedgesSize - 1] = halfedge_index::invalid;
mHalfedgeToPrevHalfedge[mHalfedgesSize - 1] = halfedge_index::invalid;
}
if (capacity_changed)
......
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