Ejemplo n.º 1
0
        private void 生成等值线ToolStripMenuItem1_Click(object sender, EventArgs e)
        {
            this.ShowContourLine = (this.生成等值线ToolStripMenuItem1.Checked == true);
            if (this.ShowContourLine == false)
            {
                this.agisControl.Refresh(); return;
            }
            ContourLineSettingForm settingForm = new ContourLineSettingForm();

            if (settingForm.ShowDialog(this) == DialogResult.OK)
            {
                //生成Tin
                CreateTIN createTin = new CreateTIN(this.mPointSet);
                Edge[]    tinEdges  = createTin.PointByPointInsertion2();
                TinEdges = tinEdges;
                TriangleSet triSet           = EdgeSet.TopologyGenerateTriangleSet(tinEdges, mPointSet);
                Triangle[]  triList          = triSet.TriangleList.ToArray();
                List <Edge> contourLinesList = new List <Edge>();
                //计算等值线条数
                int lineCount = (int)((settingForm.MaxValue - settingForm.MinValue) / settingForm.IntervalValue);
                for (int i = 0; i <= lineCount; i++)
                {
                    for (int j = 0; j < triList.Length; j++)
                    {
                        Edge contourLine = triList[j].GetContourLine(settingForm.MaxValue - i * settingForm.IntervalValue);
                        if (contourLine != null)
                        {
                            contourLinesList.Add(contourLine);
                        }
                    }
                    this.TinContourLineList = contourLinesList.ToArray();
                }
            }
            TinContourLinePen.DashStyle = System.Drawing.Drawing2D.DashStyle.Dash;
            agisControl.Refresh();
        }
Ejemplo n.º 2
0
        private void 生成等值线ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (this.UserOperation != UserOperationType.DisplayInGrid)
            {
                MessageBox.Show("当前并没有在格网下显示,请先生成网格!", "提示"); return;
            }
            else if (this.agisControl.GridIntMethod == Mehtod.GridInterpolationMehtod.None)
            {
                MessageBox.Show("尚未选择格网插值方法!\r\n请在“格网模型”中选择“距离平方倒数法”或“按方位加权平均法”!", "提示"); return;
            }
            else
            {
                this.生成等值线ToolStripMenuItem.Checked = (this.生成等值线ToolStripMenuItem.Checked == false);
                this.ShowContourLine = (this.生成等值线ToolStripMenuItem.Checked == true);
                if (this.ShowContourLine == false)
                {
                    this.agisControl.Refresh(); return;
                }
                ContourLineSettingForm settingForm = new ContourLineSettingForm();
                if (settingForm.ShowDialog(this) == DialogResult.OK)
                {
                    //生成格网矩阵
                    List <Edge>            tempGridContourLineList = new List <Edge>();
                    List <ContourPolyline> tempContourPolylineList = new List <ContourPolyline>();
                    ContourPolylineSet     tempContourPolyline     = new ContourPolylineSet();
                    //计算等值线条数
                    int lineCount = (int)((settingForm.MaxValue - settingForm.MinValue) / settingForm.IntervalValue);
                    for (int k = 0; k <= lineCount; k++)
                    {
                        double tempElevation = settingForm.MaxValue - k * settingForm.IntervalValue;
                        double[,] GridRealLoc = GridPointPositionMatrix();
                        double[,] tempHH      = 内插等值点_HH(tempElevation);
                        double[,] tempSS      = 内插等值点_SS(tempElevation);
                        int Grid_Count_all_X = this.EachGridDivisionCount_X * this.GridDivisionCount_X;
                        int Grid_Count_all_Y = this.EachGridDivisionCount_Y * this.GridDivisionCount_Y;
                        for (int i = 0; i < Grid_Count_all_X; i++)
                        {
                            for (int j = 0; j < Grid_Count_all_Y; j++)
                            {
                                List <DataPoint> tempPointList = new List <DataPoint>();
                                //横边有等值点
                                if (tempHH[i, j] < 2)
                                {
                                    tempPointList.Add(new DataPoint(-i * 1000 - j, "等值点" + (-i * 1000 - j).ToString(),
                                                                    Grid_AxisX[i] + tempHH[i, j] * (Grid_AxisX[i + 1] - Grid_AxisX[i]),
                                                                    Grid_AxisY[j], tempElevation, (-i * 1000 - j) * 1000 + (int)tempElevation));
                                }
                                //竖边有等值点
                                if (tempSS[i, j] < 2)
                                {
                                    tempPointList.Add(new DataPoint(i * 1000 + j, "等值点" + (i * 1000 + j).ToString(),
                                                                    Grid_AxisX[i],
                                                                    Grid_AxisY[j] + tempSS[i, j] * (Grid_AxisY[j + 1] - Grid_AxisY[j]),
                                                                    tempElevation, (i * 1000 + j) * 1000 + (int)tempElevation));
                                }
                                //另一条横边有等值点
                                if (tempHH[i, j + 1] < 2)
                                {
                                    tempPointList.Add(new DataPoint(-i * 1000 - j - 1, "等值点" + (-i * 1000 - j - 1).ToString(),
                                                                    Grid_AxisX[i] + tempHH[i, j + 1] * (Grid_AxisX[i + 1] - Grid_AxisX[i]),
                                                                    Grid_AxisY[j + 1], tempElevation, (-i * 1000 - j - 1) * 1000 + (int)tempElevation));
                                }
                                //另一条竖边有等值点
                                if (tempSS[i + 1, j] < 2)
                                {
                                    tempPointList.Add(new DataPoint((i + 1) * 1000 + j, "等值点" + ((1 + i) * 1000 + j).ToString(),
                                                                    Grid_AxisX[i + 1],
                                                                    Grid_AxisY[j] + tempSS[i + 1, j] * (Grid_AxisY[j + 1] - Grid_AxisY[j]),
                                                                    tempElevation, ((i + 1) * 1000 + j) * 1000 + (int)tempElevation));
                                }
                                if (tempPointList.Count < 2)//无等值线
                                {
                                    continue;
                                }
                                else if (tempPointList.Count < 4)
                                {
                                    tempGridContourLineList.Add(new Edge(tempPointList[0], tempPointList[1]));
                                }
                                else
                                {
                                    tempGridContourLineList.Add(new Edge(tempPointList[0], tempPointList[1]));
                                    tempGridContourLineList.Add(new Edge(tempPointList[2], tempPointList[3]));
                                }
                            }
                        }
                        tempContourPolyline = EdgeSet.TopologyGenerateContourPolylineSet(tempGridContourLineList.ToArray());

                        /*另一种方法
                         * GridCreateContourLine CreateContourLineClass = new GridCreateContourLine(this.Grid_AxisX, this.Grid_AxisY,
                         *  tempHH, tempSS, Grid_Count_all_X, Grid_Count_all_Y, tempElevation);
                         * tempContourPolylineList = CreateContourLineClass.CreateContourLines();
                         */
                    }
                    //this.GridContourList = tempGridContourLineList.ToArray();
                    this.GridContourPolylineList = tempContourPolyline.ContourPolylineList.ToArray();
                }
                //GridContourLinePen.DashStyle = System.Drawing.Drawing2D.DashStyle.DashDot;
                agisControl.Refresh();
            }
        }