[Paraview] Need Programmable Source Help
Favre Jean
jfavre at cscs.ch
Fri Mar 28 04:24:33 EDT 2014
Josh
you'll find details here: http://paraview.org/Wiki/ParaView/Simple_ParaView_3_Python_Filters
I am guessing that what you really want to create is a regular cartesian grid
your example, would look like that:
Get a programmable Source
Set the output type to vtkImageData
fill in the Script (RequestInformation) with:
executive = self.GetExecutive()
outInfo = executive.GetOutputInformation(0)
executive.SetExtentTranslator(outInfo, vtk.vtkExtentTranslator())
outInfo.Set(executive.WHOLE_EXTENT(), -90,90,-90,90, 0, 0)
outInfo.Set(vtk.vtkDataObject.SPACING(), 1, 1, 1)
fill in the Script with:
executive = self.GetExecutive()
outInfo = executive.GetOutputInformation(0)
updateExtent = [executive.UPDATE_EXTENT().Get(outInfo, i) for i in xrange(6)]
imageData = self.GetOutput()
imageData.SetExtent(updateExtent)
dimensions = imageData.GetDimensions()
newArray = vtk.vtkDoubleArray()
newArray.SetName("newArray")
newArray.SetNumberOfComponents(1)
newArray.SetNumberOfTuples(dimensions[0]*dimensions[1]*dimensions[2])
imageData.GetPointData().AddArray(newArray)
for i in xrange(dimensions[0]):
for j in xrange(dimensions[1]):
for k in xrange(dimensions[2]):
pointId = vtk.vtkStructuredData.ComputePointId(dimensions, (i, j, k))
newArray.SetValue(pointId,pointId)
tested with PV 4.1
--
Jean/CSCS
More information about the ParaView
mailing list