Commit 43331e55 authored by Philip Trettner's avatar Philip Trettner
Browse files

some rotate fixes

parent 1b68796e
......@@ -17,11 +17,9 @@ Best used with glm and glow.
* Test self-adjacent faces
* smart ranges: filter, map
* mid-level topo API: edge-rotate-next/prev, edge-split, edge-collapse, halfedge-split, halfedge-collapse, vertex-collapse
* annotate property preservation for mid-level topo API
* vector, set, map -> range
* opposite edges (from vertex)
* cotangens weights etc.
* smoothing
* make handle.<primitives>() contain only valid ones and provide an all_<primitives>() version
* boundary iterators
* _copy versions of topological operations that copy attributes
\ No newline at end of file
......@@ -192,6 +192,10 @@ void Mesh::assert_consistency() const
assert(h.next().vertex_from() == h.vertex_to());
assert(h.prev().vertex_to() == h.vertex_from());
auto ref_face = h.face();
for (auto h : h.ring())
assert(h.face() == ref_face);
}
// check vertex consistencies
......
......@@ -154,23 +154,7 @@ struct halfedge_handle : primitive_handle<halfedge_tag>
halfedge_handle prev() const;
halfedge_handle opposite() const;
face_handle opposite_face() const; ///< invalid if opposite boundary
};
/// ======== IMPLEMENTATION ========
template <class tag>
std::ostream& operator<<(std::ostream& out, primitive_index<tag> const& v)
{
out << primitive<tag>::name << " " << v.value;
if (v.is_invalid())
out << " (invalid)";
return out;
}
template <class tag>
std::ostream& operator<<(std::ostream& out, primitive_handle<tag> const& v)
{
out << v.idx;
return out;
}
halfedge_ring ring() const; ///< all half-edges along the same ring
};
}
......@@ -63,4 +63,6 @@ struct vertex_halfedge_in_ring;
struct vertex_face_ring;
struct vertex_edge_ring;
struct vertex_vertex_ring;
struct halfedge_ring;
}
......@@ -118,4 +118,22 @@ inline vertex_edge_ring vertex_handle::edges() const { return {*this}; }
inline vertex_face_ring vertex_handle::faces() const { return {*this}; }
inline vertex_vertex_ring vertex_handle::adjacent_vertices() const { return {*this}; }
inline halfedge_ring halfedge_handle::ring() const { return {*this}; }
template <class tag>
std::ostream& operator<<(std::ostream& out, primitive_index<tag> const& v)
{
out << primitive<tag>::name << " " << v.value;
if (v.is_invalid())
out << " (invalid)";
return out;
}
template <class tag>
std::ostream& operator<<(std::ostream& out, primitive_handle<tag> const& v)
{
out << v.idx;
return out;
}
}
......@@ -178,4 +178,11 @@ struct vertex_edge_circulator : primitive_circulator<vertex_edge_circulator>
edge_handle operator*() const { return handle.edge(); }
void advance() { handle = handle.opposite().next(); }
};
struct halfedge_ring_circulator : primitive_circulator<halfedge_ring_circulator>
{
using primitive_circulator<halfedge_ring_circulator>::primitive_circulator;
halfedge_handle operator*() const { return handle; }
void advance() { handle = handle.next(); }
};
}
......@@ -366,6 +366,17 @@ struct vertex_primitive_ring : primitive_ring<vertex_primitive_ring<tag, circula
circulator end() const { return {vertex.any_outgoing_halfedge(), true}; }
};
template <class tag, class circulator>
struct halfedge_primitive_ring : primitive_ring<halfedge_primitive_ring<tag, circulator>, tag>
{
halfedge_handle halfedge;
halfedge_primitive_ring(halfedge_handle h) { halfedge = h; }
// Iteration:
circulator begin() const { return {halfedge, false}; }
circulator end() const { return {halfedge, true}; }
};
/// all vertices belonging to a face
struct face_vertex_ring : face_primitive_ring<vertex_tag, face_vertex_circulator>
{
......@@ -420,4 +431,9 @@ struct vertex_face_ring : vertex_primitive_ring<face_tag, vertex_face_circulator
using vertex_primitive_ring<face_tag, vertex_face_circulator>::vertex_primitive_ring;
};
/// all half-edges along a ring (next -> next -> ...)
struct halfedge_ring : halfedge_primitive_ring<halfedge_tag, halfedge_ring_circulator>
{
using halfedge_primitive_ring<halfedge_tag, halfedge_ring_circulator>::halfedge_primitive_ring;
};
}
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