diff --git a/Device/Detector/Detector2D.cpp b/Device/Detector/Detector2D.cpp index 2f16dfc4e26f4f4391720824f99747ed4ef56e36..f7f0d622e7fb7b6a698bcfe00cd070846d4b2c11 100644 --- a/Device/Detector/Detector2D.cpp +++ b/Device/Detector/Detector2D.cpp @@ -35,6 +35,18 @@ Detector2D::Detector2D(size_t n_phi, double phi_min, double phi_max, size_t n_al ASSERT(-pi / 2 < alpha_max && alpha_max < +pi / 2); } +Detector2D::Detector2D(double phi_full_width, double alpha_full_width, size_t n_phi, size_t n_alpha, + double center_phi, double center_alpha) + : IDetector( + new Frame(newEquiDivision("phi_f (rad)", n_phi, center_phi - phi_full_width / 2, + center_phi + phi_full_width / 2), + newEquiDivision("alpha_f (rad)", n_alpha, center_alpha - alpha_full_width / 2, + center_alpha + alpha_full_width / 2))) +{ + ASSERT(-pi / 2 < axis(0).min() && axis(0).max() < +pi / 2); + ASSERT(-pi / 2 < axis(1).min() && axis(1).max() < +pi / 2); +} + Detector2D* Detector2D::clone() const { return new Detector2D(*this); diff --git a/Device/Detector/Detector2D.h b/Device/Detector/Detector2D.h index 9c7038025269990d47e901e5dae93e3afa3e17ba..f20e5035de051f11fe965ae35b163a989d5f7aca 100644 --- a/Device/Detector/Detector2D.h +++ b/Device/Detector/Detector2D.h @@ -26,6 +26,8 @@ class Detector2D : public IDetector { public: Detector2D(size_t n_phi, double phi_min, double phi_max, size_t n_alpha, double alpha_min, double alpha_max); + Detector2D(double phi_full_width, double alpha_full_width, size_t n_phi, size_t n_alpha, + double center_phi, double center_alpha); ~Detector2D() override = default; diff --git a/auto/Wrap/libBornAgainDevice.py b/auto/Wrap/libBornAgainDevice.py index 45be6ea4ac2ad5ccb9fb860dd5c480c43b99143a..5be2657a8f16fdfde31fa48e116796f2ec34e47a 100644 --- a/auto/Wrap/libBornAgainDevice.py +++ b/auto/Wrap/libBornAgainDevice.py @@ -2714,9 +2714,12 @@ class Detector2D(IDetector): thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") __repr__ = _swig_repr - def __init__(self, n_phi, phi_min, phi_max, n_alpha, alpha_min, alpha_max): - r"""__init__(Detector2D self, size_t n_phi, double phi_min, double phi_max, size_t n_alpha, double alpha_min, double alpha_max) -> Detector2D""" - _libBornAgainDevice.Detector2D_swiginit(self, _libBornAgainDevice.new_Detector2D(n_phi, phi_min, phi_max, n_alpha, alpha_min, alpha_max)) + def __init__(self, *args): + r""" + __init__(Detector2D self, size_t n_phi, double phi_min, double phi_max, size_t n_alpha, double alpha_min, double alpha_max) -> Detector2D + __init__(Detector2D self, double phi_full_width, double alpha_full_width, size_t n_phi, size_t n_alpha, double center_phi, double center_alpha) -> Detector2D + """ + _libBornAgainDevice.Detector2D_swiginit(self, _libBornAgainDevice.new_Detector2D(*args)) __swig_destroy__ = _libBornAgainDevice.delete_Detector2D def clone(self): diff --git a/auto/Wrap/libBornAgainDevice_wrap.cpp b/auto/Wrap/libBornAgainDevice_wrap.cpp index c0bf598e9db17603ae4fe43e7d9c55824f2fdb39..0d4750984e96a2fbb65682fc163dbbca6829ba80 100644 --- a/auto/Wrap/libBornAgainDevice_wrap.cpp +++ b/auto/Wrap/libBornAgainDevice_wrap.cpp @@ -36460,7 +36460,7 @@ SWIGINTERN PyObject *IDetector_swigregister(PyObject *SWIGUNUSEDPARM(self), PyOb return SWIG_Py_Void(); } -SWIGINTERN PyObject *_wrap_new_Detector2D(PyObject *self, PyObject *args) { +SWIGINTERN PyObject *_wrap_new_Detector2D__SWIG_0(PyObject *self, Py_ssize_t nobjs, PyObject **swig_obj) { PyObject *resultobj = 0; size_t arg1 ; double arg2 ; @@ -36480,10 +36480,9 @@ SWIGINTERN PyObject *_wrap_new_Detector2D(PyObject *self, PyObject *args) { int ecode5 = 0 ; double val6 ; int ecode6 = 0 ; - PyObject *swig_obj[6] ; Detector2D *result = 0 ; - if (!SWIG_Python_UnpackTuple(args, "new_Detector2D", 6, 6, swig_obj)) SWIG_fail; + if ((nobjs < 6) || (nobjs > 6)) SWIG_fail; ecode1 = SWIG_AsVal_size_t(swig_obj[0], &val1); if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "new_Detector2D" "', argument " "1"" of type '" "size_t""'"); @@ -36532,6 +36531,175 @@ fail: } +SWIGINTERN PyObject *_wrap_new_Detector2D__SWIG_1(PyObject *self, Py_ssize_t nobjs, PyObject **swig_obj) { + PyObject *resultobj = 0; + double arg1 ; + double arg2 ; + size_t arg3 ; + size_t arg4 ; + double arg5 ; + double arg6 ; + double val1 ; + int ecode1 = 0 ; + double val2 ; + int ecode2 = 0 ; + size_t val3 ; + int ecode3 = 0 ; + size_t val4 ; + int ecode4 = 0 ; + double val5 ; + int ecode5 = 0 ; + double val6 ; + int ecode6 = 0 ; + Detector2D *result = 0 ; + + if ((nobjs < 6) || (nobjs > 6)) SWIG_fail; + ecode1 = SWIG_AsVal_double(swig_obj[0], &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "new_Detector2D" "', argument " "1"" of type '" "double""'"); + } + arg1 = static_cast< double >(val1); + ecode2 = SWIG_AsVal_double(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "new_Detector2D" "', argument " "2"" of type '" "double""'"); + } + arg2 = static_cast< double >(val2); + ecode3 = SWIG_AsVal_size_t(swig_obj[2], &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "new_Detector2D" "', argument " "3"" of type '" "size_t""'"); + } + arg3 = static_cast< size_t >(val3); + ecode4 = SWIG_AsVal_size_t(swig_obj[3], &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "new_Detector2D" "', argument " "4"" of type '" "size_t""'"); + } + arg4 = static_cast< size_t >(val4); + ecode5 = SWIG_AsVal_double(swig_obj[4], &val5); + if (!SWIG_IsOK(ecode5)) { + SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "new_Detector2D" "', argument " "5"" of type '" "double""'"); + } + arg5 = static_cast< double >(val5); + ecode6 = SWIG_AsVal_double(swig_obj[5], &val6); + if (!SWIG_IsOK(ecode6)) { + SWIG_exception_fail(SWIG_ArgError(ecode6), "in method '" "new_Detector2D" "', argument " "6"" of type '" "double""'"); + } + arg6 = static_cast< double >(val6); + { + try { + result = (Detector2D *)new Detector2D(arg1,arg2,arg3,arg4,arg5,arg6); + } catch (const std::exception& ex) { + // message shown in the Python interpreter + const std::string msg { + "BornAgain C++ Exception: " + std::string(ex.what()) + }; + SWIG_exception(SWIG_RuntimeError, msg.c_str()); + } + } + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Detector2D, SWIG_POINTER_NEW | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_new_Detector2D(PyObject *self, PyObject *args) { + Py_ssize_t argc; + PyObject *argv[7] = { + 0 + }; + + if (!(argc = SWIG_Python_UnpackTuple(args, "new_Detector2D", 0, 6, argv))) SWIG_fail; + --argc; + if (argc == 6) { + int _v = 0; + { + int res = SWIG_AsVal_size_t(argv[0], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_double(argv[1], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_double(argv[2], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_size_t(argv[3], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_double(argv[4], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_double(argv[5], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + return _wrap_new_Detector2D__SWIG_0(self, argc, argv); + } + } + } + } + } + } + } + if (argc == 6) { + int _v = 0; + { + int res = SWIG_AsVal_double(argv[0], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_double(argv[1], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_size_t(argv[2], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_size_t(argv[3], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_double(argv[4], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_double(argv[5], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + return _wrap_new_Detector2D__SWIG_1(self, argc, argv); + } + } + } + } + } + } + } + +fail: + SWIG_Python_RaiseOrModifyTypeError("Wrong number or type of arguments for overloaded function 'new_Detector2D'.\n" + " Possible C/C++ prototypes are:\n" + " Detector2D::Detector2D(size_t,double,double,size_t,double,double)\n" + " Detector2D::Detector2D(double,double,size_t,size_t,double,double)\n"); + return 0; +} + + SWIGINTERN PyObject *_wrap_delete_Detector2D(PyObject *self, PyObject *args) { PyObject *resultobj = 0; Detector2D *arg1 = (Detector2D *) 0 ; @@ -42453,7 +42621,10 @@ static PyMethodDef SwigMethods[] = { { "IDetector_setRegionOfInterest", _wrap_IDetector_setRegionOfInterest, METH_VARARGS, "IDetector_setRegionOfInterest(IDetector self, double xlow, double ylow, double xup, double yup)"}, { "IDetector_clippedFrame", _wrap_IDetector_clippedFrame, METH_O, "IDetector_clippedFrame(IDetector self) -> Frame"}, { "IDetector_swigregister", IDetector_swigregister, METH_O, NULL}, - { "new_Detector2D", _wrap_new_Detector2D, METH_VARARGS, "new_Detector2D(size_t n_phi, double phi_min, double phi_max, size_t n_alpha, double alpha_min, double alpha_max) -> Detector2D"}, + { "new_Detector2D", _wrap_new_Detector2D, METH_VARARGS, "\n" + "Detector2D(size_t n_phi, double phi_min, double phi_max, size_t n_alpha, double alpha_min, double alpha_max)\n" + "new_Detector2D(double phi_full_width, double alpha_full_width, size_t n_phi, size_t n_alpha, double center_phi, double center_alpha) -> Detector2D\n" + ""}, { "delete_Detector2D", _wrap_delete_Detector2D, METH_O, "delete_Detector2D(Detector2D self)"}, { "Detector2D_clone", _wrap_Detector2D_clone, METH_O, "Detector2D_clone(Detector2D self) -> Detector2D"}, { "Detector2D_className", _wrap_Detector2D_className, METH_O, "Detector2D_className(Detector2D self) -> std::string"},