IMP logo
IMP Reference Guide  2.22.0
The Integrative Modeling Platform
SlabWithSphericalIndent.h
Go to the documentation of this file.
1 /**
2  * \file IMP/npc/SlabWithSphericalIndent.h
3  * \brief A decorator for a particle representing a slab with a spherical cap indent.
4  *
5  * Copyright 2007-2018 IMP Inventors. All rights reserved.
6  *
7  */
8 
9 #ifndef IMPNPC_SLAB_WITH_SPHERICAL_INDENT_H
10 #define IMPNPC_SLAB_WITH_SPHERICAL_INDENT_H
11 
12 #include <IMP/npc/npc_config.h>
13 #include <IMP/Particle.h>
14 #include <IMP/Model.h>
15 #include <IMP/Decorator.h>
16 #include <IMP/decorator_macros.h>
17 #include <IMP/exception.h>
18 
19 IMPNPC_BEGIN_NAMESPACE
20 
21 //! A decorator for a particle that represents a slab containing a spherical cap indent.
22 /** \ingroup helper
23  \ingroup decorators
24 */
25 class IMPNPCEXPORT SlabWithSphericalIndent : public Decorator {
26  /* Decorate a particle that represents a slab with an indent
27  * that is modeled as a spherical cap. The spherical cap model is
28  * specified by two parameters, a radius, R, that is the radius of the
29  * underlying sphere and a height, h, that is the distance along the
30  * perpendicular from the intersecting plane to the edge of the sphere.
31  */
32  static StringKey get_name_key();
33  //! Returns the name of the particle, which is "SlabWithSphericalIndent" by default
34  /** The create function should take arguments which allow
35  the initial state of the Decorator to be reasonable (i.e.
36  make sure there is a non-empty name).
37  */
38  static void do_setup_particle(Model *m,
39  ParticleIndex pi,
40  double R,
41  double h);
42 
43  public:
44  //! return true if the particle has a R and h defined
45  static bool get_is_setup(Model *m, ParticleIndex pi) {
46  return m->get_has_attribute(get_sphere_radius_key(), pi) && m->get_has_attribute(get_sphere_depth_key(), pi);
47  }
48 
49  // set radius
50  void set_sphere_radius(double R) {
51  get_particle()->set_value(get_sphere_radius_key(), R);
52  }
53 
54  // set sphere depth
55  void set_sphere_depth(double h) {
56  get_particle()->set_value(get_sphere_depth_key(), h);
57  }
58 
59  //! return the sphere radius
61  return get_particle()->get_value(get_sphere_radius_key());
62  }
63 
64  //! return the sphere depth
66  return get_particle()->get_value(get_sphere_depth_key());
67  }
68 
69  //Float get_base_circle_radius() const {
70  //return get_particle()->get_value(get_base_circle_radius());
71  //}
72 
73  //! get the decorator key for sphere radius
74  static FloatKey get_sphere_radius_key();
75 
76  //! get the decorator key for the sphere depth
77  static FloatKey get_sphere_depth_key();
78 
79 
80  //! Get the name added to the particle (Ensures decorator_name to be the same as the name_key)
81  std::string get_decorator_name() const {
82  return get_particle()->get_value(get_name_key());
83  }
84 
85  //! Set the name added to the particle
86  void set_decorator_name(std::string nm) {
87  // use the usage check macro to check that functions are called properly
88  IMP_USAGE_CHECK(!nm.empty(), "The name cannot be empty");
89  get_particle()->set_value(get_name_key(), nm);
90  }
91 
92  /* Declare the basic constructors and the cast function.*/
95 
96 
97 }; // end class
98 
100 
101 IMPNPC_END_NAMESPACE
102 
103 #endif /* IMPNPC_SLAB_WITH_SPHERICAL_INDENT_H */
The base class for decorators.
std::string get_decorator_name() const
Get the name added to the particle (Ensures decorator_name to be the same as the name_key) ...
Storage of a model, its restraints, constraints and particles.
Exception definitions and assertions.
A more IMP-like version of the std::vector.
Definition: Vector.h:50
Class for storing model, its restraints, constraints, and particles.
Definition: Model.h:86
A decorator for a particle that represents a slab containing a spherical cap indent.
Helper macros for implementing Decorators.
#define IMP_DECORATOR_SETUP_2(Name, FirstArgumentType, first_argument_name,SecondArgumentType, second_argument_name)
A base class for Keys.
Definition: Key.h:45
static bool get_is_setup(Model *m, ParticleIndex pi)
return true if the particle has a R and h defined
Particle * get_particle() const
Returns the particle decorated by this decorator.
Definition: Decorator.h:194
Interface to specialized Particle types (e.g. atoms)
Definition: Decorator.h:119
Classes to handle individual model particles. (Note that implementation of inline functions is in int...
void set_decorator_name(std::string nm)
Set the name added to the particle.
Float get_sphere_radius() const
return the sphere radius
#define IMP_DECORATOR_METHODS(Name, Parent)
double Float
Basic floating-point value (could be float, double...)
Definition: types.h:19
#define IMP_USAGE_CHECK(expr, message)
A runtime test for incorrect usage of a class or method.
Definition: check_macros.h:168
#define IMP_DECORATORS(Name, PluralName, Parent)
Define the types for storing sets of decorators.
bool get_has_attribute(TypeKey attribute_key, ParticleIndex particle) const
return true if particle has attribute with the specified key
Float get_sphere_depth() const
return the sphere depth