Beispiel #1
0
        public PCXRPoint GetNextPoint()
        {
            bool      pointReturned = false;
            PCXRPoint point;

            if (_PointsRead <= _Header.NumberOfPoints)
            {
                if (_BufferCurrentPoint < _NumberOfPointsToBuffer)
                {
                    pointReturned = true;
                    point         = ReadPoint();
                    return(point);
                }
                else
                {
                    // Fill buffer
                    FillBuffer();
                    point         = ReadPoint();
                    pointReturned = true;
                    return(point);
                }
            }

            if (!pointReturned)
            {
                Exception ex = new Exception("No more points in data");
                throw ex;
            }

            point = new PCXRPoint();
            return(point);
        }
Beispiel #2
0
        private PCXRPoint ReadPoint()
        {
            PCXRPoint point = new PCXRPoint();

            _OffsetInBuffer = _BufferCurrentPoint * _Header.Stride * sizeof(float);

            point.x = BitConverter.ToSingle(_Buffer, _OffsetInBuffer + 0);
            point.y = BitConverter.ToSingle(_Buffer, _OffsetInBuffer + 4);
            point.z = BitConverter.ToSingle(_Buffer, _OffsetInBuffer + 8);

            point.red   = BitConverter.ToSingle(_Buffer, _OffsetInBuffer + 12);
            point.green = BitConverter.ToSingle(_Buffer, _OffsetInBuffer + 16);
            point.blue  = BitConverter.ToSingle(_Buffer, _OffsetInBuffer + 20);
            point.alpha = BitConverter.ToSingle(_Buffer, _OffsetInBuffer + 24);

            point.deleted  = BitConverter.ToSingle(_Buffer, _OffsetInBuffer + 28);
            point.selected = BitConverter.ToSingle(_Buffer, _OffsetInBuffer + 32);

            point.intensity_normalized = BitConverter.ToSingle(_Buffer, _OffsetInBuffer + 36);
            point.classification       = BitConverter.ToSingle(_Buffer, _OffsetInBuffer + 40);

            point.id = BitConverter.ToSingle(_Buffer, _OffsetInBuffer + 44);

            _BufferCurrentPoint++;
            _PointsRead++;

            return(point);
        }
Beispiel #3
0
        public void WritePointOptimized(PCXRPoint point)
        {
            point.ToByteArray().CopyTo(_Buffer, _PointsBuffered * _Header.Stride * sizeof(float));
            _PointsBuffered++;

            if (_PointsBuffered == _NumberOfPointsToBuffer)
            {
                _PointsBuffered = 0;
                _PointsWritten += _NumberOfPointsToBuffer;
            }
        }
Beispiel #4
0
 public void WritePoint(PCXRPoint point)
 {
     _Writer.Write(point.x);
     _Writer.Write(point.y);
     _Writer.Write(point.z);
     _Writer.Write(point.red);
     _Writer.Write(point.green);
     _Writer.Write(point.blue);
     _Writer.Write(point.alpha);
     _Writer.Write(point.deleted);
     _Writer.Write(point.selected);
     _Writer.Write(point.intensity_normalized);
     _Writer.Write(point.classification);
     _Writer.Write(point.id);
 }
Beispiel #5
0
        public void WritePoint(PCXRPoint point)
        {
            if ((_UseBuffer == true) && (_PointsWritten == (_NumberOfPoints - _BufferSpill)))
            {
                _UseBuffer = false;
            }

            if (_UseBuffer)
            {
                if (_PointsBuffered < (_NumberOfPointsToBuffer - 1))
                {
                    point.ToByteArray().CopyTo(_Buffer, _PointsBuffered * _Header.Stride * sizeof(float));
                    _PointsBuffered++;
                    return;
                }
                else
                {
                    try
                    {
                        point.ToByteArray().CopyTo(_Buffer, _PointsBuffered * _Header.Stride * sizeof(float));
                        _PointsBuffered++;

                        _StreamWriter.Write(_Buffer, 0, _NumberOfPointsToBuffer * _Header.Stride * sizeof(float));
                        _PointsWritten += _NumberOfPointsToBuffer;
                    }
                    catch (Exception e)
                    {
                        Console.Write(e.Message);
                    }
                    _PointsBuffered = 0;
                    return;
                }
            }
            else
            {
                byte[] pointBytes = point.ToByteArray();
                _StreamWriter.Write(pointBytes, 0, pointBytes.Length);
                _PointsWritten++;
                return;
            }
        }