Пример #1
0
 public void ProcessCellWindow2D(int windowStartX, int windowStartY, int windowWidth, int windowHeight, ProcessRasterWindowSpanDelegate processWindowSpanDelegate)
 {
     ProcessCellWindow(new int[] { windowStartX, windowStartY }, new int[] { windowWidth, windowHeight }, processWindowSpanDelegate);
 }
Пример #2
0
 public void ProcessCellWindow(int[] windowPos, int[] windowSize, ProcessRasterWindowSpanDelegate processWindowSpanDelegate)
 {
     ProcessRasterWindow(false, windowPos, windowSize, processWindowSpanDelegate);
 }
Пример #3
0
 public void ProcessVertexWindow(int[] windowPos, int[] windowSize, ProcessRasterWindowSpanDelegate processWindowSpanDelegate)
 {
     ProcessRasterWindow(true, windowPos, windowSize, processWindowSpanDelegate);
 }
Пример #4
0
        public void ProcessRasterWindow(bool useVertices, int[] windowPos, int[] windowSize, ProcessRasterWindowSpanDelegate processWindowSpanDelegate)
        {
            if (windowPos == null)
            {
                throw new ArgumentNullException("windowPos");
            }
            if (windowSize == null)
            {
                throw new ArgumentNullException("windowSize");
            }
            if (processWindowSpanDelegate == null)
            {
                throw new ArgumentNullException("processWindowSpanDelegate");
            }
            if (windowPos.Length != m_raster.Dimension)
            {
                throw new ArgumentException("The number of entries in windowPos should match the raster axis count.");
            }
            if (windowSize.Length != m_raster.Dimension)
            {
                throw new ArgumentException("The number of entries in windowSize should match the raster axis count.");
            }

            int dimension = m_raster.Dimension;

            int[] rasterTileOfs = new int[dimension];
            int[] windowOfs     = new int[dimension];
            int[] blockSize     = new int[dimension];

            ProcessRasterWindowDimensionDelegate processRasterWindowDelegate = CreateProcessRasterWindowDimensionDelegate(dimension - 1, useVertices, windowPos, windowSize, processWindowSpanDelegate, rasterTileOfs, windowOfs, blockSize);

            processRasterWindowDelegate(0);
        }
Пример #5
0
        private ProcessRasterBlockDimensionDelegate CreateProcessBlockDimensionDelegate(int dimension, int[] windowPos, int[] windowSize,
                                                                                        ProcessRasterWindowSpanDelegate processWindowSpanDelegate, int[] rasterTileOfs, int[] blockRasterTileOfs, int[] windowOfs, int[] blockWindowOfs, int[] blockSize)
        {
            int rasterTileSizeD = m_tileSize[dimension];
            int windowSizeD     = windowSize[dimension];

            if (dimension > 0)
            {
                ProcessRasterBlockDimensionDelegate innerDelegate = CreateProcessBlockDimensionDelegate(dimension - 1, windowPos, windowSize, processWindowSpanDelegate, rasterTileOfs, blockRasterTileOfs, windowOfs, blockWindowOfs, blockSize);

                return(delegate(int rasterTileBaseIndex, int rasterTileIndexOfs, int windowIndexOfs)
                {
                    int rasterTileOfsD = rasterTileOfs[dimension];
                    int windowOfsD = windowOfs[dimension];
                    int blockSizeD = blockSize[dimension];

                    for (int blockOfsD = 0; blockOfsD < blockSizeD; ++rasterTileOfsD, ++windowOfsD, ++blockOfsD)
                    {
                        int innerRasterTileIndexOfs = rasterTileIndexOfs * rasterTileSizeD + rasterTileOfsD;
                        int innerWindowIndexOfs = windowIndexOfs * windowSizeD + windowOfsD;

                        blockRasterTileOfs[dimension] = rasterTileOfsD;
                        blockWindowOfs[dimension] = windowOfsD;

                        innerDelegate(rasterTileBaseIndex, innerRasterTileIndexOfs, innerWindowIndexOfs);
                    }
                });
            }
            else
            {
                return(delegate(int rasterTileBaseIndex, int rasterTileIndexOfs, int windowIndexOfs)
                {
                    int rasterTileOfsD = rasterTileOfs[dimension];
                    int windowOfsD = windowOfs[dimension];
                    int blockSizeD = blockSize[dimension];

                    int innerRasterTileIndexOfs = rasterTileIndexOfs * rasterTileSizeD + rasterTileOfsD;
                    int innerWindowIndexOfs = windowIndexOfs * windowSizeD + windowOfsD;

                    blockRasterTileOfs[dimension] = rasterTileOfsD;
                    blockWindowOfs[dimension] = windowOfsD;

                    int rasterIndex = rasterTileBaseIndex + innerRasterTileIndexOfs;

                    processWindowSpanDelegate(rasterIndex, blockRasterTileOfs, innerWindowIndexOfs, blockWindowOfs, blockSizeD);
                });
            }
        }
