IMP logo
IMP Reference Guide  develop.4eee3cf66f,2026/08/02
The Integrative Modeling Platform
FixedRefiner.h
Go to the documentation of this file.
1 /**
2  * \file IMP/core/FixedRefiner.h
3  * \brief A particle refiner which returns a fixed set of particles
4  *
5  * Copyright 2007-2026 IMP Inventors. All rights reserved.
6  */
7 
8 #ifndef IMPCORE_FIXED_REFINER_H
9 #define IMPCORE_FIXED_REFINER_H
10 
11 #include <IMP/core/core_config.h>
12 
13 #include <IMP/PairContainer.h>
14 #include <IMP/SingletonContainer.h>
15 #include <IMP/Refiner.h>
16 #include <cereal/access.hpp>
17 #include <cereal/types/base_class.hpp>
18 
19 IMPCORE_BEGIN_NAMESPACE
20 
21 //! The refiner can refine any particle by returning a fixed set
22 /**
23  */
24 class IMPCOREEXPORT FixedRefiner : public Refiner {
25  Model* m_;
26  ParticleIndexes pis_;
27 
28  friend class cereal::access;
29  template<class Archive> void serialize(Archive &ar) {
30  ar(cereal::base_class<Refiner>(this));
31  if (std::is_base_of<cereal::detail::OutputArchiveBase, Archive>::value) {
32  uint32_t model_id = get_model_id();
33  ar(model_id);
34  } else {
35  uint32_t model_id;
36  ar(model_id);
37  set_model_from_id(model_id);
38  }
39  ar(pis_);
40  }
41  void set_model_from_id(uint32_t model_id);
42  uint32_t get_model_id() const;
44 
45  public:
46  //! Store the set of particles
47  FixedRefiner(const ParticlesTemp &ps);
48 
49  //! Store the set of particle indexes from passed model
50  FixedRefiner(Model* m, const ParticleIndexes &pis);
51 
52  FixedRefiner() {}
53 
54  virtual bool get_can_refine(Particle *) const override
55  { return true; }
56 
57  //! Returns the fixed set of particles.
58  /** \note the passed Particle is ignored.
59  */
60  virtual const ParticlesTemp get_refined(Particle *p) const
61  override;
62 
63  //! Returns the fixed set of particles, as indexes.
64  /** @note the passed ParticleIndex is ignored.
65 
66  @note For FixedRefiner, this is a faster operation than
67  get_refined()
68 
69  @note It is assumed that the refined particles are also in model m.
70 
71  */
73  (Model* m, ParticleIndex) const override
74  {
75  IMP_USAGE_CHECK(m == m_,
76  "mismatching models for refined and coarse particles");
77  IMP_UNUSED(m);
78  return pis_;
79  }
80 
82  (Model *m, ParticleIndex pi) const override
83  {
84  IMP_USAGE_CHECK(m == m_,
85  "mismatching models for refined and coarse particles");
86  IMP_UNUSED(m);
87  IMP_UNUSED(pi);
88  return pis_;
89  }
90 
91 
92 #ifndef SWIG
94 #endif
96  Model *m, const ParticleIndexes &pis) const override;
98 };
99 
100 IMPCORE_END_NAMESPACE
101 
102 #endif /* IMPCORE_FIXED_REFINER_H */
The refiner can refine any particle by returning a fixed set.
Definition: FixedRefiner.h:24
A container for Singletons.
#define IMP_OBJECT_METHODS(Name)
Define the basic things needed by any Object.
Definition: object_macros.h:25
Class for storing model, its restraints, constraints, and particles.
Definition: Model.h:86
A container for Pairs.
Refine a particle into a list of particles.
#define IMP_UNUSED(variable)
#define IMP_OBJECT_SERIALIZE_DECL(Name)
Declare methods needed for serialization of Object pointers.
Definition: object_macros.h:95
virtual ModelObjectsTemp do_get_inputs(Model *m, const ParticleIndexes &pis) const =0
Overload this method to specify the inputs.
virtual ParticleIndexes get_refined_indexes(Model *m, ParticleIndex pi) const
Return the indexes of the particles returned by get_refined()
virtual ParticleIndexes const & get_refined_indexes_by_ref(Model *m, ParticleIndex pi) const
Return the indexes of the particles returned by get_refined()
Definition: Refiner.h:90
virtual const ParticlesTemp get_refined(Particle *a) const =0
Refine the passed particle into a set of particles.
Abstract class to implement hierarchical methods.
Definition: Refiner.h:36
Class to handle individual particles of a Model object.
Definition: Particle.h:45
#define IMP_USAGE_CHECK(expr, message)
A runtime test for incorrect usage of a class or method.
Definition: check_macros.h:168
virtual bool get_can_refine(Particle *) const override
Return true if this refiner can refine that particle.
Definition: FixedRefiner.h:54