Skip to content
Snippets Groups Projects
Commit 70dc91fd authored by Wuttke, Joachim's avatar Wuttke, Joachim
Browse files

mv Element out of Device

parent c6fa256a
No related branches found
No related tags found
1 merge request!1272Consolidate simulation classes; don't wrap SpinMatrix in PolMatrices
......@@ -23,7 +23,6 @@
#include "Device/Mask/DetectorMask.h"
#include "Device/Mask/InfinitePlane.h"
#include "Device/Resolution/ConvolutionDetectorResolution.h"
#include "Resample/Element/DiffuseElement.h"
namespace {
......@@ -168,35 +167,21 @@ void IDetector::resetRegionOfInterest()
void IDetector::applyDetectorResolution(Datafield* intensity_map) const
{
if (!m_resolution)
return;
ASSERT(intensity_map);
if (m_resolution) {
m_resolution->applyDetectorResolution(intensity_map);
if (detectorMask() && detectorMask()->hasMasks()) {
// sets amplitude in masked areas to zero
std::unique_ptr<Datafield> buff(new Datafield(intensity_map->frame().clonedAxes()));
iterateOverNonMaskedPoints([&](const_iterator it) {
(*buff)[it.roiIndex()] = (*intensity_map)[it.roiIndex()];
});
intensity_map->setVector(buff->flatVector());
}
m_resolution->applyDetectorResolution(intensity_map);
if (detectorMask() && detectorMask()->hasMasks()) {
// sets amplitude in masked areas to zero
std::unique_ptr<Datafield> buff(new Datafield(intensity_map->frame().clonedAxes()));
iterateOverNonMaskedPoints(
[&](const_iterator it) { (*buff)[it.roiIndex()] = (*intensity_map)[it.roiIndex()]; });
intensity_map->setVector(buff->flatVector());
}
}
const Datafield*
IDetector::createDetectorIntensity(const std::vector<DiffuseElement>& elements) const
{
std::unique_ptr<Datafield> detectorMap(createDetectorMap());
ASSERT(detectorMap);
size_t elementIndex = 0;
for (auto it = beginNonMaskedPoints(); it != endNonMaskedPoints(); ++it)
(*detectorMap)[it.roiIndex()] = elements[elementIndex++].intensity();
if (m_resolution)
applyDetectorResolution(detectorMap.get());
return detectorMap.release();
}
std::unique_ptr<Datafield> IDetector::createDetectorMap() const
{
const size_t dim = rank();
......
......@@ -24,7 +24,6 @@ class Beam;
class CoordSystem2D;
class Datafield;
class DetectorMask;
class DiffuseElement;
class IAxis;
class ICoordSystem;
class IDetectorResolution;
......@@ -156,9 +155,6 @@ public:
//! Returns a pointer to detector resolution object
const IDetectorResolution* detectorResolution() const { return m_resolution.get(); }
//! Returns new intensity map with resolution applied, and cropped to ROI if applicable.
const Datafield* createDetectorIntensity(const std::vector<DiffuseElement>& elements) const;
//! Return default axes units
virtual Coords defaultCoords() const = 0;
......
......@@ -20,12 +20,31 @@
#include "Device/Coord/CoordSystem2D.h"
#include "Device/Data/Datafield.h"
#include "Device/Detector/IDetector.h"
#include "Device/Detector/SimulationAreaIterator.h"
#include "Device/Histo/SimulationResult.h"
#include "Param/Distrib/DistributionHandler.h"
#include "Resample/Element/DiffuseElement.h"
#include "Sim/Background/IBackground.h"
#include "Sim/Computation/DWBAComputation.h"
namespace {
const Datafield* createDetectorIntensity(const IDetector& detector,
const std::vector<DiffuseElement>& elements)
{
std::unique_ptr<Datafield> detectorMap(detector.createDetectorMap());
ASSERT(detectorMap);
size_t elementIndex = 0;
for (auto it = detector.beginNonMaskedPoints(); it != detector.endNonMaskedPoints(); ++it)
(*detectorMap)[it.roiIndex()] = elements[elementIndex++].intensity();
detector.applyDetectorResolution(detectorMap.get());
return detectorMap.release();
}
} // namespace
ScatteringSimulation::ScatteringSimulation(const Beam& beam, const MultiLayer& sample,
const IDetector& detector)
: ISimulation(sample)
......@@ -163,7 +182,7 @@ SimulationResult ScatteringSimulation::packResult() const
m_eles[i].setIntensity(m_cache[i]);
auto* const coordsys = simCoordSystem();
std::unique_ptr<const Datafield> data(m_detector->createDetectorIntensity(m_eles));
std::unique_ptr<const Datafield> data(createDetectorIntensity(*m_detector, m_eles));
return {*data, *coordsys};
}
......
......@@ -2888,10 +2888,6 @@ class IDetector(libBornAgainBase.ICloneable, libBornAgainParam.INode):
r"""detectorResolution(IDetector self) -> IDetectorResolution"""
return _libBornAgainDevice.IDetector_detectorResolution(self)
def createDetectorIntensity(self, elements):
r"""createDetectorIntensity(IDetector self, std::vector< DiffuseElement,std::allocator< DiffuseElement > > const & elements) -> Datafield"""
return _libBornAgainDevice.IDetector_createDetectorIntensity(self, elements)
def defaultCoords(self):
r"""defaultCoords(IDetector self) -> Coords"""
return _libBornAgainDevice.IDetector_defaultCoords(self)
......
......@@ -3457,28 +3457,27 @@ namespace Swig {
#define SWIGTYPE_p_std__mapT_std__string_double_std__lessT_std__string_t_std__allocatorT_std__pairT_std__string_const_double_t_t_t swig_types[68]
#define SWIGTYPE_p_std__pairT_double_double_t swig_types[69]
#define SWIGTYPE_p_std__shared_ptrT_IAxis_t swig_types[70]
#define SWIGTYPE_p_std__vectorT_DiffuseElement_std__allocatorT_DiffuseElement_t_t swig_types[71]
#define SWIGTYPE_p_std__vectorT_IAxis_const_p_std__allocatorT_IAxis_const_p_t_t swig_types[72]
#define SWIGTYPE_p_std__vectorT_INode_const_p_std__allocatorT_INode_const_p_t_t swig_types[73]
#define SWIGTYPE_p_std__vectorT_ParaMeta_std__allocatorT_ParaMeta_t_t swig_types[74]
#define SWIGTYPE_p_std__vectorT_Vec3T_double_t_std__allocatorT_Vec3T_double_t_t_t swig_types[75]
#define SWIGTYPE_p_std__vectorT_double_std__allocatorT_double_t_t swig_types[76]
#define SWIGTYPE_p_std__vectorT_int_std__allocatorT_int_t_t swig_types[77]
#define SWIGTYPE_p_std__vectorT_size_t_std__allocatorT_size_t_t_t swig_types[78]
#define SWIGTYPE_p_std__vectorT_std__complexT_double_t_std__allocatorT_std__complexT_double_t_t_t swig_types[79]
#define SWIGTYPE_p_std__vectorT_std__pairT_double_double_t_std__allocatorT_std__pairT_double_double_t_t_t swig_types[80]
#define SWIGTYPE_p_std__vectorT_std__string_std__allocatorT_std__string_t_t swig_types[81]
#define SWIGTYPE_p_std__vectorT_std__vectorT_double_std__allocatorT_double_t_t_std__allocatorT_std__vectorT_double_std__allocatorT_double_t_t_t_t swig_types[82]
#define SWIGTYPE_p_std__vectorT_std__vectorT_int_std__allocatorT_int_t_t_std__allocatorT_std__vectorT_int_std__allocatorT_int_t_t_t_t swig_types[83]
#define SWIGTYPE_p_std__vectorT_unsigned_long_std__allocatorT_unsigned_long_t_t swig_types[84]
#define SWIGTYPE_p_swig__SwigPyIterator swig_types[85]
#define SWIGTYPE_p_unsigned_char swig_types[86]
#define SWIGTYPE_p_unsigned_int swig_types[87]
#define SWIGTYPE_p_unsigned_long_long swig_types[88]
#define SWIGTYPE_p_unsigned_short swig_types[89]
#define SWIGTYPE_p_value_type swig_types[90]
static swig_type_info *swig_types[92];
static swig_module_info swig_module = {swig_types, 91, 0, 0, 0, 0};
#define SWIGTYPE_p_std__vectorT_IAxis_const_p_std__allocatorT_IAxis_const_p_t_t swig_types[71]
#define SWIGTYPE_p_std__vectorT_INode_const_p_std__allocatorT_INode_const_p_t_t swig_types[72]
#define SWIGTYPE_p_std__vectorT_ParaMeta_std__allocatorT_ParaMeta_t_t swig_types[73]
#define SWIGTYPE_p_std__vectorT_Vec3T_double_t_std__allocatorT_Vec3T_double_t_t_t swig_types[74]
#define SWIGTYPE_p_std__vectorT_double_std__allocatorT_double_t_t swig_types[75]
#define SWIGTYPE_p_std__vectorT_int_std__allocatorT_int_t_t swig_types[76]
#define SWIGTYPE_p_std__vectorT_size_t_std__allocatorT_size_t_t_t swig_types[77]
#define SWIGTYPE_p_std__vectorT_std__complexT_double_t_std__allocatorT_std__complexT_double_t_t_t swig_types[78]
#define SWIGTYPE_p_std__vectorT_std__pairT_double_double_t_std__allocatorT_std__pairT_double_double_t_t_t swig_types[79]
#define SWIGTYPE_p_std__vectorT_std__string_std__allocatorT_std__string_t_t swig_types[80]
#define SWIGTYPE_p_std__vectorT_std__vectorT_double_std__allocatorT_double_t_t_std__allocatorT_std__vectorT_double_std__allocatorT_double_t_t_t_t swig_types[81]
#define SWIGTYPE_p_std__vectorT_std__vectorT_int_std__allocatorT_int_t_t_std__allocatorT_std__vectorT_int_std__allocatorT_int_t_t_t_t swig_types[82]
#define SWIGTYPE_p_std__vectorT_unsigned_long_std__allocatorT_unsigned_long_t_t swig_types[83]
#define SWIGTYPE_p_swig__SwigPyIterator swig_types[84]
#define SWIGTYPE_p_unsigned_char swig_types[85]
#define SWIGTYPE_p_unsigned_int swig_types[86]
#define SWIGTYPE_p_unsigned_long_long swig_types[87]
#define SWIGTYPE_p_unsigned_short swig_types[88]
#define SWIGTYPE_p_value_type swig_types[89]
static swig_type_info *swig_types[91];
static swig_module_info swig_module = {swig_types, 90, 0, 0, 0, 0};
#define SWIG_TypeQuery(name) SWIG_TypeQueryModule(&swig_module, &swig_module, name)
#define SWIG_MangledTypeQuery(name) SWIG_MangledTypeQueryModule(&swig_module, &swig_module, name)
 
......@@ -34794,39 +34793,6 @@ fail:
}
 
 
SWIGINTERN PyObject *_wrap_IDetector_createDetectorIntensity(PyObject *self, PyObject *args) {
PyObject *resultobj = 0;
IDetector *arg1 = (IDetector *) 0 ;
std::vector< DiffuseElement,std::allocator< DiffuseElement > > *arg2 = 0 ;
void *argp1 = 0 ;
int res1 = 0 ;
void *argp2 = 0 ;
int res2 = 0 ;
PyObject *swig_obj[2] ;
Datafield *result = 0 ;
if (!SWIG_Python_UnpackTuple(args, "IDetector_createDetectorIntensity", 2, 2, swig_obj)) SWIG_fail;
res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_IDetector, 0 | 0 );
if (!SWIG_IsOK(res1)) {
SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "IDetector_createDetectorIntensity" "', argument " "1"" of type '" "IDetector const *""'");
}
arg1 = reinterpret_cast< IDetector * >(argp1);
res2 = SWIG_ConvertPtr(swig_obj[1], &argp2, SWIGTYPE_p_std__vectorT_DiffuseElement_std__allocatorT_DiffuseElement_t_t, 0 | 0);
if (!SWIG_IsOK(res2)) {
SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "IDetector_createDetectorIntensity" "', argument " "2"" of type '" "std::vector< DiffuseElement,std::allocator< DiffuseElement > > const &""'");
}
if (!argp2) {
SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "IDetector_createDetectorIntensity" "', argument " "2"" of type '" "std::vector< DiffuseElement,std::allocator< DiffuseElement > > const &""'");
}
arg2 = reinterpret_cast< std::vector< DiffuseElement,std::allocator< DiffuseElement > > * >(argp2);
result = (Datafield *)((IDetector const *)arg1)->createDetectorIntensity((std::vector< DiffuseElement,std::allocator< DiffuseElement > > const &)*arg2);
resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Datafield, 0 | 0 );
return resultobj;
fail:
return NULL;
}
SWIGINTERN PyObject *_wrap_IDetector_defaultCoords(PyObject *self, PyObject *args) {
PyObject *resultobj = 0;
IDetector *arg1 = (IDetector *) 0 ;
......@@ -38786,7 +38752,6 @@ static PyMethodDef SwigMethods[] = {
{ "IDetector_detectorIndexToRegionOfInterestIndex", _wrap_IDetector_detectorIndexToRegionOfInterestIndex, METH_VARARGS, "IDetector_detectorIndexToRegionOfInterestIndex(IDetector self, size_t detectorIndex) -> size_t"},
{ "IDetector_applyDetectorResolution", _wrap_IDetector_applyDetectorResolution, METH_VARARGS, "IDetector_applyDetectorResolution(IDetector self, Datafield intensity_map)"},
{ "IDetector_detectorResolution", _wrap_IDetector_detectorResolution, METH_O, "IDetector_detectorResolution(IDetector self) -> IDetectorResolution"},
{ "IDetector_createDetectorIntensity", _wrap_IDetector_createDetectorIntensity, METH_VARARGS, "IDetector_createDetectorIntensity(IDetector self, std::vector< DiffuseElement,std::allocator< DiffuseElement > > const & elements) -> Datafield"},
{ "IDetector_defaultCoords", _wrap_IDetector_defaultCoords, METH_O, "IDetector_defaultCoords(IDetector self) -> Coords"},
{ "IDetector_regionOfInterestBounds", _wrap_IDetector_regionOfInterestBounds, METH_VARARGS, "IDetector_regionOfInterestBounds(IDetector self, size_t iAxis) -> pvacuum_double_t"},
{ "IDetector_swigregister", IDetector_swigregister, METH_O, NULL},
......@@ -39057,7 +39022,6 @@ static swig_type_info _swigt__p_std__lessT_std__string_t = {"_p_std__lessT_std__
static swig_type_info _swigt__p_std__mapT_std__string_double_std__lessT_std__string_t_std__allocatorT_std__pairT_std__string_const_double_t_t_t = {"_p_std__mapT_std__string_double_std__lessT_std__string_t_std__allocatorT_std__pairT_std__string_const_double_t_t_t", "std::map< std::string,double,std::less< std::string >,std::allocator< std::pair< std::string const,double > > > *|std::map< std::string,double > *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_std__pairT_double_double_t = {"_p_std__pairT_double_double_t", "std::pair< double,double > *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_std__shared_ptrT_IAxis_t = {"_p_std__shared_ptrT_IAxis_t", "std::shared_ptr< IAxis > *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_std__vectorT_DiffuseElement_std__allocatorT_DiffuseElement_t_t = {"_p_std__vectorT_DiffuseElement_std__allocatorT_DiffuseElement_t_t", "std::vector< DiffuseElement,std::allocator< DiffuseElement > > *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_std__vectorT_IAxis_const_p_std__allocatorT_IAxis_const_p_t_t = {"_p_std__vectorT_IAxis_const_p_std__allocatorT_IAxis_const_p_t_t", "std::vector< IAxis const *,std::allocator< IAxis const * > > *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_std__vectorT_INode_const_p_std__allocatorT_INode_const_p_t_t = {"_p_std__vectorT_INode_const_p_std__allocatorT_INode_const_p_t_t", "std::vector< INode const *,std::allocator< INode const * > > *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_std__vectorT_ParaMeta_std__allocatorT_ParaMeta_t_t = {"_p_std__vectorT_ParaMeta_std__allocatorT_ParaMeta_t_t", "std::vector< ParaMeta,std::allocator< ParaMeta > > *", 0, 0, (void*)0, 0};
......@@ -39150,7 +39114,6 @@ static swig_type_info *swig_type_initial[] = {
&_swigt__p_std__mapT_std__string_double_std__lessT_std__string_t_std__allocatorT_std__pairT_std__string_const_double_t_t_t,
&_swigt__p_std__pairT_double_double_t,
&_swigt__p_std__shared_ptrT_IAxis_t,
&_swigt__p_std__vectorT_DiffuseElement_std__allocatorT_DiffuseElement_t_t,
&_swigt__p_std__vectorT_IAxis_const_p_std__allocatorT_IAxis_const_p_t_t,
&_swigt__p_std__vectorT_INode_const_p_std__allocatorT_INode_const_p_t_t,
&_swigt__p_std__vectorT_ParaMeta_std__allocatorT_ParaMeta_t_t,
......@@ -39243,7 +39206,6 @@ static swig_cast_info _swigc__p_std__lessT_std__string_t[] = { {&_swigt__p_std_
static swig_cast_info _swigc__p_std__mapT_std__string_double_std__lessT_std__string_t_std__allocatorT_std__pairT_std__string_const_double_t_t_t[] = { {&_swigt__p_std__mapT_std__string_double_std__lessT_std__string_t_std__allocatorT_std__pairT_std__string_const_double_t_t_t, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_std__pairT_double_double_t[] = { {&_swigt__p_std__pairT_double_double_t, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_std__shared_ptrT_IAxis_t[] = { {&_swigt__p_std__shared_ptrT_IAxis_t, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_std__vectorT_DiffuseElement_std__allocatorT_DiffuseElement_t_t[] = { {&_swigt__p_std__vectorT_DiffuseElement_std__allocatorT_DiffuseElement_t_t, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_std__vectorT_IAxis_const_p_std__allocatorT_IAxis_const_p_t_t[] = { {&_swigt__p_std__vectorT_IAxis_const_p_std__allocatorT_IAxis_const_p_t_t, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_std__vectorT_INode_const_p_std__allocatorT_INode_const_p_t_t[] = { {&_swigt__p_std__vectorT_INode_const_p_std__allocatorT_INode_const_p_t_t, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_std__vectorT_ParaMeta_std__allocatorT_ParaMeta_t_t[] = { {&_swigt__p_std__vectorT_ParaMeta_std__allocatorT_ParaMeta_t_t, 0, 0, 0},{0, 0, 0, 0}};
......@@ -39336,7 +39298,6 @@ static swig_cast_info *swig_cast_initial[] = {
_swigc__p_std__mapT_std__string_double_std__lessT_std__string_t_std__allocatorT_std__pairT_std__string_const_double_t_t_t,
_swigc__p_std__pairT_double_double_t,
_swigc__p_std__shared_ptrT_IAxis_t,
_swigc__p_std__vectorT_DiffuseElement_std__allocatorT_DiffuseElement_t_t,
_swigc__p_std__vectorT_IAxis_const_p_std__allocatorT_IAxis_const_p_t_t,
_swigc__p_std__vectorT_INode_const_p_std__allocatorT_INode_const_p_t_t,
_swigc__p_std__vectorT_ParaMeta_std__allocatorT_ParaMeta_t_t,
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment