BornAgain  1.18.0
Simulate and fit neutron and x-ray scattering at grazing incidence
ParticleComposition.h
Go to the documentation of this file.
1 // ************************************************************************** //
2 //
3 // BornAgain: simulate and fit scattering at grazing incidence
4 //
5 //! @file Sample/Particle/ParticleComposition.h
6 //! @brief Defines class ParticleComposition.
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_PARTICLECOMPOSITION_H
16 #define BORNAGAIN_CORE_PARTICLE_PARTICLECOMPOSITION_H
17 
19 #include <memory>
20 
21 //! A composition of particles at fixed positions
22 //! @ingroup samples
23 
25 {
26 public:
28  ParticleComposition(const IParticle& particle, std::vector<kvector_t> positions);
29 
31  ParticleComposition* clone() const override final;
32 
33  void accept(INodeVisitor* visitor) const override final { visitor->visit(this); }
34 
35  IFormFactor* createFormFactor() const override final;
36 
37  void addParticle(const IParticle& particle);
38  void addParticle(const IParticle& particle, kvector_t position);
39  void addParticles(const IParticle& particle, std::vector<kvector_t> positions);
40 
41  //! Returns number of different particles
42  size_t nbrParticles() const { return m_particles.size(); }
43 
44  std::vector<const INode*> getChildren() const override final;
45 
46  SafePointerVector<IParticle> decompose() const override final;
47 
48  ParticleLimits bottomTopZ() const override final;
49 
50 private:
51  size_t check_index(size_t index) const;
52 
53  //! For internal use
54  void addParticlePointer(IParticle* p_particle);
55 
56  std::vector<std::unique_ptr<IParticle>> m_particles;
57  void initialize();
58 };
59 
60 #endif // BORNAGAIN_CORE_PARTICLE_PARTICLECOMPOSITION_H
Defines interface IParticle.
Pure virtual base class for all form factors.
Definition: IFormFactor.h:40
Visitor interface to visit ISample objects.
Definition: INodeVisitor.h:149
Pure virtual base class for Particle, ParticleComposition, ParticleCoreShell, MesoCrystal.
Definition: IParticle.h:33
kvector_t position() const
Returns particle position.
Definition: IParticle.h:45
A composition of particles at fixed positions.
ParticleComposition * clone() const override final
Returns a clone of this ISample object.
void addParticle(const IParticle &particle)
std::vector< std::unique_ptr< IParticle > > m_particles
size_t check_index(size_t index) const
size_t nbrParticles() const
Returns number of different particles.
void addParticlePointer(IParticle *p_particle)
For internal use.
SafePointerVector< IParticle > decompose() const override final
Decompose in constituent IParticle objects.
std::vector< const INode * > getChildren() const override final
Returns a vector of children (const).
void accept(INodeVisitor *visitor) const override final
Calls the INodeVisitor's visit method.
ParticleLimits bottomTopZ() const override final
Top and bottom z-coordinate.
void addParticles(const IParticle &particle, std::vector< kvector_t > positions)
IFormFactor * createFormFactor() const override final
Creates a form factor for this particle.
A vector of pointers, owned by *this, with methods to handle them safely.
Vertical extension of a particle, specified by bottom and top z coordinate.
Definition: ZLimits.h:21