IMP logo
IMP Reference Guide  develop.d97d4ead1f,2024/11/21
The Integrative Modeling Platform
RigidClosePairsFinder.h
Go to the documentation of this file.
1 /**
2  * \file IMP/core/RigidClosePairsFinder.h
3  * \brief Handle rigid bodies by looking at their members
4  *
5  * Copyright 2007-2023 IMP Inventors. All rights reserved.
6  */
7 
8 #ifndef IMPCORE_RIGID_CLOSE_PAIRS_FINDER_H
9 #define IMPCORE_RIGID_CLOSE_PAIRS_FINDER_H
10 
11 #include "ClosePairsFinder.h"
12 #include "rigid_bodies.h"
13 #include <IMP/Refiner.h>
14 #include <cereal/access.hpp>
15 #include <cereal/types/base_class.hpp>
16 
17 IMPCORE_BEGIN_NAMESPACE
18 
19 //! Perform more efficient close pair finding when rigid bodies are involved.
20 /** The class finds all close pairs consisting of particles taken from the
21  passed list(s) (if they are not rigid bodies) or members of rigid
22  bodies passed as input. That is, given an input list \c l, for each
23  pair of particles \c p, \c q taken from the list that are closer than
24  the distance threshold, it returns
25  - (\c p,\c q) if neither \c p or \c q are RigidBody particles
26  - all \c (\c r,\c s) where \c r is a member of \c p, \c s is a member of
27  \c q, and \c r and \c s are closer than the distance threshold if both
28  \c p and \c q are RigidBody particles
29  - pairs \c (\c p,\c s) or \c (\c r,\c q) as appropriate if only one of
30  \c p or \c q is a rigid body.
31 
32  Consequently, the user must ensure that each RigidBody is
33  assigned a radius that encloses all of its RigidMember
34  particles.
35 
36  It uses another ClosePairsFinder to find which pairs of particles in
37  the input list or lists are close. Your choice of this can be passed
38  to the constructor.
39 
40  \note The bipartite method will also not return any pairs where
41  both members are in the same rigid body.
42 
43  \note The bounding spheres are kept in internal coordinates for
44  the rigid body and transformed on the fly. It would probably be
45  faster to cache the transformed results.
46 
47  \note The particles are divided up using a grid. The number of
48  grid cells to use should be explored. In addition, with highly
49  eccentric sets of points, there will be too many cells.
50 
51  \note Do not reuse RigidClosePairsFinders for different sets of
52  particles from the same rigid body.
53 
54  \include rigid_collisions.py
55 
56  \uses{class RigidClosePairsFinder, CGAL}
57  \see ClosePairsScoreState
58  \see RigidBody
59  \see cover_members()
60  */
61 class IMPCOREEXPORT RigidClosePairsFinder : public ClosePairsFinder {
63  ObjectKey k_;
64 
65  friend class cereal::access;
66 
67  template<class Archive> void serialize(Archive &ar) {
68  ar(cereal::base_class<ClosePairsFinder>(this), cpf_);
69  if (std::is_base_of<cereal::detail::InputArchiveBase, Archive>::value) {
70  k_ = get_hierarchy_key();
71  }
72  }
74 
75  ObjectKey get_hierarchy_key() const;
76 
77  public:
79 
82  const ParticleIndexes &pa,
83  const ParticleIndexes &pb) const;
84 
85  void set_distance(double d) override {
86  cpf_->set_distance(d);
87  ClosePairsFinder::set_distance(d);
88  }
89 
90 #if !defined(SWIG) && !defined(IMP_DOXYGEN)
91  internal::MovedSingletonContainer *get_moved_singleton_container(
92  SingletonContainer *c, double threshold) const override;
93 #endif
94  virtual IntPairs get_close_pairs(const algebra::BoundingBox3Ds &bbs) const
95  override;
97  const algebra::BoundingBox3Ds &bbs) const
98  override;
100  Model *m, const ParticleIndexes &pis) const override;
101 
103  Model *m, const ParticleIndexes &pc) const override;
105  Model *m, const ParticleIndexes &pca,
106  const ParticleIndexes &pcb) const override;
108 };
109 
110 IMPCORE_END_NAMESPACE
111 
112 #endif /* IMPCORE_RIGID_CLOSE_PAIRS_FINDER_H */
A base class for algorithms to find spatial proximities.
#define IMP_OBJECT_METHODS(Name)
Define the basic things needed by any Object.
Definition: object_macros.h:25
virtual ParticleIndexPairs get_close_pairs(Model *m, const ParticleIndexes &pc) const =0
return all close pairs among pc in model m
Class for storing model, its restraints, constraints, and particles.
Definition: Model.h:86
Refine a particle into a list of particles.
functionality for defining rigid bodies
#define IMP_OBJECT_SERIALIZE_DECL(Name)
Declare methods needed for serialization of Object pointers.
Definition: object_macros.h:95
A smart pointer to a ref-counted Object that is a class member.
Definition: Pointer.h:143
virtual ModelObjectsTemp do_get_inputs(Model *m, const ParticleIndexes &pis) const =0
Overload this method to specify the inputs.
A shared container for Singletons.
A base class for algorithms to detect proximities.
Perform more efficient close pair finding when rigid bodies are involved.