Commit 954d686b authored by Philip Trettner's avatar Philip Trettner
Browse files

more topo api

parent 2847632a
......@@ -16,10 +16,11 @@ Best used with glm and glow.
* Switch primitives and valid_primitives, check if compact flag is inlined
* 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
* 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
* _copy versions of topological operations that copy attributes
\ No newline at end of file
* _copy versions of topological operations that copy attributes
* vertex split?
* half-edge collapse
\ No newline at end of file
......@@ -171,11 +171,9 @@ private:
vertex_index halfedge_split(halfedge_index h);
/// collapse a vertex
void vertex_collapse(vertex_handle v) const;
/// collapse an edge
void edge_collapse(edge_handle e) const;
void vertex_collapse(vertex_index v);
/// collapse a half-edge
void halfedge_collapse(halfedge_handle h) const;
void halfedge_collapse(halfedge_index h);
/// rotates an edge to next
void edge_rotate_next(edge_index e);
......
......@@ -703,11 +703,52 @@ inline vertex_index Mesh::halfedge_split(halfedge_index h)
return v;
}
inline void Mesh::vertex_collapse(vertex_handle v) const { assert(0 && "not implemented"); }
inline void Mesh::vertex_collapse(vertex_index v)
{
auto &v_ref = vertex(v);
inline void Mesh::edge_collapse(edge_handle e) const { assert(0 && "not implemented"); }
// isolated vertices are just removed
if (v_ref.is_isolated())
{
remove_vertex(v);
}
// boundary vertices are special
else if (is_boundary(v))
{
assert(0 && "not implemented");
}
else // interior vertex
{
auto h_begin = halfedge(vertex(v).outgoing_halfedge).next_halfedge;
remove_vertex(v);
inline void Mesh::halfedge_collapse(halfedge_handle h) const { assert(0 && "not implemented"); }
assert(is_boundary(h_begin));
// TODO: optimize
std::vector<halfedge_index> hs;
auto h = h_begin;
do
{
// add half-edge ring
hs.push_back(h);
// advance
h = halfedge(h).next_halfedge;
} while (h != h_begin);
// add face
add_face(hs.data(), (int)hs.size());
}
}
inline void Mesh::halfedge_collapse(halfedge_index h)
{
// TODO: collapse half-edge
// preserve adjacent non-triangles
assert(0 && "not implemented");
}
inline void Mesh::edge_rotate_next(edge_index e)
{
......
......@@ -564,12 +564,6 @@ void vertex_collection<iterator>::collapse(vertex_handle v) const
this->mesh->vertex_collapse(v.idx);
}
template<class iterator>
void edge_collection<iterator>::collapse(edge_handle e) const
{
this->mesh->edge_collapse(e.idx);
}
template<class iterator>
void halfedge_collection<iterator>::collapse(halfedge_handle h) const
{
......
......@@ -212,10 +212,6 @@ struct edge_collection : smart_collection<Mesh*, edge_tag, iterator>
/// The edge itself is deleted and two new ones are created
vertex_handle split(edge_handle e) const;
/// Collapsed the given edge by removing it, adding a new vertex, and triangles for each opposite edge
/// Preserves half-edge properties but not face or vertex ones
void collapse(edge_handle e) const;
/// Moves both half-edges vertices to their next half-edge vertex
/// Equivalent to an edge flip if both faces are triangular
/// Preserves all attributes
......
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