[vtkusers] Questions about vtkMolecules

David Lonie david.lonie at kitware.com
Mon Mar 13 10:10:22 EDT 2017


On Fri, Mar 10, 2017 at 12:35 PM, Edson Contreras Cárdenas
<edrecon at gmail.com> wrote:
> 1.- Custom colors for atoms
> As I read in this github commit there is a way to change vtkMoleculeMapper's
> color array and I was not able to do it, so please can you tell me how to
> achieve this :-). I tried several ways with no success. My idea is to
> specify specific rgb colors to atoms no matter their atomic number (in order
> to display zones of data)

This works just like applying colors to points for any other dataset.
You can provide a scalar array on the vtkMolecule's PointData and map
it through a look up table, or create an array containing the RGBA
values themselves. vtkMoleculeMapper uses the same APIs and
vtkPolyDataMapper for configuring coloring using these arrays.

> 2.- Cell picking (mixed polydata actors and molecule actors)
> As I explained above, I was using vtkUnstructuredGrid points + vtkGlyphs and
> that also mixed with polydata in something like attached picture
> (molecule_box.png). The image consists in a vtkMolecule -> vtkMoleculeMapper
> -> vtkActor and vtkCubeSource -> vtkMapper -> vtkActor displayed together in
> the same vtkRenderer. The problem is that if a use something like:
>
> vtkCellPicker* picker = vtkCellPicker::New();
> if( picker->Pick( screen[0], screen[1], 0.0, m_renderer ) )
> {
> // detect cube face
> }
>
> It crashes extracting mappers input as vtkPolyData (of vtkMolecule actors)
> so, do you have a clue of how to overcome it? Can I exclude actors in
> vtkCellPicker to not check for Molecule actors? Should I use other actor
> and/or picker?

See Domains/Chemistry/Testing/Cxx/TestMoleculeSelection.cxx for an
example of how picking works with molecules. It's a bit trickier than
picking other datasets, and some of the more generalized methods won't
work. There are quite a few examples of how to use vtkMolecule in that
directory.

> 3.- Dataset values in Atoms
> Is there any way of add vtkPointData and/or vtkCellData to a vtkAtom in
> order to visualize gradients later with a vtkContourBand or something like
> that? My idea is to visualize experimental potential energy and kinetic
> energy.

You'll want to create a separate dataset (vtkImageData or something)
with your gradient data and contour that. vtkMolecule only supports
atoms and bonds, with some limited support for molecular orbitals via
vtkAbstractElectronicData.

> P.D.: I have been developing a very simple port of my project as an
> opensource application, for detecting memory leaks and bad practices. The
> attached picture comes from there. it can be found under:
> https://github.com/zxnord/Qt4VTK7SimpleViewer

Cool! Glad to see more chemists using VTK :-)

HTH,
Dave


More information about the vtkusers mailing list