Exemplo n.º 1
0
 public DynamicGrid(MBR mbr, decimal xRes, decimal yRes)
     : base(mbr, xRes, yRes)
 {
     gridIntersections = new Dictionary <double2, int>();
     gridPolygons      = new DynamicPolygon[0, 0];
     intersectionList  = new IntersectionList();
 }
Exemplo n.º 2
0
        private void calcDisplayGrid()
        {
            displayGrid = new Grid(dataGrid);

            // Calculate max mbr of all shapes
            MBR mbr = new MBR(dataGrid.mbr.xMin, dataGrid.mbr.xMax, dataGrid.mbr.yMin, dataGrid.mbr.yMax);

            if (shapes.Length != 0 && shapes[0].polygon.vertices.Length != 0)
            {
                mbr = new MBR(shapes[0].polygon.mbr.xMin, shapes[0].polygon.mbr.xMax, shapes[0].polygon.mbr.yMin, shapes[0].polygon.mbr.yMax);
            }

            foreach (Shape shape in shapes)
            {
                if (shape.polygon.vertices.Length != 0)
                {
                    // Calculate new grid mbr based on shape mbr
                    mbr.xMin = shape.polygon.mbr.xMin < mbr.xMin ? shape.polygon.mbr.xMin : mbr.xMin;
                    mbr.xMax = shape.polygon.mbr.xMax > mbr.xMax ? shape.polygon.mbr.xMax : mbr.xMax;
                    mbr.yMin = shape.polygon.mbr.yMin < mbr.yMin ? shape.polygon.mbr.yMin : mbr.yMin;
                    mbr.yMax = shape.polygon.mbr.yMax > mbr.yMax ? shape.polygon.mbr.yMax : mbr.yMax;
                }
            }

            // Calculate new grid mbr based on shape mbr
            displayGrid.mbr.xMin += Math.Floor((mbr.xMin - dataGrid.mbr.xMin) / dataGrid.xRes) * dataGrid.xRes - dataGrid.xRes;
            displayGrid.mbr.yMin += Math.Floor((mbr.yMin - dataGrid.mbr.yMin) / dataGrid.yRes) * dataGrid.yRes - dataGrid.yRes;

            displayGrid.mbr.xMax += Math.Ceiling((mbr.xMax - dataGrid.mbr.xMax) / dataGrid.xRes) * dataGrid.xRes + dataGrid.xRes;
            displayGrid.mbr.yMax += Math.Ceiling((mbr.yMax - dataGrid.mbr.yMax) / dataGrid.yRes) * dataGrid.yRes + dataGrid.yRes;

            // Setup world scale
            int width  = Math.Max(512, Math.Min(4096, (int)Math.Ceiling(Math.Abs((displayGrid.mbr.xMax - displayGrid.mbr.xMin) / dataGrid.xRes) * 50)));
            int height = Math.Max(512, Math.Min(4096, (int)Math.Ceiling(Math.Abs((displayGrid.mbr.yMax - displayGrid.mbr.yMin) / dataGrid.yRes) * 50)));

            polygonBitmap = new Bitmap(width, height);
            xScale        = polygonBitmap.Width / (float)(displayGrid.mbr.xMax - displayGrid.mbr.xMin);
            yScale        = polygonBitmap.Height / (float)(displayGrid.mbr.yMax - displayGrid.mbr.yMin);
        }
Exemplo n.º 3
0
 public Grid(Grid grid)
 {
     this.mbr  = grid.mbr;
     this.xRes = grid.xRes;
     this.yRes = grid.yRes;
 }
Exemplo n.º 4
0
 public Grid(MBR mbr, decimal xRes, decimal yRes)
 {
     this.mbr  = mbr;
     this.xRes = xRes;
     this.yRes = yRes;
 }
Exemplo n.º 5
0
 public Polygon(int length = 0)
 {
     vertices = new double2[length];
     mbr      = new MBR();
     indices  = new int[length];
 }