[chimera-dev] 1.2199 and BILD

Thomas Goddard goddard at cgl.ucsf.edu
Tue Feb 28 09:28:25 PST 2006


Hi Charlie,

  I've put the Linux Chimera 1.2199 headers on the source download page.
I'll put the Mac headers up and email you when I figure out where they are.

  The BILD graphics works by creating a VRML model.  It creates a VRML
string and then uses Chimera's VRML rendering.  Creating the string
and parsing it could take some time for a large set of triangles.
That is done in Python -- see the chimera/share/Bld2VRML directory in
your Chimera distribution for exactly what translations are done.  My
impression is that our VRML rendering speed is also very slow and
memory inefficient, but this may be based on VRML scenes with spheres
and cylinders where you cannot control the subdivision level.

  For fast triangulated surface rendering I would suggest using the
Chimera _surface.Surface_Model class.  This is the model type that is
used for volume contour surfaces and multiscale model surfaces.  It
just renders sets of triangles.  It is fairly well optimized for
rendering speed and memory use but does not support triangle strips or
fans.  There is some documentation in the Chimera Programmer's
Reference Guide:

  http://www.cgl.ucsf.edu/chimera/docs/ProgrammersGuide/Reference/surface.html

I include an example making such a model below.  It can also be useful to
look at the C++ header from the Chimera source code

	chimera/contrib/_surface/surfmodel.h

to see all the attributes of Surface_Model objects.

  The PDB file reader is implemented in C++ and I believe there is no
Python interface to read from a string.  The C++ code can read from a
C++ stream (which could be a string stream), but there does not appear
to be a Python interface.  I'd suggest requesting this feature in an
email to chimera-bugs at cgl.ucsf.edu (also used for new feature requests).

	Tom

------
Example Python program to create a surface model in Chimera.

# -----------------------------------------------------------------------------
# vertices is a list of (x,y,z) vertex positions.
# triangles is a list of (i0,i1,i2) vertex index triples defining triangles.
# The order of the vertex indices in the triangles array is used to
# determining lighting normals.
#
def show_geometry(vertices, triangles, rgba):

    # _surface requires float32 and int32 arrays
    import Numeric
    varray = Numeric.array(vertices, Numeric.Float32)
    tarray = Numeric.array(triangles, Numeric.Int32)

    import _surface
    sm = _surface.Surface_Model()
    g = sm.add_group(varray, tarray, rgba)
    g.set_display_style(g.Mesh)             # Mesh or Solid (default)
    g.set_normal_orientation(g.Righthanded) # Outward normal Righthanded (default) or Lefthanded

    # See contrib/_surface/surfmodel.h for more attributes

    import chimera
    chimera.openModels.add([sm])

    return sm

# -----------------------------------------------------------------------------
# Tetrahedron exampl;e.
#
vertices = ((0,0,0), (1,0,0), (0,1,0), (0,0,1))
triangles = ((0,2,1), (0,1,3), (0,3,2), (1,2,3))
rgba = (.7,.7,.7,1)
show_geometry(vertices, triangles, rgba)




More information about the Chimera-dev mailing list