From 660eba5c642ce5790349faf1690245d5c763b1ad Mon Sep 17 00:00:00 2001 From: Walter Van Herck <w.van.herck@fz-juelich.de> Date: Tue, 2 Dec 2014 14:33:08 +0100 Subject: [PATCH] Put position inside ParticleInfo --- Core/Samples/inc/ParticleInfo.h | 10 +++++----- Core/Samples/inc/PositionParticleInfo.h | 2 +- Core/Samples/src/ParticleInfo.cpp | 8 +++----- Core/Samples/src/PositionParticleInfo.cpp | 5 ++--- 4 files changed, 11 insertions(+), 14 deletions(-) diff --git a/Core/Samples/inc/ParticleInfo.h b/Core/Samples/inc/ParticleInfo.h index 288e92a4d45..5e791de989d 100644 --- a/Core/Samples/inc/ParticleInfo.h +++ b/Core/Samples/inc/ParticleInfo.h @@ -38,14 +38,14 @@ public: virtual ParticleInfo *clone() const { return new ParticleInfo( - mP_particle->clone(), m_depth, m_abundance); + mP_particle->clone(), getDepth(), m_abundance); } //! Returns a clone with inverted magnetic fields virtual ParticleInfo *cloneInvertB() const { return new ParticleInfo( - mP_particle->cloneInvertB(), m_depth, m_abundance); + mP_particle->cloneInvertB(), getDepth(), m_abundance); } //! calls the ISampleVisitor's visit method @@ -55,10 +55,10 @@ public: const IParticle *getParticle() const { return mP_particle.get(); } //! Returns depth. - double getDepth() const { return m_depth; } + double getDepth() const { return -m_position.z(); } //! Sets depth. - void setDepth(double depth) { m_depth = depth; } + void setDepth(double depth) { m_position.setZ(-depth); } //! Returns abundance. double getAbundance() const { return m_abundance; } @@ -77,7 +77,7 @@ protected: virtual void print(std::ostream& ostr) const; std::auto_ptr<IParticle> mP_particle; - double m_depth; + kvector_t m_position; double m_abundance; }; diff --git a/Core/Samples/inc/PositionParticleInfo.h b/Core/Samples/inc/PositionParticleInfo.h index 9c1f5f2cbdd..a1cf0931c26 100644 --- a/Core/Samples/inc/PositionParticleInfo.h +++ b/Core/Samples/inc/PositionParticleInfo.h @@ -43,7 +43,7 @@ public: //! Returns particle position, including depth. kvector_t getPosition() const - { return kvector_t(m_pos_x, m_pos_y, -m_depth); } + { return kvector_t(m_pos_x, m_pos_y, m_position.z()); } //! Sets particle position, including depth. void setPosition(kvector_t position); diff --git a/Core/Samples/src/ParticleInfo.cpp b/Core/Samples/src/ParticleInfo.cpp index 9b0200cd443..c5093c96152 100644 --- a/Core/Samples/src/ParticleInfo.cpp +++ b/Core/Samples/src/ParticleInfo.cpp @@ -21,11 +21,11 @@ ParticleInfo::ParticleInfo( double depth, double abundance) : mP_particle(p_particle) - , m_depth(depth) , m_abundance(abundance) { setName("ParticleInfo"); registerChild(mP_particle.get()); + m_position = kvector_t(0.0, 0.0, -depth); init_parameters(); } @@ -34,26 +34,24 @@ ParticleInfo::ParticleInfo( double depth, double abundance) : mP_particle(p_particle.clone()) - , m_depth(depth) , m_abundance(abundance) { setName("ParticleInfo"); registerChild(mP_particle.get()); + m_position = kvector_t(0.0, 0.0, -depth); init_parameters(); } void ParticleInfo::init_parameters() { clearParameterPool(); - registerParameter("depth", &m_depth); registerParameter("abundance", &m_abundance); } - void ParticleInfo::print(std::ostream& ostr) const { ostr << "ParticleInfo:" << getName() << "<" << this << "> : {" << - " depth=" << m_depth << + " position=" << m_position << ", abundance=" << m_abundance; ostr << " }"; } diff --git a/Core/Samples/src/PositionParticleInfo.cpp b/Core/Samples/src/PositionParticleInfo.cpp index 15a2798b172..c7a79349f0e 100644 --- a/Core/Samples/src/PositionParticleInfo.cpp +++ b/Core/Samples/src/PositionParticleInfo.cpp @@ -38,7 +38,7 @@ PositionParticleInfo::PositionParticleInfo( PositionParticleInfo* PositionParticleInfo::clone() const { - kvector_t position(m_pos_x, m_pos_y, -m_depth); + kvector_t position(m_pos_x, m_pos_y, m_position.z()); return new PositionParticleInfo( mP_particle->clone(), position, m_abundance); } @@ -47,7 +47,7 @@ void PositionParticleInfo::setPosition(kvector_t position) { m_pos_x = position.x(); m_pos_y = position.y(); - m_depth = position.z(); + m_position.setZ(position.z()); } void PositionParticleInfo::init_parameters() @@ -55,7 +55,6 @@ void PositionParticleInfo::init_parameters() clearParameterPool(); registerParameter("x_position", &m_pos_x); registerParameter("y_position", &m_pos_y); - registerParameter("z_position", &m_depth); registerParameter("abundance", &m_abundance); } -- GitLab