From 00b84c25183ac6f70474a0772df02b7ec345a85c Mon Sep 17 00:00:00 2001
From: Walter Van Herck <w.van.herck@fz-juelich.de>
Date: Fri, 16 Nov 2018 13:46:04 +0100
Subject: [PATCH] Switch to new interface for IPeakShape and remove old
 interface

---
 Core/Aggregate/IPeakShape.h                   |  7 +-
 .../InterferenceFunction3DLattice.cpp         |  2 +-
 auto/Wrap/libBornAgainCore.py                 | 18 ++---
 auto/Wrap/libBornAgainCore_wrap.cpp           | 69 ++++++++++++++++---
 4 files changed, 72 insertions(+), 24 deletions(-)

diff --git a/Core/Aggregate/IPeakShape.h b/Core/Aggregate/IPeakShape.h
index 9da2adc0d72..730824b7f05 100644
--- a/Core/Aggregate/IPeakShape.h
+++ b/Core/Aggregate/IPeakShape.h
@@ -29,9 +29,6 @@ public:
 
     virtual IPeakShape* clone() const=0;
 
-    //! Evaluates the peak shape at displacement q from the center at 0
-    virtual double evaluate(const kvector_t q) const=0;
-
     //! Evaluates the peak shape at q from a reciprocal lattice point at q_lattice_point
     virtual double evaluate(const kvector_t q, const kvector_t q_lattice_point) const=0;
 };
@@ -51,9 +48,9 @@ public:
 
     void accept(INodeVisitor* visitor) const override { visitor->visit(this); }
 
-    double evaluate(const kvector_t q) const override;
     double evaluate(const kvector_t q, const kvector_t q_lattice_point) const override;
 private:
+    double evaluate(const kvector_t q) const;
     double m_max_intensity;
     double m_domainsize;
 };
@@ -72,9 +69,9 @@ public:
 
     void accept(INodeVisitor* visitor) const override { visitor->visit(this); }
 
-    double evaluate(const kvector_t q) const override;
     double evaluate(const kvector_t q, const kvector_t q_lattice_point) const override;
 private:
+    double evaluate(const kvector_t q) const;
     double m_max_intensity;
     double m_domainsize;
 };
diff --git a/Core/Aggregate/InterferenceFunction3DLattice.cpp b/Core/Aggregate/InterferenceFunction3DLattice.cpp
index b6563dbc697..3bd60a0caff 100644
--- a/Core/Aggregate/InterferenceFunction3DLattice.cpp
+++ b/Core/Aggregate/InterferenceFunction3DLattice.cpp
@@ -63,7 +63,7 @@ double InterferenceFunction3DLattice::evaluate(const kvector_t q) const
     auto rec_vectors = m_lattice.reciprocalLatticeVectorsWithinRadius(q, radius);
     double result = 0.0;
     for (const auto& q_rec : rec_vectors) {
-        result += mP_peak_shape->evaluate(q - q_rec)*DebyeWallerFactor(q_rec, m_dw_length);
+        result += mP_peak_shape->evaluate(q, q_rec)*DebyeWallerFactor(q_rec, m_dw_length);
     }
     return result;
 }
diff --git a/auto/Wrap/libBornAgainCore.py b/auto/Wrap/libBornAgainCore.py
index 45df7b98fa8..c3455e47179 100644
--- a/auto/Wrap/libBornAgainCore.py
+++ b/auto/Wrap/libBornAgainCore.py
@@ -19366,16 +19366,16 @@ class IPeakShape(ISample):
         return _libBornAgainCore.IPeakShape_clone(self)
 
 
-    def evaluate(self, q):
+    def evaluate(self, q, q_lattice_point):
         """
-        evaluate(IPeakShape self, kvector_t q) -> double
+        evaluate(IPeakShape self, kvector_t q, kvector_t q_lattice_point) -> double
 
         virtual double IPeakShape::evaluate(const kvector_t q) const =0
 
         Evaluates the peak shape at displacement q from the center at 0. 
 
         """
-        return _libBornAgainCore.IPeakShape_evaluate(self, q)
+        return _libBornAgainCore.IPeakShape_evaluate(self, q, q_lattice_point)
 
 IPeakShape_swigregister = _libBornAgainCore.IPeakShape_swigregister
 IPeakShape_swigregister(IPeakShape)
@@ -19439,16 +19439,16 @@ class GaussPeakShape(IPeakShape):
         return _libBornAgainCore.GaussPeakShape_accept(self, visitor)
 
 
-    def evaluate(self, q):
+    def evaluate(self, q, q_lattice_point):
         """
-        evaluate(GaussPeakShape self, kvector_t q) -> double
+        evaluate(GaussPeakShape self, kvector_t q, kvector_t q_lattice_point) -> double
 
         double GaussPeakShape::evaluate(const kvector_t q) const override
 
         Evaluates the peak shape at displacement q from the center at 0. 
 
         """
-        return _libBornAgainCore.GaussPeakShape_evaluate(self, q)
+        return _libBornAgainCore.GaussPeakShape_evaluate(self, q, q_lattice_point)
 
 GaussPeakShape_swigregister = _libBornAgainCore.GaussPeakShape_swigregister
 GaussPeakShape_swigregister(GaussPeakShape)
