From cf6464d9d729de297ec60a76efe961a7ee0ae80d Mon Sep 17 00:00:00 2001
From: pospelov <pospelov@fz-juelich.de>
Date: Thu, 5 Apr 2012 18:17:14 +0200
Subject: [PATCH] IAlgorithm and TestFesnelCoeff

---
 Core/Core.pro                    |  9 ++++++--
 Core/inc/HomogeneousMaterial.h   |  7 +++---
 Core/inc/IAlgorithm.h            | 13 +++++++++++
 Core/inc/Layer.h                 |  4 ++--
 Core/inc/TestFresnelCoeff.h      | 14 ++++++++++++
 Core/inc/Types.h                 |  9 ++++++++
 Core/src/HomogeneousMaterial.cpp |  2 +-
 Core/src/IAlgorithm.cpp          |  8 +++++++
 Core/src/TestFresnelCoeff.cpp    | 37 ++++++++++++++++++++++++++++++++
 Core/src/main.cpp                |  4 ++++
 10 files changed, 99 insertions(+), 8 deletions(-)
 create mode 100644 Core/inc/IAlgorithm.h
 create mode 100644 Core/inc/TestFresnelCoeff.h
 create mode 100644 Core/inc/Types.h
 create mode 100644 Core/src/IAlgorithm.cpp
 create mode 100644 Core/src/TestFresnelCoeff.cpp

diff --git a/Core/Core.pro b/Core/Core.pro
index 7d4d7b48272..247b6885ed1 100644
--- a/Core/Core.pro
+++ b/Core/Core.pro
@@ -9,7 +9,9 @@ SOURCES += src/main.cpp \
     src/MultiLayer.cpp \
     src/LayerRoughness.cpp \
     src/Exceptions.cpp \
-    src/ISample.cpp
+    src/ISample.cpp \
+    src/IAlgorithm.cpp \
+    src/TestFresnelCoeff.cpp
 
 HEADERS += \
     inc/ISample.h \
@@ -19,7 +21,10 @@ HEADERS += \
     inc/HomogeneousMaterial.h \
     inc/MultiLayer.h \
     inc/LayerRoughness.h \
-    inc/Exceptions.h
+    inc/Exceptions.h \
+    inc/IAlgorithm.h \
+    inc/TestFresnelCoeff.h \
+    inc/Types.h
 
 INCLUDEPATH += ./inc
 
diff --git a/Core/inc/HomogeneousMaterial.h b/Core/inc/HomogeneousMaterial.h
index 8f9222c6101..06c783396e3 100644
--- a/Core/inc/HomogeneousMaterial.h
+++ b/Core/inc/HomogeneousMaterial.h
@@ -2,18 +2,19 @@
 #define HOMOGENEOUSMATERIAL_H
 
 #include "IMaterial.h"
+#include "Types.h"
 
 class HomogeneousMaterial : public IMaterial
 {
 public:
-    HomogeneousMaterial(double refractive_index = 1);
+    HomogeneousMaterial(complex_t refractive_index = complex_t(1,0) );
     virtual ~HomogeneousMaterial() {}
 
-    double getRefractiveIndex() { return m_refractive_index; }
+    complex_t getRefractiveIndex() { return m_refractive_index; }
 
 
 private:
-    double m_refractive_index;
+    complex_t m_refractive_index;
 };
 
 #endif // HOMOGENEOUSMATERIAL_H
diff --git a/Core/inc/IAlgorithm.h b/Core/inc/IAlgorithm.h
new file mode 100644
index 00000000000..f3f15329f1b
--- /dev/null
+++ b/Core/inc/IAlgorithm.h
@@ -0,0 +1,13 @@
+#ifndef IALGORITHM_H
+#define IALGORITHM_H
+
+class IAlgorithm
+{
+public:
+  virtual ~IAlgorithm() {}
+
+  virtual void Run();
+};
+
+#endif // IALGORITHM_H
+
diff --git a/Core/inc/Layer.h b/Core/inc/Layer.h
index ecc411bac23..cc39632e77e 100644
--- a/Core/inc/Layer.h
+++ b/Core/inc/Layer.h
@@ -12,8 +12,8 @@ public:
 
     virtual void setThickness(double thickness);
     virtual const double getThickness() const { return m_thickness; }
-    virtual void setBulkMaterial(IMaterial* p_material) { mp_bulk_material = p_material; }
-    virtual IMaterial* getBulkMaterial() { return mp_bulk_material; }
+    virtual void setMaterial(IMaterial* p_material) { mp_bulk_material = p_material; }
+    virtual IMaterial* getMaterial() { return mp_bulk_material; }
 
 private:
     IMaterial* mp_bulk_material;
