From 7ff46b96da87af75d999d89b1b0db37d8ed4c7fd Mon Sep 17 00:00:00 2001
From: "Joachim Wuttke (h)" <j.wuttke@fz-juelich.de>
Date: Fri, 14 Aug 2020 22:20:46 +0200
Subject: [PATCH] mv Integrator to cpp files

---
 Core/Aggregate/IInterferenceFunction.cpp      |  2 -
 Core/Aggregate/IInterferenceFunction.h        |  5 +-
 .../InterferenceFunction2DLattice.cpp         |  5 +-
 .../Aggregate/InterferenceFunction2DLattice.h |  2 -
 .../InterferenceFunction2DParaCrystal.cpp     |  5 +-
 .../InterferenceFunction2DParaCrystal.h       |  2 -
 .../InterferenceFunction2DSuperLattice.cpp    |  5 +-
 .../InterferenceFunction2DSuperLattice.h      |  2 -
 .../InterferenceFunctionFinite2DLattice.cpp   |  5 +-
 .../InterferenceFunctionFinite2DLattice.h     |  2 -
 .../InterferenceFunctionHardDisk.cpp          |  3 +-
 Core/Aggregate/InterferenceFunctionHardDisk.h |  2 -
 Core/Correlations/FTDistributions2D.cpp       |  3 +-
 Core/Correlations/FTDistributions2D.h         |  4 --
 Core/Correlations/IPeakShape.cpp              | 10 ++--
 Core/Correlations/IPeakShape.h                |  3 --
 Core/HardParticle/FormFactorCone.cpp          |  3 +-
 Core/HardParticle/FormFactorCone.h            |  2 -
 Core/HardParticle/FormFactorHemiEllipsoid.cpp |  3 +-
 Core/HardParticle/FormFactorHemiEllipsoid.h   |  2 -
 .../FormFactorTruncatedSphere.cpp             |  5 +-
 Core/HardParticle/FormFactorTruncatedSphere.h |  2 -
 .../FormFactorTruncatedSpheroid.cpp           |  5 +-
 .../FormFactorTruncatedSpheroid.h             |  2 -
 Core/Intensity/SimpleUnitConverters.cpp       |  2 +-
 auto/Wrap/libBornAgainCore.py                 |  2 +-
 auto/Wrap/libBornAgainCore_wrap.cpp           | 54 +++++++++----------
 27 files changed, 62 insertions(+), 80 deletions(-)

diff --git a/Core/Aggregate/IInterferenceFunction.cpp b/Core/Aggregate/IInterferenceFunction.cpp
index 4e31f7ed11c..ad8bc3cab94 100644
--- a/Core/Aggregate/IInterferenceFunction.cpp
+++ b/Core/Aggregate/IInterferenceFunction.cpp
@@ -29,8 +29,6 @@ IInterferenceFunction::IInterferenceFunction(double position_var) : m_position_v
     registerParameter("PositionVariance", &m_position_var).setUnit("nm^2").setNonnegative();
 }
 
-IInterferenceFunction::~IInterferenceFunction() = default;
-
 // Default implementation of evaluate assumes no inner structure
 // It is only to be overriden in case of the presence of such inner structure. See for example
 // InterferenceFunction2DSuperLattice for such a case.
diff --git a/Core/Aggregate/IInterferenceFunction.h b/Core/Aggregate/IInterferenceFunction.h
index 2657a08b7d8..a18434af142 100644
--- a/Core/Aggregate/IInterferenceFunction.h
+++ b/Core/Aggregate/IInterferenceFunction.h
@@ -26,7 +26,6 @@ class BA_CORE_API_ IInterferenceFunction : public ISample
 public:
     IInterferenceFunction(const NodeMeta& meta, const std::vector<double>& PValues);
     IInterferenceFunction(double position_var);
-    virtual ~IInterferenceFunction();
 
     virtual IInterferenceFunction* clone() const = 0;
 
@@ -51,13 +50,13 @@ public:
     double DWfactor(kvector_t q) const;
 
 protected:
+    double m_position_var;
+
     //! Calculates the structure factor in the absence of extra inner structure
     double iff_no_inner(const kvector_t q, double outer_iff) const;
 
     //! Calculates the structure factor without Debye-Waller factor
     virtual double iff_without_dw(const kvector_t q) const = 0;
-
-    double m_position_var;
 };
 
 #endif // BORNAGAIN_CORE_AGGREGATE_IINTERFERENCEFUNCTION_H
