OESurfaces
and OEMolBases represent a graph in computer memory.
An OESurface provides two ways of retrieving data. The first is
a set of methods that will return a copy of the entire data array. The
second are a set of methods with the Element suffix that allow
random access directly into the array of data. Basic usage of both
will be shown for vertices and triangles.
GetNumVertices() * 3 * sizeof(float). Equivalent dimensions are
stored at every third place in the array as shown by
Figure 2.1.
|
A copy of this array can be obtained using the code fragment in
Listing 2.1, where surf is a OESurface
object.
float *coords = new float[surf.GetNumVertices()*3]; surf.GetVertices(coords);
For direct access to the vertex array use the Element version
of GetVertices. Listing 2.2 is a code
fragment that shows how to iterate over all the vertex coordinates of
a surface.
float x, y, z;
for(unsigned int i=0; i < surf.GetNumVertices(); ++i)
{
x = surf.GetVerticesElement(i * 3);
y = surf.GetVerticesElement(i * 3 + 1);
z = surf.GetVerticesElement(i * 3 + 2);
}
Consider the two triangles in Figure 2.2 defined by the vertices A, B, C, D. The triangle on the left is defined by the set (A, B, C). The triangle on the right is defined by the set (D, B, A). Also notice how the edge AB is defined in both triangles but in opposite order. This reversal of order in the two definitions is a direct consequence of the clockwise ordering rule.
|
|
All the methods of construction described in this document obey this rule. A surface that does not follow this rule can still be operated on by OESpicoli, but it is not considered a canonical surface and some results may be incorrect or ambiguous.
OESpicoli stores triangle vertices as an integer array of size
GetNumTriangles() * 3 * sizeof(unsigned int). Each integer is
an index into the vertex array explained in
Section 2.1.1. Listing 2.3 is a code fragment
that will retrieve a copy of the entire triangles array.
unsigned int *triangles = new unsigned int[surf.GetNumTriangles()*3]; surf.GetTriangles(triangles);
For direct access to the triangle array, use the Element
version of GetTriangles. Listing 2.4 is a
code fragment that shows how to iterate over all the triangles of a
surface.
unsigned int v1, v2, v3;
for(unsigned int i=0; i < surf.GetNumTriangles(); ++i)
{
v1 = surf.GetTrianglesElement(i * 3);
v2 = surf.GetTrianglesElement(i * 3 + 1);
v3 = surf.GetTrianglesElement(i * 3 + 2);
}
The OESurface also supports vertex normals since vertices are often easier to work with analytically. Vertex normals are calculated by averaging all of the face normals of triangles of which the vertex is a part. Figure 2.3 contrasts the differences between face and vertex normals respectively.
[Vertex Normals]
|
Vectors in OESpicoli are represented by three floating point
values. Normal vectors are always of unit length. They can be
calculated and stored on the OESurface object by invoking the
free functions OECalculateNormals and
OECalculateFaceNormals for vertex and face normals,
respectively.
It is important to remember that the size of a normal array is
determined by whether it is a face or vertex normal. For example the
size of the vertex normal array is GetNumVertices() * 3 *
sizeof(float). While the size of the face normal array is
GetNumTriangles() * 3 * sizeof(float).
float) Solvent accessibility of the vertex
float) The Euclidean distance to the vertex
from another portion of the surface
Curvature follows a pragmatic computational chemistry definition. It is a property of solvent molecules, represented as spheres, packed onto the surface. Figure 2.4 demonstrates the two dimensional case of how solvent molecules are packed onto a surface. The first sphere is mapped adjacent to the vertex using the vertex's normal. Two more spheres are then packed adjacent to the surface and the starting sphere. The angle between these two spheres is used to calculate the accessibility to solvent of the initial sphere using the following formula:
| (2.1) |
For this simple case the angle is also a measure of the surface curvature, hence the name. In three dimensions steradians are required to accomplish the same functional form:
| (2.2) |
Therefore, a vertex's ``curvature'' falls into a range with the following bounds:
|
[Concave (negative value)]
[Flat (zero)]
[Convex (positive value)]
|
Distance is listed as specific data because it can be derived as the distance between different portions of the surface. This can be useful for measuring the thickness of a volume that is enclosed by a surface. Distances can also be measured to other arbitrary objects as well, such as molecules and other surfaces.
unsigned int) Atom index for the vertex
floats or 4 unsigned chars) Color of the vertex
float) Electrostatic potential at the vertex
To map chemical properties onto a surface it is useful to know which
atoms are responsible for portions of the surface. When a surface is
constructed from a molecule, a data array containing the corresponding
atom index for each vertex is created. An atom's index can be obtained
from the OEAtomBase::GetIdx method and is unique over the
molecule. The reader can refer to the OEChem manual for more
information about atom indices.
To display chemical properties it is often useful to render them as either discrete colors or a spectrum of colors. The color data array allows the user to set a color for every vertex in the surface. When the surface is then read into a visualizer, such as Vida, the properties can easily be interpreted. Every vertex has the associated values: red, green, blue, and alpha. Alpha is the transparency of the vertex. If any value is retrieved as a float, then that value will range from 0 to 1 inclusive. If retrieved as an unsigned char, the value will range from 0 to 255 inclusive.
Electrostatic potentials can be calculated and displayed on a surface. This can be done with current OpenEye tools such as Zap or another application.
The potentials array is essentially an array of floats the user can use to record analytical data for each vertex.