Skip to content
Snippets Groups Projects
Commit 3bc0dedb authored by Pospelov, Gennady's avatar Pospelov, Gennady
Browse files

SimulationAreaIterator switched to ROI

parent 42544238
No related branches found
No related tags found
No related merge requests found
......@@ -16,9 +16,7 @@
#include "BornAgainNamespace.h"
#include "IDetector2D.h"
#include "Histogram2D.h"
// InfinitePlane, Line, VerticalLine, HorizontalLine
#include "RegionOfInterest.h"
DetectorMask::DetectorMask()
: m_number_of_masked_channels(0)
......@@ -63,8 +61,14 @@ void DetectorMask::initMaskData(const IDetector2D& detector)
assert(m_shapes.size() == m_mask_of_shape.size());
m_mask_data.clear();
for (size_t dim=0; dim<detector.getDimension(); ++dim)
m_mask_data.addAxis(detector.getAxis(dim));
for (size_t dim=0; dim<detector.getDimension(); ++dim) {
const IAxis &axis = detector.getAxis(dim);
// if(detector.regionOfInterest()) {
// m_mask_data.addAxis(*detector.regionOfInterest()->clipAxisToRoi(dim, axis).get());
// } else {
m_mask_data.addAxis(axis);
// }
}
process_masks();
}
......@@ -86,7 +90,7 @@ bool DetectorMask::isMasked(size_t index) const
return false;
if(index >= m_mask_data.getAllocatedSize())
throw Exceptions::RuntimeErrorException("DetectorMask::getMask() -> Error. "
throw Exceptions::RuntimeErrorException("DetectorMask::isMasked() -> Error. "
"Index is out of range "+std::to_string(index));
return m_mask_data[index];
}
......
......@@ -147,11 +147,13 @@ const RegionOfInterest *IDetector2D::regionOfInterest() const
void IDetector2D::setRegionOfInterest(double xlow, double ylow, double xup, double yup)
{
m_region_of_interest.reset(new RegionOfInterest(*this, xlow, ylow, xup, yup));
m_detector_mask.initMaskData(*this);
}
void IDetector2D::resetRegionOfInterest()
{
m_region_of_interest.reset();
m_detector_mask.initMaskData(*this);
}
void IDetector2D::removeMasks()
......
......@@ -34,7 +34,10 @@ SimulationArea::SimulationArea(const IDetector2D *detector)
throw Exceptions::RuntimeErrorException(
"SimulationArea::SimulationArea: detector is not two-dimensional");
m_max_index = m_detector->getTotalSize();
if(m_detector->regionOfInterest())
m_max_index = m_detector->regionOfInterest()->roiSize();
else
m_max_index = m_detector->getTotalSize();
}
SimulationAreaIterator SimulationArea::begin()
......@@ -56,27 +59,20 @@ bool SimulationArea::isMasked(size_t index) const
throw Exceptions::RuntimeErrorException(message.str());
}
if(m_detector->regionOfInterest())
if(!m_detector->regionOfInterest()->isInROI(index)) return true;
return m_detector->isMasked(index);
return m_detector->getDetectorMask()->isMasked(detectorIndex(index));
}
size_t SimulationArea::roiIndex(size_t index) const
{
if(!m_detector->regionOfInterest())
return index;
return m_detector->regionOfInterest()->roiIndex(index);
return index;
}
size_t SimulationArea::detectorIndex(size_t index) const
{
// if(!m_detector->regionOfInterest())
// return index;
if(!m_detector->regionOfInterest())
return index;
// return m_detector->regionOfInterest()->detectorIndex(index);
return index;
return m_detector->regionOfInterest()->detectorIndex(index);
}
// --------------------------------------------------------------------------------------
......@@ -87,10 +83,7 @@ SimulationRoiArea::SimulationRoiArea(const IDetector2D *detector)
}
bool SimulationRoiArea::isMasked(size_t index) const
bool SimulationRoiArea::isMasked(size_t) const
{
if(m_detector->regionOfInterest())
if(!m_detector->regionOfInterest()->isInROI(index)) return true;
return false;
}
......@@ -64,7 +64,7 @@ class BA_CORE_API_ SimulationRoiArea : public SimulationArea
public:
explicit SimulationRoiArea(const IDetector2D *detector);
virtual bool isMasked(size_t index) const;
virtual bool isMasked(size_t) const;
};
......
......@@ -152,19 +152,23 @@ TEST_F(SimulationAreaTest, maskAndRoiIteration)
detector.addMask(Geometry::Rectangle(-0.9, 0.1, 0.9, 1.9), true);
SimulationArea area(&detector);
std::vector<int> expectedIndexes = {6, 7, 9, 10, 11, 13, 14, 15};
std::vector<int> expectedRoiIndexes = {1, 2, 3, 4, 5, 6, 7, 8};
std::vector<int> expectedDetectorIndexes = {6, 7, 9, 10, 11, 13, 14, 15};
std::vector<int> expectedElementIndexes = {0, 1, 2, 3, 4, 5, 6, 7};
std::vector<int> indexes;
std::vector<int> elementIndexes;
std::vector<int> detectorIndexes;
std::vector<int> roiIndexes;
for(SimulationArea::iterator it = area.begin(); it!=area.end(); ++it) {
indexes.push_back(it.index());
elementIndexes.push_back(it.elementIndex());
detectorIndexes.push_back(it.detectorIndex());
roiIndexes.push_back(it.roiIndex());
}
EXPECT_EQ(indexes, expectedIndexes);
EXPECT_EQ(indexes, expectedRoiIndexes);
EXPECT_EQ(elementIndexes, expectedElementIndexes);
EXPECT_EQ(detectorIndexes, expectedIndexes);
EXPECT_EQ(detectorIndexes, expectedDetectorIndexes);
EXPECT_EQ(roiIndexes, expectedRoiIndexes);
}
//! Checking index of ROI
......@@ -176,7 +180,8 @@ TEST_F(SimulationAreaTest, indexInRoi)
detector.addMask(Geometry::Rectangle(-0.9, 0.1, 0.9, 1.9), true);
SimulationArea area(&detector);
std::vector<int> expectedIndexes = {6, 7, 9, 10, 11, 13, 14, 15};
std::vector<int> expectedIndexes = {1, 2, 3, 4, 5, 6, 7, 8};
std::vector<int> expectedDetectorIndexes = {6, 7, 9, 10, 11, 13, 14, 15};
std::vector<int> expectedElementIndexes = {0, 1, 2, 3, 4, 5, 6, 7};
std::vector<int> expectedRoi = {1, 2, 3, 4, 5, 6, 7, 8};
std::vector<int> indexes;
......@@ -192,7 +197,7 @@ TEST_F(SimulationAreaTest, indexInRoi)
EXPECT_EQ(indexes, expectedIndexes);
EXPECT_EQ(elementIndexes, expectedElementIndexes);
EXPECT_EQ(roiIndexes, expectedRoi);
EXPECT_EQ(detectorIndexes, expectedIndexes);
EXPECT_EQ(detectorIndexes, expectedDetectorIndexes);
}
#endif
......@@ -355,15 +355,15 @@ TEST_F(SphericalDetectorTest, Clone)
// checking iteration over the map of cloned detector
SimulationArea area(clone.get());
std::vector<int> expectedIndexes = {6, 9, 10, 13, 14, 17};
std::vector<int> expectedDetectorIndexes = {6, 9, 10, 13, 14, 17};
std::vector<int> expectedElementIndexes = {0, 1, 2, 3, 4, 5};
std::vector<int> indexes;
std::vector<int> detectorIndexes;
std::vector<int> elementIndexes;
for(SimulationArea::iterator it = area.begin(); it!=area.end(); ++it) {
indexes.push_back(it.index());
detectorIndexes.push_back(it.detectorIndex());
elementIndexes.push_back(it.elementIndex());
}
EXPECT_EQ(indexes, expectedIndexes);
EXPECT_EQ(detectorIndexes, expectedDetectorIndexes);
EXPECT_EQ(elementIndexes, expectedElementIndexes);
}
......
......@@ -547,3 +547,10 @@
| date | hostname | sysinfo | python | total cpu | total wall | MultiLayer | CylindersInDWBA | RotatedPyramids | CoreShell | SquareLattice | RadialParaCrystal | HexParaCrystal | SSCA | Mesocrystal | PolMagCyl | Custom FF |
| 2016-10-24 13:27:17 | scgsun | Linux x86_64 | 2.7 | 120.7920 | 19.2657 | 2.8666 | 0.6583 | 3.3504 | 0.4888 | 2.3131 | 0.6682 | 3.2659 | 1.1200 | 1.9051 | 1.7457 | 0.8838 |
# after switch to SimulationAreaIterator based on ROI
| date | hostname | sysinfo | python | total cpu | total wall | MultiLayer | CylindersInDWBA | RotatedPyramids | CoreShell | SquareLattice | RadialParaCrystal | HexParaCrystal | SSCA | Mesocrystal | PolMagCyl | Custom FF |
| 2016-10-25 17:19:59 | scgsun | Linux x86_64 | 2.7 | 121.3720 | 18.5189 | 2.8794 | 0.5891 | 3.2295 | 0.4259 | 2.2341 | 0.5990 | 3.4064 | 0.8513 | 1.7682 | 1.6408 | 0.8952 |
| 2016-10-25 17:20:43 | scgsun | Linux x86_64 | 2.7 | 120.4280 | 18.1926 | 2.8557 | 0.5722 | 3.2113 | 0.4582 | 2.2046 | 0.5936 | 3.2125 | 0.8494 | 1.7489 | 1.6168 | 0.8694 |
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