21 ParticleComposition::ParticleComposition()
26 ParticleComposition::ParticleComposition(
const IParticle& particle,
27 std::vector<kvector_t> positions)
30 addParticles(particle, positions);
33 ParticleComposition::~ParticleComposition() =
default;
39 for (
size_t index = 0; index < m_particles.size(); ++index)
40 p_result->addParticle(*m_particles[index]);
49 if (m_particles.empty())
53 for (
auto p_particle : particles) {
54 std::unique_ptr<IFormFactor> P_particle_ff{p_particle->createFormFactor()};
55 result->addFormFactor(*P_particle_ff);
60 void ParticleComposition::addParticle(
const IParticle& particle)
63 addParticlePointer(np);
70 addParticlePointer(np);
75 void ParticleComposition::addParticles(
const IParticle& particle, std::vector<kvector_t> positions)
77 for (
size_t i = 0; i < positions.size(); ++i)
78 addParticle(particle, positions[i]);
84 for (
auto& P_particle : m_particles)
85 result.push_back(P_particle.get());
94 for (
auto& P_particle : m_particles) {
95 auto sublist = P_particle->decompose();
96 for (
auto p_subparticle : sublist) {
98 p_subparticle->rotate(*p_rotation);
99 p_subparticle->translate(translation);
100 result.push_back(p_subparticle->clone());
110 for (
auto& P_particle : particles) {
112 result.m_bottom = std::min(result.m_bottom, limits.m_bottom);
113 result.m_top = std::max(result.m_top, limits.m_top);
118 size_t ParticleComposition::check_index(
size_t index)
const
120 return index < m_particles.size()
123 "ParticleComposition::check_index() -> Index is out of bounds");
126 void ParticleComposition::addParticlePointer(
IParticle* p_particle)
128 p_particle->registerAbundance(
false);
129 registerChild(p_particle);
130 m_particles.emplace_back(p_particle);
133 void ParticleComposition::initialize()
135 setName(
"ParticleComposition");
Defines many exception classes in namespace Exceptionss.
Defines class ParticleComposition.
Defines class ParticleDistribution.
Defines IRotation classes.
void setAbundance(double abundance)
Sets particle abundance.
Pure virtual base class for Particle, ParticleComposition, ParticleCoreShell, MesoCrystal.
void translate(kvector_t translation) override final
Translates the particle.
std::vector< const INode * > getChildren() const override
Returns a vector of children (const).
void setPosition(kvector_t position)
Sets relative position of the particle's reference point in the coordinate system of parent.
kvector_t position() const
Returns particle position.
const IRotation * rotation() const
Returns rotation object.
IParticle * clone() const override=0
Returns a clone of this ISample object.
void setRotation(const IRotation &rotation)
Sets transformation.
void registerParticleProperties()
Registers abundance and position.
A composition of particles at fixed positions.
ParticleComposition * clone() const override final
Returns a clone of this ISample object.
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).
ParticleLimits bottomTopZ() const override final
Top and bottom z-coordinate.
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.