diff --git a/models/boneload.py b/models/boneload.py index de2f1a3feb5235449869a26a0c248bc350dfe5bc..796da0d71247a04156a22c70df8539233352a635 100644 --- a/models/boneload.py +++ b/models/boneload.py @@ -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 diff --git a/models/dolicorhynchops/10k/mandible.stl b/models/dolicorhynchops/10k/mandible.stl new file mode 100644 index 0000000000000000000000000000000000000000..95c31595532345cc6af66429dcf019cc7777eabb Binary files /dev/null and b/models/dolicorhynchops/10k/mandible.stl differ diff --git a/models/dolicorhynchops_10k.py b/models/dolicorhynchops_10k.py index ec590e06290fbce4611c9635b3ca8870c2c29708..46e7a4a54c1d6d984358d7304c7af0c11182f4ff 100644 --- a/models/dolicorhynchops_10k.py +++ b/models/dolicorhynchops_10k.py @@ -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 diff --git a/models/mandiblemodel.py b/models/mandiblemodel.py index 85cba3355f9c4b0e04b8b5621e934e0431c76334..42582a0eaaec97bab692b13f780c4169d49a0195 100644 --- a/models/mandiblemodel.py +++ b/models/mandiblemodel.py @@ -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)