IMP logo
IMP Reference Guide  develop.7482b7c7af, 2026/12/05
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>
17#include <IMP/exception.h>
18
19IMPNPC_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*/
25class 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,
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
75
76 //! get the decorator key for the sphere depth
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.*/
94 IMP_DECORATOR_SETUP_2(SlabWithSphericalIndent, double, R, double, h);
95
96
97}; // end class
98
99IMP_DECORATORS(SlabWithSphericalIndent, SlabWithSphericalIndents, IMP::Decorators);
100
101IMPNPC_END_NAMESPACE
102
103#endif /* IMPNPC_SLAB_WITH_SPHERICAL_INDENT_H */
The base class for decorators.
Storage of a model, its restraints, constraints and particles.
Classes to handle individual model particles. (Note that implementation of inline functions is in int...
#define IMP_USAGE_CHECK(expr, message)
A runtime test for incorrect usage of a class or method.
Interface to specialized Particle types (e.g. atoms).
Definition Decorator.h:119
Particle * get_particle() const
Returns the particle decorated by this decorator.
Definition Decorator.h:194
Class for storing model, its restraints, constraints, and particles.
Definition Model.h:111
A decorator for a particle that represents a slab containing a spherical cap indent.
void set_decorator_name(std::string nm)
Set the name added to the particle.
Float get_sphere_radius() const
return the sphere radius
static bool get_is_setup(Model *m, ParticleIndex pi)
return true if the particle has a R and h defined
static FloatKey get_sphere_radius_key()
get the decorator key for sphere radius
std::string get_decorator_name() const
Get the name added to the particle (Ensures decorator_name to be the same as the name_key).
static FloatKey get_sphere_depth_key()
get the decorator key for the sphere depth
Float get_sphere_depth() const
return the sphere depth
Helper macros for implementing Decorators.
#define IMP_DECORATORS(Name, PluralName, Parent)
Define the types for storing sets of decorators.
#define IMP_DECORATOR_SETUP_2(Name, FirstArgumentType, first_argument_name, SecondArgumentType, second_argument_name)
#define IMP_DECORATOR_METHODS(Name, Parent)
Exception definitions and assertions.
Index< ParticleIndexTag > ParticleIndex
Definition base_types.h:196
Key< 2 > StringKey
The type used to identify string attributes in the Particles.
Definition base_types.h:40
double Float
Basic floating-point value (could be float, double...).
Definition types.h:19
Key< 0 > FloatKey
The type used to identify float attributes in the Particles.
Definition base_types.h:32