diff --git a/Core/Aggregate/InterferenceFunction2DLattice.cpp b/Core/Aggregate/InterferenceFunction2DLattice.cpp
index 6877abaef10..1c16d41a6f0 100644
--- a/Core/Aggregate/InterferenceFunction2DLattice.cpp
+++ b/Core/Aggregate/InterferenceFunction2DLattice.cpp
@@ -16,6 +16,7 @@
 #include "Core/Basics/Exceptions.h"
 #include "Core/Basics/MathConstants.h"
 #include "Core/Parametrization/RealParameter.h"
+#include "Core/Tools/Integrator.h"
 #include <algorithm>
 
 namespace
@@ -123,8 +124,8 @@ double InterferenceFunction2DLattice::iff_without_dw(const kvector_t q) const
     m_qy = q.y();
     if (!m_integrate_xi)
         return interferenceForXi(m_lattice->rotationAngle());
-    return m_integrator.integrate([&](double xi) -> double { return interferenceForXi(xi); }, 0.0,
-                                  M_TWOPI)
+    return RealIntegrator().integrate([&](double xi) -> double { return interferenceForXi(xi); },
+                                      0.0, M_TWOPI)
            / M_TWOPI;
 }
 
diff --git a/Core/Aggregate/InterferenceFunction2DLattice.h b/Core/Aggregate/InterferenceFunction2DLattice.h
index a86dd8c6cdc..b6c9cbdf576 100644
--- a/Core/Aggregate/InterferenceFunction2DLattice.h
+++ b/Core/Aggregate/InterferenceFunction2DLattice.h
@@ -19,7 +19,6 @@
 #include "Core/Correlations/FTDecay1D.h"
 #include "Core/Correlations/FTDecay2D.h"
 #include "Core/Lattice/Lattice2D.h"
-#include "Core/Tools/Integrator.h"
 
 //! Interference function of a 2D lattice.
 //! @ingroup interference
@@ -82,7 +81,6 @@ private:
     int m_na, m_nb; //!< determines the number of reciprocal lattice points to use
     mutable double m_qx;
     mutable double m_qy;
-    mutable RealIntegrator m_integrator;
 };
 
 #endif // BORNAGAIN_CORE_AGGREGATE_INTERFERENCEFUNCTION2DLATTICE_H
diff --git a/Core/Aggregate/InterferenceFunction2DParaCrystal.cpp b/Core/Aggregate/InterferenceFunction2DParaCrystal.cpp
index ce1c267879a..fd46adaea82 100644
--- a/Core/Aggregate/InterferenceFunction2DParaCrystal.cpp
+++ b/Core/Aggregate/InterferenceFunction2DParaCrystal.cpp
@@ -17,6 +17,7 @@
 #include "Core/Basics/MathConstants.h"
 #include "Core/Parametrization/ParameterPool.h"
 #include "Core/Parametrization/RealParameter.h"
+#include "Core/Tools/Integrator.h"
 #include <limits>
 
 InterferenceFunction2DParaCrystal::InterferenceFunction2DParaCrystal(const Lattice2D& lattice,
@@ -100,8 +101,8 @@ double InterferenceFunction2DParaCrystal::iff_without_dw(const kvector_t q) cons
     m_qy = q.y();
     if (!m_integrate_xi)
         return interferenceForXi(m_lattice->rotationAngle());
-    return m_integrator.integrate([&](double xi) -> double { return interferenceForXi(xi); }, 0.0,
-                                  M_TWOPI)
+    return RealIntegrator().integrate([&](double xi) -> double { return interferenceForXi(xi); },
+                                      0.0, M_TWOPI)
            / M_TWOPI;
 }
 
diff --git a/Core/Aggregate/InterferenceFunction2DParaCrystal.h b/Core/Aggregate/InterferenceFunction2DParaCrystal.h
index 5739bb0f7b0..ce7cf10f7a6 100644
--- a/Core/Aggregate/InterferenceFunction2DParaCrystal.h
+++ b/Core/Aggregate/InterferenceFunction2DParaCrystal.h
@@ -19,7 +19,6 @@
 #include "Core/Basics/Complex.h"
 #include "Core/Correlations/FTDistributions2D.h"
 #include "Core/Lattice/Lattice2D.h"
-#include "Core/Tools/Integrator.h"
 #include <memory>
 
 class IFTDistribution2D;
@@ -91,7 +90,6 @@ private:
     double m_domain_sizes[2]; //!< Coherence domain sizes
     mutable double m_qx;
     mutable double m_qy;
-    mutable RealIntegrator m_integrator;
 };
 
 #endif // BORNAGAIN_CORE_AGGREGATE_INTERFERENCEFUNCTION2DPARACRYSTAL_H
