mikedh / trimesh

Python library for loading and using triangular meshes.
https://trimesh.org
MIT License
2.94k stars 574 forks source link

Unable to generate tetrahedral meshes using gmsh.to_volume() - Error: Invalid boundary mesh (overlapping facets) on surface 1 surface 1 #1803

Open JorgeESantos opened 1 year ago

JorgeESantos commented 1 year ago

Greetings everyone! I'm working with TPMS meshes for FEM modulation and I've been trying to generate tetrahedral meshes from triangular meshes using Trimesh method gmsh.to_volume(). I was successful in achieving what I wanted if I smooth the mesh using the standard Laplacian smooth filter. However, if I try to generate the tetrahedral mesh without any smoothing or with a mutable Laplacian smooth method, gmsh.to_volume() fails and raises the following error "Error: Invalid boundary mesh (overlapping facets) on surface 1 surface 1".

My question is why this error occurs and how do I fix or work around it in order to build the tetrahedral meshes I'm looking for. Here is the code I'm using:

`from functions import TPMS_engine, Mesh_Volume

M, voxel_lenght, mesh_data = TPMS_engine([2,2,2], elem=40, iT=0.5)

M is a binary image that I used to generate the mesh

import trimesh mesh = trimesh.Trimesh(vertices=mesh_data[0], faces=mesh_data[1])

mesh generated from vertices and faces

from functions import trimesh_repair_mesh mesh = trimesh_repair_mesh(mesh_data[0], mesh_data[1]) trimesh.repair.fix_winding(mesh)

tried to fix the problem on my own but none of the repair functions available seem to have any impact

import trimesh

mesh_smoothed = trimesh.smoothing.filter_laplacian(mesh)

this is the condition that makes the conversion works

from trimesh.interfaces import gmsh import os dire = 'G:\O meu disco\Disciplinas\JF\Parte 3 Abaqus JF' bdf_name = os.path.join(dire, 'Gyroid_1x1x1_1.bdf')

stl_name = os.path.join(dire, 'FKS_2x2x1_smoothed.stl')

gmsh.to_volume(mesh, file_name=bdf_name, mesher_id=7)

this one fails

gmsh.to_volume(mesh_smoothed, file_name=bdf_name, mesher_id=7)

this one works`

Error trimesh

tanuj163 commented 3 months ago

Hi, were you able to solve the issue ?

JorgeESantos commented 3 months ago

Hi, were you able to solve the issue ?

Hey there. Unfortunately I didn't. The issue actually seems to be relate with the mesh watertigthness.

If the mesh is watertight then the tetrahedralization will work. If not, it will fail. Furthermore the scalar attribute that is supposed to control the element size seems not to work at all.