Exemple #1
0
        public GridBufferPosition(IPointDataChunk buffer, int index, int count, short entrySize)
        {
            m_entrySize = entrySize;

            DataPtr = buffer.PointDataPtr + (index * m_entrySize);
            DataEndPtr = DataPtr + (count * m_entrySize);
        }
Exemple #2
0
        public GridBufferPosition[,] CreatePositionGrid(IPointDataChunk segmentBuffer, short entrySize)
        {
            // create tile position counters (always buffer)
            var tilePositions = new GridBufferPosition[m_grid.SizeY + 1, m_grid.SizeX + 1];

            {
                var index = 0;
                foreach (var tile in GetCellOrdering())
                {
                    var count = m_grid.Data[tile.Row, tile.Col];
                    var pos   = new GridBufferPosition(segmentBuffer, index, count, entrySize);
                    tilePositions[tile.Row, tile.Col] = pos;

                    index += count;
                }

                // buffer the edges for overflow
                for (var x = 0; x < m_grid.SizeX; x++)
                {
                    tilePositions[m_grid.SizeY, x] = tilePositions[m_grid.SizeY - 1, x];
                }
                for (var y = 0; y <= m_grid.SizeY; y++)
                {
                    tilePositions[y, m_grid.SizeX] = tilePositions[y, m_grid.SizeX - 1];
                }
            }

            return(tilePositions);
        }
Exemple #3
0
        public GridBufferPosition(IPointDataChunk buffer, int index, int count, short entrySize)
        {
            m_entrySize = entrySize;

            DataPtr    = buffer.PointDataPtr + (index * m_entrySize);
            DataEndPtr = DataPtr + (count * m_entrySize);
        }
Exemple #4
0
		public unsafe IPointDataChunk Process(IPointDataChunk chunk)
		{
			byte* pb = chunk.PointDataPtr;
			while (pb < chunk.PointDataEndPtr)
			{
				Point3D* p = (Point3D*)pb;
				++m_counts[(int)(((*p).Z - m_min) * m_intervalsOverRangeZ)];
				pb += chunk.PointSizeBytes;
			}

			return chunk;
		}
Exemple #5
0
        private IPointDataChunk ProcessChunk(IPointDataChunk chunk)
        {
            // allow filters to replace the chunk definition
            var currentChunk = chunk;

            foreach (var chunkProcess in m_chunkProcesses)
            {
                currentChunk = chunkProcess.Process(currentChunk);
            }

            return(currentChunk);
        }
Exemple #6
0
        public unsafe IPointDataChunk Process(IPointDataChunk chunk)
        {
            // if the end of the range is the last tile in a row, then buffer it.
            var startIndex = m_range.StartPos;
            var endIndex   = m_range.EndPos;

            var rowCount = m_grid.Def.SizeY;

            var pb            = chunk.PointDataPtr;
            var pbDestination = pb;

            while (pb < chunk.PointDataEndPtr)
            {
                var p = (SQuantizedPoint3D *)pb;

                var row = (((*p).Y - m_quantizedExtent.MinY) / m_grid.CellSizeY);
                var col = (((*p).X - m_quantizedExtent.MinX) / m_grid.CellSizeX);

                // overflow on the end of rows is dealt with by the nature of the index,
                // but overflow after the last row is problematic.
                if (row == rowCount)
                {
                    --row;
                }

                var index = m_grid.Def.GetIndex(row, col);
                if (index >= startIndex && index < endIndex)
                {
                    // make copy faster?

                    // assume that most points will be shifted?
                    //if(pb != pbDestination)
                    //{
                    for (var i = 0; i < chunk.PointSizeBytes; i++)
                    {
                        pbDestination[i] = pb[i];
                    }
                    //}

                    // increment count
                    ++m_grid.Data[row, col];
                    // better would be to do it nearby and add them to the grid at the end (possibly)

                    pbDestination += chunk.PointSizeBytes;
                }

                pb += chunk.PointSizeBytes;
            }

            var pointsRemaining = (int)((pbDestination - chunk.PointDataPtr) / chunk.PointSizeBytes);

            return(chunk.CreateSegment(pointsRemaining));
        }
