void
SelectionCollection::setTopology(t_topology *top, int natoms)
{
    gmx_ana_selcollection_t *sc = &_impl->_sc;
    gmx_ana_poscalc_coll_set_topology(sc->pcc, top);
    sc->top = top;

    /* Get the number of atoms from the topology if it is not given */
    if (natoms <= 0)
    {
        if (sc->top == NULL)
        {
            GMX_THROW(APIError("Selections need either the topology or the number of atoms"));
        }
        natoms = sc->top->atoms.nr;
    }

    gmx_ana_index_init_simple(&sc->gall, natoms, NULL);
}
Esempio n. 2
0
/*!
 * \param[in,out] sc        Selection collection to set the topology for.
 * \param[in]     top       Topology data.
 * \param[in]     natoms    Number of atoms. If <=0, the number of atoms in the
 *   topology is used.
 * \returns       0 on success, EINVAL if \p top is NULL and \p natoms <= 0.
 *
 * The topology is also set for the position calculation collection
 * associated with \p sc.
 *
 * \p natoms determines the largest atom index that can be selected by the
 * selection: even if the topology contains more atoms, they will not be
 * selected.
 */
int
gmx_ana_selcollection_set_topology(gmx_ana_selcollection_t *sc, t_topology *top,
                                   int natoms)
{
    gmx_ana_poscalc_coll_set_topology(sc->pcc, top);
    sc->top = top;

    /* Get the number of atoms from the topology if it is not given */
    if (natoms <= 0)
    {
        if (!sc->top)
        {
            gmx_incons("selections need either the topology or the number of atoms");
            return EINVAL;
        }
        natoms = sc->top->atoms.nr;
    }
    gmx_ana_index_init_simple(&sc->gall, natoms, NULL);
    return 0;
}