IMP logo
IMP Reference Guide  2.19.0
The Integrative Modeling Platform
ClosePairsFinder.h
Go to the documentation of this file.
1 /**
2  * \file IMP/core/ClosePairsFinder.h
3  * \brief A base class for algorithms to detect proximities.
4  *
5  * Copyright 2007-2022 IMP Inventors. All rights reserved.
6  */
7 
8 #ifndef IMPCORE_CLOSE_PAIRS_FINDER_H
9 #define IMPCORE_CLOSE_PAIRS_FINDER_H
10 
11 #include <IMP/core/core_config.h>
12 #include <IMP/PairPredicate.h>
13 
14 #include <IMP/Object.h>
15 #include <IMP/SingletonContainer.h>
16 #include <IMP/internal/container_helpers.h>
18 #include <cereal/access.hpp>
19 #include <cereal/types/base_class.hpp>
20 
21 IMPCORE_BEGIN_NAMESPACE
22 #ifndef IMP_DOXYGEN
23 namespace internal {
24 class MovedSingletonContainer;
25 }
26 #endif
27 
28 //! A base class for algorithms to find spatial proximities
29 /** In general, the algorithm should make sure it returns all
30  pairs of appropriate objects which are within the distance
31  of one another (including their radius). They are free to
32  return more if it is convenient, but this is not
33  recommended as the list can easily become very large.
34  \see ClosePairContainer
35  \see CloseBipartitePairContainer
36  */
37 class IMPCOREEXPORT ClosePairsFinder : public ParticleInputs,
38  public IMP::Object {
39  double distance_;
40 
41  friend class cereal::access;
42  template<class Archive> void serialize(Archive &ar) {
43  ar(cereal::base_class<IMP::Object>(this), distance_,
44  mutable_access_pair_filters());
45  }
46 
47  public:
48  ClosePairsFinder(std::string name);
49  ClosePairsFinder() : IMP::Object("") {}
51 
52  //! return all close pairs among pc in model m
53  virtual ParticleIndexPairs get_close_pairs(
54  Model *m, const ParticleIndexes &pc) const = 0;
55  //! return all close pairs among pc in model m
56  virtual ParticleIndexPairs get_close_pairs(
57  Model *m, const ParticleIndexes &pca,
58  const ParticleIndexes &pcb) const = 0;
59  virtual IntPairs get_close_pairs(const algebra::BoundingBox3Ds &bbs)
60  const = 0;
61  virtual IntPairs get_close_pairs(const algebra::BoundingBox3Ds &bas,
62  const algebra::BoundingBox3Ds &bbs)
63  const = 0;
64  /** @} */
65 
66  /** \name The distance threshold
67  All pairs within this distance threshold are added to the output
68  list.
69  @{
70  */
71  virtual void set_distance(double d) { distance_ = d; }
72  double get_distance() const { return distance_; }
73  /** @} */
74 
75  public:
76  /** @name Methods to control the set of filters
77 
78  PairPredicates objects can be used as filters to prevent
79  the addition of pairs to the container output list. Pairs
80  for which the predicate evaluates to a non-zero value are
81  excluded.
82  */
83  /**@{*/
84  IMP_LIST(public, PairFilter, pair_filter, PairPredicate *, PairPredicates);
85 /**@}*/
86 #if !defined(SWIG) && !defined(IMP_DOXYGEN)
87  //! Return a container of all particles which moved more than threshold
88  virtual internal::MovedSingletonContainer *get_moved_singleton_container(
89  SingletonContainer *in, double threshold) const;
90 #endif
91 };
92 
93 IMPCORE_END_NAMESPACE
94 
95 #endif /* IMPCORE_CLOSE_PAIRS_FINDER_H */
A base class for algorithms to find spatial proximities.
A container for Singletons.
Base class for objects that take particle arguments and read from them.
#define IMP_LIST(protection, Ucname, lcname, Data, PluralData)
A macro to provide a uniform interface for storing lists of objects.
Class for storing model, its restraints, constraints, and particles.
Definition: Model.h:86
Common base class for heavy weight IMP objects.
Definition: Object.h:111
Define PairPredicate.
Classes used in the construction of ModelObjects.
A shared container for Singletons.
Abstract predicate function.
Definition: PairPredicate.h:31
A shared base class to help in debugging and things.
double get_distance(const Line3D &s, const Vector3D &p)
Get closest distance between a line and a point.