<div dir="ltr"><div><div><div><div>Hi Martin,<br><br></div>You need to set names for the point and cell data arrays.<br></div>farray.SetName("pointdata") and farray.SetName("celldata")<br><br></div>after doing that your code works for me.<br><br></div>-Sujin<br><div><div><div><div><br></div></div></div></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, May 13, 2016 at 12:16 PM, Martin Genet <span dir="ltr"><<a href="mailto:martin.genet@polytechnique.edu" target="_blank">martin.genet@polytechnique.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Dear everyone:<br>
<br>
Sorry for the triviality, but I'm getting confused with vtkProbeFilter: trying to probe an image with a mesh (not the opposite: I need the mesh data interpolated onto the image points), but can't get it to work.<br>
<br>
Consider the following code:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
import numpy<br>
import vtk<br>
<br>
image = vtk.vtkImageData()<br>
image.SetDimensions([3, 3, 1])<br>
image.SetSpacing(1./numpy.array(image.GetDimensions()))<br>
image.SetOrigin(numpy.array(image.GetSpacing())/2)<br>
<br>
points = vtk.vtkPoints()<br>
points.InsertNextPoint([1./4, 1./4, 2./4])<br>
points.InsertNextPoint([3./4, 1./4, 2./4])<br>
points.InsertNextPoint([3./4, 3./4, 2./4])<br>
points.InsertNextPoint([1./4, 3./4, 2./4])<br>
<br>
cell = vtk.vtkQuad()<br>
cell.GetPointIds().SetId(0, 0)<br>
cell.GetPointIds().SetId(1, 1)<br>
cell.GetPointIds().SetId(2, 2)<br>
cell.GetPointIds().SetId(3, 3)<br>
<br>
cell_array = vtk.vtkCellArray()<br>
cell_array.InsertNextCell(cell)<br>
<br>
ugrid = vtk.vtkUnstructuredGrid()<br>
ugrid.SetPoints(points)<br>
ugrid.SetCells(vtk.VTK_QUAD, cell_array)<br>
<br>
farray = vtk.vtkFloatArray()<br>
farray.SetNumberOfComponents(1)<br>
farray.SetNumberOfTuples(1)<br>
farray.SetTuple1(0, 2.)<br>
ugrid.GetCellData().AddArray(farray)<br>
<br>
farray = vtk.vtkFloatArray()<br>
farray.SetNumberOfComponents(1)<br>
farray.SetNumberOfTuples(4)<br>
farray.SetTuple1(0, 2.)<br>
farray.SetTuple1(2, 2.)<br>
farray.SetTuple1(3, 2.)<br>
farray.SetTuple1(4, 2.)<br>
ugrid.GetPointData().AddArray(farray)<br>
<br>
probe = vtk.vtkProbeFilter()<br>
if (vtk.vtkVersion.GetVTKMajorVersion() >= 6):<br>
    probe.SetInputData(image)<br>
    probe.SetSourceData(ugrid)<br>
else:<br>
    probe.SetInput(image)<br>
    probe.SetSource(ugrid)<br>
probe.Update()<br>
probed_image = probe.GetOutput()<br>
</blockquote>
<br>
Problem is: probed_image contains only one array, called vtkValidPointMask, but no interpolated data.<br>
<br>
If I do:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
probed_scalars = probed_image.GetPointData().GetArray("vtkValidPointMask")<br>
for k_voxels in xrange(probed_scalars.GetNumberOfTuples()): print probed_scalars.GetTuple1(k_voxels)<br>
</blockquote>
I'm getting:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
0.0<br>
0.0<br>
0.0<br>
0.0<br>
1.0<br>
0.0<br>
0.0<br>
0.0<br>
0.0<br>
</blockquote>
So I'm guessing the filter is able to figure out which image point lies within the mesh and which does not, but I can't find the interpolated data? Any help would be super appreciated. Thanks!<br>
<br>
Martin<br>
<br>
_______________________________________________<br>
Powered by <a href="http://www.kitware.com" rel="noreferrer" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" rel="noreferrer" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Please keep messages on-topic and check the VTK FAQ at: <a href="http://www.vtk.org/Wiki/VTK_FAQ" rel="noreferrer" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br>
<br>
Search the list archives at: <a href="http://markmail.org/search/?q=vtkusers" rel="noreferrer" target="_blank">http://markmail.org/search/?q=vtkusers</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://public.kitware.com/mailman/listinfo/vtkusers" rel="noreferrer" target="_blank">http://public.kitware.com/mailman/listinfo/vtkusers</a><br>
</blockquote></div><br></div>