Python Programmable Filter

From KitwarePublic
Revision as of 18:15, 10 June 2007 by OccCfi (talk | contribs)
Jump to navigationJump to search

cheap diazepam cheap xenical nokia ringtones qwest ringtones zanaflex online diazepam online verizon ringtones free motorola ringtones order lortab prozac online ericsson ringtones but ortho cheap cyclobenzaprine cheap celexa free ringtones phentermine free cool ringtones cheap prozac free qwest ringtones cialis online sprint ringtones nexium online real ringtones sagem ringtones tracfone ringtones free nokia ringtones free punk ringtones mp3 ringtones sony ringtones ativan online but hgh free midi ringtones alltel ringtones cheap flexeril sony ericsson ringtones motorola ringtones vicodin online free tracfone ringtones buy soma levitra online free motorola ringtones cheap didrex cheap sildenafil pharmacy online online zoloft online hydrocodone online free sony ringtones cingular ringtones viagra buy paxil ambien online buy lortab order hydrocodone vigrx online cheap ativan hgh online sildenafil online buy viagra ortho online nextel ringtones lisinopril free funny ringtones free sony ericsson ringtones buy vicodin hydrocodone order ativan mono ringtones clonazepam levitra free sprint ringtones cialis online sony ringtones cheap levitra zanaflex online phentermine celexa online ultracet online wwe ringtones free sharp ringtones buy norco soma online cheap ultracet free cingular ringtones cheap adipex cheap xenical cheap albuterol cheap tenuate cheap ortho free music ringtones sagem ringtones cheap lisinopril meridia online cheap propecia cheap vigrx cheap diethylpropion cheap albuterol mp3 ringtones meridia online free ringtones cheap ultram soma online cheap lortab cheap sildenafil free nextel ringtones cheap lorazepam free funny ringtones diethylpropion online free ringtones funny ringtones cingular ringtones cheap soma nokia ringtones clonazepam online zyban online clomid online buy prozac online valium order lisinopril meridia online buy tramadol sharp ringtones free midi ringtones flexeril online real ringtones celexa online zoloft online free nextel ringtones ericsson ringtones free music ringtones mtv ringtones order ultram buy valium viagra online lorazepam online cheap cialis cheap phentermine buy nexium samsung ringtones cheap norco meridia online sprint ringtones buy rivotril order carisoprodol carisoprodol online cyclobenzaprine online free qwest ringtones free qwest ringtones cheap fioricet verizon ringtones punk ringtones cheap hoodia pharmacy online online tracfone ringtones tramadol cheap rivotril tramadol online didrex online cheap fioricet music ringtones cheap albuterol free nokia ringtones buy viagra buy alprazolam buy xenical pharmacy online online free funny ringtones order zanaflex free ericsson ringtones cyclobenzaprine online adipex online cheap xanax free alltel ringtones free qwest ringtones ultram online sonyericsson ringtones free samsung ringtones cheap lortab free mono ringtones free samsung ringtones zyban online cheap celexa free funny ringtones wwe ringtones cheap rivotril but clomid buy fioricet buy hgh cheap lipitor cheap hoodia clonazepam online cool ringtones tenuate online cheap vicodin real ringtones free sonyericsson ringtones buy hoodia buy tramadol nextel ringtones cheap alprazolam ambien online == ParaView3's python programmable filter. ==

The python programmable filter is a general purpose filter that the end user can program within the paraview GUI to manipulate datasets as needed. To use the filter, turn the PARAVIEW_ENABLE_PYTHON_FILTER cmake option on. This causes the make process to wrap paraview's classes into python callable format. The wrapping process is identical to that for the PARAVIEW_EMBED_PYTHON option and the two share the same sets of libraries at run time.

The filter is a wrapper around VTK's vtkProgrammableFilter class and adds to it:

  • a string containing the user's script for the filter to execute
  • an instance of the python interpreter with the wrapped paraview libraries imported
  • the ability to easily change the output dataset type.

When the user selects "PythonScript" from the Filters menu, an empty programmable filter is created. The default behavior of the empty script is create a dataset if the same type as its input and to copy through the input dataset's structure. The GUI provides a selection menu where the user can choose from the five primary vtk dataset types for the output. The GUI also provides a text entry area where the user can type, edit or paste in a python script.

The following figure shows a python script that modifies the geometry of its input dataset. PyScriptFig1.jpg

#reads a poly data and modifies the geometry
pdi = self.GetPolyDataInput()
pdo = self.GetPolyDataOutput()
newPts = paraview.vtkPoints()
numPts = pdi.GetNumberOfPoints()
for i in range(0, numPts):
  coord = pdi.GetPoint(i)
  x,y,z = coord[:3]
  x = x * 2
  y = y * 0.5
  z = 1
  newPts.InsertPoint(i, x,y,z)
pdo.SetPoints(newPts)


The following figure shows a python script that produces an image data output with one cell per point in its input polygonal dataset. PyScriptFig2.jpg

#this example creates an Nx1x1 imagedata output
#and populates its cells with the point centered
#scalars of the input dataset

#get a hold of the input
pdi = self.GetInput()
numPts = pdi.GetNumberOfPoints()

#create the output dataset with one cell per point
ido = self.GetOutput()
ido.SetDimensions(numPts 1,2,2)
ido.SetOrigin(-1,-1,-1)
ido.SetSpacing(.1,.1,.1)
ido.SetWholeExtent(0,numPts,0,1,0,1)
ido.AllocateScalars()

#choose an input point data array to copy
ivals = pdi.GetPointData().GetScalars()
ca = paraview.vtkFloatArray()
ca.SetName(ivals.GetName())
ca.SetNumberOfComponents(1)
ca.SetNumberOfTuples(numPts)
#add the new array to the output
ido.GetCellData().AddArray(ca)

#copy the values over element by element
for i in range(0, numPts):
  ca.SetValue(i, ivals.GetValue(i))