Template Function lvr2::iterativeEdgeCollapse

Function Documentation

template<typename BaseVecT, typename CostF>
size_t lvr2::iterativeEdgeCollapse(BaseMesh<BaseVecT> &mesh, const size_t count, FaceMap<Normal<typename BaseVecT::CoordType>> &faceNormals, CostF collapseCost)

Collapses count many edges of mesh for which collapseCost returns the smallest values.

This algorithm collapses edges in the given mesh. The order of edge collapses is determined by collapseCost: the edge with the smallest cost is collapsed first, if that is possible. In case the edge is not collapsable, it is ignored and the next edge is choosen. After each collapse, the cost function is called again to update the costs for all edges that could have been affected, which are the edges of all faces which touch the vertex the edge was collapsed to.

This algorithm stops when either count many edges have been collapsed or if there are no collapsable edges left.

Parameters:
  • count[in] Number of edges to collapse

  • faceNormals[inout] A face map storing valid normals of all faces in the mesh. This map is altered by this algorithm according to the changes done in the mesh.

  • collapseCost[in] Function which is called with an edge handle and a FaceMap containing normals; it is expected to return an optional float. boost::none means that this edge cannot be collapsed.

Returns:

The number of edges actually collapsed.