IMP logo
IMP Reference Guide  2.18.0
The Integrative Modeling Platform
NeighborsTable.h
Go to the documentation of this file.
1 /**
2  * \file IMP/core/NeighborsTable.h
3  * \brief
4  *
5  * Copyright 2007-2022 IMP Inventors. All rights reserved.
6  *
7  */
8 
9 #ifndef IMPCORE_NEIGHBORS_TABLE_H
10 #define IMPCORE_NEIGHBORS_TABLE_H
11 
12 #include <IMP/core/core_config.h>
13 #include <IMP/SingletonContainer.h>
14 #include <IMP/ScoreState.h>
15 #include <IMP/Pointer.h>
16 #include <boost/unordered_map.hpp>
17 
18 IMPCORE_BEGIN_NAMESPACE
19 
20 /** Maintain a table that can be used to look up the neighbors
21  of particles. That is, you can efficiently find all
22  particles that are within a certain distance of a passed one.
23 
24  As with the container::ClosePairContainer, there may be some
25  neighbors returned that are not close neighbors, but all close
26  neighbors will be returned.
27 */
28 class IMPCOREEXPORT NeighborsTable : public ScoreState {
30  std::size_t input_version_;
31  boost::unordered_map<ParticleIndex, ParticleIndexes> data_;
32 
33  protected:
34  virtual ModelObjectsTemp do_get_inputs() const override {
35  return ModelObjectsTemp(1, input_);
36  }
37  virtual ModelObjectsTemp do_get_outputs() const override {
38  return ModelObjectsTemp();
39  }
40  virtual void do_before_evaluate() override;
41  virtual void do_after_evaluate(DerivativeAccumulator *) override {}
42 
43  public:
45  std::string name = "CloseNeighborsTable%1%");
46  /** Return all ParticleIndexes that are within the distance threshold
47  of this one (plus some that are aren't, for efficiency). */
49  set_was_used(true);
50  return data_.find(pi)->second;
51  }
53 };
54 
55 IMPCORE_END_NAMESPACE
56 
57 #endif /* IMPCORE_NEIGHBORS_TABLE_H */
A shared container for Pairs.
Definition: PairContainer.h:37
A container for Singletons.
virtual void do_before_evaluate()=0
Update the state given the current state of the model.
virtual void do_after_evaluate(DerivativeAccumulator *) override
Do any necessary updates after the model score is calculated.
#define IMP_OBJECT_METHODS(Name)
Define the basic things needed by any Object.
Definition: object_macros.h:25
A typed index.
Definition: Index.h:25
const ParticleIndexes & get_neighbors(ParticleIndex pi) const
A more IMP-like version of the std::vector.
Definition: Vector.h:42
IMP::Vector< IMP::WeakPointer< ModelObject > > ModelObjectsTemp
Definition: base_types.h:89
virtual ModelObjectsTemp do_get_inputs() const override
ScoreStates maintain invariants in the Model.
Definition: ScoreState.h:54
A smart pointer to a ref-counted Object that is a class member.
Definition: Pointer.h:146
Shared score state.
A nullptr-initialized pointer to an IMP Object.
virtual ModelObjectsTemp do_get_outputs() const override
Class for adding derivatives from restraints to the model.
void set_was_used(bool tf) const