示例#1
0
        //绘制三角网
        public void Draw_TIN()
        {
            TIN_Bmp = new Bitmap(Width1, Height1);
            MainInterface.f1.pb.Size = new Size(Width1, Height1);
            //调用绘图类
            Class_Draw draw = new Class_Draw();

            draw.gp = Graphics.FromImage(TIN_Bmp);
            draw.gp.Clear(Color.Black);

            //将网点坐标储存在列表中
            List <double> x = new List <double>();
            List <double> y = new List <double>();

            for (int i = 0; i < T1.Count; i++)
            {
                x.Add(T1[i].Tp[0].x);
                x.Add(T1[i].Tp[1].x);
                x.Add(T1[i].Tp[2].x);

                y.Add(T1[i].Tp[0].y);
                y.Add(T1[i].Tp[1].y);
                y.Add(T1[i].Tp[2].y);
            }

            draw.CalRatio(x, y, Width1, Height1);

            draw.Change(x, y, Width1 / 2, Height1 / 2);

            //画线
            Pen p1 = new Pen(Color.Red);

            for (int i = 0; i < T1.Count; i++)
            {
                draw.W_line(draw.px[i * 3], draw.py[i * 3], draw.px[i * 3 + 1], draw.py[i * 3 + 1], p1);
                draw.W_line(draw.px[i * 3 + 1], draw.py[i * 3 + 1], draw.px[i * 3 + 2], draw.py[i * 3 + 2], p1);
                draw.W_line(draw.px[i * 3], draw.py[i * 3], draw.px[i * 3 + 2], draw.py[i * 3 + 2], p1);
            }

            //画点
            for (int i = 0; i < T1.Count; i++)
            {
                draw.D_circle(draw.px[i * 3], draw.py[i * 3], 2);
                draw.D_circle(draw.px[i * 3 + 1], draw.py[i * 3 + 1], 2);
                draw.D_circle(draw.px[i * 3 + 2], draw.py[i * 3 + 2], 2);
            }
        }
示例#2
0
        //绘制等高线和——窗体界面绘图
        public void Draw_Contour()
        {
            Contour_Bmp = new Bitmap(Width, Height);

            MainInterface.f1.pb1.Size = new Size(Width, Height);

            //调用绘图类
            Class_Draw draw = new Class_Draw();

            draw.gp = Graphics.FromImage(Contour_Bmp);
            draw.gp.Clear(Color.Black);

            List <double> x = new List <double>();
            List <double> y = new List <double>();
            List <double> z = new List <double>();

            //将网点坐标储存在列表中
            for (int i = 0; i < P.Count; i++)
            {
                x.Add(P[i].x);
                y.Add(P[i].y);
            }

            //将等值点储存在列表中
            for (int i = 0; i < Contour.Count; i++)
            {
                for (int j = 0; j < Contour[i].C.Count; j++)
                {
                    x.Add(Contour[i].C[j].x);
                    y.Add(Contour[i].C[j].y);
                    z.Add(Contour[i].C[j].z);
                }
            }

            draw.CalRatio(x, y, Width - 100, Height - 100);

            draw.Change(x, y, Width / 2, Height / 2);


            float FontSize = 0;

            FontSize = Width / 200;

            Font ft = new Font("宋体", FontSize, FontStyle.Regular);

            //绘制散点图
            for (int i = 0; i < P.Count; i++)
            {
                draw.D_text(draw.px[i], draw.py[i], P[i].z.ToString("F2"), ft);
                draw.D_circle(draw.px[i], draw.py[i], (float)Width / 2000);
            }

            //绘制等高线
            List <double> x2 = new List <double>();
            List <double> y2 = new List <double>();

            for (int i = P.Count; i < x.Count; i++)
            {
                x2.Add(draw.px[i]);
                y2.Add(draw.py[i]);
            }

            int sum = 0;

            for (int i = 0; i < Contour.Count; i++)
            {
                List <double> x1 = new List <double>();
                List <double> y1 = new List <double>();
                List <double> z1 = new List <double>();

                for (int j = 0; j < Contour[i].C.Count; j++)
                {
                    if (i == 0)
                    {
                        x1.Add(x2[j]);
                        y1.Add(y2[j]);
                        z1.Add(z[j]);
                    }
                    else
                    {
                        x1.Add(x2[sum + j]);
                        y1.Add(y2[sum + j]);
                        z1.Add(z[sum + j]);
                    }
                }

                if (z1[0] % 5 == 0)
                {
                    Pen Jp = new Pen(Color.Green, 2);

                    draw.D_Curve(x1, y1, Jp);
                }
                else
                {
                    Pen Jp = new Pen(Color.Yellow);

                    draw.D_Curve(x1, y1, Jp);
                }

                sum += Contour[i].C.Count;
            }
        }