BornAgain  1.18.0
Simulate and fit neutron and x-ray scattering at grazing incidence
ParticleLayout.h
Go to the documentation of this file.
1 // ************************************************************************** //
2 //
3 // BornAgain: simulate and fit scattering at grazing incidence
4 //
5 //! @file Sample/Aggregate/ParticleLayout.h
6 //! @brief Defines class ParticleLayout.
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_AGGREGATE_PARTICLELAYOUT_H
16 #define BORNAGAIN_CORE_AGGREGATE_PARTICLELAYOUT_H
17 
20 #include <memory>
21 
22 class IAbstractParticle;
24 class IParticle;
25 
26 //! Decorator class that adds particles to ISample objects.
27 //! @ingroup samples
28 
29 class ParticleLayout : public ILayout
30 {
31 public:
33  ParticleLayout(const IAbstractParticle& particle, double abundance = -1.0);
34  ~ParticleLayout() override;
35 
36  ParticleLayout* clone() const final override;
37 
38  void accept(INodeVisitor* visitor) const final override { visitor->visit(this); }
39 
40  void addParticle(const IAbstractParticle& particle, double abundance = -1.0,
41  const kvector_t position = {}, const IRotation& rotation = IdentityRotation());
42 
43  SafePointerVector<IParticle> particles() const final override;
44 
45  const IInterferenceFunction* interferenceFunction() const final override;
46 
47  double getTotalAbundance() const final override;
48 
49  void setInterferenceFunction(const IInterferenceFunction& interference_function);
50 
51  double totalParticleSurfaceDensity() const final override;
52  void setTotalParticleSurfaceDensity(double particle_density) final override;
53 
54  std::vector<const INode*> getChildren() const final override;
55 
56 private:
59 
60  void registerParticleDensity(bool make_registered = true);
61  void registerWeight();
62 
63  SafePointerVector<IAbstractParticle> m_particles; //!< Vector of particle types
66 };
67 
68 #endif // BORNAGAIN_CORE_AGGREGATE_PARTICLELAYOUT_H
Defines and implements interface class ILayout.
Defines IRotation classes.
Interface for a generic particle.
Pure virtual base class of interference functions.
Pure virtual interface class to equip a sample layer with scattering properties.
Definition: ILayout.h:32
Visitor interface to visit ISample objects.
Definition: INodeVisitor.h:149
Base class for tree-like structures containing parameterized objects.
Definition: INode.h:49
Pure virtual base class for Particle, ParticleComposition, ParticleCoreShell, MesoCrystal.
Definition: IParticle.h:33
Pure virtual interface for rotations.
Definition: Rotations.h:27
The identity rotation, which leaves everything in place.
Definition: Rotations.h:55
Decorator class that adds particles to ISample objects.
SafePointerVector< IAbstractParticle > m_particles
Vector of particle types.
std::unique_ptr< IInterferenceFunction > mP_interference_function
void registerParticleDensity(bool make_registered=true)
double getTotalAbundance() const final override
Get total abundance of all particles.
SafePointerVector< IParticle > particles() const final override
Returns information on all particles (type and abundance) and generates new particles if an IAbstract...
void accept(INodeVisitor *visitor) const final override
Calls the INodeVisitor's visit method.
~ParticleLayout() override
std::vector< const INode * > getChildren() const final override
Returns a vector of children (const).
void setInterferenceFunction(const IInterferenceFunction &interference_function)
Adds interference functions.
double totalParticleSurfaceDensity() const final override
Returns surface density of all particles.
void setTotalParticleSurfaceDensity(double particle_density) final override
Sets total particle surface density.
const IInterferenceFunction * interferenceFunction() const final override
Returns the interference function.
void setAndRegisterInterferenceFunction(IInterferenceFunction *child)
Sets interference function with simultaneous registration in parent class.
double m_total_particle_density
void addAndRegisterAbstractParticle(IAbstractParticle *child)
Adds particle information with simultaneous registration in parent class.
void addParticle(const IAbstractParticle &particle, double abundance=-1.0, const kvector_t position={}, const IRotation &rotation=IdentityRotation())
Adds particle to the layout with abundance, position and the rotation defined.
ParticleLayout * clone() const final override
Returns a clone of this ISample object.
A vector of pointers, owned by *this, with methods to handle them safely.