Exemple #7
0
        public unsafe IPointDataChunk Process(IPointDataChunk chunk)
        {
            byte *pb = chunk.PointDataPtr;

            while (pb < chunk.PointDataEndPtr)
            {
                var p = (SQuantizedPoint3D *)pb;
                ++m_bins[((*p).Z >> SourceRightShift) - SourceMinShifted];
                pb += chunk.PointSizeBytes;
            }

            return(chunk);
        }
Exemple #8
0
        public unsafe IPointDataChunk Process(IPointDataChunk chunk)
        {
            byte *pb = chunk.PointDataPtr;

            while (pb < chunk.PointDataEndPtr)
            {
                Point3D *p = (Point3D *)pb;
                ++m_counts[(int)(((*p).Z - m_min) * m_intervalsOverRangeZ)];
                pb += chunk.PointSizeBytes;
            }

            return(chunk);
        }
Exemple #9
0
        public unsafe IPointDataChunk Process(IPointDataChunk chunk)
        {
            // if the end of the range is the last tile in a row, then buffer it.
            var startIndex = m_range.StartPos;
            var endIndex = m_range.EndPos;

            var rowCount = m_grid.Def.SizeY;

            var pb = chunk.PointDataPtr;
            var pbDestination = pb;
            while (pb < chunk.PointDataEndPtr)
            {
                var p = (SQuantizedPoint3D*)pb;

                var row = (((*p).Y - m_quantizedExtent.MinY) / m_grid.CellSizeY);
                var col = (((*p).X - m_quantizedExtent.MinX) / m_grid.CellSizeX);

                // overflow on the end of rows is dealt with by the nature of the index,
                // but overflow after the last row is problematic.
                if (row == rowCount)
                    --row;

                var index = m_grid.Def.GetIndex(row, col);
                if (index >= startIndex && index < endIndex)
                {
                    // make copy faster?

                    // assume that most points will be shifted?
                    //if(pb != pbDestination)
                    //{
                        for (var i = 0; i < chunk.PointSizeBytes; i++)
                            pbDestination[i] = pb[i];
                    //}

                    // increment count
                    ++m_grid.Data[row, col];
                    // better would be to do it nearby and add them to the grid at the end (possibly)

                    pbDestination += chunk.PointSizeBytes;
                }

                pb += chunk.PointSizeBytes;
            }

            var pointsRemaining = (int)((pbDestination - chunk.PointDataPtr) / chunk.PointSizeBytes);
            return chunk.CreateSegment(pointsRemaining);
        }
Exemple #10
0
        public IPointDataChunk Process(IPointDataChunk chunk)
        {
            byte* pb = chunk.PointDataPtr;
            while (pb < chunk.PointDataEndPtr)
            {
                var p = (SQuantizedPoint3D*)pb;

                int pixelX = (int)(((*p).X - m_minX) * m_pixelsOverRangeX);
                int pixelY = (int)(((*p).Y - m_minY) * m_pixelsOverRangeY);

                if ((*p).Z > m_gridQuantized.Data[pixelY, pixelX])
                    m_gridQuantized.Data[pixelY, pixelX] = (*p).Z;

                pb += chunk.PointSizeBytes;
            }

            return chunk;
        }
Exemple #11
0
        public IPointDataChunk Process(IPointDataChunk chunk)
        {
            byte *pb = chunk.PointDataPtr;

            while (pb < chunk.PointDataEndPtr)
            {
                var p = (SQuantizedPoint3D *)pb;

                int pixelX = (int)(((*p).X - m_minX) * m_pixelsOverRangeX);
                int pixelY = (int)(((*p).Y - m_minY) * m_pixelsOverRangeY);

                if ((*p).Z > m_gridQuantized.Data[pixelY, pixelX])
                {
                    m_gridQuantized.Data[pixelY, pixelX] = (*p).Z;
                }

                pb += chunk.PointSizeBytes;
            }

            return(chunk);
        }
