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

added edge flip special API

parent 4c01dc45
......@@ -4,57 +4,21 @@
namespace polymesh
{
inline vertex_index low_level_api_mutable::add_vertex() const
{
return alloc_vertex();
}
inline vertex_index low_level_api_mutable::add_vertex() const { return alloc_vertex(); }
inline vertex_index low_level_api_mutable::alloc_vertex() const
{
return m.alloc_vertex();
}
inline face_index low_level_api_mutable::alloc_face() const
{
return m.alloc_face();
}
inline edge_index low_level_api_mutable::alloc_edge() const
{
return m.alloc_edge();
}
inline void low_level_api_mutable::alloc_primitives(int vertices, int faces, int halfedges) const
{
m.alloc_primitives(vertices, faces, halfedges);
}
inline vertex_index low_level_api_mutable::alloc_vertex() const { return m.alloc_vertex(); }
inline face_index low_level_api_mutable::alloc_face() const { return m.alloc_face(); }
inline edge_index low_level_api_mutable::alloc_edge() const { return m.alloc_edge(); }
inline void low_level_api_mutable::alloc_primitives(int vertices, int faces, int halfedges) const { m.alloc_primitives(vertices, faces, halfedges); }
inline void low_level_api_mutable::reserve_vertices(int capacity) const
{
m.reserve_vertices(capacity);
}
inline void low_level_api_mutable::reserve_edges(int capacity) const
{
m.reserve_edges(capacity);
}
inline void low_level_api_mutable::reserve_halfedges(int capacity) const
{
m.reserve_halfedges(capacity);
}
inline void low_level_api_mutable::reserve_faces(int capacity) const
{
m.reserve_faces(capacity);
}
inline void low_level_api_mutable::reserve_vertices(int capacity) const { m.reserve_vertices(capacity); }
inline void low_level_api_mutable::reserve_edges(int capacity) const { m.reserve_edges(capacity); }
inline void low_level_api_mutable::reserve_halfedges(int capacity) const { m.reserve_halfedges(capacity); }
inline void low_level_api_mutable::reserve_faces(int capacity) const { m.reserve_faces(capacity); }
inline void low_level_api_mutable::permute_faces(const std::vector<int>& p) const
{
m.permute_faces(p);
}
inline void low_level_api_mutable::permute_edges(const std::vector<int>& p) const
{
m.permute_edges(p);
}
inline void low_level_api_mutable::permute_vertices(const std::vector<int>& p) const
{
m.permute_vertices(p);
}
inline void low_level_api_mutable::permute_faces(const std::vector<int>& p) const { m.permute_faces(p); }
inline void low_level_api_mutable::permute_edges(const std::vector<int>& p) const { m.permute_edges(p); }
inline void low_level_api_mutable::permute_vertices(const std::vector<int>& p) const { m.permute_vertices(p); }
namespace detail
{
......@@ -988,6 +952,15 @@ inline void low_level_api_mutable::edge_rotate_prev(edge_index e) const
fix_boundary_state_of(face_of(h1));
}
inline void low_level_api_mutable::edge_flip(edge_index e) const
{
POLYMESH_ASSERT(!is_boundary(e) && "does not work on boundaries");
POLYMESH_ASSERT(m.handle_of(e).faceA().halfedges().size() == 3 && "only works for triangles");
POLYMESH_ASSERT(m.handle_of(e).faceB().halfedges().size() == 3 && "only works for triangles");
edge_rotate_next(e);
}
inline void low_level_api_mutable::halfedge_rotate_next(halfedge_index h) const
{
POLYMESH_ASSERT(m.handle_of(h).next().next().next() != h && "does not work for triangles");
......
......@@ -1013,6 +1013,12 @@ void edge_collection<iterator>::rotate_prev(edge_handle e) const
low_level_api(this->m).edge_rotate_prev(e.idx);
}
template <class iterator>
void edge_collection<iterator>::flip(edge_handle e) const
{
low_level_api(this->m).edge_flip(e.idx);
}
template <class iterator>
vertex_handle halfedge_collection<iterator>::split(halfedge_handle h) const
{
......
......@@ -337,6 +337,8 @@ public:
void edge_rotate_next(edge_index e) const;
/// rotates an edge to prev
void edge_rotate_prev(edge_index e) const;
/// performs an edge flip
void edge_flip(edge_index e) const;
/// rotates a half-edge to next
void halfedge_rotate_next(halfedge_index h) const;
/// rotates a half-edge to prev
......
......@@ -376,6 +376,12 @@ struct edge_collection : smart_collection<Mesh*, edge_tag, iterator>
/// Same as rotate_next but with the previous half-edge
void rotate_prev(edge_handle e) const;
/// performs an edge flip
/// NOTE: does not work on boundaries
/// NOTE: only works if both faces are triangles
/// Preserves all attributes
void flip(edge_handle e) const;
/// Removes an edge (and both adjacent faces, vertices are NOT removed)
/// (marks them as removed, compactify mesh to actually remove them)
void remove(edge_handle e) const;
......
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