<div dir="ltr"><div><div><div><div>Hi Martin,<br><br></div>Attached is the modified script that I ran. This is the output of the script:<br>pointdata 1 9<br>(0.0,) (0.0,) (0.0,) (0.0,) (2.0,) (0.0,) (0.0,) (0.0,) (0.0,) <br>celldata 1 9<br>(0.0,) (0.0,) (0.0,) (0.0,) (2.0,) (0.0,) (0.0,) (0.0,) (0.0,) <br>vtkValidPointMask 1 9<br>(0.0,) (0.0,) (0.0,) (0.0,) (1.0,) (0.0,) (0.0,) (0.0,) (0.0,)<br><br></div>The results look correct. Is this not the behaviour you are getting? Let me know if you still have issues.<br><br></div>Thanks<br></div>Sujin<br><br></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, May 13, 2016 at 7:45 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">
  
    
  
  <div text="#000000" bgcolor="#FFFFFF">
    Thanks for your help, Sujin.<br>
    <br>
    What do you mean exactly by "your code works for me"? I sat the
    arrays names but am still getting the same behavior: the code runs
    fine, but I can't find the interpolated data. Do you know where it
    is? Thanks again.<span class="HOEnZb"><font color="#888888"><br>
    <br>
    Martin</font></span><div><div class="h5"><br>
    <br>
    <div>On 13/05/2016 18:53, Sujin Philip
      wrote:<br>
    </div>
    <blockquote type="cite">
      <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"></a><a href="http://www.kitware.com/opensource/opensource.html" 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"></a><a href="http://www.vtk.org/Wiki/VTK_FAQ" 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>
    </blockquote>
    <br>
  </div></div></div>

</blockquote></div><br></div>