/// <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);
            }
        /// <summary>
        /// Reads points from the node.
        /// </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>
        public int ReadPoints(PointCloudFilter filter, IntPtrCloudPointBuffer buffer, int start_index)
        {
            if (start_index == 0)
            {
                OctreeIndexSetIteratorList.Initialize(filter);
                OctreeIndexSetIteratorList.PrepareIterators(this);
            }

            return(OctreeIndexSetIteratorList.ReadPoints(buffer));
        }
            /// <summary>
            /// Reads points in the access and store them in the given buffer.
            /// </summary>
            /// <param name="buffer">The buffer pointer to store the points</param>
            /// <param name="buffer_size">The buffer size</param>
            /// <returns>The number of the points that are stored in the buffer</returns>
            public int ReadPoints(IntPtr buffer, int buffer_size)
            {
                int found = 0;

                if (m_done)
                {
                    return(0);
                }

                IntPtrCloudPointBuffer cp_buffer = new IntPtrCloudPointBuffer(buffer, buffer_size);

                found            = m_access.ReadPoints(m_filter, cp_buffer, m_current_index);
                m_current_index += found;

                if (m_current_index == m_access.Count || found == 0)
                {
                    m_done = true;
                }

                return(found);
            }
            /// <summary>
            /// Fetches the points from iterators and accumulates them the buffer.
            /// It calculates the portion of the points based on the buffer size and total number of the points,
            /// so each iterator gives the identical portion of their points (not exactly identical, because the number of points is integer).
            /// This allows us to give the points to Revit in approximately uniform.
            /// </summary>
            /// <param name="buffer">The buffer to contains the points</param>
            /// <returns>The number of the points that are read</returns>
            public static int ReadPoints(IntPtrCloudPointBuffer buffer)
            {
                int    point_count = 0;
                double quota_ratio = Math.Min((double)buffer.Size / s_remaining_points, 1.0);

                while (s_iterator_list.Any() && buffer.Remaining > 0)
                {
                    s_current_iterator_index %= s_iterator_list.Count;
                    OctreeIndexSetIterator it = s_iterator_list[s_current_iterator_index];

                    int quota = (int)Math.Ceiling(Math.Min(quota_ratio * it.Remaining, buffer.Remaining));
                    point_count += it.ReadPoints(buffer, quota);

                    if (it.Done)
                    {
                        s_iterator_list.RemoveAt(s_current_iterator_index); continue;
                    }
                    s_current_iterator_index++;
                }
                s_remaining_points -= point_count;

                return(point_count);
            }
Exemplo n.º 5
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);
        }
 /// <summary>
 /// Reads the points in this container.
 /// </summary>
 /// <param name="filter">The filter</param>
 /// <param name="buffer">The buffer to store the points that are read</param>
 /// <param name="start_index">The index of the point to start reading</param>
 /// <returns>The number of points that are read</returns>
 protected virtual int ReadPoints(PointCloudFilter filter, IntPtrCloudPointBuffer buffer, int start_index)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 7
0
 /// <summary>
 /// Reads points from the root.
 /// </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) => m_root.ReadPoints(filter, buffer, start_index);