diff --git a/Core/Aggregate/InterferenceFunction2DSuperLattice.cpp b/Core/Aggregate/InterferenceFunction2DSuperLattice.cpp
index 8a94239dc68..b925b1753ad 100644
--- a/Core/Aggregate/InterferenceFunction2DSuperLattice.cpp
+++ b/Core/Aggregate/InterferenceFunction2DSuperLattice.cpp
@@ -17,6 +17,7 @@
 #include "Core/Basics/Exceptions.h"
 #include "Core/Basics/MathConstants.h"
 #include "Core/Parametrization/RealParameter.h"
+#include "Core/Tools/Integrator.h"
 #include "Core/Tools/MathFunctions.h"
 
 #include <limits>
@@ -95,8 +96,8 @@ double InterferenceFunction2DSuperLattice::evaluate(const kvector_t q, double ou
     m_qy = q.y();
     if (!m_integrate_xi)
         return interferenceForXi(mP_lattice->rotationAngle());
-    return m_integrator.integrate([&](double xi) -> double { return interferenceForXi(xi); }, 0.0,
-                                  M_TWOPI)
+    return RealIntegrator().integrate([&](double xi) -> double { return interferenceForXi(xi); },
+                                      0.0, M_TWOPI)
            / M_TWOPI;
 }
 
diff --git a/Core/Aggregate/InterferenceFunction2DSuperLattice.h b/Core/Aggregate/InterferenceFunction2DSuperLattice.h
index 85b4b102c67..aadaceb843e 100644
--- a/Core/Aggregate/InterferenceFunction2DSuperLattice.h
+++ b/Core/Aggregate/InterferenceFunction2DSuperLattice.h
@@ -17,7 +17,6 @@
 
 #include "Core/Aggregate/IInterferenceFunction.h"
 #include "Core/Lattice/Lattice2D.h"
-#include "Core/Tools/Integrator.h"
 
 //! Interference function of a 2D superlattice with a configurable interference function for
 //! each lattice site.
@@ -68,7 +67,6 @@ private:
     mutable double m_qx;
     mutable double m_qy;
     mutable double m_xi;
-    mutable RealIntegrator m_integrator;
 };
 
 #endif // BORNAGAIN_CORE_AGGREGATE_INTERFERENCEFUNCTION2DSUPERLATTICE_H
diff --git a/Core/Aggregate/InterferenceFunctionFinite2DLattice.cpp b/Core/Aggregate/InterferenceFunctionFinite2DLattice.cpp
index 095b3e3c832..d68a86f7d7c 100644
--- a/Core/Aggregate/InterferenceFunctionFinite2DLattice.cpp
+++ b/Core/Aggregate/InterferenceFunctionFinite2DLattice.cpp
@@ -16,6 +16,7 @@
 #include "Core/Basics/Exceptions.h"
 #include "Core/Basics/MathConstants.h"
 #include "Core/Parametrization/RealParameter.h"
+#include "Core/Tools/Integrator.h"
 #include "Core/Tools/MathFunctions.h"
 
 #include <limits>
@@ -114,8 +115,8 @@ double InterferenceFunctionFinite2DLattice::iff_without_dw(const kvector_t q) co
     m_qy = q.y();
     if (!m_integrate_xi)
         return interferenceForXi(mP_lattice->rotationAngle());
-    return m_integrator.integrate([&](double xi) -> double { return interferenceForXi(xi); }, 0.0,
-                                  M_TWOPI)
+    return RealIntegrator().integrate([&](double xi) -> double { return interferenceForXi(xi); },
+                                      0.0, M_TWOPI)
            / M_TWOPI;
 }
 
diff --git a/Core/Aggregate/InterferenceFunctionFinite2DLattice.h b/Core/Aggregate/InterferenceFunctionFinite2DLattice.h
index 2563802c67f..dcae005653b 100644
--- a/Core/Aggregate/InterferenceFunctionFinite2DLattice.h
+++ b/Core/Aggregate/InterferenceFunctionFinite2DLattice.h
@@ -17,7 +17,6 @@
 
 #include "Core/Aggregate/IInterferenceFunction.h"
 #include "Core/Lattice/Lattice2D.h"
-#include "Core/Tools/Integrator.h"
 
 //! Interference function of a finite 2D lattice.
 //! @ingroup interference
@@ -63,7 +62,6 @@ private:
     unsigned m_N_1, m_N_2; //!< Size of the finite lattice in lattice units
     mutable double m_qx;
     mutable double m_qy;
-    mutable RealIntegrator m_integrator;
 };
 
 #endif // BORNAGAIN_CORE_AGGREGATE_INTERFERENCEFUNCTIONFINITE2DLATTICE_H
