|
a |
|
b/CLI/MusculoskeletalAnalysisCLITools/shape.py |
|
|
1 |
def bWshape(shape, threshold): |
|
|
2 |
"""Creates a triangular mesh shape using marching cubes algorithm.""" |
|
|
3 |
from skimage import measure |
|
|
4 |
from trimesh import base |
|
|
5 |
|
|
|
6 |
verts, face, normals, _ = measure.marching_cubes(shape, level=threshold, allow_degenerate=False) |
|
|
7 |
mesh=base.Trimesh(vertices=verts, faces=face, vertex_normals=normals, validate=True) |
|
|
8 |
return mesh |
|
|
9 |
|
|
|
10 |
|
|
|
11 |
def updateVertices(mesh, newVert): |
|
|
12 |
"""Creates a mesh using a previous mesh's faces with new vertices locations.""" |
|
|
13 |
from trimesh import base |
|
|
14 |
|
|
|
15 |
mesh = base.Trimesh(vertices=newVert, faces=mesh.faces, vertex_normals=mesh.vertex_normals, validate=True) |
|
|
16 |
return mesh |