diff --git a/Core/inc/TestFresnelCoeff.h b/Core/inc/TestFresnelCoeff.h
new file mode 100644
index 00000000000..0b3682cdcc8
--- /dev/null
+++ b/Core/inc/TestFresnelCoeff.h
@@ -0,0 +1,14 @@
+#ifndef TESTFRESNELCOEFF_H
+#define TESTFRESNELCOEFF_H
+
+#include "IAlgorithm.h"
+
+class TestFresnelCoeff : public IAlgorithm
+{
+public:
+  TestFresnelCoeff();
+
+  void Run();
+};
+
+#endif // TESTFRESNELCOEFF_H
diff --git a/Core/inc/Types.h b/Core/inc/Types.h
new file mode 100644
index 00000000000..b1226b9c0c0
--- /dev/null
+++ b/Core/inc/Types.h
@@ -0,0 +1,9 @@
+#ifndef TYPES_H
+#define TYPES_H
+
+
+#include <complex>
+
+typedef std::complex<double > complex_t;
+
+#endif // TYPES_H
diff --git a/Core/src/HomogeneousMaterial.cpp b/Core/src/HomogeneousMaterial.cpp
index d9f1c56a967..2bf7e38e613 100644
--- a/Core/src/HomogeneousMaterial.cpp
+++ b/Core/src/HomogeneousMaterial.cpp
@@ -1,6 +1,6 @@
 #include "HomogeneousMaterial.h"
 
-HomogeneousMaterial::HomogeneousMaterial(double refractive_index)
+HomogeneousMaterial::HomogeneousMaterial(complex_t refractive_index)
     : m_refractive_index(refractive_index)
 {
 }
diff --git a/Core/src/IAlgorithm.cpp b/Core/src/IAlgorithm.cpp
new file mode 100644
index 00000000000..f25735fd448
--- /dev/null
+++ b/Core/src/IAlgorithm.cpp
@@ -0,0 +1,8 @@
+#include "IAlgorithm.h"
+#include "Exceptions.h"
+
+
+void IAlgorithm::Run()
+{
+    throw NotImplementedException("This algorithm can't tun.");
+}
diff --git a/Core/src/TestFresnelCoeff.cpp b/Core/src/TestFresnelCoeff.cpp
new file mode 100644
index 00000000000..cad7a762820
--- /dev/null
+++ b/Core/src/TestFresnelCoeff.cpp
@@ -0,0 +1,37 @@
+#include "TestFresnelCoeff.h"
+#include <iostream>
+
+#include "Layer.h"
+#include "MultiLayer.h"
+#include "HomogeneousMaterial.h"
+
+
+TestFresnelCoeff::TestFresnelCoeff()
+{
+    std::cout << "TestFresnelCoeff::TestFresnelCoeff() -> Info." << std::endl;
+}
+
+
+
+void TestFresnelCoeff::Run()
+{
+    std::cout << "TestFresnelCoeff::Run() -> Info." << std::endl;
+
+    MultiLayer mySample;
+
+    HomogeneousMaterial mAmbience;
+
+    Layer ag1;
+    ag1.setThickness(1500.0);
+    ag1.setMaterial( &mAmbience );
+
+    mySample.addLayerWithTopRoughness(&ag1, 0);
+}
+
+
+
+//mySample.AddLayer( BLayerHomogenious("Ambience", 0.0, 1.0) );
+//BLayerHomogenious ag1("Ag1", 1500.,  complex_t(0.99999653774962993,0) );
+//BLayerHomogenious cr1("Cr1", 1200.0, complex_t(0.99999701914797656,0) );
+//mySample.AddLayer( ag1, cr1, nrepetitions );
+//mySample.AddLayer( BLayerHomogenious("Substrate", 0.0, 0.99999692440971188) );
diff --git a/Core/src/main.cpp b/Core/src/main.cpp
index eac6dfa0e5b..3db044e5a98 100644
--- a/Core/src/main.cpp
+++ b/Core/src/main.cpp
@@ -1,10 +1,14 @@
 #include <iostream>
+#include "TestFresnelCoeff.h"
 
 using namespace std;
 
 int main()
 {
     cout << "Hello Brave New World!" << endl;
+
+    TestFresnelCoeff test;
+    test.Run();
     return 0;
 }
 
-- 
GitLab