Beispiel #1
0
        protected virtual void Initialize(FloodParameters parameters, int[,] markMatrix)
        {
            MarkMatrix = markMatrix;

            // deconstructing parameters
            NeighbourhoodType              = parameters.NeighbourhoodType;
            StartX                         = parameters.StartX;
            StartY                         = parameters.StartY;
            ProcessStartAsFirstNeighbour   = parameters.ProcessStartAsFirstNeighbour;
            Qualifier                      = parameters.Qualifier;
            NeighbourProcessor             = parameters.NeighbourProcessor;
            NeighbourStopCondition         = parameters.NeighbourStopCondition;
            SpreadingPositionVisitor       = parameters.SpreadingPositionVisitor;
            SpreadingPositionStopCondition = parameters.SpreadingPositionStopCondition;
            PositionsToVisit               = parameters.PositionsToVisitQueue;
            if (PositionsToVisit.Any())
            {
                throw new ArgumentException("Provided PositionsToVisitQueue was not empty at the beginning of flood spilling.", nameof(parameters));
            }
            FloodBounds boundsRestriction = parameters.BoundsRestriction
                                            ?? new FloodBounds(markMatrix.GetLength(0), markMatrix.GetLength(1));

            GuardBounds(boundsRestriction, StartX, StartY);
            OffsetX = -boundsRestriction.MinX;
            OffsetY = -boundsRestriction.MinY;
            MinX    = boundsRestriction.MinX;
            MinY    = boundsRestriction.MinY;
            MaxX    = boundsRestriction.MaxX;
            MaxY    = boundsRestriction.MaxY;

            InitializeMarkMatrix();
        }
Beispiel #2
0
 public FloodParameters(PositionQueueAdapter positionsToVisitQueue, int startX, int startY)
 {
     PositionsToVisitQueue = positionsToVisitQueue;
     StartX = startX;
     StartY = startY;
 }