8 #ifndef IMPCORE_PREDICATES_H
9 #define IMPCORE_PREDICATES_H
11 #include <IMP/core/core_config.h>
16 IMPCORE_BEGIN_NAMESPACE
24 "InBoundingBox3DSingletonPredicate%1%")
28 return bb_.get_contains(
XYZ(m, pi).get_coordinates()) ? 1 : 0;
46 "AttributeSingletonPredicate%1%")
71 m->get_sphere(std::get<0>(pi)).get_radius()
72 + m->get_sphere(std::get<1>(pi)).get_radius();
73 #if IMP_HAS_CHECKS > 1
75 XYZR(m, std::get<1>(pi))) <= 0);
77 for (
unsigned int i = 0; i < 3; ++i) {
78 double delta = std::abs(m->get_sphere(std::get<0>(pi)).get_center()[i] -
79 m->get_sphere(std::get<1>(pi)).get_center()[i]);
87 m->get_sphere(std::get<0>(pi)).get_center(),
88 m->get_sphere(std::get<1>(pi)).get_center()) <
89 algebra::get_squared(sr);
106 template <
class Predicate,
class Score = SingletonScore>
111 Score *get_score(
int val)
const {
112 if (val < offset_ || val > scores_.size() + offset_) {
115 return scores_[val + offset_];
121 std::string name =
"PredicateScore%1%")
123 void set_singleton_score(
int val, Score *score) {
125 "Negative predicate values not supported yet");
126 scores_.resize(std::max<int>(val + 1, scores_.size()));
127 scores_[val] = score;
137 #if !defined(SWIG) && !defined(IMP_DOXYGEN)
138 template <
class Predicate,
class Score>
142 int val = pred_->get_value(m, p);
143 Score *s = get_score(val);
145 return s->Score::evaluate_index(m, p, da);
153 template <
class Predicate,
class Score>
154 inline PredicateSingletonScore<Predicate, Score> *
158 ret->set_score(val, score);
162 IMPCORE_END_NAMESPACE
Return 1 if the XYZ is in the bounding box, 0 otherwise.
#define IMP_OBJECT_METHODS(Name)
Define the basic things needed by any Object.
virtual ModelObjectsTemp do_get_inputs(Model *m, const ParticleIndexes &pi) const override
Overload this method to specify the inputs.
double get_squared_distance(const VectorD< D > &v1, const VectorD< D > &v2)
Compute the squared distance between two vectors.
Macros for various classes.
ParticlesTemp get_particles(Model *m, const ParticleIndexes &ps)
Get the particles from a list of indexes.
virtual int get_value_index(Model *m, ParticleIndex pi) const override
Compute the predicate and the derivative if needed.
virtual ModelObjectsTemp do_get_inputs(Model *m, const ParticleIndexes &pi) const override
Overload this method to specify the inputs.
A more IMP-like version of the std::vector.
A smart pointer to a reference counted object.
#define IMP_INTERNAL_CHECK(expr, message)
An assertion to check for internal errors in IMP. An IMP::ErrorException will be thrown.
Define SingletonPredicate.
Class for storing model, its restraints, constraints, and particles.
Return the value of an int attribute as the predicate value.
Abstract class for scoring object(s) of type ParticleIndex.
#define IMP_SINGLETON_SCORE_METHODS(Name)
virtual int get_value_index(Model *m, const ParticleIndexPair &pi) const override
Compute the predicate and the derivative if needed.
A decorator for a particle with x,y,z coordinates.
virtual int get_value_index(Model *m, ParticleIndex pi) const override
Compute the predicate and the derivative if needed.
virtual ModelObjectsTemp do_get_inputs(Model *m, const ParticleIndexes &pi) const override
Overload this method to specify the inputs.
Return 1 if two XYZRs collide.
#define IMP_SINGLETON_PREDICATE_METHODS(Name)
Define extra the functions needed for a SingletonPredicate.
Abstract predicate function.
Abstract predicate function.
double Float
Basic floating-point value (could be float, double...)
#define IMP_USAGE_CHECK(expr, message)
A runtime test for incorrect usage of a class or method.
PredicateSingletonScore< Predicate, Score > * create_predicates_singleton_score(Predicate *pred, int val, Score *score)
Type get_attribute(TypeKey attribute_key, ParticleIndex particle)
get the value of the particle attribute with the specified key
double get_distance(const Line3D &s, const Vector3D &p)
Get closest distance between a line and a point.
Class for adding derivatives from restraints to the model.
#define IMP_PAIR_PREDICATE_METHODS(Name)
Define extra the functions needed for a PairPredicate.
A decorator for a particle with x,y,z coordinates and a radius.