Open MarcelHeu opened 2 years ago
Could you share the mesh file?
Thanks for your answer, here you go:
https://www.file-upload.net/download-14873962/waxup_slm_cad.stl.html
hey @banesullivan,
can you assume what could be the issue or do i have to pass maybe another parameter to the function?
best regards, Marcel
I can reproduce a segfault on my debian linux (which is the same thing as "Windows fatal exception: access violation" in your case). Here's the snippet I used, taken from your question on Stack Overflow:
import pymeshfix
import trimesh
model = trimesh.load("waxup_slm_cad.stl")
# Create object from vertex and face arrays
meshfix = pymeshfix.MeshFix(model.vertices, model.faces)
# Repair the mesh
meshfix.repair()
I don't know exactly what's going on, but I've investigated a bit:
pyvista.wrap(model)
it's composed entirely of triangles, and .clean()
does nothing with the mesh. This suggests no funny business with degenerate cells.duplicateNonManifoldVertices()
.Here's the layout of execution:
meshfix.repair()
-> https://github.com/pyvista/pymeshfix/blob/a7f91fcb8443604761b1f5c37386ae83942dc225/pymeshfix/meshfix.py#L207-L209
(note that this is before the actual repairing starts; the segfault happens during tin.load_array()
)
-> Basic_TMesh_wrap::loadArray()
https://github.com/pyvista/pymeshfix/blob/a7f91fcb8443604761b1f5c37386ae83942dc225/pymeshfix/cython/meshfix.cpp#L319-L320
We're getting close: the segfault happens on line 317, inside the call to Basic_TMesh::cutAndStitch()
:
And the final destination is Basic_TMesh::duplicateNonManifoldVertices()
:
The segfault seems to happen on line 138 of the above:
Since I'm not familiar with the library I'm not going to try and reverse-engineer that data structure with somewhat opaque member names :) Hopefully this will help someone who knows the library figure out what's wrong.
maybe this problem has been fixed. I didnt run into any issue loading the geometry with pyvista
@chen112p loading the mesh is fine. What breaks is repair()
of pymeshfix, see my snippet in https://github.com/pyvista/pymeshfix/issues/41#issuecomment-1121573606.
Got similar error, while trying to repair my mesh. Any workarounds?
For what it's worth, I get this error nondeterministically. When using faulthandler to try to localize it, I see the following:
Current thread 0x000000020b9b3a80 (most recent call first):
File "/opt/homebrew/lib/python3.10/site-packages/pymeshfix/meshfix.py", line 201 in repair
That line number is the point at which clean_from_arrays gets called:
(Actually, I see this is the exact same problem that @adeak has already pinpointed more precisely.)
For what it's worth, I get this error nondeterministically.
Unfortunately segfaults inherently have a tendency to be nondeterministic. The reason for a segfault is that the process tries to access (actually, write to) memory that doesn't belong to it. When you have a minor off-by-few indexing issue you might end up addressing memory that is out of bounds for the given object (say, an array), but still within the memory allocated to your process. In this situation you can normally change the value at the corresponding memory address, so instead of a segfault you get silently corrupted state for your program (something somewhere changed accidentally). But when the referenced memory address is so far from the intended place (or when the constellation of memory allocation in a modern operating system is such) that it doesn't belong to the same process, you get the segfault.
Hello again. I managed to avoid this problem by using pyvista like this:
pv_mesh = pv.wrap(model.get_mesh())
pv_mesh.save('pyvista_mesh.ply')
tin = PyTMesh(False)
tin.load_file('pyvista_mesh.ply')
tin.fill_small_boundaries(nbe=nbe, refine=refine)
P.S.
model.get_mesh()
is my class, which returns trimesh
Hey,
If i try to repair an input mesh file, the following error will follow:
i got the following pyvista Report: