From 9d3c4befff027aee85c6de9824588ae6d1e46e04 Mon Sep 17 00:00:00 2001
From: "Joachim Wuttke (h)" <j.wuttke@fz-juelich.de>
Date: Wed, 18 May 2022 18:23:35 +0200
Subject: [PATCH] API + DetectorMask::patternAt

---
 Device/Mask/DetectorMask.cpp          |  5 ++++
 Device/Mask/DetectorMask.h            |  2 ++
 auto/Wrap/doxygenDevice.i             |  3 +++
 auto/Wrap/libBornAgainDevice.py       |  8 ++++++
 auto/Wrap/libBornAgainDevice_wrap.cpp | 35 +++++++++++++++++++++++++++
 5 files changed, 53 insertions(+)

diff --git a/Device/Mask/DetectorMask.cpp b/Device/Mask/DetectorMask.cpp
index 1d598791527..df4c0ef6dff 100644
--- a/Device/Mask/DetectorMask.cpp
+++ b/Device/Mask/DetectorMask.cpp
@@ -102,6 +102,11 @@ const IShape2D* DetectorMask::getMaskShape(size_t mask_index, bool& mask_value)
     return m_stack[mask_index]->shape;
 }
 
+const MaskPattern* DetectorMask::patternAt(size_t iMask) const
+{
+    return m_stack.at(iMask);
+}
+
 void DetectorMask::process_masks()
 {
     m_masked->setAllTo(false);
diff --git a/Device/Mask/DetectorMask.h b/Device/Mask/DetectorMask.h
index a89921e059a..b78363176de 100644
--- a/Device/Mask/DetectorMask.h
+++ b/Device/Mask/DetectorMask.h
@@ -71,6 +71,8 @@ public:
 
     const IShape2D* getMaskShape(size_t mask_index, bool& mask_value) const;
 
+    const MaskPattern* patternAt(size_t iMask) const;
+
 private:
     void process_masks();
 
diff --git a/auto/Wrap/doxygenDevice.i b/auto/Wrap/doxygenDevice.i
index e19a9ede129..36263075233 100644
--- a/auto/Wrap/doxygenDevice.i
+++ b/auto/Wrap/doxygenDevice.i
@@ -456,6 +456,9 @@ Returns true if has masks.
 %feature("docstring")  DetectorMask::getMaskShape "const IShape2D * DetectorMask::getMaskShape(size_t mask_index, bool &mask_value) const
 ";
 
+%feature("docstring")  DetectorMask::patternAt "const MaskPattern * DetectorMask::patternAt(size_t iMask) const
+";
+
 
 // File: classEllipse.xml
 %feature("docstring") Ellipse "
diff --git a/auto/Wrap/libBornAgainDevice.py b/auto/Wrap/libBornAgainDevice.py
index f12cdb01cac..bd78d5d9f8b 100644
--- a/auto/Wrap/libBornAgainDevice.py
+++ b/auto/Wrap/libBornAgainDevice.py
@@ -3707,6 +3707,14 @@ class DetectorMask(object):
         """
         return _libBornAgainDevice.DetectorMask_getMaskShape(self, mask_index, mask_value)
 
+    def patternAt(self, iMask):
+        r"""
+        patternAt(DetectorMask self, size_t iMask) -> MaskPattern
+        const MaskPattern * DetectorMask::patternAt(size_t iMask) const
+
+        """
+        return _libBornAgainDevice.DetectorMask_patternAt(self, iMask)
+
 # Register DetectorMask in _libBornAgainDevice:
 _libBornAgainDevice.DetectorMask_swigregister(DetectorMask)
 
diff --git a/auto/Wrap/libBornAgainDevice_wrap.cpp b/auto/Wrap/libBornAgainDevice_wrap.cpp
index 6a803b3f9d2..fbeeca394c4 100644
--- a/auto/Wrap/libBornAgainDevice_wrap.cpp
+++ b/auto/Wrap/libBornAgainDevice_wrap.cpp
@@ -33747,6 +33747,36 @@ fail:
 }
 
 
+SWIGINTERN PyObject *_wrap_DetectorMask_patternAt(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  DetectorMask *arg1 = (DetectorMask *) 0 ;
+  size_t arg2 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  size_t val2 ;
+  int ecode2 = 0 ;
+  PyObject *swig_obj[2] ;
+  MaskPattern *result = 0 ;
+  
+  if (!SWIG_Python_UnpackTuple(args, "DetectorMask_patternAt", 2, 2, swig_obj)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_DetectorMask, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "DetectorMask_patternAt" "', argument " "1"" of type '" "DetectorMask const *""'"); 
+  }
+  arg1 = reinterpret_cast< DetectorMask * >(argp1);
+  ecode2 = SWIG_AsVal_size_t(swig_obj[1], &val2);
+  if (!SWIG_IsOK(ecode2)) {
+    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "DetectorMask_patternAt" "', argument " "2"" of type '" "size_t""'");
+  } 
+  arg2 = static_cast< size_t >(val2);
+  result = (MaskPattern *)((DetectorMask const *)arg1)->patternAt(arg2);
+  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_MaskPattern, 0 |  0 );
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
 SWIGINTERN PyObject *DetectorMask_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *obj;
   if (!SWIG_Python_UnpackTuple(args, "swigregister", 1, 1, &obj)) return NULL;
@@ -43914,6 +43944,11 @@ static PyMethodDef SwigMethods[] = {
 		"const IShape2D * DetectorMask::getMaskShape(size_t mask_index, bool &mask_value) const\n"
 		"\n"
 		""},
+	 { "DetectorMask_patternAt", _wrap_DetectorMask_patternAt, METH_VARARGS, "\n"
+		"DetectorMask_patternAt(DetectorMask self, size_t iMask) -> MaskPattern\n"
+		"const MaskPattern * DetectorMask::patternAt(size_t iMask) const\n"
+		"\n"
+		""},
 	 { "DetectorMask_swigregister", DetectorMask_swigregister, METH_O, NULL},
 	 { "DetectorMask_swiginit", DetectorMask_swiginit, METH_VARARGS, NULL},
 	 { "IDetector_clone", _wrap_IDetector_clone, METH_O, "\n"
-- 
GitLab