diff --git a/Core/Aggregate/InterferenceFunctionHardDisk.cpp b/Core/Aggregate/InterferenceFunctionHardDisk.cpp
index fc1f769dcde..56948d53d45 100644
--- a/Core/Aggregate/InterferenceFunctionHardDisk.cpp
+++ b/Core/Aggregate/InterferenceFunctionHardDisk.cpp
@@ -14,6 +14,7 @@
 
 #include "Core/Aggregate/InterferenceFunctionHardDisk.h"
 #include "Core/Parametrization/RealParameter.h"
+#include "Core/Tools/Integrator.h"
 #include "Core/Tools/MathFunctions.h"
 #include <cmath>
 
@@ -69,7 +70,7 @@ double InterferenceFunctionHardDisk::iff_without_dw(const kvector_t q) const
     m_s2 = S2(m_packing);
     double c_q =
         2.0 * M_PI
-        * m_integrator.integrate([&](double x) -> double { return integrand(x); }, 0.0, 1.0);
+        * RealIntegrator().integrate([&](double x) -> double { return integrand(x); }, 0.0, 1.0);
     double rho = 4.0 * m_packing / M_PI;
     return 1.0 / (1.0 - rho * c_q);
 }
diff --git a/Core/Aggregate/InterferenceFunctionHardDisk.h b/Core/Aggregate/InterferenceFunctionHardDisk.h
index 3845affa62e..18c5b38dddc 100644
--- a/Core/Aggregate/InterferenceFunctionHardDisk.h
+++ b/Core/Aggregate/InterferenceFunctionHardDisk.h
@@ -16,7 +16,6 @@
 #define BORNAGAIN_CORE_AGGREGATE_INTERFERENCEFUNCTIONHARDDISK_H
 
 #include "Core/Aggregate/IInterferenceFunction.h"
-#include "Core/Tools/Integrator.h"
 
 //! Percus-Yevick hard disk interference function.
 //!
@@ -49,7 +48,6 @@ private:
     double m_density;
 
     mutable double m_q, m_c_zero, m_s2, m_packing;
-    mutable RealIntegrator m_integrator;
 };
 
 #endif // BORNAGAIN_CORE_AGGREGATE_INTERFERENCEFUNCTIONHARDDISK_H
diff --git a/Core/Correlations/FTDistributions2D.cpp b/Core/Correlations/FTDistributions2D.cpp
index 6c7d334f522..8f0b8d942c2 100644
--- a/Core/Correlations/FTDistributions2D.cpp
+++ b/Core/Correlations/FTDistributions2D.cpp
@@ -16,6 +16,7 @@
 #include "Core/Basics/Algorithms.h"
 #include "Core/Basics/Exceptions.h"
 #include "Core/Basics/MathConstants.h"
+#include "Core/Tools/Integrator.h"
 #include "Core/Tools/MathFunctions.h"
 #include <limits>
 
@@ -155,7 +156,7 @@ double FTDistribution2DCone::evaluate(double qx, double qy) const
     if (scaled_q < std::numeric_limits<double>::epsilon())
         return 1.0 - 3.0 * scaled_q * scaled_q / 40.0;
     // second part of the integrand: \f$u^2\cdot J_0(u)\f$
-    double integral = m_integrator.integrate(
+    double integral = RealIntegrator().integrate(
         [](double x) -> double { return x * x * MathFunctions::Bessel_J0(x); }, 0.0, scaled_q);
     return 6.0 * (MathFunctions::Bessel_J1c(scaled_q) - integral / scaled_q / scaled_q / scaled_q);
 }
diff --git a/Core/Correlations/FTDistributions2D.h b/Core/Correlations/FTDistributions2D.h
index b9af89f7d0f..3e782e12f42 100644
--- a/Core/Correlations/FTDistributions2D.h
+++ b/Core/Correlations/FTDistributions2D.h
@@ -19,7 +19,6 @@
 #include "Core/Basics/MathConstants.h"
 #include "Core/Correlations/IDistribution2DSampler.h"
 #include "Core/Parametrization/INode.h"
-#include "Core/Tools/Integrator.h"
 
 //! Interface for two-dimensional distributions in Fourier space.
 //! @ingroup distribution_internal
@@ -129,9 +128,6 @@ public:
 #ifndef SWIG
     std::unique_ptr<IDistribution2DSampler> createSampler() const final;
 #endif
-
-private:
-    mutable RealIntegrator m_integrator;
 };
 
 //! Two-dimensional Voigt distribution in Fourier space;
diff --git a/Core/Correlations/IPeakShape.cpp b/Core/Correlations/IPeakShape.cpp
index 2104274ebd7..af0d83456a2 100644
--- a/Core/Correlations/IPeakShape.cpp
+++ b/Core/Correlations/IPeakShape.cpp
@@ -14,8 +14,8 @@
 
 #include "Core/Correlations/IPeakShape.h"
 #include "Core/Basics/MathConstants.h"
