/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2009,2010,2011,2012,2013, by the GROMACS development team, led by
- * David van der Spoel, Berk Hess, Erik Lindahl, and including many
- * others, as listed in the AUTHORS file in the top-level source
- * directory and at http://www.gromacs.org.
+ * Copyright (c) 2009,2010,2011,2012,2013,2014, by the GROMACS development team, led by
+ * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
+ * and including many others, as listed in the AUTHORS file in the
+ * top-level source directory and at http://www.gromacs.org.
*
* GROMACS is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* \author Teemu Murtola <teemu.murtola@gmail.com>
* \ingroup module_selection
*/
+#include "gmxpre.h"
+
#include "selection.h"
-#include "nbsearch.h"
-#include "position.h"
+#include "gromacs/selection/nbsearch.h"
+#include "gromacs/selection/position.h"
+#include "gromacs/topology/topology.h"
+
#include "selelem.h"
#include "selvalue.h"
coveredFraction_(1.0), averageCoveredFraction_(1.0),
bDynamic_(false), bDynamicCoveredFraction_(false)
{
- gmx_ana_pos_clear(&rawPositions_);
-
if (elem->child->type == SEL_CONST)
{
// TODO: This is not exception-safe if any called function throws.
SelectionData::~SelectionData()
{
- gmx_ana_pos_deinit(&rawPositions_);
}
GMX_ASSERT(top != NULL, "Should not have been called with NULL topology");
masses->clear();
charges->clear();
- for (int b = 0; b < pos.nr; ++b)
+ for (int b = 0; b < pos.count(); ++b)
{
real mass = 0.0;
real charge = 0.0;
for (int i = pos.m.mapb.index[b]; i < pos.m.mapb.index[b+1]; ++i)
{
- int index = pos.g->index[i];
+ const int index = pos.m.mapb.a[i];
mass += top->atoms.atom[index].m;
charge += top->atoms.atom[index].q;
}
if (isDynamic())
{
gmx_ana_pos_t &p = rawPositions_;
- gmx_ana_index_copy(p.g, rootElement().v.u.g, false);
- gmx_ana_indexmap_update(&p.m, p.g, hasFlag(gmx::efSelection_DynamicMask));
- p.nr = p.m.nr;
+ gmx_ana_indexmap_update(&p.m, rootElement().v.u.g,
+ hasFlag(gmx::efSelection_DynamicMask));
refreshMassesAndCharges(top);
}
}
Selection::operator AnalysisNeighborhoodPositions() const
{
- return AnalysisNeighborhoodPositions(data().rawPositions_.x,
- data().rawPositions_.nr);
+ AnalysisNeighborhoodPositions pos(data().rawPositions_.x,
+ data().rawPositions_.count());
+ if (hasOnlyAtoms())
+ {
+ pos.exclusionIds(atomIndices());
+ }
+ return pos;
}
fprintf(fp, " ");
printInfo(fp);
fprintf(fp, " Group ");
- gmx_ana_index_dump(fp, p.g, nmaxind);
+ gmx_ana_index_t g;
+ gmx_ana_index_set(&g, p.m.mapb.nra, p.m.mapb.a, 0);
+ gmx_ana_index_dump(fp, &g, nmaxind);
fprintf(fp, " Block (size=%d):", p.m.mapb.nr);
if (!p.m.mapb.index)
SelectionPosition::operator AnalysisNeighborhoodPositions() const
{
- return AnalysisNeighborhoodPositions(sel_->rawPositions_.x,
- sel_->rawPositions_.nr)
- .selectSingleFromArray(i_);
+ AnalysisNeighborhoodPositions pos(sel_->rawPositions_.x,
+ sel_->rawPositions_.count());
+ if (sel_->hasOnlyAtoms())
+ {
+ // TODO: Move atomIndices() such that it can be reused here as well.
+ pos.exclusionIds(constArrayRefFromArray<int>(sel_->rawPositions_.m.mapb.a,
+ sel_->rawPositions_.m.mapb.nra));
+ }
+ return pos.selectSingleFromArray(i_);
}
} // namespace gmx