From 165b38f97cd35be0ef60d9ac86e751dfd586e111 Mon Sep 17 00:00:00 2001 From: "Joachim Wuttke (h)" <j.wuttke@fz-juelich.de> Date: Mon, 21 Dec 2020 13:15:50 +0100 Subject: [PATCH] + fcts ISimulation2D::detector2D() --- Core/Simulation/ISimulation.h | 2 + Core/Simulation/ISimulation2D.cpp | 17 +++ Core/Simulation/ISimulation2D.h | 3 + Device/Instrument/Instrument.cpp | 6 +- Device/Instrument/Instrument.h | 1 + auto/Wrap/doxygenCore.i | 12 ++ auto/Wrap/doxygenDevice.i | 3 + auto/Wrap/libBornAgainCore.py | 18 +++ auto/Wrap/libBornAgainCore_wrap.cpp | 168 ++++++++++++++++++++++++++++ 9 files changed, 229 insertions(+), 1 deletion(-) diff --git a/Core/Simulation/ISimulation.h b/Core/Simulation/ISimulation.h index b7f314ed781..f62f9566f8e 100644 --- a/Core/Simulation/ISimulation.h +++ b/Core/Simulation/ISimulation.h @@ -58,6 +58,8 @@ public: Beam& beam() { return m_instrument.beam(); } const Beam& beam() const { return m_instrument.beam(); } + IDetector* getDetector() { return m_instrument.getDetector(); } + const IDetector* getDetector() const { return m_instrument.getDetector(); } IDetector& detector() { return m_instrument.detector(); } const IDetector& detector() const { return m_instrument.detector(); } diff --git a/Core/Simulation/ISimulation2D.cpp b/Core/Simulation/ISimulation2D.cpp index 44f6bbc62b4..d1b2360e53e 100644 --- a/Core/Simulation/ISimulation2D.cpp +++ b/Core/Simulation/ISimulation2D.cpp @@ -14,6 +14,7 @@ #include "Core/Simulation/ISimulation2D.h" #include "Base/Pixel/SimulationElement.h" +#include "Base/Utils/Assert.h" #include "Core/Computation/DWBAComputation.h" #include "Core/Computation/IBackground.h" #include "Device/Detector/DetectorContext.h" @@ -35,6 +36,22 @@ ISimulation2D::ISimulation2D() = default; ISimulation2D::~ISimulation2D() = default; +IDetector2D& ISimulation2D::detector2D() +{ + ASSERT(getDetector()); + IDetector2D* p = dynamic_cast<IDetector2D*>(getDetector()); + ASSERT(p); + return *p; +} + +const IDetector2D& ISimulation2D::detector2D() const +{ + ASSERT(getDetector()); + const IDetector2D* p = dynamic_cast<const IDetector2D*>(getDetector()); + ASSERT(p); + return *p; +} + void ISimulation2D::prepareSimulation() { ISimulation::prepareSimulation(); diff --git a/Core/Simulation/ISimulation2D.h b/Core/Simulation/ISimulation2D.h index 0d9531aacf4..ea0b8b27724 100644 --- a/Core/Simulation/ISimulation2D.h +++ b/Core/Simulation/ISimulation2D.h @@ -35,6 +35,9 @@ public: ISimulation2D* clone() const override = 0; + IDetector2D& detector2D(); + const IDetector2D& detector2D() const; + //! Put into a clean state for running a simulation void prepareSimulation() override; diff --git a/Device/Instrument/Instrument.cpp b/Device/Instrument/Instrument.cpp index 3fc7007725e..aa6369dfd69 100644 --- a/Device/Instrument/Instrument.cpp +++ b/Device/Instrument/Instrument.cpp @@ -90,7 +90,11 @@ void Instrument::setBeam(const Beam& beam) const IDetector* Instrument::getDetector() const { - ASSERT(m_detector); + return m_detector.get(); +} + +IDetector* Instrument::getDetector() +{ return m_detector.get(); } diff --git a/Device/Instrument/Instrument.h b/Device/Instrument/Instrument.h index 12d4bfd032e..a25fe399822 100644 --- a/Device/Instrument/Instrument.h +++ b/Device/Instrument/Instrument.h @@ -47,6 +47,7 @@ public: //! Sets the beam wavelength and incoming angles void setBeamParameters(double wavelength, double alpha_i, double phi_i); + IDetector* getDetector(); const IDetector* getDetector() const; IDetector& detector(); const IDetector& detector() const; diff --git a/auto/Wrap/doxygenCore.i b/auto/Wrap/doxygenCore.i index 57fb95c8e18..6787901d991 100644 --- a/auto/Wrap/doxygenCore.i +++ b/auto/Wrap/doxygenCore.i @@ -1019,6 +1019,12 @@ Run a simulation in a MPI environment. %feature("docstring") ISimulation::beam "const Beam& ISimulation::beam() const "; +%feature("docstring") ISimulation::getDetector "IDetector* ISimulation::getDetector() +"; + +%feature("docstring") ISimulation::getDetector "const IDetector* ISimulation::getDetector() const +"; + %feature("docstring") ISimulation::detector "IDetector& ISimulation::detector() "; @@ -1124,6 +1130,12 @@ C++ includes: ISimulation2D.h %feature("docstring") ISimulation2D::clone "ISimulation2D* ISimulation2D::clone() const override=0 "; +%feature("docstring") ISimulation2D::detector2D "IDetector2D & ISimulation2D::detector2D() +"; + +%feature("docstring") ISimulation2D::detector2D "const IDetector2D & ISimulation2D::detector2D() const +"; + %feature("docstring") ISimulation2D::prepareSimulation "void ISimulation2D::prepareSimulation() override Put into a clean state for running a simulation. diff --git a/auto/Wrap/doxygenDevice.i b/auto/Wrap/doxygenDevice.i index 0989b7c8ef5..262e941a7f5 100644 --- a/auto/Wrap/doxygenDevice.i +++ b/auto/Wrap/doxygenDevice.i @@ -1340,6 +1340,9 @@ C++ includes: Instrument.h Sets the beam wavelength and incoming angles. "; +%feature("docstring") Instrument::getDetector "IDetector * Instrument::getDetector() +"; + %feature("docstring") Instrument::getDetector "const IDetector * Instrument::getDetector() const "; diff --git a/auto/Wrap/libBornAgainCore.py b/auto/Wrap/libBornAgainCore.py index 5ca93f77cbd..d92e2e5b84c 100644 --- a/auto/Wrap/libBornAgainCore.py +++ b/auto/Wrap/libBornAgainCore.py @@ -3537,6 +3537,15 @@ class ISimulation(libBornAgainBase.ICloneable, libBornAgainParam.INode): """ return _libBornAgainCore.ISimulation_beam(self, *args) + def getDetector(self, *args): + r""" + getDetector(ISimulation self) -> IDetector + getDetector(ISimulation self) -> IDetector const * + const IDetector* ISimulation::getDetector() const + + """ + return _libBornAgainCore.ISimulation_getDetector(self, *args) + def detector(self, *args): r""" detector(ISimulation self) -> IDetector @@ -3729,6 +3738,15 @@ class ISimulation2D(ISimulation): """ return _libBornAgainCore.ISimulation2D_clone(self) + def detector2D(self, *args): + r""" + detector2D(ISimulation2D self) -> IDetector2D + detector2D(ISimulation2D self) -> IDetector2D const & + const IDetector2D & ISimulation2D::detector2D() const + + """ + return _libBornAgainCore.ISimulation2D_detector2D(self, *args) + def prepareSimulation(self): r""" prepareSimulation(ISimulation2D self) diff --git a/auto/Wrap/libBornAgainCore_wrap.cpp b/auto/Wrap/libBornAgainCore_wrap.cpp index ac0b1ad27f4..f3f49be3a41 100644 --- a/auto/Wrap/libBornAgainCore_wrap.cpp +++ b/auto/Wrap/libBornAgainCore_wrap.cpp @@ -39020,6 +39020,84 @@ fail: } +SWIGINTERN PyObject *_wrap_ISimulation_getDetector__SWIG_0(PyObject *SWIGUNUSEDPARM(self), Py_ssize_t nobjs, PyObject **swig_obj) { + PyObject *resultobj = 0; + ISimulation *arg1 = (ISimulation *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + IDetector *result = 0 ; + + if ((nobjs < 1) || (nobjs > 1)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_ISimulation, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ISimulation_getDetector" "', argument " "1"" of type '" "ISimulation *""'"); + } + arg1 = reinterpret_cast< ISimulation * >(argp1); + result = (IDetector *)(arg1)->getDetector(); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_IDetector, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ISimulation_getDetector__SWIG_1(PyObject *SWIGUNUSEDPARM(self), Py_ssize_t nobjs, PyObject **swig_obj) { + PyObject *resultobj = 0; + ISimulation *arg1 = (ISimulation *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + IDetector *result = 0 ; + + if ((nobjs < 1) || (nobjs > 1)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_ISimulation, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ISimulation_getDetector" "', argument " "1"" of type '" "ISimulation const *""'"); + } + arg1 = reinterpret_cast< ISimulation * >(argp1); + result = (IDetector *)((ISimulation const *)arg1)->getDetector(); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_IDetector, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ISimulation_getDetector(PyObject *self, PyObject *args) { + Py_ssize_t argc; + PyObject *argv[2] = { + 0 + }; + + if (!(argc = SWIG_Python_UnpackTuple(args, "ISimulation_getDetector", 0, 1, argv))) SWIG_fail; + --argc; + if (argc == 1) { + int _v; + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_ISimulation, 0); + _v = SWIG_CheckState(res); + if (_v) { + return _wrap_ISimulation_getDetector__SWIG_0(self, argc, argv); + } + } + if (argc == 1) { + int _v; + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_ISimulation, 0); + _v = SWIG_CheckState(res); + if (_v) { + return _wrap_ISimulation_getDetector__SWIG_1(self, argc, argv); + } + } + +fail: + SWIG_Python_RaiseOrModifyTypeError("Wrong number or type of arguments for overloaded function 'ISimulation_getDetector'.\n" + " Possible C/C++ prototypes are:\n" + " ISimulation::getDetector()\n" + " ISimulation::getDetector() const\n"); + return 0; +} + + SWIGINTERN PyObject *_wrap_ISimulation_detector__SWIG_0(PyObject *SWIGUNUSEDPARM(self), Py_ssize_t nobjs, PyObject **swig_obj) { PyObject *resultobj = 0; ISimulation *arg1 = (ISimulation *) 0 ; @@ -40098,6 +40176,84 @@ fail: } +SWIGINTERN PyObject *_wrap_ISimulation2D_detector2D__SWIG_0(PyObject *SWIGUNUSEDPARM(self), Py_ssize_t nobjs, PyObject **swig_obj) { + PyObject *resultobj = 0; + ISimulation2D *arg1 = (ISimulation2D *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + IDetector2D *result = 0 ; + + if ((nobjs < 1) || (nobjs > 1)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_ISimulation2D, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ISimulation2D_detector2D" "', argument " "1"" of type '" "ISimulation2D *""'"); + } + arg1 = reinterpret_cast< ISimulation2D * >(argp1); + result = (IDetector2D *) &(arg1)->detector2D(); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_IDetector2D, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ISimulation2D_detector2D__SWIG_1(PyObject *SWIGUNUSEDPARM(self), Py_ssize_t nobjs, PyObject **swig_obj) { + PyObject *resultobj = 0; + ISimulation2D *arg1 = (ISimulation2D *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + IDetector2D *result = 0 ; + + if ((nobjs < 1) || (nobjs > 1)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_ISimulation2D, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ISimulation2D_detector2D" "', argument " "1"" of type '" "ISimulation2D const *""'"); + } + arg1 = reinterpret_cast< ISimulation2D * >(argp1); + result = (IDetector2D *) &((ISimulation2D const *)arg1)->detector2D(); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_IDetector2D, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ISimulation2D_detector2D(PyObject *self, PyObject *args) { + Py_ssize_t argc; + PyObject *argv[2] = { + 0 + }; + + if (!(argc = SWIG_Python_UnpackTuple(args, "ISimulation2D_detector2D", 0, 1, argv))) SWIG_fail; + --argc; + if (argc == 1) { + int _v; + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_ISimulation2D, 0); + _v = SWIG_CheckState(res); + if (_v) { + return _wrap_ISimulation2D_detector2D__SWIG_0(self, argc, argv); + } + } + if (argc == 1) { + int _v; + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_ISimulation2D, 0); + _v = SWIG_CheckState(res); + if (_v) { + return _wrap_ISimulation2D_detector2D__SWIG_1(self, argc, argv); + } + } + +fail: + SWIG_Python_RaiseOrModifyTypeError("Wrong number or type of arguments for overloaded function 'ISimulation2D_detector2D'.\n" + " Possible C/C++ prototypes are:\n" + " ISimulation2D::detector2D()\n" + " ISimulation2D::detector2D() const\n"); + return 0; +} + + SWIGINTERN PyObject *_wrap_ISimulation2D_prepareSimulation(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; ISimulation2D *arg1 = (ISimulation2D *) 0 ; @@ -44627,6 +44783,12 @@ static PyMethodDef SwigMethods[] = { "const Beam& ISimulation::beam() const\n" "\n" ""}, + { "ISimulation_getDetector", _wrap_ISimulation_getDetector, METH_VARARGS, "\n" + "ISimulation_getDetector(ISimulation self) -> IDetector\n" + "ISimulation_getDetector(ISimulation self) -> IDetector const *\n" + "const IDetector* ISimulation::getDetector() const\n" + "\n" + ""}, { "ISimulation_detector", _wrap_ISimulation_detector, METH_VARARGS, "\n" "ISimulation_detector(ISimulation self) -> IDetector\n" "ISimulation_detector(ISimulation self) -> IDetector const &\n" @@ -44743,6 +44905,12 @@ static PyMethodDef SwigMethods[] = { "ISimulation2D* ISimulation2D::clone() const override=0\n" "\n" ""}, + { "ISimulation2D_detector2D", _wrap_ISimulation2D_detector2D, METH_VARARGS, "\n" + "ISimulation2D_detector2D(ISimulation2D self) -> IDetector2D\n" + "ISimulation2D_detector2D(ISimulation2D self) -> IDetector2D const &\n" + "const IDetector2D & ISimulation2D::detector2D() const\n" + "\n" + ""}, { "ISimulation2D_prepareSimulation", _wrap_ISimulation2D_prepareSimulation, METH_O, "\n" "ISimulation2D_prepareSimulation(ISimulation2D self)\n" "void ISimulation2D::prepareSimulation() override\n" -- GitLab