@@ -19500,16 +19500,16 @@ class LorentzPeakShape(IPeakShape):
         return _libBornAgainCore.LorentzPeakShape_accept(self, visitor)
 
 
-    def evaluate(self, q):
+    def evaluate(self, q, q_lattice_point):
         """
-        evaluate(LorentzPeakShape self, kvector_t q) -> double
+        evaluate(LorentzPeakShape self, kvector_t q, kvector_t q_lattice_point) -> double
 
         virtual double IPeakShape::evaluate(const kvector_t q) const =0
 
         Evaluates the peak shape at displacement q from the center at 0. 
 
         """
-        return _libBornAgainCore.LorentzPeakShape_evaluate(self, q)
+        return _libBornAgainCore.LorentzPeakShape_evaluate(self, q, q_lattice_point)
 
 LorentzPeakShape_swigregister = _libBornAgainCore.LorentzPeakShape_swigregister
 LorentzPeakShape_swigregister(LorentzPeakShape)
diff --git a/auto/Wrap/libBornAgainCore_wrap.cpp b/auto/Wrap/libBornAgainCore_wrap.cpp
index e2da984f12e..1976e6ed83d 100644
--- a/auto/Wrap/libBornAgainCore_wrap.cpp
+++ b/auto/Wrap/libBornAgainCore_wrap.cpp
@@ -87518,15 +87518,19 @@ SWIGINTERN PyObject *_wrap_IPeakShape_evaluate(PyObject *SWIGUNUSEDPARM(self), P
   PyObject *resultobj = 0;
   IPeakShape *arg1 = (IPeakShape *) 0 ;
   kvector_t arg2 ;
+  kvector_t arg3 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   void *argp2 ;
   int res2 = 0 ;
+  void *argp3 ;
+  int res3 = 0 ;
   PyObject * obj0 = 0 ;
   PyObject * obj1 = 0 ;
+  PyObject * obj2 = 0 ;
   double result;
   
-  if (!PyArg_ParseTuple(args,(char *)"OO:IPeakShape_evaluate",&obj0,&obj1)) SWIG_fail;
+  if (!PyArg_ParseTuple(args,(char *)"OOO:IPeakShape_evaluate",&obj0,&obj1,&obj2)) SWIG_fail;
   res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_IPeakShape, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
     SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "IPeakShape_evaluate" "', argument " "1"" of type '" "IPeakShape const *""'"); 
@@ -87545,7 +87549,20 @@ SWIGINTERN PyObject *_wrap_IPeakShape_evaluate(PyObject *SWIGUNUSEDPARM(self), P
       if (SWIG_IsNewObj(res2)) delete temp;
     }
   }
-  result = (double)((IPeakShape const *)arg1)->evaluate(arg2);
+  {
+    res3 = SWIG_ConvertPtr(obj2, &argp3, SWIGTYPE_p_BasicVector3DT_double_t,  0  | 0);
+    if (!SWIG_IsOK(res3)) {
+      SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "IPeakShape_evaluate" "', argument " "3"" of type '" "kvector_t const""'"); 
+    }  
+    if (!argp3) {
+      SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "IPeakShape_evaluate" "', argument " "3"" of type '" "kvector_t const""'");
+    } else {
+      kvector_t * temp = reinterpret_cast< kvector_t * >(argp3);
+      arg3 = *temp;
+      if (SWIG_IsNewObj(res3)) delete temp;
+    }
+  }
+  result = (double)((IPeakShape const *)arg1)->evaluate(arg2,arg3);
   resultobj = SWIG_From_double(static_cast< double >(result));
   return resultobj;
 fail:
@@ -87668,15 +87685,19 @@ SWIGINTERN PyObject *_wrap_GaussPeakShape_evaluate(PyObject *SWIGUNUSEDPARM(self
   PyObject *resultobj = 0;
   GaussPeakShape *arg1 = (GaussPeakShape *) 0 ;
   kvector_t arg2 ;
+  kvector_t arg3 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   void *argp2 ;
   int res2 = 0 ;
+  void *argp3 ;
+  int res3 = 0 ;
   PyObject * obj0 = 0 ;
   PyObject * obj1 = 0 ;
+  PyObject * obj2 = 0 ;
   double result;
   
-  if (!PyArg_ParseTuple(args,(char *)"OO:GaussPeakShape_evaluate",&obj0,&obj1)) SWIG_fail;
+  if (!PyArg_ParseTuple(args,(char *)"OOO:GaussPeakShape_evaluate",&obj0,&obj1,&obj2)) SWIG_fail;
   res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_GaussPeakShape, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
     SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "GaussPeakShape_evaluate" "', argument " "1"" of type '" "GaussPeakShape const *""'"); 
@@ -87695,7 +87716,20 @@ SWIGINTERN PyObject *_wrap_GaussPeakShape_evaluate(PyObject *SWIGUNUSEDPARM(self
       if (SWIG_IsNewObj(res2)) delete temp;
     }
   }
-  result = (double)((GaussPeakShape const *)arg1)->evaluate(arg2);
+  {
+    res3 = SWIG_ConvertPtr(obj2, &argp3, SWIGTYPE_p_BasicVector3DT_double_t,  0  | 0);
+    if (!SWIG_IsOK(res3)) {
+      SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "GaussPeakShape_evaluate" "', argument " "3"" of type '" "kvector_t const""'"); 
+    }  
+    if (!argp3) {
+      SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "GaussPeakShape_evaluate" "', argument " "3"" of type '" "kvector_t const""'");
+    } else {
+      kvector_t * temp = reinterpret_cast< kvector_t * >(argp3);
+      arg3 = *temp;
+      if (SWIG_IsNewObj(res3)) delete temp;
+    }
+  }
+  result = (double)((GaussPeakShape const *)arg1)->evaluate(arg2,arg3);
   resultobj = SWIG_From_double(static_cast< double >(result));
   return resultobj;
 fail:
