<div dir="ltr"><div><div><div><div><span style="font-family:courier new,monospace">Dear VTK users,<br><br></span></div><span style="font-family:courier new,monospace">I would like to use an instance of class<i> vtkCellLocatorInterpolatedVelocityField with Python.<br>
<br></i></span></div><span style="font-family:courier new,monospace"><i>I manage to create an instance, but I can' access the main function FunctionValues<br><br></i></span></div><span style="font-family:courier new,monospace"><i>I guess it is possible since I succeeded doing it with C++.<br>
<br></i></span></div><span style="font-family:courier new,monospace"><i>Any help appreciated!!<br></i></span><div><div><div><div><span style="font-family:courier new,monospace"><br></span></div><div><span style="font-family:courier new,monospace">I know this problem was already reported by Yifei Li on VTK mailing list with VTK 5.8, but I found no answer.<br>
</span></div><div><span style="font-family:courier new,monospace"><br><a href="http://www.vtk.org/pipermail/vtkusers/2011-November/070977.html">http://www.vtk.org/pipermail/vtkusers/2011-November/070977.html</a><br><br></span></div>
<div><span style="font-family:courier new,monospace">I am working on Windows with Python 2.7 and the package VTK compiled by Christoph Gohlke<br><a href="http://www.lfd.uci.edu/~gohlke/pythonlibs/#vtk">http://www.lfd.uci.edu/~gohlke/pythonlibs/#vtk</a><br>
<br></span></div><div><span style="font-family:courier new,monospace">Below is the function I use to create an instance of </span><br><span style="font-family:courier new,monospace">vtkCellLocatorInterpolatedVelocityField from a vtkM</span><span style="font-family:courier new,monospace">ultiBlockDataSet</span></div>
<div><span style="font-family:courier new,monospace"><br>def createVtkCellLocatorInterpolatedVelocityField(multiBlockDataSet, field = 'Velocity'):<br> cl = vtk.vtkCellLocator()<br> clivf = vtk.vtkCellLocatorInterpolatedVelocityField()<br>
clivf.SetCellLocatorPrototype(cl)<br> if VTKMajorVersion <= 5:<br> clivf.SelectVectors(field)<br> else:<br> # clivf.SelectVectors(vtkDataObject::FIELD_ASSOCIATION_POINTS, vMBDS_getFieldArrayName(multiBlockDataSet));<br>
pass<br> iter = multiBlockDataSet.NewIterator()<br> iter.InitTraversal()<br> while iter.IsDoneWithTraversal() == 0:<br> dataObj = iter.GetCurrentDataObject()<br> if dataObj.GetNumberOfCells() > 0:<br>
cdTPD = vtk.vtkCellDataToPointData()<br> cdTPD.RemoveAllInputs()<br> if VTKMajorVersion <= 5:<br> cdTPD.SetInput(dataObj)<br> else:<br> cdTPD.SetInputData(dataObj)<br>
cdTPD.Update()<br> clivf.AddDataSet(cdTPD.GetOutput())<br> iter.GoToNextItem()<br> del iter<br> return clivf<br></span></div></div></div></div></div>