BornAgain  1.19.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 reflection and scattering
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_SAMPLE_PARTICLE_PARTICLECOMPOSITION_H
16 #define BORNAGAIN_SAMPLE_PARTICLE_PARTICLECOMPOSITION_H
17 
19 #include <memory>
20 
21 //! A composition of particles at fixed positions
22 //! @ingroup samples
23 
25 public:
27  ParticleComposition(const IParticle& particle, std::vector<kvector_t> positions);
28 
30  ParticleComposition* clone() const final;
31 
32  void accept(INodeVisitor* visitor) const final { visitor->visit(this); }
33 
34  IFormFactor* createFormFactor() const final;
35 
36  void addParticle(const IParticle& particle);
37  void addParticle(const IParticle& particle, kvector_t position);
38  void addParticles(const IParticle& particle, std::vector<kvector_t> positions);
39 
40  //! Returns number of different particles
41  size_t nbrParticles() const { return m_particles.size(); }
42 
43  std::vector<const INode*> getChildren() const final;
44 
45  SafePointerVector<IParticle> decompose() const final;
46 
47  ParticleLimits bottomTopZ() const final;
48 
49 private:
50  size_t check_index(size_t index) const;
51 
52  //! For internal use
53  void addParticlePointer(IParticle* p_particle);
54 
55  std::vector<std::unique_ptr<IParticle>> m_particles;
56  void initialize();
57 };
58 
59 #endif // BORNAGAIN_SAMPLE_PARTICLE_PARTICLECOMPOSITION_H
Defines interface IParticle.
Abstract base class for all form factors.
Definition: IFormFactor.h:36
Visitor interface to visit ISampleNode objects.
Definition: INodeVisitor.h:146
Abstract 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.
IFormFactor * createFormFactor() const final
Creates a form factor for this particle.
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.
ParticleLimits bottomTopZ() const final
Top and bottom z-coordinate.
ParticleComposition * clone() const final
Returns a clone of this ISampleNode object.
std::vector< const INode * > getChildren() const final
Returns a vector of children.
void accept(INodeVisitor *visitor) const final
Calls the INodeVisitor's visit method.
void addParticles(const IParticle &particle, std::vector< kvector_t > positions)
SafePointerVector< IParticle > decompose() const final
Decompose in constituent IParticle objects.
A vector of pointers, owned by *this, with methods to handle them safely.
Definition: filesystem.h:81
Vertical extension of a particle, specified by bottom and top z coordinate.
Definition: ZLimits.h:26