7.3 OEDepictFixedCoordinates

bool OEDepictFixedCoordinates(OEChem::OEMolBase &mol,
                              const unsigned char *afixed,
                              const unsigned char *bfixed = 0)

This function is an extended for of the OEDepictCoordinates API, that allows the user to specify or ``fix'' a subset of atoms of the current molecule. The afixed input parameter must be a valid pointer to the start of an array at least mol.GetMaxAtomIdx() bytes long, and the bfixed input parameter, if specified, must be a valid pointer to the start of an array at least mol.GetMaxBondIdx() bytes long.

For each atom in the molecule, a non-zero value for afixed[atm->GetIdx()] indicates that it's ``layout'' should be fixed, and a zero value indicates that the depicition algorithm should provide co-ordinates. When bfixed is not specified, a bond bnd is considered fixed when both of its end atoms are fixed, i.e. afixed[bnd->GetBgnIdx()] && afixed[bnd->GetEndIdx()]. However, there are times when finer control is required, and the bfixed array allows the caller to specify which bonds are fixed. This is useful for in applications such as using ring templates, where in molecules such as biphenyl, all the atoms may be given co-ordinates, but the non-ring bond linking them may not have been ``fixed'' and so OEDepictCoordinates is expected to arrange the two rings relative to each other.

If a bond is fixed, its distance (bond length) is preserved by this function. Likewise, for two fixed bonds that share a common fixed atom, the bond angle between them is perserved. If all of the fixed atoms of a molecule are ``connected'' by fixed bonds, then the co-ordinates of the fixed atoms should be preserved on output (perhaps with minor differences due to rounding errors). If the fixed substructures of a molecule aren't connected, the orientation of the first is preserved, but the relative layout (lengths and angles) of the others are preserved. Hence, if all the atoms and bonds of a molecule are fixed, this function should return (approximately) the same co-ordinates as the input molecule. If all of the atoms and bonds are unfixed, this function should be equivalent to calling OEDepictCoordinates.

This function returns true if 2D co-ordinates were sucessfully assigned to every atom. In the current implementation, this function fails if the input molecule is a disconnected structure (i.e. multiple parts) or if the molecule's dimension (as returned by the method OEMolBase::GetDimension) isn't two. Future releases may relax the single connected component restriction.