private Rectangle GetVertexCellArea(Point vertexPos, int lineRadius, int cellSize, CheckCellOccupationDelegate cellProcessed) { // Calculate the cells occupied by the vertex point considering its line radius // (for performance reasons, we assume the point to be a rectangle) Point cellLT = ShapeUtils.CalcCell(vertexPos.X - lineRadius, vertexPos.Y - lineRadius, cellSize); Point cellRB = ShapeUtils.CalcCell(vertexPos.X + lineRadius, vertexPos.Y + lineRadius, cellSize); Rectangle cells = Rectangle.Empty; cells.Location = cellLT; cells.Width = cellRB.X - cellLT.X; cells.Height = cellRB.Y - cellLT.Y; return cells; }
private IEnumerable<Point> GetAreaCells(int cellsLeft, int cellsTop, int cellsRight, int cellsBottom, CheckCellOccupationDelegate cellProcessed) { // Calculate the cells occupied by the vertex point considering its line radius // (for performance reasons, we assume the point to be a rectangle) Point p = Point.Empty; for (p.X = cellsLeft; p.X <= cellsRight; p.X += 1) { for (p.Y = cellsTop; p.Y <= cellsBottom; p.Y += 1) { if (cellProcessed == null) yield return p; else if (!cellProcessed(p)) yield return p; } } }