private void drawIntersection(Shape shape, ref Bitmap bitmap, Color color) { Graphics gfx = Graphics.FromImage(bitmap); Brush brush = new SolidBrush(color); if (!Single.IsInfinity(xScale) && !Single.IsInfinity(yScale)) { int l = 0; for (int i = 0; i < shape.intersectingPolygons.GetLength(0); ++i) { for (int j = 0; j < shape.intersectingPolygons.GetLength(1); ++j, ++l) { if (shape.intersectingPolygons[i, j] != null && shape.intersectingPolygons[i, j].Length != 0) { DynamicPolygon polygon = shape.intersectingPolygons[i, j]; Point[] points = new Point[polygon.Length]; for (int k = 0; k < polygon.Length; ++k) { points[k] = worldToScreenCoordinates(polygon[k], bitmap); } gfx.FillPolygon(brush, points); } } } } }
public DynamicGrid(Grid grid) : base(grid) { gridIntersections = new Dictionary <double2, int>(); int nColumns = (int)Math.Ceiling((mbr.xMax - mbr.xMin - double2.Tolerance) / xRes); int nRows = (int)Math.Ceiling((mbr.yMax - mbr.yMin - double2.Tolerance) / yRes) + 1; gridPolygons = new DynamicPolygon[nColumns, nRows]; for (int i = 0; i < nColumns; ++i) { for (int j = 0; j < nRows; ++j) { gridPolygons[i, j] = new DynamicPolygon(); gridPolygons[i, j][0] = new double2(mbr.xMin + ((i) * xRes), mbr.yMax - ((j) * yRes)); gridPolygons[i, j][1] = new double2(mbr.xMin + ((i + 1) * xRes), mbr.yMax - ((j) * yRes)); gridPolygons[i, j][2] = new double2(mbr.xMin + ((i + 1) * xRes), mbr.yMax - ((j + 1) * yRes)); gridPolygons[i, j][3] = new double2(mbr.xMin + ((i) * xRes), mbr.yMax - ((j + 1) * yRes)); } } intersectionList = new IntersectionList(); }