private static List <PointInt> LocalRegion(List <PointInt> smallList, RectInt smallRect, bool[,] isSearched, double[,] project, double filterProject) { var pointList = new List <PointInt>(); var queue = new Queue <PointInt>(); foreach (var point in smallList) { queue.Enqueue(point); isSearched[point.X, point.Y] = true; } var rect = new RectInt(smallRect.X1 - smallRect.XLen / 2, smallRect.Y1 - smallRect.YLen / 2, smallRect.X2 + smallRect.XLen / 2, smallRect.Y2 + smallRect.YLen / 2); while (queue.Count > 0) { var point = queue.Dequeue(); var filter = project[point.X, point.Y]; pointList.Add(point); var newPoint = new PointInt(point.X - 1, point.Y); Test(newPoint, isSearched, project, queue, filterProject); newPoint = new PointInt(point.X + 1, point.Y); Test(newPoint, isSearched, project, queue, filterProject); newPoint = new PointInt(point.X, point.Y - 1); Test(newPoint, isSearched, project, queue, filterProject); newPoint = new PointInt(point.X, point.Y + 1); Test(newPoint, isSearched, project, queue, filterProject); } return(pointList); }
public bool Contains(PointInt point) { if (point.X > X1 && point.Y > Y1 && point.X < X2 && point.Y < Y2) { return(true); } return(false); }
private static void Test(PointInt newPoint, bool[,] isSearched, double[,] project, Queue <PointInt> queue, double filter) { var newProject = project[newPoint.X, newPoint.Y]; if (!isSearched[newPoint.X, newPoint.Y] && newProject < filter) { queue.Enqueue(newPoint); isSearched[newPoint.X, newPoint.Y] = true; } }