[Insight-users] Use of PointSet and VectorContainer in python
Roel Zinkstok
rzinkstok at gmail.com
Thu May 26 10:57:36 EDT 2011
Hi!
I've just started using Python(x,y), the scientific Python platform that
includes ITK 3.16. I'm interested in using PointSets and VectorContainers,
ultimately to use Meshes. I am trying to work through chapter 4 of the ITK
Software Guide, but I'm having a hard time translating the examples to
Python, and I cannot find any python examples online.
So far I've been able to do the following:
======================
import itk
pixeltype = itk.D
dim = 3
traitstype = itk.DefaultStaticMeshTraits[pixeltype, dim, dim, pixeltype]
pointsettype = itk.PointSet[pixeltype, dim, traitstype]
pointset = pointsettype.New()
pointset.SetPoint(0, [1,0,0])
pointset.SetPoint(1, [0,1,0])
pointset.SetPoint(2, [0,0,1])
print pointset.GetNumberOfPoints()
pointtype = itk.Point[itk.D,3]
pp = pointtype()
print pointset.GetPoint(1, pp)
print pp.GetElement(0), pp.GetElement(1), pp.GetElement(2)
==========================
This works ok, but the ITK Software Guide says it's better to use
containers. And if I am to work with Meshes, it will be even more important
to use containers, or am I mistaken?
The problem is that I can't get the container to work: if I try:
import itk
pixeltype = itk.D
dim = 3
pointtype = itk.Point[pixeltype, dim]
vectorcontainertype = itk.VectorContainer[itk.UL, pointtype]
python raises the error:
raise KeyError, 'itkTemplate : No template %s for the %s class' %
(str(parameters), self.__name__)
KeyError: "itkTemplate : No template (<itkCType unsigned long>, <class
'itkPoint.itkPointD3'>) for the itk::VectorContainer class"
I've tried a lot of different combinations, but always the same sort of
result. Does anybody know the correct syntax? And more generally, are there
examples somewhere that show the use of meshes in python?
Hopefully someone can help!
Regards,
Roel Zinkstok
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20110526/166eb6e2/attachment.htm>
More information about the Insight-users
mailing list