Exemple #12
0
        public unsafe IPointDataChunk Process(IPointDataChunk chunk)
        {
            if (m_index + chunk.PointCount <= m_count)
            {
                byte *pb = chunk.PointDataPtr;

                if (m_quantized)
                {
                    int[][] values = m_values as int[][];
                    while (pb < chunk.PointDataEndPtr)
                    {
                        SQuantizedPoint3D *p = (SQuantizedPoint3D *)pb;
                        values[0][m_index] = (*p).X;
                        values[1][m_index] = (*p).Y;
                        values[2][m_index] = (*p).Z;
                        ++m_index;
                        pb += chunk.PointSizeBytes;
                    }
                }
                else
                {
                    double[][] values = m_values as double[][];
                    while (pb < chunk.PointDataEndPtr)
                    {
                        Point3D *p = (Point3D *)pb;
                        values[0][m_index] = (*p).X;
                        values[1][m_index] = (*p).Y;
                        values[2][m_index] = (*p).Z;
                        ++m_index;
                        pb += chunk.PointSizeBytes;
                    }
                }
            }

            return(chunk);
        }
Exemple #13
0
        public GridBufferPosition[,] CreatePositionGrid(IPointDataChunk segmentBuffer, short entrySize)
        {
            // create tile position counters (always buffer)
            var tilePositions = new GridBufferPosition[m_grid.SizeY + 1, m_grid.SizeX + 1];
            {
                var index = 0;
                foreach (var tile in GetCellOrdering())
                {
                    var count = m_grid.Data[tile.Row, tile.Col];
                    var pos = new GridBufferPosition(segmentBuffer, index, count, entrySize);
                    tilePositions[tile.Row, tile.Col] = pos;

                    index += count;
                }

                // buffer the edges for overflow
                for (var x = 0; x < m_grid.SizeX; x++)
                    tilePositions[m_grid.SizeY, x] = tilePositions[m_grid.SizeY - 1, x];
                for (var y = 0; y <= m_grid.SizeY; y++)
                    tilePositions[y, m_grid.SizeX] = tilePositions[y, m_grid.SizeX - 1];
            }

            return tilePositions;
        }
        public unsafe IPointDataChunk Process(IPointDataChunk chunk)
        {
            byte* pb = chunk.PointDataPtr;
            while (pb < chunk.PointDataEndPtr)
            {
                var p = (SQuantizedPoint3D*)pb;
                ++m_bins[((*p).Z >> SourceRightShift) - SourceMinShifted];
                pb += chunk.PointSizeBytes;
            }

            return chunk;
        }
Exemple #15
0
        public unsafe IPointDataChunk Process(IPointDataChunk chunk)
        {
            if (chunk.PointCount > m_maxPointCountPerChunk)
                m_maxPointCountPerChunk = chunk.PointCount;

            // get the tile indices for this chunk
            var tileIndices = new HashSet<int>();
            var lastIndex = -1;

            // JUST TESTING TO SEE IF I LIKE THIS WAY BETTER (slightly slower?)
            //var iterator = new SQuantizedPoint3DIterator(chunk);
            //while (iterator.IsValid)
            //{
            //    var p = iterator.Next();
            //    var y = (ushort)(((*p).Y - minY) * tilesOverRangeY);
            //    var x = (ushort)(((*p).X - minX) * tilesOverRangeX);

            //    ++m_grid.Data[y, x];

            //    // indexing
            //    int tileIndex = PointCloudTileCoord.GetIndex(y, x);
            //    if (tileIndex != lastIndex)
            //    {
            //        tileIndices.Add(tileIndex);
            //        lastIndex = tileIndex;
            //    }
            //}

            // JUST TESTING TO SEE IF I LIKE THIS WAY BETTER (slightly slower?)
            foreach (var pp in chunk.GetSQuantizedPoint3DEnumerator())
            {
                //var p = (LASPointFormat1*)pp.GetPointer();
                var p = pp.GetPointer();
                var y = (((*p).Y - m_quantizedExtent.MinY) / m_grid.CellSizeY);
                var x = (((*p).X - m_quantizedExtent.MinX) / m_grid.CellSizeX);

                ++m_grid.Data[y, x];

                // indexing
                int tileIndex = PointCloudTileCoord.GetIndex(y, x);
                if (tileIndex != lastIndex)
                {
                    tileIndices.Add(tileIndex);
                    lastIndex = tileIndex;
                }
            }

            //var pb = chunk.PointDataPtr;
            //while (pb < chunk.PointDataEndPtr)
            //{
            //    var p = (SQuantizedPoint3D*)pb;

            //    var y = (ushort)(((*p).Y - minY) * tilesOverRangeY);
            //    var x = (ushort)(((*p).X - minX) * tilesOverRangeX);

            //    ++m_grid.Data[y, x];

            //    // indexing
            //    int tileIndex = PointCloudTileCoord.GetIndex(y, x);
            //    if (tileIndex != lastIndex)
            //    {
            //        tileIndices.Add(tileIndex);
            //        lastIndex = tileIndex;
            //    }

            //    pb += chunk.PointSizeBytes;
            //}

            m_chunkTiles.Add(tileIndices.ToArray());

            return chunk;
        }
