Пример #1
0
        /// <summary>
        /// Grow selection outwards from seed vertex, until it hits boundaries defined by vertex filter.
        /// </summary>
        public void FloodFill(int[] Seeds, Func <int, bool> VertIncludedF = null)
        {
            var stack = new DVector <int>(Seeds);

            for (int k = 0; k < Seeds.Length; ++k)
            {
                add(Seeds[k]);
            }

            while (stack.size > 0)
            {
                int vID = stack.back;
                stack.pop_back();

                foreach (int nbr_vid in Mesh.VtxVerticesItr(vID))
                {
                    if (IsSelected(nbr_vid) == true || VertIncludedF(nbr_vid) == false)
                    {
                        continue;
                    }

                    add(nbr_vid);
                    stack.push_back(nbr_vid);
                }
            }
        }
Пример #2
0
        /// <summary>
        /// Grow selection outwards from seed triangles, until it hits boundaries defined by triangle and edge filters.
        /// Edge filter is not effective unless it (possibly combined w/ triangle filter) defines closed loops.
        /// </summary>
        public void FloodFill(int[] Seeds, Func <int, bool> TriFilterF = null, Func <int, bool> EdgeFilterF = null)
        {
            DVector <int> stack = new DVector <int>(Seeds);

            for (int k = 0; k < Seeds.Length; ++k)
            {
                add(Seeds[k]);
            }
            while (stack.size > 0)
            {
                int tID = stack.back;
                stack.pop_back();

                Index3i nbrs = Mesh.GetTriNeighbourTris(tID);
                for (int j = 0; j < 3; ++j)
                {
                    int nbr_tid = nbrs[j];
                    if (nbr_tid == DMesh3.InvalidID || IsSelected(nbr_tid))
                    {
                        continue;
                    }
                    if (TriFilterF != null && TriFilterF(nbr_tid) == false)
                    {
                        continue;
                    }
                    if (EdgeFilterF != null && EdgeFilterF(Mesh.GetTriEdge(tID, j)) == false)
                    {
                        continue;
                    }
                    add(nbr_tid);

                    stack.push_back(nbr_tid);
                }
            }
        }
Пример #3
0
 public int allocate()
 {
     used_count++;
     if (free_indices.empty)
     {
         // [RMS] do we need this branch anymore?
         ref_counts.push_back(1);
         return(ref_counts.size - 1);
     }
     else
     {
         int iFree = invalid;
         while (iFree == invalid && free_indices.empty == false)
         {
             iFree = free_indices.back;
             free_indices.pop_back();
         }
         if (iFree != invalid)
         {
             ref_counts[iFree] = 1;
             return(iFree);
         }
         else
         {
             ref_counts.push_back(1);
             return(ref_counts.size - 1);
         }
     }
 }
Пример #4
0
        /// <summary>
        /// Grow selection outwards from seed vertex, until it hits boundaries defined by vertex filter.
        /// </summary>
        public void FloodFill(int[] Seeds, Func <int, bool> VertIncludedF = null)
        {
            DVector <int> stack = new DVector <int>(Seeds);

            for (int k = 0; k < Seeds.Length; ++k)
            {
                add(Seeds[k]);
            }
            while (stack.size > 0)
            {
                int vID = stack.back;
                stack.pop_back();

                foreach (int nbr_vid in Mesh.VtxVerticesItr(vID))
                {
                    // cherry-picked from https://github.com/ZelimDamian/geometry3Sharp/tree/zelim
                    if (IsSelected(nbr_vid) || VertIncludedF?.Invoke(nbr_vid) == false)
                    {
                        continue;
                    }
                    add(nbr_vid);
                    stack.push_back(nbr_vid);
                }
            }
        }
Пример #5
0
        public void FloodFill(int[] Seeds, Func <int, bool> FilterF = null)
        {
            DVector <int> stack = new DVector <int>(Seeds);

            while (stack.size > 0)
            {
                int tID = stack.back;
                stack.pop_back();

                Index3i nbrs = Mesh.GetTriNeighbourTris(tID);
                for (int j = 0; j < 3; ++j)
                {
                    int nbr_tid = nbrs[j];
                    if (nbr_tid == DMesh3.InvalidID || IsSelected(nbr_tid))
                    {
                        continue;
                    }
                    if (FilterF != null && FilterF(nbr_tid) == false)
                    {
                        continue;
                    }
                    add(nbr_tid);

                    stack.push_back(nbr_tid);
                }
            }
        }
Пример #6
0
 public T Allocate()
 {
     if (Free.size > 0)
     {
         T allocated = Free[Free.size - 1];
         Free.pop_back();
         return(allocated);
     }
     else
     {
         T newval = new T();
         Allocated.Add(newval);
         return(newval);
     }
 }
Пример #7
0
 public int allocate()
 {
     used_count++;
     if (free_indices.empty)
     {
         ref_counts.push_back(1);
         return(ref_counts.size - 1);
     }
     else
     {
         int iFree = free_indices.back;
         free_indices.pop_back();
         ref_counts[iFree] = 1;
         return(iFree);
     }
 }
Пример #8
0
        // grab a block from the free list, or allocate a new one
        protected int allocate_block()
        {
            int nfree = free_blocks.size;

            if (nfree > 0)
            {
                int ptr = free_blocks[nfree - 1];
                free_blocks.pop_back();
                return(ptr);
            }
            int nsize = block_store.size;

            block_store.insert(Null, nsize + BLOCK_LIST_OFFSET);
            block_store[nsize] = 0;
            allocated_count++;
            return(nsize);
        }