Пример #6
0
        private ProcessRasterWindowDimensionDelegate CreateProcessRasterWindowDimensionDelegate(int dimension, bool useVertices, int[] windowPos, int[] windowSize,
                                                                                                ProcessRasterWindowSpanDelegate processRasterWindowSpanDelegate, int[] rasterTileOfs, int[] windowOfs, int[] blockSize)
        {
            int rasterSizeD = useVertices ? m_raster.GetVertexIndexCount(dimension) : m_raster.GetVertexIndexCount(dimension) - 1;
            int tileSizeD   = m_tileSize[dimension];
            int tileCountD  = (rasterSizeD + tileSizeD - 1) / tileSizeD;
            int windowSizeD = windowSize[dimension];
            int windowPosD  = windowPos[dimension];

            ProcessRasterWindowDimensionDelegate innerDelegate;

            if (dimension > 0)
            {
                innerDelegate = CreateProcessRasterWindowDimensionDelegate(dimension - 1, useVertices, windowPos, windowSize, processRasterWindowSpanDelegate, rasterTileOfs, windowOfs, blockSize);

                return(delegate(int rasterTileNum)
                {
                    int windowOfsD = 0;
                    while (windowOfsD < windowSizeD)
                    {
                        int rasterPosD = windowPosD + windowOfsD;
                        if (rasterPosD < 0)
                        {
                            windowOfsD += -rasterPosD;
                            continue;
                        }
                        if (rasterPosD >= rasterSizeD)
                        {
                            break;
                        }

                        int rasterTileNumD = rasterPosD / tileSizeD;
                        int rasterTileOfsD = rasterPosD % tileSizeD;

                        int innerRasterTileNum = rasterTileNum * tileCountD + rasterTileNumD;

                        int nextRasterPosD = (rasterTileNumD + 1) * tileSizeD;
                        if (nextRasterPosD > rasterSizeD)
                        {
                            nextRasterPosD = rasterSizeD;
                        }
                        if (nextRasterPosD > windowPosD + windowSizeD)
                        {
                            nextRasterPosD = windowPosD + windowSizeD;
                        }

                        rasterTileOfs[dimension] = rasterTileOfsD;
                        windowOfs[dimension] = windowOfsD;
                        blockSize[dimension] = nextRasterPosD - rasterPosD;

                        innerDelegate(innerRasterTileNum);

                        windowOfsD += nextRasterPosD - rasterPosD;
                    }
                });
            }
            else
            {
                int rasterTileIndexCount = m_tileIndexCount;

                int rasterDimension = m_raster.Dimension;

                int[] blockRasterTileOfs = new int[rasterDimension];
                int[] blockWindowOfs     = new int[rasterDimension];

                ProcessRasterBlockDimensionDelegate processRasterBlockDelegate = CreateProcessBlockDimensionDelegate(rasterDimension - 1, windowPos, windowSize, processRasterWindowSpanDelegate, rasterTileOfs, blockRasterTileOfs, windowOfs, blockWindowOfs, blockSize);

                return(delegate(int rasterTileNum)
                {
                    int windowOfsD = 0;
                    while (windowOfsD < windowSizeD)
                    {
                        int rasterPosD = windowPosD + windowOfsD;
                        if (rasterPosD < 0)
                        {
                            windowOfsD += -rasterPosD;
                            continue;
                        }
                        if (rasterPosD >= rasterSizeD)
                        {
                            break;
                        }

                        int rasterTileNumD = rasterPosD / tileSizeD;
                        int rasterTileOfsD = rasterPosD % tileSizeD;

                        int innerRasterTileNum = rasterTileNum * tileCountD + rasterTileNumD;

                        int nextRasterPosD = (rasterTileNumD + 1) * tileSizeD;
                        if (nextRasterPosD > rasterSizeD)
                        {
                            nextRasterPosD = rasterSizeD;
                        }
                        if (nextRasterPosD > windowPosD + windowSizeD)
                        {
                            nextRasterPosD = windowPosD + windowSizeD;
                        }

                        rasterTileOfs[dimension] = rasterTileOfsD;
                        windowOfs[dimension] = windowOfsD;
                        blockSize[dimension] = nextRasterPosD - rasterPosD;

                        int rasterTileBaseIndex = innerRasterTileNum * rasterTileIndexCount;

                        processRasterBlockDelegate(rasterTileBaseIndex, 0, 0);

                        windowOfsD += nextRasterPosD - rasterPosD;
                    }
                });
            }
        }