80 static_assert(tFactor >= 2u,
"Invalid factor!");
82 const unsigned int width = layerI_.width();
83 const unsigned int height = layerI_.height();
85 const unsigned int coarserWidth = coarserLayerI_.width();
86 const unsigned int coarserHeight = coarserLayerI_.height();
88 ocean_assert(width / tFactor == coarserWidth);
89 ocean_assert(height / tFactor == coarserHeight);
91 MappingI& mapping = layerI_.mapping();
92 const MappingI& coarserMapping = coarserLayerI_.mapping();
96 const uint8_t*
const mask = layerI_.mask().template constdata<uint8_t>();
97 const uint8_t*
const coarserMask = coarserLayerI_.mask().template constdata<uint8_t>();
99 const unsigned int maskStrideElements = layerI_.mask().strideElements();
100 const unsigned int coarserMaskStrideElements = coarserLayerI_.mask().strideElements();
102 for (
unsigned int y = firstRow; y < firstRow + numberRows; ++y)
104 const uint8_t* maskRow = mask + y * maskStrideElements;
107 const unsigned int yCoarser = min(y / tFactor, coarserHeight - 1u);
109 const uint8_t* coarserMaskRow = coarserMask + yCoarser * coarserMaskStrideElements;
112 for (
unsigned int x = firstColumn; x < firstColumn + numberColumns; ++x)
114 if (maskRow[x] != 0xFFu)
116 const unsigned int xCoarser = min(x / tFactor, coarserWidth - 1u);
119 if (coarserMaskRow[xCoarser] != 0xFFu)
121 const PixelPosition& coarserPosition = coarserPositionRow[xCoarser];
122 ocean_assert(coarserPosition.
x() < coarserLayerI_.width());
123 ocean_assert(coarserPosition.
y() < coarserLayerI_.height());
125 const unsigned int candidateX = (
unsigned int)(
int(x) + (int(coarserPosition.
x()) - int(xCoarser)) *
int(tFactor));
126 const unsigned int candidateY = (
unsigned int)(
int(y) + (int(coarserPosition.
y()) - int(yCoarser)) *
int(tFactor));
128 ocean_assert(candidateX < width);
129 ocean_assert(candidateY < height);
131 if (mask[candidateY * maskStrideElements + candidateX] == 0xFFu)
138 unsigned int candidateX, candidateY;
144 while (mask[candidateY * maskStrideElements + candidateX] != 0xFFu);
void initializeSubset(const unsigned int firstColumn, const unsigned int numberColumns, const unsigned int firstRow, const unsigned int numberRows) const override
Initializes a subset of the entire mapping area.
Definition InitializerCoarserMappingAdaptionI1.h:78
InitializerCoarserMappingAdaptionI1(LayerI1 &layer, RandomGenerator &randomGenerator, const LayerI1 &coarserLayer)
Creates a new initializer object.
Definition InitializerCoarserMappingAdaptionI1.h:66
PixelPositionT< unsigned int > PixelPosition
Definition of the default PixelPosition object with a data type allowing only positive coordinate val...
Definition PixelPosition.h:34