CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   ParaView (https://www.cfd-online.com/Forums/paraview/)
-   -   [General] Clip Filter as Type Cylinder (https://www.cfd-online.com/Forums/paraview/155354-clip-filter-type-cylinder.html)

Mr.Robot June 29, 2015 08:29

Clip Filter as Type Cylinder
 
Hello!

I am using ParaView 4.1.0 and I require to apply slices, as well as cuts to my model- but in cylindrical shapes.

I went through the forums thoroughly and was able to find programmable filters for the same. The Cylindrical Slice worked, but with a slight modification to cutter.SetInput() -> cutter.SetInputData().
You can see the complete code

Code:

#Change 'Output Data Set Type' to vtkPolyData

input = self.GetInputDataObject(0, 0)
inp_copy = input.NewInstance()
inp_copy.ShallowCopy(input)
inp_copy.UnRegister(None)
cutter = vtk.vtkCutter()
transf = vtk.vtkTransform()
transf.RotateX(90)
cyl = vtk.vtkCylinder()

#Define radius and cylinder centre- in the following two lines of code

cyl.SetCenter(0,0,0)
cyl.SetRadius(0.00375)
cyl.SetTransform(transf)
cutter.SetCutFunction(cyl)
cutter.SetInputData(inp_copy)
cutter.Update()
self.GetOutputDataObject(0).ShallowCopy(cutter.GetOutputDataObject(0))

I found a similar post by the same user for a cylindrical clip function which is quite consistent but for some reason it does not work. The code is below, followed by the error message I get,

Code:

input = self.GetInputDataObject(0, 0)
inp_copy = input.NewInstance()
inp_copy.ShallowCopy(input)
inp_copy.UnRegister(None)

transf = vtk.vtkTransform()
transf.RotateX(90)
cyl = vtk.vtkCylinder()
cyl.SetCenter(0,0,0)
cyl.SetRadius(0.00375)
cyl.SetTransform(transf)

clipper = vtk.vtkClipDataSet()
clipper.SetClipFunction(cyl)
clipper.SetInputData(inp_copy)
#clipper.InsideOutOn()
clipper.Update()

self.GetOutputDataObject(0).ShallowCopy(clipper.GetOutputDataObject(0))

Traceback (most recent call last):
File "<string>", line 22, in <module>
File "<string>", line 14, in RequestData
AttributeError: 'module' object has no attribute 'vtkClipDataSet'


Could someone please explain what is wrong with the Clip Programmable Filter?

The link for the original posts by wyldckat :

http://www.cfd-online.com/Forums/ope...-cylinder.html
http://www.cfd-online.com/Forums/ope...ere-plane.html


Would really appreciate a quick reply,

thank you in advance!

wyldckat August 20, 2015 15:43

Greetings Mr.Robot,

Sorry for the late reply, but only today did I finally manage to look into this. The problem is that you were missing this line:
Code:

import vtk
This will load the complete "vtk" module. I don't know why the "Programmable Filter" doesn't load it all at once :(

The complete script therefore being this:
Code:

import vtk

input = self.GetInputDataObject(0, 0)
inp_copy = input.NewInstance()
inp_copy.ShallowCopy(input)
inp_copy.UnRegister(None)

transf = vtk.vtkTransform()
transf.RotateX(90)
cyl = vtk.vtkCylinder()
cyl.SetCenter(0,0,0)
cyl.SetRadius(0.00375)
cyl.SetTransform(transf)

clipper = vtk.vtkClipDataSet()
clipper.SetClipFunction(cyl)
clipper.SetInputData(inp_copy)
#clipper.InsideOutOn()
clipper.Update()

self.GetOutputDataObject(0).ShallowCopy(clipper.GetOutputDataObject(0))

Best regards,
Bruno


All times are GMT -4. The time now is 06:14.