-
Notifications
You must be signed in to change notification settings - Fork 29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Segmentation fault when trying to load it through load_array #63
Comments
Here's an alternative script: import numpy as np
import trimesh
import pyvista as pv
from pymeshfix._meshfix import PyTMesh
from pymeshfix import _meshfix, meshfix
filepath = 'nonWatertightPosMesh.stl'
probPart = trimesh.load_mesh(filepath)
print("Is watertight: ", probPart.is_watertight)
mesh = pv.read(filepath)
mfix = meshfix.MeshFix(mesh)
mfix.repair(verbose=True)
mfix.plot() With output:
Arrays can be accessed from: mfix.v
mfix.f Note that many triangles have been removed from the original surface, but if you subdivide, you can preserve the volume of the original surface using subdivide: import numpy as np
import trimesh
import pyvista as pv
from pymeshfix._meshfix import PyTMesh
from pymeshfix import _meshfix, meshfix
filepath = 'nonWatertightPosMesh.stl'
probPart = trimesh.load_mesh(filepath)
print("Is watertight: ", probPart.is_watertight)
mesh = pv.read(filepath)
mesh = mesh.subdivide(1).clean()
print('Original volume:', mesh.volume)
mfix = meshfix.MeshFix(mesh)
mfix.repair(verbose=True)
mfix.plot()
print('Final volume:', mesh.volume)
mfix.save('WatertightPosMesh.stl') |
Hello and thank you for the quick response. The problem is indeed solved by loading the mesh directly from the .stl file but as I already mentioned above my problem is that I want to load the vertices and the faces of the mesh dynamically since I already have them in the trimesh format after various modifications. Do you maybe know why everything is working as expected when I load it from the file but I get the segmentation fault when I read the mesh from the arrays? |
That's perplexing for me as well, especially as when loading from a PyVista mesh. I'm afraid don't have the time at the moment to dedicate to debugging the C++ layer (which is where this bug is occurring), but PyVista and Trimesh to PyVistapart = trimesh.load_mesh(filepath)
pv_mesh = pv.wrap(part) Trimesh to PyVistafaces_as_array = pv_mesh.faces.reshape((self.n_faces, 4))[:, 1:]
tmesh = trimesh.Trimesh(pv_mesh.points, faces_as_array) |
I also have a segfault for which I have no workaround: it is raised by both |
I was running into a similar issue when using pymeshfix on the output from pyacvd and found that rolling back scipy to v1.12.0 resolved the issue (see pyvista/pyacvd#47 from pyacvd). Prior to finding this solution I was able to track the issue down to Hopefully that works to give someone else who understands more of the cpp code a lead to track down the source of the issue. In the meantime, maybe rolling back the scipy version would solve the segfault issue? |
Hello, I am trying to load the attached mesh using the following code and get
Segmentation fault (core dumped)
.Please note that the vertices and faces are given using trimesh since I am doing some operation with it. The mesh is not watertight.
However if I load it as follows I do not get any error and the mesh is watertight.
Do you maybe have any suggestions or possible solutions that I could use?
nonWatertightPosMesh.zip
The text was updated successfully, but these errors were encountered: