void
SelectionCollection::setOutputPosType(const char *type)
{
    GMX_RELEASE_ASSERT(type != NULL, "Cannot assign NULL position type");
    //! Check that the type is valid.
    e_poscalc_t  dummytype;
    int          dummyflags;
    gmx_ana_poscalc_type_from_enum(type, &dummytype, &dummyflags);
    _impl->_spost = type;
}
bool
SelectionCollection::requiresTopology() const
{
    t_selelem   *sel;
    e_poscalc_t  type;
    int          flags;

    if (!_impl->_rpost.empty())
    {
        flags = 0;
        // Should not throw, because has been checked earlier.
        gmx_ana_poscalc_type_from_enum(_impl->_rpost.c_str(), &type, &flags);
        if (type != POS_ATOM)
        {
            return true;
        }
    }
    if (!_impl->_spost.empty())
    {
        flags = 0;
        // Should not throw, because has been checked earlier.
        gmx_ana_poscalc_type_from_enum(_impl->_spost.c_str(), &type, &flags);
        if (type != POS_ATOM)
        {
            return true;
        }
    }

    sel = _impl->_sc.root;
    while (sel)
    {
        if (_gmx_selelem_requires_top(sel))
        {
            return true;
        }
        sel = sel->next;
    }
    return false;
}
Beispiel #3
0
/*!
 * \param[in]  sc  Selection collection to query.
 * \returns    TRUE if any selection in \p sc requires topology information,
 *   FALSE otherwise.
 *
 * Before gmx_ana_selcollection_parse_*(), the return value is based just on
 * the position types set.
 * After gmx_ana_selcollection_parse_*(), the return value also takes into account the
 * selection keywords used.
 */
bool
gmx_ana_selcollection_requires_top(gmx_ana_selcollection_t *sc)
{
    t_selelem   *sel;
    e_poscalc_t  type;
    int          flags;
    int          rc;

    if (sc->rpost)
    {
        flags = 0;
        rc = gmx_ana_poscalc_type_from_enum(sc->rpost, &type, &flags);
        if (rc == 0 && type != POS_ATOM)
        {
            return TRUE;
        }
    }
    if (sc->spost)
    {
        flags = 0;
        rc = gmx_ana_poscalc_type_from_enum(sc->spost, &type, &flags);
        if (rc == 0 && type != POS_ATOM)
        {
            return TRUE;
        }
    }

    sel = sc->root;
    while (sel)
    {
        if (_gmx_selelem_requires_top(sel))
        {
            return TRUE;
        }
        sel = sel->next;
    }
    return FALSE;
}
Beispiel #4
0
/*!
 * \param[out] pcp   Position calculation data structure pointer to initialize.
 * \param[in,out] pcc   Position calculation collection.
 * \param[in]  post  One of the strings acceptable for
 *   gmx_ana_poscalc_type_from_enum().
 * \param[in]  flags Flags for setting calculation options
 *   (see \ref poscalc_flags "documentation of the flags").
 * \returns    0 on success, a non-zero error value on error.
 *
 * This is a convenience wrapper for gmx_ana_poscalc_create().
 * \p flags sets the default calculation options if not overridden by \p post;
 * see gmx_ana_poscalc_type_from_enum().
 *
 * \see gmx_ana_poscalc_create(), gmx_ana_poscalc_type_from_enum()
 */
int
gmx_ana_poscalc_create_enum(gmx_ana_poscalc_t **pcp, gmx_ana_poscalc_coll_t *pcc,
                            const char *post, int flags)
{
    e_poscalc_t  type;
    int          cflags;
    int          rc;

    cflags = flags;
    rc = gmx_ana_poscalc_type_from_enum(post, &type, &cflags);
    if (rc != 0)
    {
        *pcp = NULL;
        return rc;
    }
    return gmx_ana_poscalc_create(pcp, pcc, type, cflags);
}