BornAgain  1.19.79
Open-source research software to simulate and fit neutron and x-ray reflectometry and grazing-incidence small-angle scattering
IParticle.cpp
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file Sample/Particle/IParticle.cpp
6 //! @brief Implements 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 
17 
18 IParticle::~IParticle() = default;
19 
20 std::vector<const INode*> IParticle::nodeChildren() const
21 {
22  return std::vector<const INode*>() << m_rotation;
23 }
24 
26 {
27  m_position += translation;
28  return this;
29 }
30 
32 {
33  return m_rotation.get();
34 }
35 
36 void IParticle::setRotation(const IRotation& rotation)
37 {
38  m_rotation.reset(rotation.clone());
39 }
40 
42 {
43  if (m_rotation)
45  else
46  m_rotation.reset(rotation.clone());
48  return this;
49 }
50 
51 #ifndef SWIG
52 std::vector<std::unique_ptr<IParticle>> IParticle::decompose() const
53 {
54  std::vector<std::unique_ptr<IParticle>> result;
55  result.emplace_back(this->clone());
56  return result;
57 }
58 #endif
Defines interface IParticle.
IRotation * createProduct(const IRotation &left, const IRotation &right)
Returns concatenated rotation (first right, then left).
Definition: Rotations.cpp:59
Defines IRotation classes.
Abstract base class for Particle, ParticleComposition, ParticleCoreShell, MesoCrystal....
Definition: IParticle.h:31
~IParticle() override
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
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
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
void setRotation(const IRotation &rotation)
Sets transformation.
Definition: IParticle.cpp:36
Abstract base class for rotations.
Definition: Rotations.h:29
IRotation * clone() const override=0
R3 transformed(const R3 &v) const
Definition: Rotations.cpp:42