22 static ossimTrace traceDebug(
"ossimRectanglePartitioner:debug");
34 vector<ossimIrect>& result,
44 if (maxSizeInBytes == 0)
47 <<
"Waning: 0 passed for max size in bytes. Returning..." 54 <<
"Waning: 0 passed for number of bands. Returning..." 58 if (bytesPerPixel == 0)
61 <<
"Waning: 0 passed for bytes per pixel. Returning..." 68 <<
"Waning: Input rectangle has nans in it! Returning..." 72 if ( (maxSizeInBytes / (bands*bytesPerPixel)) < 4)
76 <<
"Waning: Max size in bytes too small. Returning..." 83 if (getSize(inputRectangle, bands, bytesPerPixel) <= maxSizeInBytes)
85 result.push_back(inputRectangle);
89 trace(inputRectangle, result, maxSizeInBytes, bands, bytesPerPixel);
98 splitUntilLessThanMax(tileRect,
102 internalOverlapPixels);
110 ossim_int32 tiles_wide = (input_width % tile_width) ?
111 ( (input_width/tile_width)+1) : (input_width/tile_width);
112 ossim_int32 tiles_high = (input_height % tile_height) ?
113 ( (input_height/tile_height)+1) : (input_height/tile_height);
116 ossim_int32 y_stop = y_start + tile_height - 1 + internalOverlapPixels;
121 if (y_stop > inputRectangle.
lr().
y)
123 y_stop = inputRectangle.
lr().
y;
127 ossim_int32 x_stop = x_start + tile_width - 1 + internalOverlapPixels;
132 if (x_stop > inputRectangle.
lr().
x)
134 x_stop = inputRectangle.
lr().
x;
137 ossimIrect r(x_start, y_start, x_stop, y_stop);
144 x_start += tile_width - internalOverlapPixels;
148 x_start += tile_width;
150 x_stop += tile_width;
156 y_start += tile_height - internalOverlapPixels;
160 y_start += tile_height;
162 y_stop += tile_height;
168 trace(inputRectangle, result, maxSizeInBytes, bands, bytesPerPixel);
183 }
while ( getSize(rect,
186 internalOverlapPixels) > maxSizeInBytes );
199 new_height = (height % 2) ? ( (height/2) + 1 ) : (height/2);
203 new_width = (width % 2) ? ( (width/2) + 1) : (width/2);
207 rect =
ossimIrect(0, 0, new_width-1, new_height-1);
216 return( ( rect.
width() + 2 * internalOverlapPixels ) *
217 ( rect.
height() + 2 * internalOverlapPixels ) *
218 bands * bytesPerPixel );
222 const std::vector<ossimIrect>& v,
228 <<
"ossimRectanglePartitioner DEBUG:" 229 <<
"\nInput rectangle: " << r
230 <<
"\nInput rectangle byte size: " << getSize(r, bands, bytesPerPixel)
231 <<
"\nTile max size in bytes: " << maxSizeInBytes
232 <<
"\nbands: " << bands
233 <<
"\nbytesPerPixel: " << bytesPerPixel
234 <<
"\nNumber of output tiles: " << v.
size()
235 <<
"\nTiled rectangles:\n";
238 vector<ossimIrect>::const_iterator i = v.begin();
242 <<
"tile[" << index <<
"]: " << *i
243 <<
"\nsize in bytes: " << getSize(*i, bands, bytesPerPixel)
ossimRectanglePartitioner()
default construtor
ossim_uint64 getSize(const ossimIrect &rect, ossim_uint32 bands, ossim_uint32 bytesPerPixel, ossim_uint32 internalOverlapPixels=0) const
ossim_uint32 height() const
const ossimIpt & ul() const
void trace(const ossimIrect &r, const std::vector< ossimIrect > &v, ossim_uint64 maxSizeInBytes, ossim_uint32 bands, ossim_uint32 bytesPerPixel) const
Convenience trace method.
void splitUntilLessThanMax(ossimIrect &rect, ossim_uint64 maxSizeInBytes, ossim_uint32 bands, ossim_uint32 bytesPerPixel, ossim_uint32 internalOverlapPixels=0) const
Recursively splits the input rectangle until the size is less than or equal to maxSizeInBytes.
unsigned long long ossim_uint64
unsigned int ossim_uint32
void splitRect(ossimIrect &rect) const
Splits rectangle in half rounding up if needed.
const ossimIpt & lr() const
ossim_uint32 width() const
void binaryPartition(const ossimIrect &inputRectangle, std::vector< ossimIrect > &result, ossim_uint64 maxSizeInBytes, ossim_uint32 bands, ossim_uint32 bytesPerPixel, ossim_uint32 internalOverlapPixels=0) const
Partitions the rectangle doing a binary split on the longest dimension until the total size is less t...
~ossimRectanglePartitioner()
destructor
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)