public static Targets Create(ChannelsTree channelsTree, GridMap targetMap, double targetValue, GridMap floodMap) { var zones = GetChannelZones(channelsTree, targetMap.Width, targetMap.Height); var needFlood = new ChannelCells(); var alreadyFlooded = new ChannelCells(); foreach (var channelZone in zones) { var zoneFloodedCells = new List <(int, int)>(); var zoneDryCells = new List <(int, int)>(); foreach (var(x, y) in channelZone.Value) { if (targetMap[x, y] == targetValue) { if (floodMap[x, y] == 0) { zoneDryCells.Add((x, y)); } else { zoneFloodedCells.Add((x, y)); } } } needFlood[channelZone.Key] = zoneDryCells; alreadyFlooded[channelZone.Key] = zoneFloodedCells; } return(new Targets(zones, needFlood, alreadyFlooded)); }
public Targets(ChannelCells zones, ChannelCells needFlood, ChannelCells alreadyFlooded) { this.zones = zones ?? throw new ArgumentNullException(nameof(zones)); this.needFlood = needFlood ?? throw new ArgumentNullException(nameof(needFlood)); this.alreadyFlooded = alreadyFlooded ?? throw new ArgumentNullException(nameof(alreadyFlooded)); }