representation of atoms in molecule viewer?

Nigel Nunn nNunn at ausport.gov.au
Tue May 30 21:45:51 EDT 2000


Hi Maneesh,

> Trying to make an assembly composed of low resolution sphere 
> actors works fine for about 4000 atoms... but on  a beast like 
> hemolysin (20k atoms); my dual PIII and 256mb ram just chokes;
> 
> Anyone have any hints as to what I should/could do to have 
> a pickable representation of large  molecules in vtk.  My 
> package will also allow various representations (ribbon/dots 
> etc.); which are no problem with vtk; but I really would like 
> to have a ball-stick (with thickness)  type thing... and am 
> kinda confused about the general way to do it..


Seems similar to a problem I've been working these last few days: 
given a vtkUstructuredGrid of thousand of cells, how to manipulate 
an actual point in the grid, be it represented as glyph, dot, 
intersection etc.  What I currently have working is adapted from 

  :\vtk\graphics\examplesCxx\pickCells.cxx

Swap the renderer's default picker for a vtkPointPicker

  vtkPointPicker *picker = vtkPointPicker::New();
    picker->SetTolerance(0.01);

  m_IRen = vtkRenderWindowInteractor::New(); 
  m_IRen->SetRenderWindow(m_RenWin);
  m_IRen->SetPicker(picker);


then pick into the displayed dataset.  A vtkPointPicker 
allows us to select a particular "node" (i.e. atom, 
molecule, vertex).  Easiest thing I could think of was 
to use a single simple vtkActor as a "Pick-Glyph" e.g. 
display a sphere at the picked point, then switch to 
object mode and drag the "Pick-Glyph".  When finished 
dragging, move the location of the picked node to the 
location of the "Pick-Glyph": 

void CVtkPanelView::UpdateManipulatedGrid()
{
  // If the glyph was moved, update the grid.

  try {

    // Load the current position of the Glyph.
    m_glyphActor->GetPosition(m_GlyphPosition);

    double d = vtkMath::Distance2BetweenPoints(
                          m_GlyphPosition, m_PickPosition);

    // Have we moved the glyph?
    if (d > PANEL_ADJUST_TOL)
    {
      // Move manipulated grid point to position of glyph.
      m_panelGrid->GetPoints()->
                 SetPoint(m_nVertexId, m_GlyphPosition);

      m_panelGrid->Modified();
    }

  } 
  catch (...) 
  {
    m_bAdjusted = false;
    m_bAdjustMode = false;
    cout << "\nERROR: ... " << endl;
  }
}


Even neater, using the list of all neighboring cells that 
use the selected node, returned from the call

  plateOutput->GetPointCells(picker->GetPointId(), cellIds);

make a "miniature manipulator", a temporary vtkUnstructuredGrid, 
consisting of just those neighboring cells.  

  for (i=0; i < cellIds->GetNumberOfIds(); i++)
  {
    cellId = cellIds->GetId(i);
    plateOutput->GetCellPoints(cellId, ptIds);
    cells->InsertNextCell(plateOutput->GetCellType(cellId), ptIds);
  }

Interactive updating of this simple mesh of (usually) 4 cells 
is very quick, and can give useful feedback about the changes
we are making to the points in the underlying grid.

PS:  You might make the primary actors vtkLODActors, so that
when manipulated, the display can fall back to "point clouds"
or even "bounding box".

PPS:  To get the above working, I intercept all mouse messages
and handle them appropriately.  (Win32/VisualC++/MFC)
Not easy, but learnt much!

Cheers,
Nigel



On Tue 30/05/2000, Maneesh Yadav wrote

-----  [97yadavm at scar.utoronto.ca]  ----- 


Hi all (thanks for all the responses to the dynamic 
visualization stuff) I may end up putting my foot in 
my mouth later, but I think i have finally zenned the 
most fundamental vtkisms...but I am left with a question.
What's the best way to represent the atoms of a molecule 
in such a way that they can each be picked and moved?

That is, 
I want balls representing atoms up on screen; but in order 
to make a true molecular modelling package; these actors 
should be pickable and moveable; and I should be able to 
move these changes in position back to my underlying data 
representation.

As far as I understand; putting them in glyph represents 
them fine, but doesn't represent each glyph component as 
an actor (yes?);  

things also work fine with using  a vtkDataSetMapper 
unstructured grid whose components are the atom positions.

Trying to make an assembly composed of low resolution sphere 
actors works fine for about 4000 atoms... but on  a beast like 
hemolysin (20k atoms); my dual PIII and 256mb ram just chokes;

Anyone have any hints as to what I should/could do to have 
a pickable representation of large  molecules in vtk.  My 
package will also allow various representations (ribbon/dots 
etc.); which are no problem with vtk; but I really would like 
to have a ball-stick (with thickness)  type thing... and am 
kinda confused about the general way to do it..

All advice will be appreciated.

Many thanks,
Maneesh
--------------------------------------------------------------------
This is the private VTK discussion list. Please keep messages on-topic.
Check the FAQ at: <http://public.kitware.com/cgi-bin/vtkfaq>
To UNSUBSCRIBE, send message body containing "unsubscribe vtkusers" to
<majordomo at public.kitware.com>. For help, send message body containing
"info vtkusers" to the same address.
--------------------------------------------------------------------



More information about the vtkusers mailing list