BornAgain  1.19.79
Open-source research software to simulate and fit neutron and x-ray reflectometry and grazing-incidence small-angle scattering
Particle.cpp
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file Sample/Particle/Particle.cpp
6 //! @brief Implements class Particle.
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 
16 #include "Base/Util/Assert.h"
17 #include "Base/Vector/RotMatrix.h"
19 
20 Particle::Particle(Material material, const IFormFactor& formfactor)
21  : m_material(std::move(material))
22  , m_formfactor(formfactor.clone())
23 {
24 }
25 
26 Particle::Particle(Material material, const IFormFactor& formfactor, const IRotation& rotation)
27  : Particle(material, formfactor)
28 {
30 }
31 
32 Particle::~Particle() = default;
33 
35 {
37  auto* p_result = new Particle(m_material, *m_formfactor);
38  p_result->setAbundance(m_abundance);
39  if (m_rotation)
40  p_result->setRotation(*m_rotation);
41  p_result->setParticlePosition(m_position);
42 
43  return p_result;
44 }
45 
46 std::vector<const INode*> Particle::nodeChildren() const
47 {
48  return std::vector<const INode*>() << IParticle::nodeChildren() << m_formfactor;
49 }
Defines the macro ASSERT.
#define ASSERT(condition)
Definition: Assert.h:45
Defines class Particle.
Declares class RotMatrix.
Defines IRotation classes.
Abstract base class for Born form factors.
Definition: IFormFactor.h:36
R3 m_position
Definition: IParticle.h:79
const IRotation * rotation() const
Returns rotation object.
Definition: IParticle.cpp:31
double m_abundance
Definition: IParticle.h:78
std::vector< const INode * > nodeChildren() const override
Returns all children.
Definition: IParticle.cpp:20
std::unique_ptr< IRotation > m_rotation
Definition: IParticle.h:80
void setRotation(const IRotation &rotation)
Sets transformation.
Definition: IParticle.cpp:36
Abstract base class for rotations.
Definition: Rotations.h:29
A wrapper for underlying material implementation.
Definition: Material.h:35
A particle with a form factor and refractive index.
Definition: Particle.h:25
~Particle() override
Particle(Material material, const IFormFactor &formfactor)
Definition: Particle.cpp:20
Particle * clone() const override
Returns a clone of this ISampleNode object.
Definition: Particle.cpp:34
std::vector< const INode * > nodeChildren() const override
Returns all children.
Definition: Particle.cpp:46
const Material m_material
Definition: Particle.h:40
std::unique_ptr< const IFormFactor > m_formfactor
Definition: Particle.h:41