IMP logo
IMP Reference Guide  develop.7482b7c7af, 2026/12/05
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>
15#include <IMP/Refiner.h>
16#include <cereal/access.hpp>
17#include <cereal/types/base_class.hpp>
18
19IMPCORE_BEGIN_NAMESPACE
20
21//! The refiner can refine any particle by returning a fixed set
22/**
23 */
24class 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
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
100IMPCORE_END_NAMESPACE
101
102#endif /* IMPCORE_FIXED_REFINER_H */
A container for Pairs.
Refine a particle into a list of particles.
A container for Singletons.
#define IMP_USAGE_CHECK(expr, message)
A runtime test for incorrect usage of a class or method.
Class for storing model, its restraints, constraints, and particles.
Definition Model.h:111
Class to handle individual particles of a Model object.
Definition Particle.h:45
virtual const ParticlesTemp get_refined(Particle *a) const =0
Refine the passed particle into a set of particles.
Refiner(std::string name="Refiner %1%", bool is_by_ref=false)
Constructs the refiner.
virtual const ParticlesTemp get_refined(Particle *p) const override
Returns the fixed set of particles.
virtual ModelObjectsTemp do_get_inputs(Model *m, const ParticleIndexes &pis) const override
Overload this method to specify the inputs.
FixedRefiner(const ParticlesTemp &ps)
Store the set of particles.
FixedRefiner(Model *m, const ParticleIndexes &pis)
Store the set of particle indexes from passed model.
virtual ParticleIndexes get_refined_indexes(Model *m, ParticleIndex) const override
Returns the fixed set of particles, as indexes.
virtual ParticleIndexes const & get_refined_indexes_by_ref(Model *m, ParticleIndex pi) const override
Return the indexes of the particles returned by get_refined().
virtual bool get_can_refine(Particle *) const override
Return true if this refiner can refine that particle.
Index< ParticleIndexTag > ParticleIndex
Definition base_types.h:196
Vector< ParticleIndex, std::allocator< ParticleIndex > > ParticleIndexes
A list of particles, each identified by its ParticleIndex.
Definition base_types.h:199
IMP::Vector< IMP::WeakPointer< ModelObject > > ModelObjectsTemp
Definition base_types.h:122
#define IMP_OBJECT_SERIALIZE_DECL(Name)
Declare methods needed for serialization of Object pointers.
#define IMP_OBJECT_METHODS(Name)
Define the basic things needed by any Object.
#define IMP_UNUSED(variable)