#include <boost/shared_ptr.hpp>
-#include "../math/vectypes.h"
-#include "../utility/common.h"
-#include "../utility/gmxassert.h"
-#include "../utility/real.h"
+#include "gromacs/math/vectypes.h"
+#include "gromacs/utility/arrayref.h"
+#include "gromacs/utility/common.h"
+#include "gromacs/utility/gmxassert.h"
+#include "gromacs/utility/real.h"
+struct t_blocka;
struct t_pbc;
namespace gmx
* to methods that accept positions.
*/
AnalysisNeighborhoodPositions(const rvec &x)
- : count_(1), index_(-1), x_(&x)
+ : count_(1), index_(-1), x_(&x), exclusionIds_(NULL)
{
}
/*! \brief
* Initializes positions from an array of position vectors.
*/
AnalysisNeighborhoodPositions(const rvec x[], int count)
- : count_(count), index_(-1), x_(x)
+ : count_(count), index_(-1), x_(x), exclusionIds_(NULL)
{
}
+ /*! \brief
+ * Sets indices to use for mapping exclusions to these positions.
+ *
+ * The exclusion IDs can always be set, but they are ignored unless
+ * actual exclusions have been set with
+ * AnalysisNeighborhood::setTopologyExclusions().
+ */
+ AnalysisNeighborhoodPositions &
+ exclusionIds(ConstArrayRef<int> ids)
+ {
+ GMX_ASSERT(static_cast<int>(ids.size()) == count_,
+ "Exclusion id array should match the number of positions");
+ exclusionIds_ = ids.data();
+ return *this;
+ }
+
/*! \brief
* Selects a single position to use from an array.
*
int count_;
int index_;
const rvec *x_;
+ const int *exclusionIds_;
//! To access the positions for initialization.
friend class internal::AnalysisNeighborhoodSearchImpl;
* a single thread.
*
* \todo
- * Support for exclusions.
- * The 4.5/4.6 C API had very low-level support for exclusions, which was not
- * very convenient to use, and hadn't been tested much. The internal code that
- * it used to do the exclusion during the search itself is still there, but it
- * needs more thought on what would be a convenient way to initialize it.
- * Can be implemented once there is need for it in some calling code.
+ * Generalize the exclusion machinery to make it easier to use for other cases
+ * than atom-atom exclusions from the topology.
*
* \inpublicapi
* \ingroup module_selection
* Does not throw.
*/
void setXYMode(bool bXY);
+ /*! \brief
+ * Sets atom exclusions from a topology.
+ *
+ * The \p excls structure specifies the exclusions from test positions
+ * to reference positions, i.e., a block starting at `excls->index[i]`
+ * specifies the exclusions for test position `i`, and the indices in
+ * `excls->a` are indices of the reference positions. If `excls->nr`
+ * is smaller than a test position id, then such test positions do not
+ * have any exclusions.
+ * It is assumed that the indices within a block of indices in
+ * `excls->a` is ascending.
+ *
+ * Does not throw.
+ *
+ * \see AnalysisNeighborhoodPositions::exclusionIds()
+ */
+ void setTopologyExclusions(const t_blocka *excls);
/*! \brief
* Sets the algorithm to use for searching.
*