#include <string>
#include <vector>
-#include "../utility/arrayref.h"
-#include "../utility/common.h"
-#include "../utility/gmxassert.h"
-
-#include "position.h"
-#include "selectionenums.h"
+#include "gromacs/selection/position.h"
+#include "gromacs/selection/selectionenums.h"
+#include "gromacs/utility/arrayref.h"
+#include "gromacs/utility/common.h"
+#include "gromacs/utility/gmxassert.h"
struct t_topology;
bool isDynamic() const { return bDynamic_; }
//! Returns the type of positions in the selection.
e_index_t type() const { return rawPositions_.m.type; }
+ //! Returns true if the selection only contains positions with a single atom each.
+ bool hasOnlyAtoms() const { return type() == INDEX_ATOM; }
//! Number of positions in the selection.
int posCount() const { return rawPositions_.count(); }
bool isDynamic() const { return data().isDynamic(); }
//! Returns the type of positions in the selection.
e_index_t type() const { return data().type(); }
+ //! Returns true if the selection only contains positions with a single atom each.
+ bool hasOnlyAtoms() const { return data().hasOnlyAtoms(); }
//! Total number of atoms in the selection.
int atomCount() const
//! Returns atom indices of all atoms in the selection.
ConstArrayRef<int> atomIndices() const
{
- return ConstArrayRef<int>(sel_->rawPositions_.m.mapb.a,
- sel_->rawPositions_.m.mapb.nra);
+ return constArrayRefFromArray(sel_->rawPositions_.m.mapb.a,
+ sel_->rawPositions_.m.mapb.nra);
}
//! Number of positions in the selection.
int posCount() const { return data().posCount(); }
//! Returns coordinates for this selection as a continuous array.
ConstArrayRef<rvec> coordinates() const
{
- return ConstArrayRef<rvec>(data().rawPositions_.x, posCount());
+ return constArrayRefFromArray(data().rawPositions_.x, posCount());
}
//! Returns whether velocities are available for this selection.
bool hasVelocities() const { return data().rawPositions_.v != NULL; }
ConstArrayRef<rvec> velocities() const
{
GMX_ASSERT(hasVelocities(), "Velocities accessed, but unavailable");
- return ConstArrayRef<rvec>(data().rawPositions_.v, posCount());
+ return constArrayRefFromArray(data().rawPositions_.v, posCount());
}
//! Returns whether forces are available for this selection.
bool hasForces() const { return sel_->rawPositions_.f != NULL; }
ConstArrayRef<rvec> forces() const
{
GMX_ASSERT(hasForces(), "Forces accessed, but unavailable");
- return ConstArrayRef<rvec>(data().rawPositions_.f, posCount());
+ return constArrayRefFromArray(data().rawPositions_.f, posCount());
}
//! Returns masses for this selection as a continuous array.
ConstArrayRef<real> masses() const
// (and thus the masses and charges are fixed).
GMX_ASSERT(data().posMass_.size() >= static_cast<size_t>(posCount()),
"Internal inconsistency");
- return ConstArrayRef<real>(data().posMass_.begin(),
- data().posMass_.begin() + posCount());
+ return constArrayRefFromVector<real>(data().posMass_.begin(),
+ data().posMass_.begin() + posCount());
}
//! Returns charges for this selection as a continuous array.
ConstArrayRef<real> charges() const
// (and thus the masses and charges are fixed).
GMX_ASSERT(data().posCharge_.size() >= static_cast<size_t>(posCount()),
"Internal inconsistency");
- return ConstArrayRef<real>(data().posCharge_.begin(),
- data().posCharge_.begin() + posCount());
+ return constArrayRefFromVector<real>(data().posCharge_.begin(),
+ data().posCharge_.begin() + posCount());
}
/*! \brief
* Returns reference IDs for this selection as a continuous array.
*/
ConstArrayRef<int> refIds() const
{
- return ConstArrayRef<int>(data().rawPositions_.m.refid, posCount());
+ return constArrayRefFromArray(data().rawPositions_.m.refid, posCount());
}
/*! \brief
* Returns mapped IDs for this selection as a continuous array.
*/
ConstArrayRef<int> mappedIds() const
{
- return ConstArrayRef<int>(data().rawPositions_.m.mapid, posCount());
+ return constArrayRefFromArray(data().rawPositions_.m.mapid, posCount());
}
//! Returns whether the covered fraction can change between frames.
return ConstArrayRef<int>();
}
const int first = sel_->rawPositions_.m.mapb.index[i_];
- return ConstArrayRef<int>(&atoms[first], atomCount());
+ return constArrayRefFromArray(&atoms[first], atomCount());
}
/*! \brief
* Returns whether this position is selected in the current frame.