Skip to content
Snippets Groups Projects
Commit 0a801c70 authored by Boman Romain's avatar Boman Romain
Browse files

add support for .stl, arrays of points (teeths), stop if nodes are not identified

parent 5bee4f5c
No related branches found
No related tags found
No related merge requests found
......@@ -143,11 +143,10 @@ def identify_nodes(coords, all_no, all_coords, eps=1e-3):
ntags.append(no)
break
if not found:
notfound.append(no)
notfound.append(n)
if(len(notfound)!=0):
Exception(f'ERROR: {len(notfound)} nodes have not been found!')
raise Exception(f'ERROR: {len(notfound)} nodes have not been found!')
return ntags
......
File added
......@@ -3,18 +3,21 @@
# Dolicorhynchops osborni FHSM VP404
# 10k faces on the mandible surface
def parms(d={}):
p = {}
path = 'dolicorhynchops/10k'
p['mandible'] = f'{path}/mandible.ply'
p['teeth'] = f'{path}/teeth.off'
p['mandible'] = f'{path}/mandible.stl'
p['teeth'] = [[-10.20362, -17.46838, -229.9061],
[-11.92466, 26.3042, -229.5354]]
p['LTMJ'] = f'{path}/LTMJ.off'
p['RTMJ'] = f'{path}/RTMJ.off'
p['RTMJ'] = [ -8.716309, 79.13171, 233.8385 ]
p['muscles'] = [
{
'file': f'{path}/Lmuscle.ply',
'force': 100.,
'focalpt': [-100.1458893, -173.13895, 227.3909], #f'{path}/LmuscleF.off',
# f'{path}/LmuscleF.off',
'focalpt': [-100.1458893, -173.13895, 227.3909],
'method': 'U' # 'U', 'T', 'T+N'
},
{
......@@ -24,10 +27,10 @@ def parms(d={}):
'method': 'T'
}
]
p['fixations'] = {
p['fixations'] = {
'teeth': ['x'],
'LTMJ': ['x','y','z'],
'RTMJ': ['x','z']
'LTMJ': ['x', 'y', 'z'],
'RTMJ': ['x', 'z']
}
# material properties
......
......@@ -236,7 +236,7 @@ def import_mesh(domain, filename):
raise Exception(f'{mandible_gmsh} not found!')
# extract extension
noext,ext = os.path.splitext(mandible_gmsh)
if ext=='.ply':
if ext in ['.ply', '.stl']:
plyfile = mandible_gmsh
# create 2 workspace files
basename = os.path.join(os.getcwd(), os.path.basename(noext))
......@@ -257,6 +257,10 @@ def import_mesh(domain, filename):
f.write('Mesh.MshFileVersion = 2.2;\n')
f.close()
mandible_gmsh=geofile
elif ext in ['.geo', '.msh']:
pass
else:
raise Exception(f'Unknown extension: {ext}, please use .ply, .stl, .msh, .geo')
print(f'importing {mandible_gmsh}')
from toolbox.gmsh import GmshImport
......@@ -283,17 +287,30 @@ def create_group(mesh_file_or_coord, all_no, all_coords, domain, groups, gname=N
"""loads the mesh file "mesh_file_or_coord" and identify vertices among vertices
stored in all_coords.
Then, the routine creates a group named "gname" (built from mesh_file_or_coord if None)
"""
# load mesh file
if isinstance(mesh_file_or_coord, str):
mesh_file_or_coord can be either:
a filename
an array of points: [ [x1,y1,z1], [x2,y2,z2], ... ]
one single point: [x1,y1,z1]
"""
if isinstance(mesh_file_or_coord, str):
# load mesh file
print(f'\n* create_group {mesh_file_or_coord}...')
fullpath = os.path.join(os.path.dirname(__file__), mesh_file_or_coord)
nodes, tris = boneload.load_msh(fullpath)
else:
nodes = [ mesh_file_or_coord ]
elif type(mesh_file_or_coord) in [list, tuple]:
print(f'\n* create_group {gname}...')
if type(mesh_file_or_coord[0]) in [list, tuple]:
# array of points
nodes = mesh_file_or_coord
else:
# one single point
nodes = [ mesh_file_or_coord ]
print(f'nodes={nodes}')
print(f'mesh_file_or_coord={mesh_file_or_coord}')
tris = []
else:
raise Exception(f'Data is not understood: {mesh_file_or_coord}')
# identify nodes of the mesh among the given vertices of the main mesh
ntags = boneload.identify_nodes(nodes, all_no, all_coords)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment