[vtkusers] vtkProbe on an Exodus II file ...

Meehan, Bernard MEEHANBT at nv.doe.gov
Tue Sep 2 12:01:38 EDT 2014


Hi - I'm trying to project a dataset from one mesh (stored in an Exodus II file) onto another mesh (also, stored on an Exodus II file). I was hoping that I could do it with vtkProbe, in a fashion somewhat similar to:  http://www.vtk.org/Wiki/VTK/Examples/Cxx/PolyData/InterpolateMeshOnGrid, and I am hoping that it is just a simple oversight on my part. I wasn't sure if the mailing list took attachments ... I tried not to make them large.

(note that the "g" extension, namely the Genesis file format, is readable with the vtkExodusIIReader).
The script I was using doesn't seem to map anything at all I just get zero data?

import vtk
from math import exp, hypot

rdr1 = vtk.vtkExodusIIReader()
rdr1.SetFileName("waffly.g")
rdr1.Update()

rdr2 = vtk.vtkExodusIIReader()
rdr2.SetFileName("roundish.g")
rdr2.Update()

spot = vtk.vtkFloatArray()
spot.SetName("Gaussian Spot")
inputdata = rdr2.GetOutput().GetBlock(0).GetBlock(0)
outputdata = rdr1.GetOutput().GetBlock(0).GetBlock(0)

for i in range(inputdata.GetNumberOfPoints()):
  x, y = inputdata.GetPoint(i)[:2]
  r    = hypot(x, y)
  spot.InsertValue(i, exp(-r**2))

inputdata.GetPointData().SetScalars(spot)

#-------------#
# Probe Stuff #
#-------------#
p = vtk.vtkProbeFilter()
p.SetInputData(outputdata)
p.SetSourceData(inputdata) # <-has scalars you want
p.Update()

#-----------------#
# Rendering stuff #
#-----------------#
mapper1 = vtk.vtkDataSetMapper()
mapper1.SetInputData(inputdata)

mapper2 = vtk.vtkDataSetMapper()
mapper2.SetInputData(outputdata)

actor1 = vtk.vtkActor()
actor1.SetMapper(mapper1)

actor2 = vtk.vtkActor()
actor2.SetMapper(mapper2)

left_ren = vtk.vtkRenderer()
left_ren.SetViewport(0.0, 0.0, 0.5, 1.0)
left_ren.AddActor(actor1)

right_ren = vtk.vtkRenderer()
right_ren.SetViewport(0.5, 0.0, 1.0, 1.0)
right_ren.SetActiveCamera(left_ren.GetActiveCamera())
right_ren.AddActor(actor2)

renw = vtk.vtkRenderWindow()
renw.AddRenderer(left_ren)
renw.AddRenderer(right_ren)
renw.SetSize(800, 400)

iren = vtk.vtkRenderWindowInteractor()
iren.SetRenderWindow(renw)

left_ren.ResetCamera()
renw.Render()
iren.Start()
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20140902/0956afc5/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Archive.zip
Type: application/zip
Size: 6552 bytes
Desc: Archive.zip
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20140902/0956afc5/attachment.zip>


More information about the vtkusers mailing list