+#include "Core/Tools/Integrator.h"
 #include "Core/Tools/MathFunctions.h"
-
 #include <limits>
 
 namespace
@@ -252,8 +252,8 @@ double MisesFisherGaussPeakShape::evaluate(const kvector_t q, const kvector_t q_
     m_theta = std::acos(q.unit().dot(m_zenith));
     double pre_1 = FisherPrefactor(m_kappa_1);
     double pre_2 = MisesPrefactor(m_kappa_2);
-    double integral =
-        m_integrator.integrate([&](double phi) -> double { return integrand(phi); }, 0.0, M_TWOPI);
+    double integral = RealIntegrator().integrate(
+        [&](double phi) -> double { return integrand(phi); }, 0.0, M_TWOPI);
     return m_max_intensity * radial_part * pre_1 * pre_2 * integral;
 }
 
@@ -300,8 +300,8 @@ double MisesGaussPeakShape::evaluate(const kvector_t q, const kvector_t q_lattic
     m_phi = std::acos(q_ortho.unit().dot(m_ux));
     m_theta = std::acos(q.unit().dot(m_zenith));
     double pre = MisesPrefactor(m_kappa);
-    double integral =
-        m_integrator.integrate([&](double phi) -> double { return integrand(phi); }, 0.0, M_TWOPI);
+    double integral = RealIntegrator().integrate(
+        [&](double phi) -> double { return integrand(phi); }, 0.0, M_TWOPI);
     return m_max_intensity * pre * integral;
 }
 
diff --git a/Core/Correlations/IPeakShape.h b/Core/Correlations/IPeakShape.h
index 0067487823f..1f7eb7f5c43 100644
--- a/Core/Correlations/IPeakShape.h
+++ b/Core/Correlations/IPeakShape.h
@@ -16,7 +16,6 @@
 #define BORNAGAIN_CORE_CORRELATIONS_IPEAKSHAPE_H
 
 #include "Core/Scattering/ISample.h"
-#include "Core/Tools/Integrator.h"
 #include "Core/Vector/Vectors3D.h"
 
 //! Pure virtual interface class that defines the peak shape of a Bragg peak.
@@ -164,7 +163,6 @@ private:
     double m_kappa_1, m_kappa_2;
     mutable double m_theta, m_phi;
     mutable kvector_t m_ux, m_uy, m_up;
-    mutable RealIntegrator m_integrator;
 };
 
 //! Class that implements a peak shape that is a convolution of a Mises-Fisher distribution
@@ -194,7 +192,6 @@ private:
     double m_kappa;
     mutable double m_theta, m_phi, m_qr;
     mutable kvector_t m_ux, m_uy, m_p;
-    mutable RealIntegrator m_integrator;
 };
 
 #endif // BORNAGAIN_CORE_CORRELATIONS_IPEAKSHAPE_H
diff --git a/Core/HardParticle/FormFactorCone.cpp b/Core/HardParticle/FormFactorCone.cpp
index 3959d13a924..77474e7a463 100644
--- a/Core/HardParticle/FormFactorCone.cpp
+++ b/Core/HardParticle/FormFactorCone.cpp
@@ -16,6 +16,7 @@
 #include "Core/Basics/Exceptions.h"
 #include "Core/Basics/MathConstants.h"
 #include "Core/Shapes/DoubleEllipse.h"
+#include "Core/Tools/Integrator.h"
 #include "Core/Tools/MathFunctions.h"
 #include <limits>
 
@@ -73,7 +74,7 @@ complex_t FormFactorCone::evaluate_for_q(cvector_t q) const
         return M_PI / 3. * (R * R * H + (R * R - R2 * R2) * (apex_height - H));
     } else {
         complex_t integral =
-            m_integrator.integrate([&](double Z) { return Integrand(Z); }, 0., m_height);
+            ComplexIntegrator().integrate([&](double Z) { return Integrand(Z); }, 0., m_height);
         return M_TWOPI * integral;
     }
 }
diff --git a/Core/HardParticle/FormFactorCone.h b/Core/HardParticle/FormFactorCone.h
index 73913a44030..ff8b31ada3d 100644
--- a/Core/HardParticle/FormFactorCone.h
+++ b/Core/HardParticle/FormFactorCone.h
@@ -16,7 +16,6 @@
 #define BORNAGAIN_CORE_HARDPARTICLE_FORMFACTORCONE_H
 
 #include "Core/Scattering/IFormFactorBorn.h"
-#include "Core/Tools/Integrator.h"
 
 //! A conical frustum (cone truncated parallel to the base) with circular base.
 //! @ingroup hardParticle
