Hi, I am trying to convert a .stl file to mesh data. It seems there is no direct way to implement it. So, my idea is first convert the file to a temporary .vtk file and then using itk.meshread() to get the mesh data.
However, when I tried to run this program, it just exited at itk.meshread(). To be more exact, I looked into the code of meshread, and the code stopped at reader.Update() at the second line from the bottom in that function. There is no error message and the only message is Process finished with exit code 139 (interrupted by signal 11: SIGSEGV).
Do you have any suggestions on how to solve this problem? How can I determine whether it is because the impropriate input .vtk file or something else?
Also, please tell me if there is a better way to get the mesh data from .stl file.
Thank you!
But it throws an error for the first line saying that:
Traceback (most recent call last):
File "/Users/anthony/.conda/envs/dicom-rt/lib/python3.7/unittest/loader.py", line 154, in loadTestsFromName
module = __import__(module_name)
File "/Users/anthony/Desktop/DICOM/dicom-rt/tests/dicom_rt/test_dicomrt.py", line 6, in <module>
from itk import itkSTLMeshIOPython
File "/Users/anthony/.conda/envs/dicom-rt/lib/python3.7/site-packages/itk/itkSTLMeshIOPython.py", line 32, in <module>
_itkSTLMeshIOPython = swig_import_helper()
File "/Users/anthony/.conda/envs/dicom-rt/lib/python3.7/site-packages/itk/itkSTLMeshIOPython.py", line 24, in swig_import_helper
import _itkSTLMeshIOPython
ModuleNotFoundError: No module named '_itkSTLMeshIOPython'
I checked that module but don’t know how to solve that. So I just tried to find another way to solve my problem.
Can you please follow this post and convert to a .vtk file and then try to read using ITK ?
If this also fails then will it be possible to share the .vtk file with me ?
Also try to write the file by calling SetFileVersion(42).
I made it by setting the .vtk version number. The latest vtk library will write the .vtk file with version 5.4(I forget about it but it is over 5), but it seems meshread() function does not support this version right now.
By the way, so right now, is it impossible to convert a .stl to mesh data directly instead of converting to .vtk first and then load it? Or are there any other simpler ways to implement it?
No, there is no support to directly read STL files directly in ITK.
I also faced this issue and wrote that post last year.
If you want to avoid writing to file, then you can also convert from VTK mesh to ITK mesh in python by inserting points and cells in a new ITK mesh.
I am trying this one. Here the type of my input is <class 'vtkCommonDataModelPython.vtkPolyData'>, and when I called this method, it throws an error for line itk_mesh.SetPoints(itk.vector_container_from_array(points_numpy)) saying that RuntimeError: No suitable template parameter can be found. May I ask is it because of the version number or I should convert this input type to vtkmesh?