One of the module interface method I’m working on takes an
as parameter. In python, this translates to
itkMeshF3_Pointer. I tries to convert the output of
itkMeshF3_Pointer but the type seems unknown by default. Do I have to wrap it as part of my module?
Thanks for your help!
You may want to try the ITK 5.1.0 Python packages, which have support for both
itk.Mesh.D3 – note that this can be found with:
And the convenient way to load files in ITK 5.1.0 without type specification is:
mesh = itk.meshread('mesh_filename.off')
@matt.mccormick Thanks for your help.
Here the result of
6: [<itkCType double>, 2]
6: [<itkCType double>, 3]
6: [<itkCType float>, 2]
6: [<itkCType float>, 3]
6: [<itkCType signed short>, 2]
6: [<itkCType signed short>, 3]
6: [<itkCType unsigned char>, 2]
6: [<itkCType unsigned char>, 3]
When trying to read a mesh, I got the following error:
>>> mesh = itk.meshread(fixed_filename)
6: File "ITK-build/Wrapping/Generators/Python/itkExtras.py", line 767, in meshread
6: reader = TemplateReaderType.New(**kwargs)
6: File "ITK-build/Wrapping/Generators/Python/itkTemplate.py", line 473, in New
6: return self._NewMeshReader(itk.MeshFileReader, *args, **kwargs)
6: File "ITK-build/Wrapping/Generators/Python/itkTemplate.py", line 633, in _NewMeshReader
6: PixelType = itkTemplate._pixelTypeFromIO(pixel, component, numberOfComponents)
6: File "ITK-build/Wrapping/Generators/Python/itkTemplate.py", line 666, in _pixelTypeFromIO
6: raise RuntimeError("Unknown pixel type: %s." % pixel)
Even if I manage to get rid of this error, would I be able to do something like
mesh_ptr = itkMeshF3_Pointer(itk.meshread(fixed_filename))
given that my generated interface seems to expect itkMeshF3_Pointer?
The detected type of the files may not be what is supported, so you can cast to a desired type, e.g. a
float type makes sense for many cases, like this:
mesh = itk.meshread(fixed_filename, itk.F)
This works, thanks. Though, I’m still not able to convert it to
That is the equivalent of the result – pointers are not handled directly in Python.
Indeed… Updating my interface to take pointer instead of smart pointer fixes the issue.
Thanks for your help!