@@ -55,7 +54,6 @@ private:
     const double& m_alpha;
     double m_cot_alpha;
     mutable cvector_t m_q;
-    mutable ComplexIntegrator m_integrator;
 };
 
 #endif // BORNAGAIN_CORE_HARDPARTICLE_FORMFACTORCONE_H
diff --git a/Core/HardParticle/FormFactorHemiEllipsoid.cpp b/Core/HardParticle/FormFactorHemiEllipsoid.cpp
index 49875b55019..ee73ec817ff 100644
--- a/Core/HardParticle/FormFactorHemiEllipsoid.cpp
+++ b/Core/HardParticle/FormFactorHemiEllipsoid.cpp
@@ -15,6 +15,7 @@
 #include "Core/HardParticle/FormFactorHemiEllipsoid.h"
 #include "Core/Basics/MathConstants.h"
 #include "Core/Shapes/TruncatedEllipsoid.h"
+#include "Core/Tools/Integrator.h"
 #include "Core/Tools/MathFunctions.h"
 #include <limits>
 
@@ -72,7 +73,7 @@ complex_t FormFactorHemiEllipsoid::evaluate_for_q(cvector_t q) const
 
     if (std::abs(m_q.mag()) <= std::numeric_limits<double>::epsilon())
         return M_TWOPI * R * W * H / 3.;
-    return M_TWOPI * m_integrator.integrate([&](double Z) { return Integrand(Z); }, 0., H);
+    return M_TWOPI * ComplexIntegrator().integrate([&](double Z) { return Integrand(Z); }, 0., H);
 }
 
 void FormFactorHemiEllipsoid::onChange()
diff --git a/Core/HardParticle/FormFactorHemiEllipsoid.h b/Core/HardParticle/FormFactorHemiEllipsoid.h
index e3fdaef86a8..7453c429dea 100644
--- a/Core/HardParticle/FormFactorHemiEllipsoid.h
+++ b/Core/HardParticle/FormFactorHemiEllipsoid.h
@@ -16,7 +16,6 @@
 #define BORNAGAIN_CORE_HARDPARTICLE_FORMFACTORHEMIELLIPSOID_H
 
 #include "Core/Scattering/IFormFactorBorn.h"
-#include "Core/Tools/Integrator.h"
 
 //! An hemi ellipsoid,
 //!   obtained by truncating a full ellipsoid in the middle plane spanned by two principal axes.
@@ -53,7 +52,6 @@ private:
     const double& m_radius_y;
     const double& m_height;
     mutable cvector_t m_q;
-    mutable ComplexIntegrator m_integrator;
 };
 
 #endif // BORNAGAIN_CORE_HARDPARTICLE_FORMFACTORHEMIELLIPSOID_H
diff --git a/Core/HardParticle/FormFactorTruncatedSphere.cpp b/Core/HardParticle/FormFactorTruncatedSphere.cpp
index a09bd3b4338..0bbec494e35 100644
--- a/Core/HardParticle/FormFactorTruncatedSphere.cpp
+++ b/Core/HardParticle/FormFactorTruncatedSphere.cpp
@@ -16,6 +16,7 @@
 #include "Core/Basics/Exceptions.h"
 #include "Core/Basics/MathConstants.h"
 #include "Core/Shapes/TruncatedEllipsoid.h"
+#include "Core/Tools/Integrator.h"
 #include "Core/Tools/MathFunctions.h"
 #include "Fit/Tools/RealLimits.h"
 #include <limits>
@@ -76,8 +77,8 @@ complex_t FormFactorTruncatedSphere::evaluate_for_q(cvector_t q) const
                   - m_dh * m_dh * (3. * m_radius - m_dh));
     }
     // else
-    complex_t integral = m_integrator.integrate([&](double Z) { return Integrand(Z); },
-                                                m_radius - m_height, m_radius - m_dh);
+    complex_t integral = ComplexIntegrator().integrate([&](double Z) { return Integrand(Z); },
+                                                       m_radius - m_height, m_radius - m_dh);
     return M_TWOPI * integral * exp_I(q.z() * (m_height - m_radius));
 }
 
diff --git a/Core/HardParticle/FormFactorTruncatedSphere.h b/Core/HardParticle/FormFactorTruncatedSphere.h
index a646b509347..aaab6b54cd4 100644
--- a/Core/HardParticle/FormFactorTruncatedSphere.h
+++ b/Core/HardParticle/FormFactorTruncatedSphere.h
@@ -16,7 +16,6 @@
 #define BORNAGAIN_CORE_HARDPARTICLE_FORMFACTORTRUNCATEDSPHERE_H
 
 #include "Core/Scattering/IFormFactorBorn.h"
