diff --git a/Device/Detector/IDetector.cpp b/Device/Detector/IDetector.cpp index 44688794d042a0e6b126568da413afeaa7bc90ff..dd976601c1e690db8cb8110b39f031415de5d416 100644 --- a/Device/Detector/IDetector.cpp +++ b/Device/Detector/IDetector.cpp @@ -14,7 +14,6 @@ #include "Device/Detector/IDetector.h" #include "Base/Pixel/SimulationElement.h" -#include "Device/Detector/SimulationArea.h" #include "Device/ProDetector/DetectorMask.h" #include "Device/ProDetector/RegionOfInterest.h" #include "Device/Resolution/ConvolutionDetectorResolution.h" @@ -96,6 +95,22 @@ size_t IDetector::totalSize() const return result; } +size_t IDetector::sizeOfRegionOfInterest() const +{ + if (regionOfInterest() != nullptr) + return regionOfInterest()->roiSize(); + + return totalSize(); +} + +size_t IDetector::regionOfInterestIndexToDetectorIndex(const size_t regionOfInterestIndex) const +{ + if (regionOfInterest() != nullptr) + return regionOfInterest()->detectorIndex(regionOfInterestIndex); + + return regionOfInterestIndex; +} + void IDetector::setAnalyzerProperties(const kvector_t direction, double efficiency, double total_transmission) { @@ -199,8 +214,7 @@ void IDetector::iterateOverRegionOfInterest(std::function<void(const_iterator)> if (this->dimension() == 0) return; - SimulationRoiArea area(this); - for (auto it = area.begin(); it != area.end(); ++it) + for (auto it = beginRegionOfInterestPoints(); it != endRegionOfInterestPoints(); ++it) func(it); } @@ -209,7 +223,26 @@ void IDetector::iterateOverNonMaskedPoints(std::function<void(const_iterator)> f if (this->dimension() == 0) return; - SimulationArea area(this); - for (auto it = area.begin(); it != area.end(); ++it) + for (auto it = beginNonMaskedPoints(); it != endNonMaskedPoints(); ++it) func(it); } + +SimulationAreaIterator IDetector::beginNonMaskedPoints() const +{ + return SimulationAreaIterator::createBegin(this, SimulationAreaIterator::notMasked); +} + +SimulationAreaIterator IDetector::endNonMaskedPoints() const +{ + return SimulationAreaIterator::createEnd(this, SimulationAreaIterator::notMasked); +} + +SimulationAreaIterator IDetector::beginRegionOfInterestPoints() const +{ + return SimulationAreaIterator::createBegin(this, SimulationAreaIterator::regionOfInterest); +} + +SimulationAreaIterator IDetector::endRegionOfInterestPoints() const +{ + return SimulationAreaIterator::createEnd(this, SimulationAreaIterator::regionOfInterest); +} diff --git a/Device/Detector/IDetector.h b/Device/Detector/IDetector.h index 961681b8562c2865ad4a7efe3354e390df32a2e0..3e14fd4a680751fc55997ffb337f6634ad39bff8 100644 --- a/Device/Detector/IDetector.h +++ b/Device/Detector/IDetector.h @@ -70,6 +70,26 @@ public: //! interest" are also treated as "masked". void iterateOverNonMaskedPoints(std::function<void(const_iterator)> func) const; +#ifndef SWIG + //! Create begin-iterator to iterate over all points which are not masked and lay + //! within the "Region of Interest" + SimulationAreaIterator beginNonMaskedPoints() const; + + //! Create end-iterator to iterate over all points which are not masked and lay + //! within the "Region of Interest" + SimulationAreaIterator endNonMaskedPoints() const; + + //! Create begin-iterator to iterate over all points which lay + //! within the "Region of Interest". + //! No matter whether masked or not. + SimulationAreaIterator beginRegionOfInterestPoints() const; + + //! Create end-iterator to iterate over all points which lay + //! within the "Region of Interest". + //! No matter whether masked or not. + SimulationAreaIterator endRegionOfInterestPoints() const; +#endif // SWIG + const CloneableVector<IAxis>& axes() const { return m_axes; } const IAxis& axis(size_t index) const; @@ -82,7 +102,14 @@ public: //! Returns total number of pixels // #baROI rename to totalPixels size_t totalSize() const; - // #baROI add roiPixels; docu: same as totalPixels if no roi set + //! The size of the "Region of Interest". Same as totalSize() + //! if no region of interest has been set. + size_t sizeOfRegionOfInterest() const; + + //! Convert an index of the region of interest to an index of the detector. + //! If no region of interest is set, then the index stays unmodified (since ROI == detector + //! area). + size_t regionOfInterestIndexToDetectorIndex(const size_t regionOfInterestIndex) const; //! Applies the detector resolution to the given intensity maps void applyDetectorResolution(OutputData<double>* p_intensity_map) const; diff --git a/Device/Detector/SimulationArea.cpp b/Device/Detector/SimulationArea.cpp deleted file mode 100644 index 9476d5c4e870251e7432d2f4a9dd6b111590b0d2..0000000000000000000000000000000000000000 --- a/Device/Detector/SimulationArea.cpp +++ /dev/null @@ -1,71 +0,0 @@ -// ************************************************************************************************ -// -// BornAgain: simulate and fit reflection and scattering -// -//! @file Device/Detector/SimulationArea.cpp -//! @brief Implements class SimulationArea. -//! -//! @homepage http://www.bornagainproject.org -//! @license GNU General Public License v3 or higher (see COPYING) -//! @copyright Forschungszentrum Jülich GmbH 2018 -//! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS) -// -// ************************************************************************************************ - -#include "Device/Detector/SimulationArea.h" -#include "Device/Detector/IDetector.h" -#include "Device/Mask/Rectangle.h" -#include "Device/ProDetector/DetectorMask.h" -#include "Device/ProDetector/RegionOfInterest.h" -#include <sstream> - -SimulationArea::SimulationArea(const IDetector* detector) : m_detector(detector), m_max_index(0) -{ - if (m_detector == nullptr) - throw std::runtime_error("SimulationArea::SimulationArea: null pointer passed" - " as detector"); - - if (m_detector->dimension() == 0) - throw std::runtime_error( - "SimulationArea::SimulationArea: detector of unspecified dimensionality"); - - // #baROI refactor: create method m_detector->roiPixels() - if (m_detector->regionOfInterest()) - m_max_index = m_detector->regionOfInterest()->roiSize(); - else - m_max_index = m_detector->totalSize(); -} - -SimulationAreaIterator SimulationArea::begin() -{ - return SimulationAreaIterator(this, 0); -} - -SimulationAreaIterator SimulationArea::end() -{ - return SimulationAreaIterator(this, m_max_index); -} - -bool SimulationArea::isMasked(size_t index) const -{ - auto masks = m_detector->detectorMask(); - return (masks && masks->isMasked(detectorIndex(index))); -} - -size_t SimulationArea::detectorIndex(size_t index) const -{ - // #baROI create method m_detector->roiIndex() - if (!m_detector->regionOfInterest()) - return index; - - return m_detector->regionOfInterest()->detectorIndex(index); -} - -// -------------------------------------------------------------------------------------- - -SimulationRoiArea::SimulationRoiArea(const IDetector* detector) : SimulationArea(detector) {} - -bool SimulationRoiArea::isMasked(size_t) const -{ - return false; -} diff --git a/Device/Detector/SimulationArea.h b/Device/Detector/SimulationArea.h deleted file mode 100644 index 8f0850540707bf55e2f10c9d3a649affdc976840..0000000000000000000000000000000000000000 --- a/Device/Detector/SimulationArea.h +++ /dev/null @@ -1,70 +0,0 @@ -// ************************************************************************************************ -// -// BornAgain: simulate and fit reflection and scattering -// -//! @file Device/Detector/SimulationArea.h -//! @brief Defines class SimulationArea. -//! -//! @homepage http://www.bornagainproject.org -//! @license GNU General Public License v3 or higher (see COPYING) -//! @copyright Forschungszentrum Jülich GmbH 2018 -//! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS) -// -// ************************************************************************************************ - -#ifdef SWIG -#error no need to expose this header to Swig -#endif - -#ifndef USER_API -#ifndef BORNAGAIN_DEVICE_DETECTOR_SIMULATIONAREA_H -#define BORNAGAIN_DEVICE_DETECTOR_SIMULATIONAREA_H - -#include "Device/Detector/SimulationAreaIterator.h" - -class IDetector; - -//! Holds iteration logic over active detector channels in the presence of masked areas -//! and RegionOfInterest defined. -//! @ingroup detector - -class SimulationArea { -public: - using iterator = SimulationAreaIterator; - explicit SimulationArea(const IDetector* detector); - virtual ~SimulationArea() {} - - SimulationAreaIterator begin(); - SimulationAreaIterator end(); - - //! returns true if given iterator index correspond to masked detector channel - virtual bool isMasked(size_t index) const; - - size_t totalSize() const; - - //! Return detector index from iterator index - size_t detectorIndex(size_t index) const; - -protected: - const IDetector* m_detector; - size_t m_max_index; -}; - -inline size_t SimulationArea::totalSize() const -{ - return m_max_index; -} - -//! Holds iteration logic over active detector channels in the presence of ROI. -//! In contrast to class SimulationArea, iterates also over masked areas. -//! @ingroup detector - -class SimulationRoiArea : public SimulationArea { -public: - explicit SimulationRoiArea(const IDetector* detector); - - virtual bool isMasked(size_t) const; -}; - -#endif // BORNAGAIN_DEVICE_DETECTOR_SIMULATIONAREA_H -#endif // USER_API diff --git a/Device/Detector/SimulationAreaIterator.cpp b/Device/Detector/SimulationAreaIterator.cpp index 47d5cf3d8de6a8a7ba2ff8327eba3eb95d0e5376..339e6e4fcb15ba9f6ffcebb91c240bed4f4e23e9 100644 --- a/Device/Detector/SimulationAreaIterator.cpp +++ b/Device/Detector/SimulationAreaIterator.cpp @@ -13,19 +13,38 @@ // ************************************************************************************************ #include "Device/Detector/IDetector2D.h" -#include "Device/Detector/SimulationArea.h" -SimulationAreaIterator::SimulationAreaIterator(const SimulationArea* area, size_t start_at_index) - : m_area(area), m_index(start_at_index), m_element_index(0) +SimulationAreaIterator::SimulationAreaIterator(const IDetector* detector, Mode mode, + size_t start_at_index) + : m_detector(detector) + , m_index(start_at_index) + , m_maxIndex(m_detector->sizeOfRegionOfInterest()) + , m_element_index(0) + , m_mode(mode) { - if (m_index > m_area->totalSize()) + if (m_index > m_maxIndex) throw std::runtime_error("SimulationAreaIterator::SimulationAreaIterator() " "-> Error. Invalid initial index"); - if (m_index != m_area->totalSize() && m_area->isMasked(m_index)) + if (m_index != m_maxIndex && isMasked(m_index)) m_index = nextIndex(m_index); } +SimulationAreaIterator SimulationAreaIterator::createBegin(const IDetector* detector, Mode mode) +{ + return SimulationAreaIterator(detector, mode, 0); +} + +SimulationAreaIterator SimulationAreaIterator::createEnd(const IDetector* detector, Mode mode) +{ + return SimulationAreaIterator(detector, mode, detector->sizeOfRegionOfInterest()); +} + +SimulationAreaIterator SimulationAreaIterator::createEnd() const +{ + return createEnd(m_detector, m_mode); +} + size_t SimulationAreaIterator::roiIndex() const { return m_index; @@ -33,7 +52,7 @@ size_t SimulationAreaIterator::roiIndex() const size_t SimulationAreaIterator::detectorIndex() const { - return m_area->detectorIndex(m_index); + return m_detector->regionOfInterestIndexToDetectorIndex(m_index); } SimulationAreaIterator& SimulationAreaIterator::operator++() @@ -55,15 +74,29 @@ SimulationAreaIterator SimulationAreaIterator::operator++(int) size_t SimulationAreaIterator::nextIndex(size_t currentIndex) { + // #baROI + this can be optimized: Check whether a RegionOfInterest is present, then do not + // check every single point + + size_t result = ++currentIndex; - if (result < m_area->totalSize()) { - while (m_area->isMasked(result)) { + if (result < m_maxIndex) { + while (isMasked(result)) { ++result; - if (result == m_area->totalSize()) + if (result == m_maxIndex) break; } } else { - return m_area->totalSize(); + return m_maxIndex; } return result; } + +bool SimulationAreaIterator::isMasked(size_t index) const +{ + if (m_mode == regionOfInterest) + return false; + + const auto masks = m_detector->detectorMask(); + const auto detectorIndex = m_detector->regionOfInterestIndexToDetectorIndex(index); + return (masks && masks->isMasked(detectorIndex)); +} diff --git a/Device/Detector/SimulationAreaIterator.h b/Device/Detector/SimulationAreaIterator.h index 3f718eebf9ba0ef4c39c194e4c3b115d9f276d56..cb98af7871390a5d576c4ae67e99abfb555a739c 100644 --- a/Device/Detector/SimulationAreaIterator.h +++ b/Device/Detector/SimulationAreaIterator.h @@ -21,14 +21,33 @@ #define BORNAGAIN_DEVICE_DETECTOR_SIMULATIONAREAITERATOR_H #include <cstdlib> -class SimulationArea; + +class IDetector; //! An iterator for SimulationArea. //! @ingroup detector class SimulationAreaIterator { public: - explicit SimulationAreaIterator(const SimulationArea* area, size_t start_at_index); + //! Mode how the points shall be traversed + enum Mode { + regionOfInterest, //!< iterate over all points in "region of interest", no matter whether + //!< masked + notMasked //!< iterate over all points in "region of interest" and not masked + }; + +private: + explicit SimulationAreaIterator(const IDetector* detector, Mode mode, size_t start_at_index); + +public: + //! Create begin-iterator to iterate over all points according to the given mode. + static SimulationAreaIterator createBegin(const IDetector* detector, Mode mode); + + //! Create end-iterator to iterate over all points according to the given mode. + static SimulationAreaIterator createEnd(const IDetector* detector, Mode mode); + + //! Convenience function to create an end-iterator matching to this iterator. + SimulationAreaIterator createEnd() const; size_t index() const { return m_index; } size_t elementIndex() const { return m_element_index; } @@ -46,14 +65,21 @@ public: private: size_t nextIndex(size_t currentIndex); - const SimulationArea* m_area; + + //! Check whether masked according to the given mode (always false if mode is regionOfInterest). + //! index is an ROI index. + bool isMasked(size_t index) const; + + const IDetector* m_detector; size_t m_index; //!< ROI related index + size_t m_maxIndex; //!< ROI related maximum index size_t m_element_index; //!< sequential number for SimulationElementVector + Mode m_mode; }; inline bool SimulationAreaIterator::operator==(const SimulationAreaIterator& other) const { - return m_area == other.m_area && m_index == other.m_index; + return m_detector == other.m_detector && m_index == other.m_index && m_mode == other.m_mode; } inline bool SimulationAreaIterator::operator!=(const SimulationAreaIterator& right) const diff --git a/Tests/UnitTests/Core/Instrument/SimulationAreaTest.cpp b/Tests/UnitTests/Core/Instrument/SimulationAreaTest.cpp index 08deb7753d5b17e6ec5821e77c676ec78d8a3dec..40506f399af4db6bfdfb411efb1c96f6cdc498c7 100644 --- a/Tests/UnitTests/Core/Instrument/SimulationAreaTest.cpp +++ b/Tests/UnitTests/Core/Instrument/SimulationAreaTest.cpp @@ -1,4 +1,4 @@ -#include "Device/Detector/SimulationArea.h" +#include "Device/Detector/SimulationAreaIterator.h" #include "Device/Detector/SphericalDetector.h" #include "Device/Mask/Rectangle.h" #include "Tests/GTestWrapper/google_test.h" @@ -13,17 +13,16 @@ class SimulationAreaTest : public ::testing::Test { TEST_F(SimulationAreaTest, iteratorOperations) { SphericalDetector detector(4, -1.0, 3.0, 2, 0.0, 2.0); - SimulationArea area(&detector); // begin iterator - SimulationArea::iterator it_begin = area.begin(); + SimulationAreaIterator it_begin = detector.beginNonMaskedPoints(); EXPECT_EQ(it_begin.index(), 0u); EXPECT_EQ(it_begin.elementIndex(), 0u); - EXPECT_TRUE(it_begin == area.begin()); - EXPECT_FALSE(it_begin != area.begin()); + EXPECT_TRUE(it_begin == detector.beginNonMaskedPoints()); + EXPECT_FALSE(it_begin != detector.beginNonMaskedPoints()); // end iterator - SimulationArea::iterator it_end = area.end(); + SimulationAreaIterator it_end = detector.endNonMaskedPoints(); EXPECT_EQ(it_end.index(), detector.totalSize()); EXPECT_EQ(it_end.elementIndex(), 0u); // has initial value @@ -32,7 +31,7 @@ TEST_F(SimulationAreaTest, iteratorOperations) EXPECT_FALSE(it_begin == it_end); // assignment - SimulationArea::iterator it = area.begin(); + SimulationAreaIterator it = detector.beginNonMaskedPoints(); EXPECT_TRUE(it == it_begin); EXPECT_FALSE(it != it_begin); @@ -58,7 +57,6 @@ TEST_F(SimulationAreaTest, iteratorOperations) TEST_F(SimulationAreaTest, detectorIteration) { SphericalDetector detector(4, -1.0, 3.0, 2, 0.0, 2.0); - SimulationArea area(&detector); std::vector<size_t> expectedIndexes = {0, 1, 2, 3, 4, 5, 6, 7}; std::vector<size_t> expectedElementIndexes = {0, 1, 2, 3, 4, 5, 6, 7}; @@ -66,7 +64,7 @@ TEST_F(SimulationAreaTest, detectorIteration) std::vector<size_t> indexes; std::vector<size_t> elementIndexes; std::vector<size_t> detectorIndexes; - for (SimulationArea::iterator it = area.begin(); it != area.end(); ++it) { + for (auto it = detector.beginNonMaskedPoints(); it != detector.endNonMaskedPoints(); ++it) { indexes.push_back(it.index()); elementIndexes.push_back(it.elementIndex()); detectorIndexes.push_back(it.detectorIndex()); @@ -83,13 +81,12 @@ TEST_F(SimulationAreaTest, maskedIteration) SphericalDetector detector(5, -1.0, 4.0, 4, 0.0, 4.0); detector.addMask(Rectangle(0.1, 1.1, 2.9, 2.9), true); detector.addMask(Rectangle(3.1, 3.1, 3.9, 3.9), true); - SimulationArea area(&detector); std::vector<size_t> expectedIndexes = {0, 1, 2, 3, 4, 7, 8, 11, 12, 15, 16, 17, 18}; std::vector<size_t> expectedElementIndexes = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}; std::vector<size_t> indexes; std::vector<size_t> elementIndexes; - for (SimulationArea::iterator it = area.begin(); it != area.end(); ++it) { + for (auto it = detector.beginNonMaskedPoints(); it != detector.endNonMaskedPoints(); ++it) { indexes.push_back(it.index()); elementIndexes.push_back(it.elementIndex()); } @@ -97,14 +94,13 @@ TEST_F(SimulationAreaTest, maskedIteration) EXPECT_EQ(elementIndexes, expectedElementIndexes); } -//! Iteration over the detector with first and alst bin masked +//! Iteration over the detector with first and last bin masked TEST_F(SimulationAreaTest, maskedCornerIteration) { SphericalDetector detector(5, -1.0, 4.0, 4, 0.0, 4.0); detector.addMask(Rectangle(-0.9, 0.1, -0.1, 0.9), true); detector.addMask(Rectangle(3.1, 3.1, 3.9, 3.9), true); - SimulationArea area(&detector); std::vector<size_t> expectedIndexes = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18}; @@ -112,7 +108,7 @@ TEST_F(SimulationAreaTest, maskedCornerIteration) 9, 10, 11, 12, 13, 14, 15, 16, 17}; std::vector<size_t> indexes; std::vector<size_t> elementIndexes; - for (SimulationArea::iterator it = area.begin(); it != area.end(); ++it) { + for (auto it = detector.beginNonMaskedPoints(); it != detector.endNonMaskedPoints(); ++it) { indexes.push_back(it.index()); elementIndexes.push_back(it.elementIndex()); } @@ -126,11 +122,11 @@ TEST_F(SimulationAreaTest, allMaskedIteration) { SphericalDetector detector(5, -1.0, 4.0, 4, 0.0, 4.0); detector.addMask(Rectangle(-0.9, 0.1, 3.9, 3.9), true); - SimulationArea area(&detector); std::vector<size_t> indexes; std::vector<size_t> elementIndexes; - for (SimulationArea::iterator it = area.begin(); it != area.end(); ++it) { + + for (auto it = detector.beginNonMaskedPoints(); it != detector.endNonMaskedPoints(); ++it) { indexes.push_back(it.index()); elementIndexes.push_back(it.elementIndex()); } @@ -145,7 +141,6 @@ TEST_F(SimulationAreaTest, maskAndRoiIteration) SphericalDetector detector(5, -1.0, 4.0, 4, 0.0, 4.0); detector.setRegionOfInterest(0.1, 1.1, 2.9, 3.9); detector.addMask(Rectangle(-0.9, 0.1, 0.9, 1.9), true); - SimulationArea area(&detector); std::vector<size_t> expectedRoiIndexes = {1, 2, 3, 4, 5, 6, 7, 8}; std::vector<size_t> expectedDetectorIndexes = {6, 7, 9, 10, 11, 13, 14, 15}; @@ -154,7 +149,7 @@ TEST_F(SimulationAreaTest, maskAndRoiIteration) std::vector<size_t> elementIndexes; std::vector<size_t> detectorIndexes; std::vector<size_t> roiIndexes; - for (SimulationArea::iterator it = area.begin(); it != area.end(); ++it) { + for (auto it = detector.beginNonMaskedPoints(); it != detector.endNonMaskedPoints(); ++it) { indexes.push_back(it.index()); elementIndexes.push_back(it.elementIndex()); detectorIndexes.push_back(it.detectorIndex()); @@ -189,7 +184,6 @@ TEST_F(SimulationAreaTest, maskAndRoiIterationVisitMasks) SphericalDetector detector(5, -1.0, 4.0, 4, 0.0, 4.0); detector.setRegionOfInterest(0.1, 1.1, 2.9, 3.9); detector.addMask(Rectangle(-0.9, 0.1, 0.9, 1.9), true); - SimulationRoiArea area(&detector); std::vector<size_t> expectedRoiIndexes = {0, 1, 2, 3, 4, 5, 6, 7, 8}; std::vector<size_t> expectedDetectorIndexes = {5, 6, 7, 9, 10, 11, 13, 14, 15}; @@ -198,7 +192,8 @@ TEST_F(SimulationAreaTest, maskAndRoiIterationVisitMasks) std::vector<size_t> elementIndexes; std::vector<size_t> detectorIndexes; std::vector<size_t> roiIndexes; - for (SimulationArea::iterator it = area.begin(); it != area.end(); ++it) { + for (auto it = detector.beginRegionOfInterestPoints(); + it != detector.endRegionOfInterestPoints(); ++it) { indexes.push_back(it.index()); elementIndexes.push_back(it.elementIndex()); detectorIndexes.push_back(it.detectorIndex()); @@ -233,7 +228,6 @@ TEST_F(SimulationAreaTest, indexInRoi) SphericalDetector detector(5, -1.0, 4.0, 4, 0.0, 4.0); detector.setRegionOfInterest(0.1, 1.1, 2.9, 3.9); detector.addMask(Rectangle(-0.9, 0.1, 0.9, 1.9), true); - SimulationArea area(&detector); std::vector<size_t> expectedIndexes = {1, 2, 3, 4, 5, 6, 7, 8}; std::vector<size_t> expectedDetectorIndexes = {6, 7, 9, 10, 11, 13, 14, 15}; @@ -243,7 +237,7 @@ TEST_F(SimulationAreaTest, indexInRoi) std::vector<size_t> elementIndexes; std::vector<size_t> roiIndexes; std::vector<size_t> detectorIndexes; - for (SimulationArea::iterator it = area.begin(); it != area.end(); ++it) { + for (auto it = detector.beginNonMaskedPoints(); it != detector.endNonMaskedPoints(); ++it) { indexes.push_back(it.index()); elementIndexes.push_back(it.elementIndex()); roiIndexes.push_back(it.roiIndex()); diff --git a/Tests/UnitTests/Core/Instrument/SpecularDetector1DTest.cpp b/Tests/UnitTests/Core/Instrument/SpecularDetector1DTest.cpp index b094b289f5bcc231d4918c6efb76fe011f722077..907f93090aee6d935db39289422291ab72420858 100644 --- a/Tests/UnitTests/Core/Instrument/SpecularDetector1DTest.cpp +++ b/Tests/UnitTests/Core/Instrument/SpecularDetector1DTest.cpp @@ -2,7 +2,6 @@ #include "Base/Const/Units.h" #include "Device/Beam/Beam.h" #include "Device/Data/OutputData.h" -#include "Device/Detector/SimulationArea.h" #include "Tests/GTestWrapper/google_test.h" #include <memory> @@ -62,12 +61,11 @@ TEST_F(SpecularDetectorTest, Clone) EXPECT_EQ(nullptr, clone->detectorMask()); // checking iteration over the map of cloned detector - SimulationArea area(clone.get()); const std::vector<size_t> expectedDetectorIndexes = {0, 1, 2, 3, 4}; const std::vector<size_t> expectedElementIndexes = expectedDetectorIndexes; std::vector<size_t> detectorIndexes; std::vector<size_t> elementIndexes; - for (SimulationArea::iterator it = area.begin(); it != area.end(); ++it) { + for (auto it = clone->beginNonMaskedPoints(); it != clone->endNonMaskedPoints(); ++it) { detectorIndexes.push_back(it.detectorIndex()); elementIndexes.push_back(it.elementIndex()); } diff --git a/Tests/UnitTests/Core/Instrument/SphericalDetectorTest.cpp b/Tests/UnitTests/Core/Instrument/SphericalDetectorTest.cpp index fb9095282e8556c1be5b9dcbb3f9355805230f9a..76a81cef8f240abcf342ffa44a7a7be358d6463f 100644 --- a/Tests/UnitTests/Core/Instrument/SphericalDetectorTest.cpp +++ b/Tests/UnitTests/Core/Instrument/SphericalDetectorTest.cpp @@ -1,7 +1,6 @@ #include "Device/Detector/SphericalDetector.h" #include "Base/Const/Units.h" #include "Device/Beam/Beam.h" -#include "Device/Detector/SimulationArea.h" #include "Device/Mask/Polygon.h" #include "Device/Mask/Rectangle.h" #include "Device/ProDetector/RegionOfInterest.h" @@ -205,12 +204,11 @@ TEST_F(SphericalDetectorTest, Clone) EXPECT_EQ(clone->detectorMask()->numberOfMaskedChannels(), 8); // checking iteration over the map of cloned detector - SimulationArea area(clone.get()); std::vector<size_t> expectedDetectorIndexes = {6, 9, 10, 13, 14, 17}; std::vector<size_t> expectedElementIndexes = {0, 1, 2, 3, 4, 5}; std::vector<size_t> detectorIndexes; std::vector<size_t> elementIndexes; - for (SimulationArea::iterator it = area.begin(); it != area.end(); ++it) { + for (auto it = clone->beginNonMaskedPoints(); it != clone->endNonMaskedPoints(); ++it) { detectorIndexes.push_back(it.detectorIndex()); elementIndexes.push_back(it.elementIndex()); }