BornAgain  1.19.79
Open-source research software to simulate and fit neutron and x-ray reflectometry and grazing-incidence small-angle scattering
IParticle.h
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
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 USER_API
16 #ifndef BORNAGAIN_SAMPLE_PARTICLE_IPARTICLE_H
17 #define BORNAGAIN_SAMPLE_PARTICLE_IPARTICLE_H
18 
20 #include <heinz/Vectors3D.h>
21 #include <memory>
22 #include <vector>
23 
24 class IRotation;
25 
26 //! Abstract base class for Particle, ParticleComposition, ParticleCoreShell, MesoCrystal.
27 //! Provides position/rotation and form factor. Abundance is inherited from IParticle.
28 //!
29 //! @ingroup samples
30 
31 class IParticle : public ISampleNode {
32 public:
33  ~IParticle() override;
34 
35  IParticle* clone() const override = 0;
36  std::vector<const INode*> nodeChildren() const override;
37 
38  double abundance() const { return m_abundance; }
39 
40  //! Sets particle abundance.
41  //! @param abundance: proportion of this type of particles normalized to the
42  //! total number of particles in the layout.
44 
45  //! Returns particle position.
46  R3 particlePosition() const { return m_position; }
47 
48  //! Sets relative position of the particle's reference point in the
49  //! coordinate system of parent.
50  //! @param position: relative position vector (components are in nanometers)
51  void setParticlePosition(R3 position) { m_position = position; }
52 
53  //! Sets relative position of the particle's reference point in the
54  //! coordinate system of parent.
55  //! @param x: x-coordinate in nanometers
56  //! @param y: y-coordinate in nanometers
57  //! @param z: z-coordinate in nanometers
58  void setParticlePosition(double x, double y, double z) { m_position = R3(x, y, z); }
59 
60  //! Translates the particle, and returns this.
61  IParticle* translate(R3 translation);
62 
63  //! Returns rotation object
64  const IRotation* rotation() const;
65 
66  //! Sets transformation.
67  void setRotation(const IRotation& rotation);
68 
69  //! Rotates the particle, and returns this.
71 
72 #ifndef SWIG
73  //! Decompose in constituent IParticle objects
74  virtual std::vector<std::unique_ptr<IParticle>> decompose() const;
75 #endif
76 
77 protected:
78  double m_abundance{1.0}; // not a Parameter
80  std::unique_ptr<IRotation> m_rotation;
81 };
82 
83 #endif // BORNAGAIN_SAMPLE_PARTICLE_IPARTICLE_H
84 #endif // USER_API
Defines interface class ISampleNode.
Abstract base class for Particle, ParticleComposition, ParticleCoreShell, MesoCrystal....
Definition: IParticle.h:31
~IParticle() override
double abundance() const
Definition: IParticle.h:38
void setParticlePosition(double x, double y, double z)
Sets relative position of the particle's reference point in the coordinate system of parent.
Definition: IParticle.h:58
virtual std::vector< std::unique_ptr< IParticle > > decompose() const
Decompose in constituent IParticle objects.
Definition: IParticle.cpp:52
IParticle * translate(R3 translation)
Translates the particle, and returns this.
Definition: IParticle.cpp:25
void setAbundance(double abundance)
Sets particle abundance.
Definition: IParticle.h:43
void setParticlePosition(R3 position)
Sets relative position of the particle's reference point in the coordinate system of parent.
Definition: IParticle.h:51
R3 m_position
Definition: IParticle.h:79
const IRotation * rotation() const
Returns rotation object.
Definition: IParticle.cpp:31
IParticle * rotate(const IRotation &rotation)
Rotates the particle, and returns this.
Definition: IParticle.cpp:41
double m_abundance
Definition: IParticle.h:78
std::vector< const INode * > nodeChildren() const override
Returns all children.
Definition: IParticle.cpp:20
IParticle * clone() const override=0
Returns a clone of this ISampleNode object.
std::unique_ptr< IRotation > m_rotation
Definition: IParticle.h:80
R3 particlePosition() const
Returns particle position.
Definition: IParticle.h:46
void setRotation(const IRotation &rotation)
Sets transformation.
Definition: IParticle.cpp:36
Abstract base class for rotations.
Definition: Rotations.h:29
Abstract base class for sample components and properties related to scattering.
Definition: ISampleNode.h:27