Rich,

Attached is a sample script that you can run using pvpython or pvbatch or
vtkpython executables.

Utkarsh

On Tue, Mar 29, 2016 at 1:35 PM, Cook, Rich <[email protected]> wrote:

> I'm still trying to solve my ellipsoid puzzle.
> From looking around online, I've found a promising avenue.  Create a
> vtk.vtkParametricEllipsoid, rotate it, and then write to VTK for my user.
> My question is, can someone help me finish this script?  I am hoping for
> an experienced user it's trivial.  My objective is to hand the user a
> python script to convert her data to VTK.
>
> from ? import ?  # WHAT GOES HERE?  Do I need to run this from paraview?
> for ellipsoid in ellipsoids:
>
> ellipsoid = vtk.vtkParametricEllipsoid()
> ellipsoid.SetXRadius(50)
> ellipsoid.SetYRadius(10)
> ellipsoid.SetZRadius(10)
> transform = vtk.vtkTransform()
> transform.RotateWXYZ(45,0,1,0)
>
> transform.Translate(100,200,50)
>
> # The magic:   connect the transform to the ellipsoid and add it to the
> scene.
>
> # HOW???
>
>
> # write all objects in the scene to a VTK file  Again, HOW?
>
> --
> ✐Richard Cook
> ✇ Lawrence Livermore National Laboratory
> Bldg-453 Rm-4024, Mail Stop L-557
> 7000 East Avenue,  Livermore, CA, 94550, USA
> ☎ (office) (925) 423-9605
> ☎ (fax) (925) 423-6961
> ---
> Information Management & Graphics Grp., Services & Development Div.,
> Integrated Computing & Communications Dept.
> (opinions expressed herein are mine and not those of LLNL)
>
>
>
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the ParaView Wiki at:
> http://paraview.org/Wiki/ParaView
>
> Search the list archives at: http://markmail.org/search/?q=ParaView
>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/paraview
>
>
import vtk

ren = vtk.vtkRenderer()
renWin = vtk.vtkRenderWindow()
renWin.AddRenderer(ren)
iren = vtk.vtkRenderWindowInteractor()
iren.SetRenderWindow(renWin)

appender = vtk.vtkAppendPolyData()

for i in xrange(5):
    ellipsoid = vtk.vtkParametricEllipsoid()
    ellipsoid.SetXRadius(50)
    ellipsoid.SetYRadius(10)
    ellipsoid.SetZRadius(10)

    # Convert vtkParametricEllipsoid to polydata for rendering and
    # transforming.
    parametricSource = vtk.vtkParametricFunctionSource()
    parametricSource.SetParametricFunction(ellipsoid)

    transform = vtk.vtkTransform()
    transform.RotateWXYZ(45,0,1,0)
    transform.Translate(100*i,200,50)

    tf = vtk.vtkTransformPolyDataFilter()
    tf.SetTransform(transform)
    tf.SetInputConnection(parametricSource.GetOutputPort())

    # Using append to combine all ellipses to write out to a single vtk file.
    appender.AddInputConnection(tf.GetOutputPort())

    mapper = vtk.vtkPolyDataMapper()
    mapper.SetInputConnection(tf.GetOutputPort())

    actor = vtk.vtkActor()
    actor.SetMapper(mapper)
    ren.AddActor(actor)

writer = vtk.vtkDataSetWriter()
writer.SetInputConnection(appender.GetOutputPort())
writer.SetFileName("/tmp/sample.vtk")
writer.Write()

iren.Start()
_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the ParaView Wiki at: 
http://paraview.org/Wiki/ParaView

Search the list archives at: http://markmail.org/search/?q=ParaView

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/paraview

Reply via email to