meshpro / meshplex

:spider_web: Compute interesting points, areas, and volumes in simplex meshes of any dimension.
104 stars 22 forks source link

new flip_until_delaunay mwe #155

Open rob-rb opened 3 years ago

rob-rb commented 3 years ago

Hi Nico I learned to extract sub-meshes here a small problem which still leads to non-manifold edges.

points=[[-59.930511474609375, -16.41863441467285, 72.35279083251953], [-59.930511474609375, -16.431669235229492, 72.3821029663086], [-58.85724639892578, -15.331669807434082, 72.35279083251953], [-58.83051300048828, -15.331669807434082, 72.46239471435547], [-59.930511474609375, -16.821197509765625, 73.45278930664062], [-59.33971405029297, -16.431669235229492, 73.45278930664062], [-58.83051300048828, -15.742518424987793, 73.45278930664062], [-56.74711608886719, -16.431669235229492, 73.45278930664062], [-58.222530364990234, -15.331669807434082, 73.45278930664062], [-57.24854278564453, -15.331669807434082, 73.45278930664062], [-57.73051452636719, -15.331669807434082, 74.52413177490234], [-59.930511474609375, -17.462806701660156, 74.55279541015625], [-56.92106246948242, -17.53166961669922, 74.55279541015625], [-58.866580963134766, -16.431669235229492, 74.55279541015625], [-58.83051300048828, -16.364282608032227, 74.55279541015625], [-58.83051300048828, -16.431669235229492, 74.68785858154297], [-57.181068420410156, -16.431669235229492, 74.55279541015625], [-57.73051452636719, -15.35062026977539, 74.55279541015625], [-57.14170837402344, -18.631669998168945, 75.65279388427734], [-59.22215270996094, -17.53166961669922, 75.65279388427734], [-58.83051300048828, -16.93937873840332, 75.65279388427734], [-58.83051300048828, -17.53166961669922, 76.5542984008789], [-57.28594207763672, -17.53166961669922, 75.65279388427734], [-58.095924377441406, -16.431669235229492, 75.65279388427734], [-57.52948760986328, -16.431669235229492, 75.65279388427734], [-57.73051452636719, -15.959747314453125, 75.65279388427734], [-57.73051452636719, -16.431669235229492, 76.41547393798828], [-57.73051452636719, -15.331669807434082, 76.28267669677734], [-58.83051300048828, -14.231670379638672, 76.5550765991211], [-57.43680191040039, -14.231670379638672, 75.65279388427734], [-57.73051452636719, -14.231670379638672, 75.7003173828125], [-57.45465850830078, -18.631669998168945, 76.75279235839844], [-58.38652420043945, -17.53166961669922, 76.75279235839844], [-57.58670425415039, -17.53166961669922, 76.75279235839844], [-57.73051452636719, -16.8353271484375, 76.75279235839844], [-57.73051452636719, -17.53166961669922, 77.44210815429688], [-57.73051452636719, -16.092775344848633, 76.75279235839844], [-57.73051452636719, -16.431669235229492, 76.94086456298828], [-56.63051223754883, -16.431669235229492, 77.78882598876953], [-58.014957427978516, -15.331669807434082, 76.75279235839844], [-58.83051300048828, -14.508148193359375, 76.75279235839844], [-58.83051300048828, -15.331669807434082, 77.35101318359375], [-56.80352783203125, -15.331669807434082, 76.75279235839844], [-56.63051223754883, -15.288931846618652, 76.75279235839844], [-56.63051223754883, -15.331669807434082, 76.7909164428711], [-57.720733642578125, -18.631669998168945, 77.85279083251953], [-57.73051452636719, -17.339282989501953, 77.85279083251953], [-56.63051223754883, -16.49909019470215, 77.85279083251953]]
faces=[[4, 1, 5], [2, 3, 6], [0, 2, 6], [0, 6, 5], [0, 5, 1], [6, 3, 8], [11, 4, 5], [13, 11, 5], [7, 12, 16], [5, 14, 13], [6, 14, 5], [8, 10, 17], [8, 17, 6], [6, 17, 14], [10, 16, 17], [10, 9, 16], [9, 7, 16], [18, 22, 12], [13, 15, 20], [11, 13, 20], [11, 20, 19], [20, 15, 23], [12, 22, 16], [22, 24, 16], [13, 14, 15], [15, 25, 23], [15, 14, 25], [14, 17, 25], [24, 17, 16], [25, 17, 24], [18, 31, 22], [31, 33, 22], [19, 20, 21], [23, 26, 34], [20, 23, 34], [20, 34, 32], [20, 32, 21], [26, 33, 34], [26, 24, 33], [24, 22, 33], [27, 23, 25], [27, 39, 23], [26, 23, 36], [36, 23, 39], [36, 24, 26], [36, 42, 24], [25, 24, 27], [27, 24, 42], [39, 28, 40], [39, 27, 28], [27, 30, 28], [29, 27, 43], [29, 30, 27], [42, 43, 27], [35, 33, 45], [33, 31, 45], [37, 32, 34], [37, 33, 38], [37, 34, 33], [38, 33, 47], [35, 46, 33], [47, 33, 46], [37, 39, 41], [37, 36, 39], [42, 36, 37], [42, 37, 44], [39, 40, 41], [42, 44, 43]]

import meshplex
import numpy as np
from meshplex import *
import npx

mesh = meshplex.MeshTri(points, faces)
def control_mesh(mesh):
    s = mesh.idx_hierarchy.shape
    a = np.sort(mesh.idx_hierarchy.reshape(s[0], -1).T)
    b, cts = npx.unique_rows(a, return_counts=True)
    if cts.max() > 2:
        bad = np.where(cts > 2)
        print(f"control_mesh found non-manifold edges", bad)

control_mesh(mesh)
mesh.flip_until_delaunay()
control_mesh(mesh)
rob-rb commented 2 years ago

hi nico, I write you again about non-manifold problems in flip_until_delaunay. You have rewritten the code once to try to avoid such problems. Since I still have such problems, maybe it would be easier to change it back to the faster old version. Contrary what I would love to have is a new paramter which represents a list of triangles which is not touched by flip_until_delaunay. (Sometimes I am happy to have perfect triangulation and smoothness in easy parts of the mesh while the problematic part will be just held fixed and ugly. I do that now by replacing sub-meshes with non-manifold edges with the original sub-mesh, this is kind of slow!). By the way I saw that your library is not lgpl which I assumed, so maybe we should have a talk about licence fees for our company.

rob-rb commented 2 years ago

hi nico, This comment above is kind of obsolete, I just could remove those triangles from the Mesh.