IMP  2.3.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-2014 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"
15 #include <IMP/kernel/ScoreState.h>
16 #include <IMP/base/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 kernel::ScoreState {
31  std::size_t input_version_;
32  boost::unordered_map<kernel::ParticleIndex, kernel::ParticleIndexes> data_;
33 
34  protected:
36  return kernel::ModelObjectsTemp(1, input_);
37  }
39  return kernel::ModelObjectsTemp();
40  }
41  virtual void do_before_evaluate() IMP_OVERRIDE;
42  virtual void do_after_evaluate(DerivativeAccumulator *) IMP_OVERRIDE {}
43 
44  public:
45  NeighborsTable(kernel::PairContainer *input,
46  std::string name = "CloseNeighborsTable%1%");
47  /** Return all kernel::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 */
virtual kernel::ModelObjectsTemp do_get_inputs() const
Class for adding derivatives from restraints to the model.
IMP::base::Vector< IMP::base::WeakPointer< kernel::ModelObject > > ModelObjectsTemp
void set_was_used(bool tf) const
A smart pointer to a ref-counted Object that is a class member.
Definition: Pointer.h:147
#define IMP_OBJECT_METHODS(Name)
Define the basic things needed by any Object.
Definition: object_macros.h:25
A shared container for Pairs.
ScoreStates maintain invariants in the Model.
virtual kernel::ModelObjectsTemp do_get_outputs() const
Shared score state.
A nullptr-initialized pointer to an IMP Object.
const kernel::ParticleIndexes & get_neighbors(kernel::ParticleIndex pi) const
A container for Singletons.
#define IMP_OVERRIDE
Cause a compile error if this method does not override a parent method.