Commit 000cdc8f authored by Emmanuel Christophe's avatar Emmanuel Christophe

work in progress

parent 9c690560
......@@ -62,86 +62,81 @@ namespace otb
template <unsigned int VImageDimension>
itk::ImageRegion<VImageDimension>
ImageRegionTileMapSplitter<VImageDimension>
::GetSplit(unsigned int i, unsigned int numberOfPieces,
const RegionType &region)
{
int splitAxis;
RegionType splitRegion;
IndexType splitIndex;
SizeType splitSize, regionSize;
::GetSplit(unsigned int i, unsigned int numberOfPieces, const RegionType &region)
{
int splitAxis;
RegionType splitRegion;
IndexType splitIndex;
SizeType splitSize, regionSize;
// Initialize the splitRegion to the requested region
splitRegion = region;
splitIndex = splitRegion.GetIndex();
splitSize = splitRegion.GetSize();
splitRegion = region;
splitIndex = splitRegion.GetIndex();
splitSize = splitRegion.GetSize();
regionSize = region.GetSize();
regionSize = region.GetSize();
// split on the outermost dimension available
splitAxis = VImageDimension - 1;
while (regionSize[splitAxis] == 1)
{
--splitAxis;
if (splitAxis < 0)
{ // cannot split
itkDebugMacro(" Cannot Split");
return splitRegion;
}
}
splitAxis = VImageDimension - 1;
while (regionSize[splitAxis] == 1)
{
--splitAxis;
if (splitAxis < 0)
{ // cannot split
itkDebugMacro(" Cannot Split");
return splitRegion;
}
}
// determine the actual number of pieces that will be generated
SizeValueType range = regionSize[splitAxis];
int valuesPerPiece = ((int)::ceil(range/((double)numberOfPieces*256))) * 256;
int maxPieceUsed = (int)::ceil(range/(double)valuesPerPiece);
SizeValueType range = regionSize[splitAxis];
int valuesPerPiece = ((int)::ceil(range/((double)numberOfPieces*256))) * 256;
int maxPieceUsed = (int)::ceil(range/(double)valuesPerPiece);
// Split the region
if ((int) i == maxPieceUsed-1)
{
splitIndex[splitAxis] += i*valuesPerPiece;
if ((int) i == maxPieceUsed-1)
{
splitIndex[splitAxis] += i*valuesPerPiece;
// last piece needs to process the "rest" dimension being split
// splitSize[splitAxis] = splitSize[splitAxis] - i*valuesPerPiece;
splitSize[splitAxis] = regionSize[splitAxis] - splitIndex[splitAxis];
}
if (((int) i == 0) && ((int) i != maxPieceUsed-1))
{
splitSize[splitAxis] = regionSize[splitAxis] - splitIndex[splitAxis];
}
if (((int) i == 0) && ((int) i != maxPieceUsed-1))
{
//First piece may not contain a whole piece
//splitIndex stay at splitRegion.GetIndex();
splitSize[splitAxis] = (((int)::floor(splitIndex[splitAxis]/valuesPerPiece))+1)
*valuesPerPiece - splitIndex[splitAxis];
}
if ((int) i < maxPieceUsed-1)
{
splitIndex[splitAxis] += i*valuesPerPiece;
splitSize[splitAxis] = valuesPerPiece;
}
splitSize[splitAxis] = (((int)::floor(splitIndex[splitAxis]/valuesPerPiece))+1)
*valuesPerPiece - splitIndex[splitAxis];
}
if ((int) i < maxPieceUsed-1)
{
splitIndex[splitAxis] += i*valuesPerPiece;
splitSize[splitAxis] = valuesPerPiece;
}
// set the split region ivars
splitRegion.SetIndex( splitIndex );
splitRegion.SetSize( splitSize );
splitRegion.SetIndex( splitIndex );
splitRegion.SetSize( splitSize );
std::cout << "Part: " << i << std::endl;
std::cout << splitIndex << std::endl;//TODO remove
std::cout << splitSize << std::endl;
std::cout.flush();
itkDebugMacro(" Split Piece: " << splitRegion );
itkDebugMacro(" Split Piece: " << splitRegion );
return splitRegion;
}
return splitRegion;
}
/**
*
*
*/
template <unsigned int VImageDimension>
void
ImageRegionTileMapSplitter<VImageDimension>
template <unsigned int VImageDimension>
void
ImageRegionTileMapSplitter<VImageDimension>
::PrintSelf(std::ostream& os, itk::Indent indent) const
{
Superclass::PrintSelf(os,indent);
}
{
Superclass::PrintSelf(os,indent);
}
} // end namespace itk
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment