0

I am using the python scikit-image marching cubes implementation to create real time moving surface meshes. I am running into a problem where sometimes I get really small surface elements, or else really narrow / high aspect ratio triangles. You can see some of these in the example code here:

https://scikit-image.org/docs/stable/auto_examples/edges/plot_marching_cubes.html?highlight=marching%20cubes

arrow points to problem elements

Is there a way to threshold these out? For example, is there any way that I can say "if a point lies less than X% away from a node, then just put it on the node?" I see that there is a flag to smooth out 0 area elements as well. Is there a way to smooth out area < X?

Thanks!

import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d.art3d import Poly3DCollection

from skimage import measure
from skimage.draw import ellipsoid


# Generate a level set about zero of two identical ellipsoids in 3D
ellip_base = ellipsoid(6, 10, 16, levelset=True)
ellip_double = np.concatenate((ellip_base[:-1, ...],
                               ellip_base[2:, ...]), axis=0)

# Use marching cubes to obtain the surface mesh of these ellipsoids
verts, faces, normals, values = measure.marching_cubes(ellip_double, 0)

# Display resulting triangular mesh using Matplotlib. This can also be done
# with mayavi (see skimage.measure.marching_cubes_lewiner docstring).
fig = plt.figure(figsize=(10, 10))
ax = fig.add_subplot(111, projection='3d')

# Fancy indexing: `verts[faces]` to generate a collection of triangles
mesh = Poly3DCollection(verts[faces])
mesh.set_edgecolor('k')
ax.add_collection3d(mesh)

ax.set_xlabel("x-axis: a = 6 per ellipsoid")
ax.set_ylabel("y-axis: b = 10")
ax.set_zlabel("z-axis: c = 16")

ax.set_xlim(0, 24)  # a = 6 (times two for 2nd ellipsoid)
ax.set_ylim(0, 20)  # b = 10
ax.set_zlim(0, 32)  # c = 16

plt.tight_layout()
plt.show()
Alex
  • 427
  • 6
  • 12
  • "geometry processing". I don't know any libraries for that but it's a thing. plenty of active research as well as well-known traditional algorithms. https://pymesh.readthedocs.io/en/latest/mesh_processing.html#remeshing you should also look for approaches *specific* to marching cubes or meshes calculated from implicit surfaces. there are probably special cases that make the task cheaper and/or the result prettier. – Christoph Rackwitz Oct 26 '22 at 18:19
  • I definitely want this to be using the marching cubes, as we are already using that for the meshing. This would not be that hard to implement in the MC routine, I am just wondering if there is some top secret flag or option buried in the doc somewhere that already does this. – Alex Nov 02 '22 at 03:36

0 Answers0