/// <summary>
            /// Reads the points of the node
            /// </summary>
            /// <param name="buffer">The buffer to contains the points</param>
            /// <param name="quota">The quota of which the number of the points that the invocation of this function should provide</param>
            /// <returns>The number of points that are read</returns>
            public int ReadPoints(IntPtrCloudPointBuffer buffer, int quota)
            {
                int count = 0;

                if (m_partially_accepted)                  // gives the points that pass the test.
                {
                    m_filter.PrepareForCell(Access.LowerLeft, Access.UpperRight, quota);
                    while (quota > 0)
                    {
                        CloudPoint cp = Access.Points[m_halton_sequence[m_current_index++]];
                        if (m_filter.TestPoint(cp))
                        {
                            buffer.AddCloudPoint(cp); count++;
                        }
                        quota--;
                    }
                }
                else                 // gives all the points.
                {
                    while (quota > 0)
                    {
                        buffer.AddCloudPoint(Access.Points[m_halton_sequence[m_current_index++]]);
                        quota--; count++;
                    }
                }
                return(count);
            }
Exemplo n.º 2
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);
        }