Ejemplo n.º 1
0
        /// <summary>
        /// gets points at specified index
        /// </summary>
        /// <param name="startIndex"></param>
        /// <param name="number"></param>
        /// <returns></returns>
        public unsafe object GetPoints(uint startIndex, int number)
        {
            if (m_reader == null)
            {
                return(null);
            }

            positionAtPointN(startIndex);

            byte[] pointdata = m_reader.ReadBytes(sizeOfPointStruct * number);

            if (pointdata == null)
            {
                return(null);
            }

            //number of points actually read
            int numPointsRead = pointdata.Length / sizeOfPointStruct;

            if (numPointsRead == 0)
            {
                return(null);
            }

            //Console.WriteLine("num points to read: {0}, num read: {1}", number, numPointsRead);

            if (header.PointDataFormat == 0)
            {
                LASPointFormat0[] pf0_buffer = new LASPointFormat0[numPointsRead];

                fixed(LASPointFormat0 *p = pf0_buffer)
                {
                    IntPtr MyIntPtr = (IntPtr)p;

                    Marshal.Copy(pointdata, 0, MyIntPtr, pointdata.Length);
                }

                return(pf0_buffer);
            }
            else if (header.PointDataFormat == 1)
            {
                LASPointFormat1[] pf1_buffer = new LASPointFormat1[numPointsRead];

                fixed(LASPointFormat1 *p = pf1_buffer)
                {
                    IntPtr MyIntPtr = (IntPtr)p;

                    Marshal.Copy(pointdata, 0, MyIntPtr, pointdata.Length);
                }

                return(pf1_buffer);
            }

            //if smth goes wrong return null
            return(null);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// gets an array of points starting at the current position
        /// </summary>
        /// <returns></returns>
        public unsafe object GetPoints(int number)
        {
            if (m_reader == null)
            {
                return(null);
            }

            byte[] pointdata = m_reader.ReadBytes(number * sizeOfPointStruct);

            if (pointdata == null)
            {
                return(null);
            }

            //number of points actually read
            int numPointsRead = pointdata.Length / sizeOfPointStruct;

            //Console.WriteLine("num points to read: {0}, num read: {1}", number, numPointsRead);

            if (header.PointDataFormat == 0)
            {
                LASPointFormat0[] arr = new LASPointFormat0[numPointsRead];

                fixed(LASPointFormat0 *p = arr)
                {
                    IntPtr MyIntPtr = (IntPtr)p;

                    Marshal.Copy(pointdata, 0, MyIntPtr, pointdata.Length);
                }

                return(arr);
            }
            else if (header.PointDataFormat == 1)
            {
                LASPointFormat1[] arr = new LASPointFormat1[numPointsRead];

                fixed(LASPointFormat1 *p = arr)
                {
                    IntPtr MyIntPtr = (IntPtr)p;

                    Marshal.Copy(pointdata, 0, MyIntPtr, pointdata.Length);
                }

                return(arr);
            }

            return(null);
        }