-#include "Core/Tools/Integrator.h"
 
 //! A truncated Sphere.
 //! @ingroup hardParticle
@@ -55,7 +54,6 @@ private:
     const double& m_height;
     const double& m_dh;
     mutable cvector_t m_q;
-    mutable ComplexIntegrator m_integrator;
 };
 
 #endif // BORNAGAIN_CORE_HARDPARTICLE_FORMFACTORTRUNCATEDSPHERE_H
diff --git a/Core/HardParticle/FormFactorTruncatedSpheroid.cpp b/Core/HardParticle/FormFactorTruncatedSpheroid.cpp
index 561b14d73cb..b7e93ff2092 100644
--- a/Core/HardParticle/FormFactorTruncatedSpheroid.cpp
+++ b/Core/HardParticle/FormFactorTruncatedSpheroid.cpp
@@ -16,6 +16,7 @@
 #include "Core/Basics/Exceptions.h"
 #include "Core/Basics/MathConstants.h"
 #include "Core/Shapes/TruncatedEllipsoid.h"
+#include "Core/Tools/Integrator.h"
 #include "Core/Tools/MathFunctions.h"
 #include <limits>
 
@@ -83,8 +84,8 @@ complex_t FormFactorTruncatedSpheroid::evaluate_for_q(cvector_t q) const
         return M_PI / 3. / fp * (H * H * (3. * R - H / fp) - m_dh * m_dh * (3. * R - m_dh / fp));
     complex_t z_part = std::exp(complex_t(0.0, 1.0) * m_q.z() * (H - fp * R));
     return M_TWOPI * z_part
-           * m_integrator.integrate([&](double Z) { return Integrand(Z); }, fp * R - H,
-                                    fp * R - m_dh);
+           * ComplexIntegrator().integrate([&](double Z) { return Integrand(Z); }, fp * R - H,
+                                           fp * R - m_dh);
 }
 
 IFormFactor* FormFactorTruncatedSpheroid::sliceFormFactor(ZLimits limits, const IRotation& rot,
diff --git a/Core/HardParticle/FormFactorTruncatedSpheroid.h b/Core/HardParticle/FormFactorTruncatedSpheroid.h
index 7b3e449efe0..887fa7a8ae2 100644
--- a/Core/HardParticle/FormFactorTruncatedSpheroid.h
+++ b/Core/HardParticle/FormFactorTruncatedSpheroid.h
@@ -16,7 +16,6 @@
 #define BORNAGAIN_CORE_HARDPARTICLE_FORMFACTORTRUNCATEDSPHEROID_H
 
 #include "Core/Scattering/IFormFactorBorn.h"
-#include "Core/Tools/Integrator.h"
 
 //! A truncated spheroid.
 //! An ellipsoid with two equal axis, truncated by a plane perpendicular to the third axis.
@@ -58,7 +57,6 @@ private:
     const double& m_height_flattening;
     const double& m_dh;
     mutable cvector_t m_q;
-    mutable ComplexIntegrator m_integrator;
 };
 
 #endif // BORNAGAIN_CORE_HARDPARTICLE_FORMFACTORTRUNCATEDSPHEROID_H
diff --git a/Core/Intensity/SimpleUnitConverters.cpp b/Core/Intensity/SimpleUnitConverters.cpp
index 85de14fef2a..e3238c2d5f0 100644
--- a/Core/Intensity/SimpleUnitConverters.cpp
+++ b/Core/Intensity/SimpleUnitConverters.cpp
@@ -17,9 +17,9 @@
 #include "Core/Basics/Units.h"
 #include "Core/Beam/Beam.h"
 #include "Core/Detector/RectangularDetector.h"
+#include "Core/Detector/RectangularPixel.h"
 #include "Core/Detector/RegionOfInterest.h"
 #include "Core/Detector/SphericalDetector.h"
-#include "Core/Detector/RectangularPixel.h"
 #include "Core/Intensity/AxisNames.h"
 #include <algorithm>
 #include <cmath>
diff --git a/auto/Wrap/libBornAgainCore.py b/auto/Wrap/libBornAgainCore.py
index cd73caeeba0..0cf0c748d5d 100644
--- a/auto/Wrap/libBornAgainCore.py
+++ b/auto/Wrap/libBornAgainCore.py
@@ -12116,7 +12116,6 @@ class IInterferenceFunction(ISample):
         else:
             _self = self
         _libBornAgainCore.IInterferenceFunction_swiginit(self, _libBornAgainCore.new_IInterferenceFunction(_self, *args))
