IMP logo
IMP Reference Guide  2.6.1
The Integrative Modeling Platform
NeighborsTable.h
Go to the documentation of this file.
1 /**
2  * \file IMP/core/NeighborsTable.h
3  * \brief Angle restraint between three particles.
4  *
5  * Copyright 2007-2016 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 "internal/CoreClosePairContainer.h"
14 #include <IMP/SingletonContainer.h>
15 #include <IMP/ScoreState.h>
16 #include <IMP/Pointer.h>
17 #include <boost/unordered_map.hpp>
18 
19 IMPCORE_BEGIN_NAMESPACE
20 
21 /** Maintain a table that can be used to look up the neighbors
22  of particles. That is, you can efficiently find all
23  particles that are within a certain distance of a passed one.
24 
25  As with the container::ClosePairContainer, there may be some
26  neighbors returned that are not close neighbors, but all close
27  neighbors will be returned.
28 */
29 class IMPCOREEXPORT NeighborsTable : public ScoreState {
31  std::size_t input_version_;
32  boost::unordered_map<ParticleIndex, ParticleIndexes> data_;
33 
34  protected:
36  return ModelObjectsTemp(1, input_);
37  }
39  return ModelObjectsTemp();
40  }
41  virtual void do_before_evaluate() IMP_OVERRIDE;
42  virtual void do_after_evaluate(DerivativeAccumulator *) IMP_OVERRIDE {}
43 
44  public:
45  NeighborsTable(PairContainer *input,
46  std::string name = "CloseNeighborsTable%1%");
47  /** Return all ParticleIndexes that are within the distance threshold
48  of this one (plus some that are aren't, for efficiency). */
50  set_was_used(true);
51  return data_.find(pi)->second;
52  }
54 };
55 
56 IMPCORE_END_NAMESPACE
57 
58 #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
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