nmwsharp / learned-triangulation

Source code for "PointTriNet: Learned Triangulation of 3D Point Sets", by Nicholas Sharp and Maks Ovsjanikov at ECCV 2020
MIT License
104 stars 15 forks source link

WaterTight #4

Open qpaozixu opened 3 years ago

qpaozixu commented 3 years ago

How could I measure the watertight rate of result mesh ?

nmwsharp commented 3 years ago

For the results in the paper, watertightness was measured by counting the number of edges which have != 2 incident triangles. So for instance percent watertightness might be given by:

100 * num_edge_with_2_tris / num_total_edge

Here's a little snippet of Python code that might help compute some of these counts. (I grabbed this from a random codebase and haven't tested recently, be sure to verify it before trusting blindly!)

    verts, faces = #your mesh

    halfedges = []
    for i in range(3):
        ind_low = np.minimum(faces[:,i], faces[:,(i+1)%3])
        ind_high = np.maximum(faces[:,i], faces[:,(i+1)%3])
        halfedges.append(np.stack((ind_low, ind_high), axis=-1))
    halfedges = np.concatenate(halfedges, axis=0)

    u_vals, u_inv, u_count = np.unique(halfedges, axis=0, return_inverse=True, return_counts=True)

    n_distinct = u_vals.shape[0]
    n_1 = np.count_nonzero(u_count == 1) # number of edges with 1 face incident
    n_2 = np.count_nonzero(u_count == 2) # number of edges with 2 faces incident
    n_3p = np.count_nonzero(u_count > 2) # number of edges with >=3 faces incident
qpaozixu commented 3 years ago

OK, very thanks for your help!