CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM Paraview & paraFoam (http://www.cfd-online.com/Forums/openfoam-paraview/)
-   -   Cut/Clip cylinder instead of sphere/plane? (http://www.cfd-online.com/Forums/openfoam-paraview/95729-cut-clip-cylinder-instead-sphere-plane.html)

Ruehri December 30, 2011 10:10

Cut/Clip cylinder instead of sphere/plane?
 
Dear Foamers,

I would like to make a cut in paraview with the form of a cylinder. Is there any way I can do this? When using the cut command, I can only choose sphere or plane, but would like to have cylinder surface.

Thanks all.

wyldckat May 18, 2013 14:54

Sorry for digging this thread from so far in the past.
But since this shows up in the top Google search results when looking for this question, I'll leave a note to the recent solution: http://www.cfd-online.com/Forums/ope...tml#post428465

nisha October 15, 2013 03:04

Cylinder clip
 
Quote:

Originally Posted by wyldckat (Post 428466)
Sorry for digging this thread from so far in the past.
But since this shows up in the top Google search results when looking for this question, I'll leave a note to the recent solution: http://www.cfd-online.com/Forums/ope...tml#post428465

Dear Wyldckat,

The link above gives solution for cylinder-"slice". I am looking for cylinder-"clip" like "box" or "sphere" option. I need the entire data that is enclosed in the cylinder. Please help. Thanks.

Nisha

wyldckat October 19, 2013 13:09

Greetings Nisha,

Very good point! Back when I figured out how to use the "Cylinder" for slicing the results, I didn't properly read that this thread was about clipping and not slicing!

OK, basing myself on my other post, here goes...
It requires two things:
  1. That you are using ParaView 3.12 or 3.14, including the Python capabilities inside ParaView. The reason for this is that in ParaView 3.98, the necessary VTK filter is not present.
  2. That you use the "Programmable Filter" instead of the normal "Clip" filter. The reason for this is because the "Cylinder" is an implicit function that for some reason they forgot to include in ParaView :(
Instructions:
  1. Apply the "Programmable Filter" to the item you want to cut.
  2. Use the following code in the first text edit box:
    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.4)
    cyl.SetTransform(transf)

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

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

  3. Notes on important details:
    1. The cylinder is infinite, because it's an implicit function.
    2. "cyl.SetRadius(0.4)" - defines the radius.
    3. "cyl.SetCenter(0,0,0)" - defines the centre of the cylinder.
    4. The transformation is done with these lines of code:
      Code:

      transf = vtk.vtkTransform()
      transf.RotateX(90)

    5. If more transformations are needed, see the list of methods here: http://www.vtk.org/doc/release/5.10/...Transform.html
    6. Remove the "#" if you want the inside side of the clip, instead of the outside... or vice-versa!?
    7. More possible options for the "vtkClipDataSet" filter are given here: http://www.vtk.org/doc/release/5.10/...ipDataSet.html
Best regards,
Bruno

nisha October 21, 2013 04:30

Works like charm! Thanks wlydckat !!

babala December 18, 2013 09:46

Quote:

Originally Posted by wyldckat (Post 457823)
Greetings Nisha,

Very good point! Back when I figured out how to use the "Cylinder" for slicing the results, I didn't properly read that this thread was about clipping and not slicing!

OK, basing myself on my other post, here goes...
It requires two things:
  1. That you are using ParaView 3.12 or 3.14, including the Python capabilities inside ParaView. The reason for this is that in ParaView 3.98, the necessary VTK filter is not present.
  2. That you use the "Programmable Filter" instead of the normal "Clip" filter. The reason for this is because the "Cylinder" is an implicit function that for some reason they forgot to include in ParaView :(
Instructions:
  1. Apply the "Programmable Filter" to the item you want to cut.
  2. Use the following code in the first text edit box:
    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.4)
    cyl.SetTransform(transf)
     
    clipper = vtk.vtkClipDataSet()
    clipper.SetClipFunction(cyl)
    clipper.SetInput(inp_copy)
    #clipper.InsideOutOn()
    clipper.Update()
     
    self.GetOutputDataObject(0).ShallowCopy(clipper.GetOutputDataObject(0))

  3. Notes on important details:
    1. The cylinder is infinite, because it's an implicit function.
    2. "cyl.SetRadius(0.4)" - defines the radius.
    3. "cyl.SetCenter(0,0,0)" - defines the centre of the cylinder.
    4. The transformation is done with these lines of code:
      Code:

      transf = vtk.vtkTransform()
      transf.RotateX(90)

    5. If more transformations are needed, see the list of methods here: http://www.vtk.org/doc/release/5.10/...Transform.html
    6. Remove the "#" if you want the inside side of the clip, instead of the outside... or vice-versa!?
    7. More possible options for the "vtkClipDataSet" filter are given here: http://www.vtk.org/doc/release/5.10/...ipDataSet.html
Best regards,
Bruno

Hi Bruno,
does this method work on paraview which is Windows version? And the VTK is created by OF-2.2.2, I find that the paraview 3-14 can't open this VTK file.Do you know why?

best regards,
Zhiyuan

wyldckat December 25, 2013 12:49

Greetings Zhiyuan,

Quote:

Originally Posted by babala (Post 466917)
does this method work on paraview which is Windows version? And the VTK is created by OF-2.2.2, I find that the paraview 3-14 can't open this VTK file.Do you know why?

That's very strange. What was the exact command line you used to export the case to VTK?


And the reported Python code should work on any Operating System that can run ParaView 3.14.

Best regards,
Bruno


All times are GMT -4. The time now is 18:27.