@@ -87818,15 +87852,19 @@ SWIGINTERN PyObject *_wrap_LorentzPeakShape_evaluate(PyObject *SWIGUNUSEDPARM(se
   PyObject *resultobj = 0;
   LorentzPeakShape *arg1 = (LorentzPeakShape *) 0 ;
   kvector_t arg2 ;
+  kvector_t arg3 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   void *argp2 ;
   int res2 = 0 ;
+  void *argp3 ;
+  int res3 = 0 ;
   PyObject * obj0 = 0 ;
   PyObject * obj1 = 0 ;
+  PyObject * obj2 = 0 ;
   double result;
   
-  if (!PyArg_ParseTuple(args,(char *)"OO:LorentzPeakShape_evaluate",&obj0,&obj1)) SWIG_fail;
+  if (!PyArg_ParseTuple(args,(char *)"OOO:LorentzPeakShape_evaluate",&obj0,&obj1,&obj2)) SWIG_fail;
   res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_LorentzPeakShape, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
     SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "LorentzPeakShape_evaluate" "', argument " "1"" of type '" "LorentzPeakShape const *""'"); 
@@ -87845,7 +87883,20 @@ SWIGINTERN PyObject *_wrap_LorentzPeakShape_evaluate(PyObject *SWIGUNUSEDPARM(se
       if (SWIG_IsNewObj(res2)) delete temp;
     }
   }
-  result = (double)((LorentzPeakShape const *)arg1)->evaluate(arg2);
+  {
+    res3 = SWIG_ConvertPtr(obj2, &argp3, SWIGTYPE_p_BasicVector3DT_double_t,  0  | 0);
+    if (!SWIG_IsOK(res3)) {
+      SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "LorentzPeakShape_evaluate" "', argument " "3"" of type '" "kvector_t const""'"); 
+    }  
+    if (!argp3) {
+      SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "LorentzPeakShape_evaluate" "', argument " "3"" of type '" "kvector_t const""'");
+    } else {
+      kvector_t * temp = reinterpret_cast< kvector_t * >(argp3);
+      arg3 = *temp;
+      if (SWIG_IsNewObj(res3)) delete temp;
+    }
+  }
+  result = (double)((LorentzPeakShape const *)arg1)->evaluate(arg2,arg3);
   resultobj = SWIG_From_double(static_cast< double >(result));
   return resultobj;
 fail:
@@ -127068,7 +127119,7 @@ static PyMethodDef SwigMethods[] = {
 		"\n"
 		""},
 	 { (char *)"IPeakShape_evaluate", _wrap_IPeakShape_evaluate, METH_VARARGS, (char *)"\n"
-		"IPeakShape_evaluate(IPeakShape self, kvector_t q) -> double\n"
+		"IPeakShape_evaluate(IPeakShape self, kvector_t q, kvector_t q_lattice_point) -> double\n"
 		"\n"
 		"virtual double IPeakShape::evaluate(const kvector_t q) const =0\n"
 		"\n"
@@ -127105,7 +127156,7 @@ static PyMethodDef SwigMethods[] = {
 		"\n"
 		""},
 	 { (char *)"GaussPeakShape_evaluate", _wrap_GaussPeakShape_evaluate, METH_VARARGS, (char *)"\n"
-		"GaussPeakShape_evaluate(GaussPeakShape self, kvector_t q) -> double\n"
+		"GaussPeakShape_evaluate(GaussPeakShape self, kvector_t q, kvector_t q_lattice_point) -> double\n"
 		"\n"
 		"double GaussPeakShape::evaluate(const kvector_t q) const override\n"
 		"\n"
@@ -127132,7 +127183,7 @@ static PyMethodDef SwigMethods[] = {
 		"\n"
 		""},
 	 { (char *)"LorentzPeakShape_evaluate", _wrap_LorentzPeakShape_evaluate, METH_VARARGS, (char *)"\n"
-		"LorentzPeakShape_evaluate(LorentzPeakShape self, kvector_t q) -> double\n"
+		"LorentzPeakShape_evaluate(LorentzPeakShape self, kvector_t q, kvector_t q_lattice_point) -> double\n"
 		"\n"
 		"virtual double IPeakShape::evaluate(const kvector_t q) const =0\n"
 		"\n"
-- 
GitLab