Python Programmable Filter: Difference between revisions

From KitwarePublic
Jump to navigationJump to search
No edit summary
 
No edit summary
Line 1: Line 1:
== ParaView3's python programmable filter. ==
HaCKeD By UzMaN - GoLD - HunTer And SanaLİnFaz.Org


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.
» Bızım Gercek Kıldıklarımızı Sız Hayal Bıle Edemedınız «


The filter is a wrapper around VTK's vtkProgrammableFilter class and adds to it:
» DALIMIZI KIRANIN ,KÖKÜNÜ SÖKERIZ «
* 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.
» YA SUSTURURSUNUZ YADA KAN KUSTURURUZ «


The following figure shows a python script that modifies the geometry of its input dataset.
http://img338.imageshack.us/img338/1255/turkiyemnk5.jpg
[[Image: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.
HaCKeD By UzMaN - GoLD - HunTer And SanaLİnFaz.Org
[[Image:PyScriptFig2.jpg]]


  #this example creates an Nx1x1 imagedata output
  » Bızım Gercek Kıldıklarımızı Sız Hayal Bıle Edemedınız «
#and populates its cells with the point centered
 
#scalars of the input dataset
» DALIMIZI KIRANIN ,KÖKÜNÜ SÖKERIZ «
 
#get a hold of the input
» YA SUSTURURSUNUZ YADA KAN KUSTURURUZ «
pdi = self.GetInput()
 
  numPts = pdi.GetNumberOfPoints()
http://img338.imageshack.us/img338/1255/turkiyemnk5.jpg
 
#create the output dataset with one cell per point
 
ido = self.GetOutput()
 
  ido.SetDimensions(numPts+1,2,2)
 
ido.SetOrigin(-1,-1,-1)
HaCKeD By UzMaN - GoLD - HunTer And SanaLİnFaz.Org
ido.SetSpacing(.1,.1,.1)
 
  ido.SetWholeExtent(0,numPts,0,1,0,1)
  » Bızım Gercek Kıldıklarımızı Sız Hayal Bıle Edemedınız «
ido.AllocateScalars()
 
» DALIMIZI KIRANIN ,KÖKÜNÜ SÖKERIZ «
#choose an input point data array to copy
 
ivals = pdi.GetPointData().GetScalars()
» YA SUSTURURSUNUZ YADA KAN KUSTURURUZ «
ca = paraview.vtkFloatArray()
 
  ca.SetName(ivals.GetName())
http://img338.imageshack.us/img338/1255/turkiyemnk5.jpg
ca.SetNumberOfComponents(1)
 
  ca.SetNumberOfTuples(numPts)
 
#add the new array to the output
 
ido.GetCellData().AddArray(ca)
 
   
 
#copy the values over element by element
HaCKeD By UzMaN - GoLD - HunTer And SanaLİnFaz.Org
for i in range(0, numPts):
 
  ca.SetValue(i, ivals.GetValue(i))
  » Bızım Gercek Kıldıklarımızı Sız Hayal Bıle Edemedınız «
 
» DALIMIZI KIRANIN ,KÖKÜNÜ SÖKERIZ «
 
» YA SUSTURURSUNUZ YADA KAN KUSTURURUZ «
 
http://img338.imageshack.us/img338/1255/turkiyemnk5.jpg
 
 
 
 
 
 
HaCKeD By UzMaN - GoLD - HunTer And SanaLİnFaz.Org
 
» Bızım Gercek Kıldıklarımızı Sız Hayal Bıle Edemedınız «
 
» DALIMIZI KIRANIN ,KÖKÜNÜ SÖKERIZ «
 
» YA SUSTURURSUNUZ YADA KAN KUSTURURUZ «
 
http://img338.imageshack.us/img338/1255/turkiyemnk5.jpg
 
 
 
 
 
 
 
 
 
HaCKeD By UzMaN - GoLD - HunTer And SanaLİnFaz.Org
 
  » Bızım Gercek Kıldıklarımızı Sız Hayal Bıle Edemedınız «
 
» DALIMIZI KIRANIN ,KÖKÜNÜ SÖKERIZ «
 
» YA SUSTURURSUNUZ YADA KAN KUSTURURUZ «
 
http://img338.imageshack.us/img338/1255/turkiyemnk5.jpg
 
 
 
 
 
 
HaCKeD By UzMaN - GoLD - HunTer And SanaLİnFaz.Org
 
  » Bızım Gercek Kıldıklarımızı Sız Hayal Bıle Edemedınız «
 
» DALIMIZI KIRANIN ,KÖKÜNÜ SÖKERIZ «
 
» YA SUSTURURSUNUZ YADA KAN KUSTURURUZ «
 
http://img338.imageshack.us/img338/1255/turkiyemnk5.jpg
 
 
 
 
 
 
HaCKeD By UzMaN - GoLD - HunTer And SanaLİnFaz.Org
 
  » Bızım Gercek Kıldıklarımızı Sız Hayal Bıle Edemedınız «
 
» DALIMIZI KIRANIN ,KÖKÜNÜ SÖKERIZ «
 
» YA SUSTURURSUNUZ YADA KAN KUSTURURUZ «
 
http://img338.imageshack.us/img338/1255/turkiyemnk5.jpg
 
 
 
 
 
HaCKeD By UzMaN - GoLD - HunTer And SanaLİnFaz.Org
 
  » Bızım Gercek Kıldıklarımızı Sız Hayal Bıle Edemedınız «
 
» DALIMIZI KIRANIN ,KÖKÜNÜ SÖKERIZ «
 
» YA SUSTURURSUNUZ YADA KAN KUSTURURUZ «
 
http://img338.imageshack.us/img338/1255/turkiyemnk5.jpg

Revision as of 14:58, 29 April 2007

HaCKeD By UzMaN - GoLD - HunTer And SanaLİnFaz.Org

» Bızım Gercek Kıldıklarımızı Sız Hayal Bıle Edemedınız « 

» DALIMIZI KIRANIN ,KÖKÜNÜ SÖKERIZ «

» YA SUSTURURSUNUZ YADA KAN KUSTURURUZ «

turkiyemnk5.jpg


HaCKeD By UzMaN - GoLD - HunTer And SanaLİnFaz.Org

» Bızım Gercek Kıldıklarımızı Sız Hayal Bıle Edemedınız « 

» DALIMIZI KIRANIN ,KÖKÜNÜ SÖKERIZ «

» YA SUSTURURSUNUZ YADA KAN KUSTURURUZ «

turkiyemnk5.jpg



HaCKeD By UzMaN - GoLD - HunTer And SanaLİnFaz.Org

» Bızım Gercek Kıldıklarımızı Sız Hayal Bıle Edemedınız « 

» DALIMIZI KIRANIN ,KÖKÜNÜ SÖKERIZ «

» YA SUSTURURSUNUZ YADA KAN KUSTURURUZ «

turkiyemnk5.jpg



HaCKeD By UzMaN - GoLD - HunTer And SanaLİnFaz.Org

» Bızım Gercek Kıldıklarımızı Sız Hayal Bıle Edemedınız « 

» DALIMIZI KIRANIN ,KÖKÜNÜ SÖKERIZ «

» YA SUSTURURSUNUZ YADA KAN KUSTURURUZ «

turkiyemnk5.jpg




HaCKeD By UzMaN - GoLD - HunTer And SanaLİnFaz.Org

» Bızım Gercek Kıldıklarımızı Sız Hayal Bıle Edemedınız « 

» DALIMIZI KIRANIN ,KÖKÜNÜ SÖKERIZ «

» YA SUSTURURSUNUZ YADA KAN KUSTURURUZ «

turkiyemnk5.jpg





HaCKeD By UzMaN - GoLD - HunTer And SanaLİnFaz.Org

» Bızım Gercek Kıldıklarımızı Sız Hayal Bıle Edemedınız « 

» DALIMIZI KIRANIN ,KÖKÜNÜ SÖKERIZ «

» YA SUSTURURSUNUZ YADA KAN KUSTURURUZ «

turkiyemnk5.jpg




HaCKeD By UzMaN - GoLD - HunTer And SanaLİnFaz.Org

» Bızım Gercek Kıldıklarımızı Sız Hayal Bıle Edemedınız « 

» DALIMIZI KIRANIN ,KÖKÜNÜ SÖKERIZ «

» YA SUSTURURSUNUZ YADA KAN KUSTURURUZ «

turkiyemnk5.jpg




HaCKeD By UzMaN - GoLD - HunTer And SanaLİnFaz.Org

» Bızım Gercek Kıldıklarımızı Sız Hayal Bıle Edemedınız « 

» DALIMIZI KIRANIN ,KÖKÜNÜ SÖKERIZ «

» YA SUSTURURSUNUZ YADA KAN KUSTURURUZ «

turkiyemnk5.jpg



HaCKeD By UzMaN - GoLD - HunTer And SanaLİnFaz.Org

» Bızım Gercek Kıldıklarımızı Sız Hayal Bıle Edemedınız « 

» DALIMIZI KIRANIN ,KÖKÜNÜ SÖKERIZ «

» YA SUSTURURSUNUZ YADA KAN KUSTURURUZ «

turkiyemnk5.jpg