collapse static method
Implementation
static void collapse(List<Vertex> vertices,List<Tri> faces, Vertex u, Vertex? v){ // u and v are pointers to vertices of an edge
// Collapse the edge uv by moving vertex u onto v
if (v == null) {
// u is a vertex all by itself so just delete it..
removeVertex( u, vertices );
return;
}
final tmpVertices = [];
for (int i = 0; i < u.neighbors.length; i ++ ) {
tmpVertices.add( u.neighbors[ i ] );
}
// delete triangles on edge uv:
for (int i = u.faces.length - 1; i >= 0; i -- ) {
if(u.faces[i] != null && u.faces[ i ]!.hasVertex( v ) ) {
removeFace( u.faces[ i ]!, faces );
}
}
// update remaining triangles to have v instead of u
for (int i = u.faces.length - 1; i >= 0; i -- ) {
if(u.faces[i] != null){
u.faces[i]!.replaceVertex(u, v);
}
}
removeVertex( u, vertices );
// recompute the edge collapse costs in neighborhood
for (int i = 0; i < tmpVertices.length; i ++ ) {
computeEdgeCostAtVertex( tmpVertices[ i ] );
}
}