Ejemplo n.º 1
0
 static void InitiateFloodFill(Cell cell, ref VoxelizationBounds bounds, BufferPool pool, ref CellSet occupiedCells, ref CellSet newlyFilledCells, ref CellList cellsToVisit)
 {
     //Check to make sure that this cell isn't already occupied before starting a new fill.
     if (occupiedCells.Contains(cell))
     {
         return;
     }
     cellsToVisit.Add(cell, pool);
     while (cellsToVisit.Count > 0)
     {
         if (cellsToVisit.TryPop(out cell))
         {
             if (!TryFloodFill(cell, ref bounds, pool, ref occupiedCells, ref newlyFilledCells, ref cellsToVisit))
             {
                 //The flood fill escaped the voxel bounds. Must be an open area; don't fill.
                 cellsToVisit.Clear();
                 newlyFilledCells.Clear();
                 return;
             }
         }
     }
     //Flood fill completed without reaching the voxel bounds. Dump newly filled cells.
     for (int i = 0; i < newlyFilledCells.Count; ++i)
     {
         occupiedCells.Add(newlyFilledCells[i], pool);
     }
     newlyFilledCells.Clear();
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Set new initial set of points.
        /// </summary>
        private void Restart()
        {
            if (CellSet == null)
            {
                return;
            }

            // prevent timer's start until cell set will be reinit
            SetCommandProviderMode(CommandProviderMode.None);
            PauseIteration();

            using (Application.Current.Dispatcher.DisableProcessing())
            {
                CellSet.Clear();
                var points = GenerateRandomPoints();
                CellSet.SetPoints(points);
            }

            // post recreating actions
            if (_postponedTimer)
            {
                StartTimer();
            }
            else
            {
                SetCommandProviderMode(CommandProviderMode.Init);
            }
        }