Editing
Software Plugins and Codes
(section)
Jump to navigation
Jump to search
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
====Method 1: Using a Programmable Filter==== This example will demonstrate several things: * Using a filter with multiple inputs. * Using a programmable filter. * Using numpy arrays within a ParaView Programmable Filter. (See [http://paraview.org/Wiki/Python_Programmable_Filter#Center_Data_using_numpy].) Here are the steps: # Open both data files. In this example, one will be a FAIM output file, while the other will be in the form of a VTK Unstructured Grid file. # Select both files at once in the Pipeline Browser. This is done in OS-X by clicking on one, then holding down the Command key and clicking on the other. # Now select a Programmable Filter from the menu. # Enter this script: <source lang=python> from paraview.vtk import dataset_adapter as DA # Get inputs/outputs as VTK objects input0 = self.GetInputDataObject(0,0) input1 = self.GetInputDataObject(0,1) output = self.GetOutputDataObject(0) # We can get the array data from the "inputs" object, which is an alternative interface (more Pythonesque) to the same data. # This gives us numpy arrays. x0 = inputs[0].PointData.GetArray("NODAL_DISPLACEMENTS") # Change the following to GetArray("NODAL_DISPLACEMENTS") if your second input is also a FAIM data file. x1 = inputs[1].PointData.GetArray("displacement") # Numpy arrays can be operated on element-by-element with simple expressions. (Both x0 and x1 are Nx3 arrays.) # You could also do a loop over the elements, but it would be slower and more verbose. xdiff = x1 - x0 # Convert from a numpy array to a VTK array. # Call it "dispdiff", but you could name it anything. xdiff_vtk = DA.numpyTovtkDataArray(xdiff, 'dispdiff') # The output is a copy of the first input, except we attach our new vector data to the points. output.ShallowCopy(input0) output.GetPointData().AddArray(xdiff_vtk) </source> # Click OK # Change the Display of the programmable filter to "dispdiff", and click "Toggle Color Legend Visibility" button. [[Image:ParaviewDifferenceInDisp.png]]
Summary:
Please note that all contributions to bone.wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
BoneWiki:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Navigation menu
Personal tools
Not logged in
Talk
Contributions
Create account
Log in
associated-pages
Page
Discussion
English
Views
Read
Edit
View history
More
Search
Navigation
Main page
Documents
Recent changes
Help
Tools
What links here
Related changes
Page information