BornAgain  1.18.0
Simulate and fit neutron and x-ray scattering at grazing incidence
IParticle.h
Go to the documentation of this file.
1 // ************************************************************************** //
2 //
3 // BornAgain: simulate and fit scattering at grazing incidence
4 //
5 //! @file Sample/Particle/IParticle.h
6 //! @brief Defines interface IParticle.
7 //!
8 //! @homepage http://www.bornagainproject.org
9 //! @license GNU General Public License v3 or higher (see COPYING)
10 //! @copyright Forschungszentrum Jülich GmbH 2018
11 //! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS)
12 //
13 // ************************************************************************** //
14 
15 #ifndef BORNAGAIN_CORE_PARTICLE_IPARTICLE_H
16 #define BORNAGAIN_CORE_PARTICLE_IPARTICLE_H
17 
20 #include <memory>
21 
22 struct SlicedParticle;
23 struct ParticleLimits;
24 class Rotations;
25 class ZLimits;
26 
27 //! Pure virtual base class for Particle, ParticleComposition, ParticleCoreShell, MesoCrystal.
28 //! Provides position/rotation and form factor. Abundance is inherited from IAbstractParticle.
29 //!
30 //! @ingroup samples
31 
33 {
34 public:
36  IParticle* clone() const override = 0;
37 
38  //! Creates a form factor for this particle
39  virtual IFormFactor* createFormFactor() const;
40 
41  //! Creates a sliced form factor for this particle
42  virtual SlicedParticle createSlicedParticle(ZLimits limits) const;
43 
44  //! Returns particle position.
45  kvector_t position() const { return m_position; }
46 
47  //! Sets relative position of the particle's reference point in the
48  //! coordinate system of parent.
49  //! @param position: relative position vector (components are in nanometers)
51 
52  //! Sets relative position of the particle's reference point in the
53  //! coordinate system of parent.
54  //! @param x: x-coordinate in nanometers
55  //! @param y: y-coordinate in nanometers
56  //! @param z: z-coordinate in nanometers
57  void setPosition(double x, double y, double z) { m_position = kvector_t(x, y, z); }
58 
59  //! Translates the particle
60  void translate(kvector_t translation) override final;
61 
62  //! Returns rotation object
63  const IRotation* rotation() const;
64 
65  //! Sets transformation.
66  void setRotation(const IRotation& rotation);
67 
68  //! Rotates the particle
69  void rotate(const IRotation& rotation) override final;
70 
71  std::vector<const INode*> getChildren() const override;
72 
73  void registerAbundance(bool make_registered = true);
74 
75  //! Registers the three components of its position
76  void registerPosition(bool make_registered = true);
77 
78  //! Decompose in constituent IParticle objects
80 
81  //! Top and bottom z-coordinate
82  virtual ParticleLimits bottomTopZ() const;
83 
84 protected:
85  //! Creates a composed IRotation object
86  IRotation* createComposedRotation(const IRotation* p_rotation) const;
87 
88  //! Gets a composed translation vector
89  kvector_t composedTranslation(const IRotation* p_rotation, kvector_t translation) const;
90 
91  //! Registers abundance and position
93 
95  std::unique_ptr<IRotation> mP_rotation;
96 };
97 
98 #endif // BORNAGAIN_CORE_PARTICLE_IPARTICLE_H
Defines interface IAbstractParticle.
Defines and implements template class SafePointerVector.
BasicVector3D< double > kvector_t
Definition: Vectors3D.h:21
Interface for a generic particle.
Pure virtual base class for all form factors.
Definition: IFormFactor.h:40
Pure virtual base class for Particle, ParticleComposition, ParticleCoreShell, MesoCrystal.
Definition: IParticle.h:33
void registerAbundance(bool make_registered=true)
Definition: IParticle.cpp:66
void translate(kvector_t translation) override final
Translates the particle.
Definition: IParticle.cpp:34
virtual SafePointerVector< IParticle > decompose() const
Decompose in constituent IParticle objects.
Definition: IParticle.cpp:87
virtual SlicedParticle createSlicedParticle(ZLimits limits) const
Creates a sliced form factor for this particle.
Definition: IParticle.cpp:28
void registerPosition(bool make_registered=true)
Registers the three components of its position.
Definition: IParticle.cpp:76
std::vector< const INode * > getChildren() const override
Returns a vector of children (const).
Definition: IParticle.cpp:61
void setPosition(kvector_t position)
Sets relative position of the particle's reference point in the coordinate system of parent.
Definition: IParticle.h:50
void setPosition(double x, double y, double z)
Sets relative position of the particle's reference point in the coordinate system of parent.
Definition: IParticle.h:57
void rotate(const IRotation &rotation) override final
Rotates the particle.
Definition: IParticle.cpp:50
std::unique_ptr< IRotation > mP_rotation
Definition: IParticle.h:95
IRotation * createComposedRotation(const IRotation *p_rotation) const
Creates a composed IRotation object.
Definition: IParticle.cpp:101
kvector_t position() const
Returns particle position.
Definition: IParticle.h:45
const IRotation * rotation() const
Returns rotation object.
Definition: IParticle.cpp:39
kvector_t composedTranslation(const IRotation *p_rotation, kvector_t translation) const
Gets a composed translation vector.
Definition: IParticle.cpp:116
IParticle * clone() const override=0
Returns a clone of this ISample object.
kvector_t m_position
Definition: IParticle.h:94
void setRotation(const IRotation &rotation)
Sets transformation.
Definition: IParticle.cpp:44
virtual IFormFactor * createFormFactor() const
Creates a form factor for this particle.
Definition: IParticle.cpp:23
virtual ParticleLimits bottomTopZ() const
Top and bottom z-coordinate.
Definition: IParticle.cpp:94
void registerParticleProperties()
Registers abundance and position.
Definition: IParticle.cpp:125
Pure virtual interface for rotations.
Definition: Rotations.h:27
A vector of pointers, owned by *this, with methods to handle them safely.
Class that contains upper and lower limits of the z-coordinate for the slicing of form factors.
Definition: ZLimits.h:41
Vertical extension of a particle, specified by bottom and top z coordinate.
Definition: ZLimits.h:21
Struct that contains information on a sliced particle.