From 433d10f24007b5c9a1d0ddcb95c608f15bbf4a4c Mon Sep 17 00:00:00 2001
From: Walter Van Herck <w.van.herck@fz-juelich.de>
Date: Thu, 26 Sep 2013 10:47:06 +0200
Subject: [PATCH] Replaced refractive index by IMaterial in
 DiffuseDWBASimulation

---
 Core/Algorithms/inc/DiffuseDWBASimulation.h   |  7 +++----
 Core/Algorithms/src/DiffuseDWBASimulation.cpp | 15 ++++++++++++---
 Core/Samples/src/Layer.cpp                    |  3 +--
 3 files changed, 16 insertions(+), 9 deletions(-)

diff --git a/Core/Algorithms/inc/DiffuseDWBASimulation.h b/Core/Algorithms/inc/DiffuseDWBASimulation.h
index c22e6a074c9..4ab5e332826 100644
--- a/Core/Algorithms/inc/DiffuseDWBASimulation.h
+++ b/Core/Algorithms/inc/DiffuseDWBASimulation.h
@@ -23,7 +23,7 @@ class DiffuseDWBASimulation: public LayerDWBASimulation
 {
 public:
     DiffuseDWBASimulation()
-        : m_refractive_index(1., 0.), m_surface_density(1.) {}
+        : m_surface_density(1.0) {}
 
     virtual ~DiffuseDWBASimulation() {}
 
@@ -34,7 +34,7 @@ public:
     void addParticleInfo(DiffuseParticleInfo *p_info)
     { m_np_infos.push_back(p_info); }
 
-    void setRefractiveIndex(complex_t n) { m_refractive_index = n; }
+    void setMaterial(const IMaterial *p_material);
 
     void setSurfaceDensity(double surface_density)
     { m_surface_density = surface_density; }
@@ -45,8 +45,7 @@ public:
             m_np_infos[np_index]->scaleAbundance(factor);
     }
 
-protected:
-    complex_t m_refractive_index;
+private:
     double m_surface_density;
     SafePointerVector<DiffuseParticleInfo> m_np_infos;
     struct DiffuseFormFactorTerm {
diff --git a/Core/Algorithms/src/DiffuseDWBASimulation.cpp b/Core/Algorithms/src/DiffuseDWBASimulation.cpp
index b4f890ce54f..fc889b7998b 100644
--- a/Core/Algorithms/src/DiffuseDWBASimulation.cpp
+++ b/Core/Algorithms/src/DiffuseDWBASimulation.cpp
@@ -111,8 +111,19 @@ void DiffuseDWBASimulation::run()
     }
 }
 
-//! Initializes vector<DiffuseFormFactorTerm*> term.
+void DiffuseDWBASimulation::setMaterial(const IMaterial* p_material)
+{
+    SafePointerVector<DiffuseParticleInfo>::iterator it =
+            m_np_infos.begin();
+    while (it != m_np_infos.end()) {
+        (*it)->setAmbientMaterial(p_material);
+        ++it;
+    }
+}
+
 
+//! Initializes vector<DiffuseFormFactorTerm*> term.
+//!
 //! Called near beginning of this->run().
 //! Collect one entry (p_diffuse_term) per particle type and layer[?].
 //! For each entry, set
@@ -162,5 +173,3 @@ void DiffuseDWBASimulation::initDiffuseFormFactorTerms(
     }
 }
 
-
-
diff --git a/Core/Samples/src/Layer.cpp b/Core/Samples/src/Layer.cpp
index 055a473975c..32bc1556643 100644
--- a/Core/Samples/src/Layer.cpp
+++ b/Core/Samples/src/Layer.cpp
@@ -157,7 +157,6 @@ DiffuseDWBASimulation* Layer::createDiffuseDWBASimulation() const
         if (p_diffuse_nps) {
             for (size_t j=0; j<p_diffuse_nps->size(); ++j) {
                 DiffuseParticleInfo *p_diff_info = (*p_diffuse_nps)[j];
-                p_diff_info->setAmbientMaterial(p_layer_material);
                 p_diff_info->setNumberPerMeso(
                     particle_density * p_info->getAbundance() *
                     p_diff_info->getNumberPerMeso());
@@ -170,7 +169,7 @@ DiffuseDWBASimulation* Layer::createDiffuseDWBASimulation() const
         }
     }
     if (p_sim->getSize()>0) {
-        p_sim->setRefractiveIndex(getRefractiveIndex());
+        p_sim->setMaterial(p_layer_material);
         return p_sim;
     }
     delete p_sim;
-- 
GitLab