Example #1
0
        /// <summary>
        /// Reads points from the cells.
        /// </summary>
        /// <param name="filter">The filter that determines which point is to be read</param>
        /// <param name="buffer">The buffer to contain the points</param>
        /// <param name="start_index">The index of points to start fetching</param>
        /// <returns>The number of points that are fetched</returns>
        protected override int ReadPoints(PointCloudFilter filter, IntPtrCloudPointBuffer buffer, int start_index)
        {
            int point_index   = 0;
            int current_index = start_index;
            int total_points  = 0;
            int start_cell    = 0;

            for (int k = 0; k < m_cells.Length; k++)
            {
                UniformGridCell cell = m_cells[k];

                int filter_result = filter.TestCell(cell.LowerLeft, cell.UpperRight);
                if (filter_result == -1)
                {
                    continue;
                }

                total_points += cell.Count;
                if (current_index < total_points)
                {
                    start_cell    = k;
                    current_index = Math.Max(0, start_index - total_points);
                    break;
                }
            }

            for (int k = start_cell; k < m_cells.Length; k++)
            {
                UniformGridCell cell = m_cells[k];

                int filter_result = filter.TestCell(cell.LowerLeft, cell.UpperRight);
                if (filter_result == -1)
                {
                    continue;
                }

                if (filter_result == 0)
                {
                    filter.PrepareForCell(m_outline.MinimumPoint, m_outline.MaximumPoint, cell.Count);
                }

                for (int s = current_index; s < cell.Count; s++)
                {
                    if (filter_result == 0)
                    {
                        if (filter.TestPoint(m_points[cell.Indices[s]]) == false)
                        {
                            continue;
                        }
                    }
                    buffer.AddCloudPoint(m_points[cell.Indices[s]]);
                    point_index++;

                    if (point_index >= buffer.Size)
                    {
                        break;
                    }
                }

                if (point_index >= buffer.Size)
                {
                    break;
                }
                current_index = 0;
            }
            return(point_index);
        }
 public UniformGridIndexAccessIterator(UniformGridCell access)
 {
     m_access = access;
 }