IMP logo
IMP Reference Guide  develop.7482b7c7af, 2026/12/05
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
17IMPCORE_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 container::ClosePairContainer
58 \see RigidBody
59 \see cover_members()
60 */
61class 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 }
73 IMP_OBJECT_SERIALIZE_DECL(RigidClosePairsFinder);
74
75 ObjectKey get_hierarchy_key() const;
76
77 public:
78 RigidClosePairsFinder(ClosePairsFinder *cpf = nullptr);
79
80 ParticleIndexPairs get_close_pairs(
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;
96 virtual IntPairs get_close_pairs(const algebra::BoundingBox3Ds &bas,
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;
107 IMP_OBJECT_METHODS(RigidClosePairsFinder);
108};
109
110IMPCORE_END_NAMESPACE
111
112#endif /* IMPCORE_RIGID_CLOSE_PAIRS_FINDER_H */
A base class for algorithms to detect proximities.
Refine a particle into a list of particles.
Class for storing model, its restraints, constraints, and particles.
Definition Model.h:111
A shared container for Singletons.
virtual ParticleIndexPairs get_close_pairs(Model *m, const ParticleIndexes &pca, const ParticleIndexes &pcb) const override
return all close pairs among pc in model m
virtual ParticleIndexPairs get_close_pairs(Model *m, const ParticleIndexes &pc) const override
return all close pairs among pc in model m
virtual ModelObjectsTemp do_get_inputs(Model *m, const ParticleIndexes &pis) const override
Overload this method to specify the inputs.
IMP::Vector< BoundingBox3D > BoundingBox3Ds
Index< ParticleIndexTag > ParticleIndex
Definition base_types.h:196
IMP::Vector< ParticleIndexPair, std::allocator< ParticleIndexPair > > ParticleIndexPairs
Definition base_types.h:208
IMP::Vector< IntPair > IntPairs
Definition types.h:40
Vector< ParticleIndex, std::allocator< ParticleIndex > > ParticleIndexes
A list of particles, each identified by its ParticleIndex.
Definition base_types.h:199
Key< 4 > ObjectKey
The type used to identify an Object attribute.
Definition base_types.h:48
IMP::Vector< IMP::WeakPointer< ModelObject > > ModelObjectsTemp
Definition base_types.h:122
#define IMP_OBJECT_SERIALIZE_DECL(Name)
Declare methods needed for serialization of Object pointers.
#define IMP_OBJECT_METHODS(Name)
Define the basic things needed by any Object.
functionality for defining rigid bodies
A smart pointer to a ref-counted Object that is a class member.
Definition Pointer.h:144