コード例 #1
0
void
SelectionCollection::printTree(FILE *fp, bool bValues) const
{
    SelectionTreeElementPointer sel = impl_->sc_.root;
    while (sel)
    {
        _gmx_selelem_print_tree(fp, *sel, bValues, 0);
        sel = sel->next;
    }
}
コード例 #2
0
void
SelectionCollection::printTree(FILE *fp, bool bValues) const
{
    t_selelem *sel;

    sel = _impl->_sc.root;
    while (sel)
    {
        _gmx_selelem_print_tree(fp, sel, bValues, 0);
        sel = sel->next;
    }
}
コード例 #3
0
ファイル: selection.c プロジェクト: aar2163/GROMACS
/*!
 * \param[in] fp      File handle to receive the output.
 * \param[in] sc      Selection collection to print.
 * \param[in] bValues If TRUE, the evaluated values of selection elements
 *   are printed as well.
 */
void
gmx_ana_selcollection_print_tree(FILE *fp, gmx_ana_selcollection_t *sc, bool bValues)
{
    t_selelem *sel;

    sel = sc->root;
    while (sel)
    {
        _gmx_selelem_print_tree(fp, sel, bValues, 0);
        sel = sel->next;
    }
}
コード例 #4
0
ファイル: selelem.cpp プロジェクト: losalamos/gromacs-kokkos
/*!
 * \param[in] fp      File handle to receive the output.
 * \param[in] sel     Root of the selection subtree to print.
 * \param[in] bValues If true, the evaluated values of selection elements
 *   are printed as well.
 * \param[in] level   Indentation level, starting from zero.
 */
void
_gmx_selelem_print_tree(FILE *fp, const gmx::SelectionTreeElement &sel,
                        bool bValues, int level)
{
    int          i;

    fprintf(fp, "%*c %s %s", level*2+1, '*',
            _gmx_selelem_type_str(sel), _gmx_sel_value_type_str(&sel.v));
    if (!sel.name().empty())
    {
        fprintf(fp, " \"%s\"", sel.name().c_str());
    }
    fprintf(fp, " flg=");
    if (sel.flags & SEL_FLAGSSET)
    {
        fprintf(fp, "s");
    }
    if (sel.flags & SEL_SINGLEVAL)
    {
        fprintf(fp, "S");
    }
    if (sel.flags & SEL_ATOMVAL)
    {
        fprintf(fp, "A");
    }
    if (sel.flags & SEL_VARNUMVAL)
    {
        fprintf(fp, "V");
    }
    if (sel.flags & SEL_DYNAMIC)
    {
        fprintf(fp, "D");
    }
    if (!(sel.flags & SEL_VALFLAGMASK))
    {
        fprintf(fp, "0");
    }
    if (sel.flags & SEL_ALLOCVAL)
    {
        fprintf(fp, "Av");
    }
    if (sel.flags & SEL_ALLOCDATA)
    {
        fprintf(fp, "Ad");
    }
    if (sel.mempool)
    {
        fprintf(fp, "P");
    }
    if (sel.type == SEL_CONST)
    {
        if (sel.v.type == INT_VALUE)
        {
            fprintf(fp, " %d", sel.v.u.i[0]);
        }
        else if (sel.v.type == REAL_VALUE)
        {
            fprintf(fp, " %f", sel.v.u.r[0]);
        }
        else if (sel.v.type == GROUP_VALUE)
        {
            const gmx_ana_index_t *g = sel.v.u.g;
            if (!g || g->isize == 0)
            {
                g = &sel.u.cgrp;
            }
            fprintf(fp, " (%d atoms)", g->isize);
        }
    }
    else if (sel.type == SEL_BOOLEAN)
    {
        fprintf(fp, " %s", _gmx_selelem_boolean_type_str(sel));
    }
    else if (sel.type == SEL_EXPRESSION
             && sel.u.expr.method->name == sm_compare.name)
    {
        _gmx_selelem_print_compare_info(fp, sel.u.expr.mdata);
    }
    if (sel.evaluate)
    {
        fprintf(fp, " eval=");
        _gmx_sel_print_evalfunc_name(fp, sel.evaluate);
    }
    if (sel.v.nalloc < 0)
    {
        fprintf(fp, " (ext)");
    }
    fprintf(fp, "\n");

    if ((sel.type == SEL_CONST && sel.v.type == GROUP_VALUE) || sel.type == SEL_ROOT)
    {
        const gmx_ana_index_t *g = sel.v.u.g;
        if (!g || g->isize == 0 || sel.evaluate != NULL)
        {
            g = &sel.u.cgrp;
        }
        if (g->isize < 0)
        {
            fprintf(fp, "%*c group: (null)\n", level*2+1, ' ');
        }
        else if (g->isize > 0)
        {
            fprintf(fp, "%*c group:", level*2+1, ' ');
            if (g->isize <= 20)
            {
                for (i = 0; i < g->isize; ++i)
                {
                    fprintf(fp, " %d", g->index[i] + 1);
                }
            }
            else
            {
                fprintf(fp, " %d atoms", g->isize);
            }
            fprintf(fp, "\n");
        }
    }
    else if (sel.type == SEL_EXPRESSION)
    {
        if (sel.u.expr.pc)
        {
            fprintf(fp, "%*c COM", level*2+3, '*');
            fprintf(fp, "\n");
        }
    }
    else if (sel.type == SEL_SUBEXPRREF && sel.u.param != NULL)
    {
        fprintf(fp, "%*c param", level*2+1, ' ');
        if (sel.u.param->name != NULL)
        {
            fprintf(fp, " \"%s\"", sel.u.param->name);
        }
        if (sel.u.param->val.nalloc < 0)
        {
            fprintf(fp, " (ext)");
        }
        else
        {
            fprintf(fp, " nalloc: %d", sel.u.param->val.nalloc);
        }
        fprintf(fp, "\n");
    }

    if (sel.cdata)
    {
        _gmx_selelem_print_compiler_info(fp, sel, level);
    }

    if (bValues && sel.type != SEL_CONST && sel.type != SEL_ROOT && sel.v.u.ptr)
    {
        fprintf(fp, "%*c value: ", level*2+1, ' ');
        switch (sel.v.type)
        {
        case POS_VALUE:
            /* In normal use, the pointer should never be NULL, but it's
             * useful to have the check for debugging to avoid accidental
             * segfaults when printing the selection tree. */
            if (sel.v.u.p->x)
            {
                fprintf(fp, "(%f, %f, %f)",
                        sel.v.u.p->x[0][XX], sel.v.u.p->x[0][YY],
                        sel.v.u.p->x[0][ZZ]);
            }
            else
            {
                fprintf(fp, "(null)");
            }
            break;
        case GROUP_VALUE:
            fprintf(fp, "%d atoms", sel.v.u.g->isize);
            if (sel.v.u.g->isize < 20)
            {
                if (sel.v.u.g->isize > 0)
                {
                    fprintf(fp, ":");
                }
                for (i = 0; i < sel.v.u.g->isize; ++i)
                {
                    fprintf(fp, " %d", sel.v.u.g->index[i] + 1);
                }
            }
            break;
        default:
            fprintf(fp, "???");
            break;
        }
        fprintf(fp, "\n");
    }

    /* Print the subexpressions with one more level of indentation */
    gmx::SelectionTreeElementPointer child = sel.child;
    while (child)
    {
        if (!(sel.type == SEL_SUBEXPRREF && child->type == SEL_SUBEXPR))
        {
            _gmx_selelem_print_tree(fp, *child, bValues, level+1);
        }
        child = child->next;
    }
}