-    __swig_destroy__ = _libBornAgainCore.delete_IInterferenceFunction
 
     def clone(self):
         r"""
@@ -12191,6 +12190,7 @@ class IInterferenceFunction(ISample):
     def iff_without_dw(self, q):
         r"""iff_without_dw(IInterferenceFunction self, kvector_t q) -> double"""
         return _libBornAgainCore.IInterferenceFunction_iff_without_dw(self, q)
+    __swig_destroy__ = _libBornAgainCore.delete_IInterferenceFunction
     def __disown__(self):
         self.this.disown()
         _libBornAgainCore.disown_IInterferenceFunction(self)
diff --git a/auto/Wrap/libBornAgainCore_wrap.cpp b/auto/Wrap/libBornAgainCore_wrap.cpp
index ee57d5406db..c65e2a55c3d 100644
--- a/auto/Wrap/libBornAgainCore_wrap.cpp
+++ b/auto/Wrap/libBornAgainCore_wrap.cpp
@@ -82450,28 +82450,6 @@ fail:
 }
 
 
-SWIGINTERN PyObject *_wrap_delete_IInterferenceFunction(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
-  PyObject *resultobj = 0;
-  IInterferenceFunction *arg1 = (IInterferenceFunction *) 0 ;
-  void *argp1 = 0 ;
-  int res1 = 0 ;
-  PyObject *swig_obj[1] ;
-  
-  if (!args) SWIG_fail;
-  swig_obj[0] = args;
-  res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_IInterferenceFunction, SWIG_POINTER_DISOWN |  0 );
-  if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_IInterferenceFunction" "', argument " "1"" of type '" "IInterferenceFunction *""'"); 
-  }
-  arg1 = reinterpret_cast< IInterferenceFunction * >(argp1);
-  delete arg1;
-  resultobj = SWIG_Py_Void();
-  return resultobj;
-fail:
-  return NULL;
-}
-
-
 SWIGINTERN PyObject *_wrap_IInterferenceFunction_clone(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
   IInterferenceFunction *arg1 = (IInterferenceFunction *) 0 ;
@@ -82888,6 +82866,28 @@ fail:
 }
 
 
+SWIGINTERN PyObject *_wrap_delete_IInterferenceFunction(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  IInterferenceFunction *arg1 = (IInterferenceFunction *) 0 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  PyObject *swig_obj[1] ;
+  
+  if (!args) SWIG_fail;
+  swig_obj[0] = args;
+  res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_IInterferenceFunction, SWIG_POINTER_DISOWN |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_IInterferenceFunction" "', argument " "1"" of type '" "IInterferenceFunction *""'"); 
+  }
+  arg1 = reinterpret_cast< IInterferenceFunction * >(argp1);
+  delete arg1;
+  resultobj = SWIG_Py_Void();
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
 SWIGINTERN PyObject *_wrap_disown_IInterferenceFunction(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
   IInterferenceFunction *arg1 = (IInterferenceFunction *) 0 ;
@@ -128385,11 +128385,6 @@ static PyMethodDef SwigMethods[] = {
 		"IInterferenceFunction::IInterferenceFunction(const IInterferenceFunction &other)\n"
 		"\n"
 		""},
-	 { "delete_IInterferenceFunction", _wrap_delete_IInterferenceFunction, METH_O, "\n"
-		"delete_IInterferenceFunction(IInterferenceFunction self)\n"
-		"IInterferenceFunction::~IInterferenceFunction()\n"
-		"\n"
-		""},
 	 { "IInterferenceFunction_clone", _wrap_IInterferenceFunction_clone, METH_O, "\n"
 		"IInterferenceFunction_clone(IInterferenceFunction self) -> IInterferenceFunction\n"
 		"virtual IInterferenceFunction* IInterferenceFunction::clone() const =0\n"
@@ -128440,6 +128435,11 @@ static PyMethodDef SwigMethods[] = {
 		"\n"
 		""},
 	 { "IInterferenceFunction_iff_without_dw", _wrap_IInterferenceFunction_iff_without_dw, METH_VARARGS, "IInterferenceFunction_iff_without_dw(IInterferenceFunction self, kvector_t q) -> double"},
+	 { "delete_IInterferenceFunction", _wrap_delete_IInterferenceFunction, METH_O, "\n"
+		"delete_IInterferenceFunction(IInterferenceFunction self)\n"
+		"IInterferenceFunction::~IInterferenceFunction()\n"
+		"\n"
+		""},
 	 { "disown_IInterferenceFunction", _wrap_disown_IInterferenceFunction, METH_O, NULL},
 	 { "IInterferenceFunction_swigregister", IInterferenceFunction_swigregister, METH_O, NULL},
 	 { "IInterferenceFunction_swiginit", IInterferenceFunction_swiginit, METH_VARARGS, NULL},
-- 
GitLab