Skip to content
Snippets Groups Projects
Commit 2c19f2b2 authored by Van Herck, Walter's avatar Van Herck, Walter
Browse files

Refactored ParticleDecoration and removed TODO

parent adec994e
No related branches found
No related tags found
No related merge requests found
......@@ -26,33 +26,13 @@
class BA_CORE_API_ ParticleDecoration : public IDecoration
{
public:
ParticleDecoration()
: m_total_abundance(0.0)
{
setName("ParticleDecoration");
}
ParticleDecoration();
ParticleDecoration(
Particle* p_particle, double depth=0., double abundance=1.)
: m_total_abundance(0.0)
{
setName("ParticleDecoration");
addParticle(p_particle, depth, abundance);
}
Particle* p_particle, double depth=0., double abundance=1.);
ParticleDecoration(
const Particle& p_particle, double depth=0., double abundance=1.)
: m_total_abundance(0.0)
{
setName("ParticleDecoration");
addParticle(p_particle.clone(), depth, abundance);
}
~ParticleDecoration()
{
for (size_t i=0; i<m_particles.size(); ++i)
delete m_particles[i];
}
const Particle& p_particle, double depth=0., double abundance=1.);
virtual ~ParticleDecoration();
virtual ParticleDecoration *clone() const;
......@@ -114,10 +94,10 @@ private:
void print(std::ostream& ostr) const;
//TODO: replace with SafePointerVector
std::vector<ParticleInfo*> m_particles;
//! Vector of the types of particles
SafePointerVector<ParticleInfo> m_particles;
//! Vector of interference functions
SafePointerVector<IInterferenceFunction> m_interference_functions;
//! Currently only a scalar interference function (instead of matrix)
......
......@@ -23,9 +23,34 @@
#include <iomanip>
ParticleDecoration::ParticleDecoration()
: m_total_abundance(0.0)
{
setName("ParticleDecoration");
}
ParticleDecoration::ParticleDecoration(
Particle* p_particle, double depth, double abundance)
: m_total_abundance(0.0)
{
setName("ParticleDecoration");
addParticle(p_particle, depth, abundance);
}
ParticleDecoration::ParticleDecoration(
const Particle& p_particle, double depth, double abundance)
: m_total_abundance(0.0)
{
setName("ParticleDecoration");
addParticle(p_particle.clone(), depth, abundance);
}
ParticleDecoration::~ParticleDecoration()
{
}
ParticleDecoration* ParticleDecoration::clone() const
{
// msglog(MSG::DEBUG) << "ParticleDecoration::clone()";
ParticleDecoration *p_new = new ParticleDecoration();
p_new->setName(getName());
......@@ -44,7 +69,6 @@ ParticleDecoration* ParticleDecoration::clone() const
ParticleDecoration* ParticleDecoration::cloneInvertB() const
{
// msglog(MSG::DEBUG) << "ParticleDecoration::clone()";
ParticleDecoration *p_new = new ParticleDecoration();
p_new->setName(getName() + "_inv");
......@@ -62,13 +86,13 @@ ParticleDecoration* ParticleDecoration::cloneInvertB() const
}
//! Adds generic particle, *-version.
void ParticleDecoration::addParticle(
Particle* p_particle, const Geometry::ITransform3D& transform,
double depth, double abundance)
{
if(!abundance) {
throw LogicErrorException("ParticleDecoration::addParticle() -> Error! Abundance can't be equal to 0.0");
throw LogicErrorException("ParticleDecoration::addParticle() ->"
" Error! Abundance can't be equal to 0.0");
}
p_particle->setTransform(transform);
addAndRegisterParticleInfo(
......@@ -76,13 +100,13 @@ void ParticleDecoration::addParticle(
}
//! Adds generic particle, &-version.
void ParticleDecoration::addParticle(
const Particle& p_particle, const Geometry::ITransform3D& transform,
double depth, double abundance)
{
if(!abundance) {
throw LogicErrorException("ParticleDecoration::addParticle() -> Error! Abundance can't be equal to 0.0");
throw LogicErrorException("ParticleDecoration::addParticle() ->"
" Error! Abundance can't be equal to 0.0");
}
Particle *p_particle_clone = p_particle.clone();
p_particle_clone->setTransform(transform);
......@@ -91,18 +115,15 @@ void ParticleDecoration::addParticle(
}
//! Adds particle without rotation, *-version.
void ParticleDecoration::addParticle(
Particle* p_particle,
double depth, double abundance)
{
addAndRegisterParticleInfo(
new ParticleInfo(p_particle, depth, abundance));
// addParticle(p_particle, Geometry::ITransform3D(), depth, abundance);
}
//! Adds particle without rotation, &-version.
void ParticleDecoration::addParticle(
const Particle& p_particle,
double depth, double abundance)
......@@ -110,18 +131,15 @@ void ParticleDecoration::addParticle(
Particle *p_particle_clone = p_particle.clone();
addAndRegisterParticleInfo(
new ParticleInfo(p_particle_clone, depth, abundance));
// addParticle(p_particle.clone(), Geometry::PTransform3D(), depth, abundance);
}
//! Adds particle info.
void ParticleDecoration::addParticleInfo(const ParticleInfo& info)
{
addAndRegisterParticleInfo( info.clone() );
}
//! Returns particle info
const ParticleInfo* ParticleDecoration::getParticleInfo(size_t index) const
{
if (index<m_particles.size())
......@@ -137,7 +155,6 @@ double ParticleDecoration::getAbundanceFractionOfParticle(size_t index) const
}
//! Adds interference functions
void ParticleDecoration::addInterferenceFunction(
IInterferenceFunction* p_interference_function)
{
......@@ -164,14 +181,12 @@ const IInterferenceFunction* ParticleDecoration::getInterferenceFunction(
void ParticleDecoration::addAndRegisterParticleInfo(
ParticleInfo *child)
{
// msglog(MSG::DEBUG) << "ParticleDecoration::addAndRegisterParticleInfo {" << *child << "}";
m_total_abundance += child->getAbundance();
m_particles.push_back(child);
registerChild(child);
}
//! Adds interference function with simultaneous registration in parent class.
void ParticleDecoration::addAndRegisterInterferenceFunction(
IInterferenceFunction *child)
{
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment