IMP  2.0.1
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-2013 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/base/Object.h>
15 #include <IMP/SingletonContainer.h>
16 #include <IMP/internal/container_helpers.h>
18 
19 IMPCORE_BEGIN_NAMESPACE
20 #ifndef IMP_DOXYGEN
21 namespace internal {
22  class MovedSingletonContainer;
23 }
24 #endif
25 
26 
27 //! A base class for algorithms to find spatial proximities
28 /** In general, the algorithm should make sure it returns all
29  pairs of appropriate objects which are within the distance
30  of one another (including their radius). They are free to
31  return more if it is convenient, but this is not
32  recommended as the list can easily become very large.
33  \see ClosePairContainer
34  \see CloseBipartitePairContainer
35  */
36 class IMPCOREEXPORT ClosePairsFinder : public IMP::base::Object
37 {
38  double distance_;
39  public:
40  ClosePairsFinder(std::string name);
42 
43  /** \name Methods to find close pairs
44  The methods add appropriately close pairs of particles from the
45  input list (or lists, for the bipartite version) to the out
46  list. The ones that take bounding boxes return pairs of ints
47  indexing the input list(s).
48  @{
49  */
50  virtual ParticlePairsTemp get_close_pairs(const ParticlesTemp &pc) const =0;
51  virtual ParticlePairsTemp get_close_pairs(const ParticlesTemp &pca,
52  const ParticlesTemp &pcb) const =0;
53 #if !defined(SWIG)
54  virtual ParticleIndexPairs get_close_pairs(Model *m,
55  const ParticleIndexes &pc) const {
56  return IMP::internal::
57  get_index(get_close_pairs(IMP::internal::get_particle(m, pc)));
58  }
59  virtual ParticleIndexPairs get_close_pairs(Model *m,
60  const ParticleIndexes &pca,
61  const ParticleIndexes &pcb) const {
62  return IMP::internal::
63  get_index(get_close_pairs(IMP::internal::get_particle(m, pca),
64  IMP::internal::get_particle(m, pcb)));
65  }
66 #endif
67  virtual IntPairs get_close_pairs(const algebra::BoundingBox3Ds &bbs) const=0;
68  virtual IntPairs get_close_pairs(const algebra::BoundingBox3Ds &bas,
69  const algebra::BoundingBox3Ds &bbs) const=0;
70  /** @} */
71 
72  /** \name The distance threshold
73  All pairs within this distance threshold are added to the output
74  list.
75  @{
76  */
77  virtual void set_distance(double d) {
78  distance_=d;
79  }
80  double get_distance() const {
81  return distance_;
82  }
83  /** @} */
84 
85 #if IMP_HAS_DEPRECATED
87  ParticlesTemp get_input_particles(const ParticlesTemp &ps) const {
88  IMP_DEPRECATED_FUNCTION(use get_inputs() instead);
89  return IMP::get_input_particles(get_inputs(ps[0]->get_model(),
90  IMP::get_indexes(ps)));
91  }
93  ContainersTemp get_input_containers(const ParticlesTemp &ps) const {
94  IMP_DEPRECATED_FUNCTION(use get_inputs() instead);
95  return IMP::get_input_containers(get_inputs(ps[0]->get_model(),
96  IMP::get_indexes(ps)));
97  }
98 #endif
100  /** @name Methods to control the set of filters
101 
102  PairPredicates objects can be used as filters to prevent
103  the addition of pairs to the containeroutput list. Pairs
104  for which the predicate evaluates to a non-zero value are
105  excluded.
106  */
107  /**@{*/
108  IMP_LIST(public, PairFilter, pair_filter,
110  /**@}*/
111 #if !defined(SWIG) && !defined(IMP_DOXYGEN)
112  /** \brief Return a container which lists all particles which moved more
113  than threshold
114  */
115  virtual internal::MovedSingletonContainer*
116  get_moved_singleton_container(SingletonContainer *in,
117  double threshold)const;
118 #endif
119 };
120 
121 IMPCORE_END_NAMESPACE
122 
123 #endif /* IMPCORE_CLOSE_PAIRS_FINDER_H */