IMP logo
IMP Reference Guide  2.12.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-2019 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:
35  return ModelObjectsTemp(1, input_);
36  }
38  return ModelObjectsTemp();
39  }
40  virtual void do_before_evaluate() IMP_OVERRIDE;
41  virtual void do_after_evaluate(DerivativeAccumulator *) IMP_OVERRIDE {}
42 
43  public:
44  NeighborsTable(PairContainer *input,
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.
#define IMP_OBJECT_METHODS(Name)
Define the basic things needed by any Object.
Definition: object_macros.h:25
A typed index.
Definition: Index.h:24
const ParticleIndexes & get_neighbors(ParticleIndex pi) const
virtual ModelObjectsTemp do_get_outputs() const
virtual ModelObjectsTemp do_get_inputs() const
A more IMP-like version of the std::vector.
Definition: Vector.h:39
IMP::Vector< IMP::WeakPointer< ModelObject > > ModelObjectsTemp
Definition: base_types.h:82
ScoreStates maintain invariants in the Model.
Definition: ScoreState.h:53
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.
#define IMP_OVERRIDE
Cause a compile error if this method does not override a parent method.
Class for adding derivatives from restraints to the model.
void set_was_used(bool tf) const