OECalculateTriangleAreas¶
bool OECalculateTriangleAreas(const OESurface &surf, float *areas)
Will calculate the area of every triangle of surf
and store the
result in the array areas
of that should be large enough to
hold GetNumTriangles()
floats. The array is indexed by the
triangle indices.
Listing 1
demonstrates how to calculate the surface area contribution from
each atom. It is assumed surf
is an
OESurface created from the molecule mol
.
Listing 1: Calculates the surface area contribution from each atom
OEFloatArray areas = new OEFloatArray(surf.GetNumTriangles());
oespicoli.OECalculateTriangleAreas(surf, areas);
float[] atomareas = new float[mol.GetMaxAtomIdx()];
OEUIntArray tri = new OEUIntArray(3);
for (int i=0; i < surf.GetNumTriangles(); i++)
{
surf.GetTriangle(i, tri);
int a1 = surf.GetAtomsElement(tri.getItem(0));
int a2 = surf.GetAtomsElement(tri.getItem(1));
int a3 = surf.GetAtomsElement(tri.getItem(2));
atomareas[a1] += areas.getItem(i)/3.0;
atomareas[a2] += areas.getItem(i)/3.0;
atomareas[a3] += areas.getItem(i)/3.0;
}
for (OEAtomBase atom : mol.GetAtoms())
System.out.printf("atom %d area = %2.4f\n", atom.GetIdx(), atomareas[atom.GetIdx()]);