[vtkusers] A set of spheres within one actor?
Bill Lorensen
bill.lorensen at gmail.com
Mon Sep 14 12:16:47 EDT 2009
You should use vtkGlyph3D to display many spheres for molecular
visualization. Look at:
VTK/IO/Testing/Tcl/TestXYZMol.tcl for some ideas.
Bill
On Mon, Sep 14, 2009 at 6:26 AM, Piotr Byzia <piotr.byzia at gmail.com> wrote:
> Dear list members,
>
> I'd like to say hello to everybody, as this is my first post on this list.
>
> I want to use VTK to build some simple molecular viewer for biological
> structures, represented by spheres, and in the near future also by lines and
> sticks.
>
> I succeeded in drawing a sphere representation for a couple of atoms, and I
> want to be able to add another *set* of atoms and manipulate them separately
> from the 1st set. I found the SetCurrentStyleToTrackballActor() property and
> it works fine, but for a single sphere.
>
> My question is how to create a set of spheres within 1 actor?
>
> Below is the code in Python I used, and error is:
> vtkStreamingDemandDrivenPipeline (0x584c10): Input port 0 of algorithm
> vtkDataSetMapper(0x9ff800) has 38 connections but is not repeatable.
>
> ren = vtk.vtkRenderer()
> renWin.AddRenderer(ren)
>
> iren = vtk.vtkRenderWindowInteractor()
> iren.SetRenderWindow(renWin)
>
> isty = vtk.vtkInteractorStyleSwitch()
> isty.SetCurrentStyleToTrackballCamera()
> isty.SetCurrentStyleToTrackballActor() # pick one actor and act only on it
> iren.SetInteractorStyle(isty)
>
> sphereMapper = vtk.vtkDataSetMapper()
>
> for i in atoms:
> # Create a sphere source, mapper, and actor.
> sphere = vtk.vtkSphereSource()
>
> sphere.SetCenter(i[0], i[1], i[2]);
> sphere.SetRadius(1.0);
>
> sphere.SetThetaResolution(18)
> sphere.SetPhiResolution(18)
>
> sphereMapper.AddInputConnection(sphere.GetOutputPort())
>
> sphereActor = vtk.vtkLODActor()
> sphereActor.SetMapper(sphereMapper)
> sphereActor.GetProperty().SetColor(0.0, 0.0, 0.6) # RGB = red green blue
> sphereActor.GetProperty().SetOpacity(1)
> ren.AddActor(sphereActor)
>
>
> Also, how could I programmatically set which set of spheres (which actor)
> should be used by RenderWindowInteractor? In other words, I'd like to be
> able to chose a particular actor (as in shift + left mouse button in the
> window) and manipulate (rotate, transform, zoom) only that particular actor.
>
> Please correct me, if I'm incorrectly using any terms related to VTK, I just
> started ;-)
>
> Best wishes,
> Piotr Byzia
> _______________________________________________
> 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 VTK FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>
More information about the vtkusers
mailing list