_______________________________________
I would like to map an unstructured grid (describing particle data
with per particle attributes I would like interpolated onto the
regular grid) onto a regular mesh.  I am trying to use the 'Resample
With Dataset' filter but have not been having much luck.
________________________________________

As far as I understand, what you are trying to do is not possible, with the 
"Resample with dataset filter". The reason is that your input dataset does not 
seem to have 3D cells. Resampling needs 3D cells for interpolation.

There is a method, vtkShepardMethod 
(http://www.vtk.org/doc/nightly/html/classvtkShepardMethod.html),  which does 
exactly what you need. However, Shepard is not included in ParaView. No 
problem, you can do it off-line:

I have tried the following python script with my paraview compilation and my 
./bin/vtkpython and it produced the required output. See if it fits your 
purpose.

from vtk import *
numPts = 300

ps = vtk.vtkPointSource()
ps.SetRadius(1)
ps.SetNumberOfPoints(numPts)
ps.Update()

ca = vtk.vtkFloatArray()
ca.SetName("datavalue")
ca.SetNumberOfComponents(1)
ca.SetNumberOfTuples(numPts)

for i in range(0, numPts):
  ca.SetValue(i, ps.GetOutput().GetPoint(i)[0])

ps.GetOutput().GetPointData().AddArray(ca)
ps.GetOutput().GetPointData().SetScalars(ca)
ps.Update()
ps.GetOutput().GetPointData().SetScalars(ca)

sh = vtk.vtkShepardMethod()
sh.SetSampleDimensions(20,20,20)
sh.SetInputConnection(ps.GetOutputPort())
sh.SetModelBounds(ps.GetOutput().GetBounds())

wr = vtk.vtkDataSetWriter()
wr.SetInputConnection(sh.GetOutputPort())
wr.SetFileName("/tmp/foo.vtk")
wr.Write()

-----------------
Jean M. Favre
Swiss National Supercomputing Center

_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the ParaView Wiki at: 
http://paraview.org/Wiki/ParaView

Follow this link to subscribe/unsubscribe:
http://www.paraview.org/mailman/listinfo/paraview

Reply via email to