Exemple #16
0
 public SQuantizedPoint3DIterator(IPointDataChunk chunk)
 {
     m_chunk = chunk;
     m_p     = m_chunk.PointDataPtr;
 }
Exemple #17
0
 public SQuantizedPoint3DEnumerator(IPointDataChunk chunk)
 {
     m_chunk = chunk;
     Reset();
 }
Exemple #18
0
        public unsafe IPointDataChunk Process(IPointDataChunk chunk)
        {
            if (chunk.PointCount > m_maxPointCountPerChunk)
            {
                m_maxPointCountPerChunk = chunk.PointCount;
            }

            // get the tile indices for this chunk
            var tileIndices = new HashSet <int>();
            var lastIndex   = -1;

            // JUST TESTING TO SEE IF I LIKE THIS WAY BETTER (slightly slower?)
            //var iterator = new SQuantizedPoint3DIterator(chunk);
            //while (iterator.IsValid)
            //{
            //    var p = iterator.Next();
            //    var y = (ushort)(((*p).Y - minY) * tilesOverRangeY);
            //    var x = (ushort)(((*p).X - minX) * tilesOverRangeX);

            //    ++m_grid.Data[y, x];

            //    // indexing
            //    int tileIndex = PointCloudTileCoord.GetIndex(y, x);
            //    if (tileIndex != lastIndex)
            //    {
            //        tileIndices.Add(tileIndex);
            //        lastIndex = tileIndex;
            //    }
            //}

            // JUST TESTING TO SEE IF I LIKE THIS WAY BETTER (slightly slower?)
            foreach (var pp in chunk.GetSQuantizedPoint3DEnumerator())
            {
                //var p = (LASPointFormat1*)pp.GetPointer();
                var p = pp.GetPointer();
                var y = (((*p).Y - m_quantizedExtent.MinY) / m_grid.CellSizeY);
                var x = (((*p).X - m_quantizedExtent.MinX) / m_grid.CellSizeX);

                ++m_grid.Data[y, x];

                // indexing
                int tileIndex = PointCloudTileCoord.GetIndex(y, x);
                if (tileIndex != lastIndex)
                {
                    tileIndices.Add(tileIndex);
                    lastIndex = tileIndex;
                }
            }

            //var pb = chunk.PointDataPtr;
            //while (pb < chunk.PointDataEndPtr)
            //{
            //    var p = (SQuantizedPoint3D*)pb;

            //    var y = (ushort)(((*p).Y - minY) * tilesOverRangeY);
            //    var x = (ushort)(((*p).X - minX) * tilesOverRangeX);

            //    ++m_grid.Data[y, x];

            //    // indexing
            //    int tileIndex = PointCloudTileCoord.GetIndex(y, x);
            //    if (tileIndex != lastIndex)
            //    {
            //        tileIndices.Add(tileIndex);
            //        lastIndex = tileIndex;
            //    }

            //    pb += chunk.PointSizeBytes;
            //}

            m_chunkTiles.Add(tileIndices.ToArray());

            return(chunk);
        }
Exemple #19
0
 public static SQuantizedPoint3DEnumerator GetSQuantizedPoint3DEnumerator(this IPointDataChunk chunk)
 {
     return(new SQuantizedPoint3DEnumerator(chunk));
 }