• 大小: 52KB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2021-05-04
  • 语言: C#
  • 标签: 道格拉斯  

资源简介

利用C#编写的道格拉斯窗体应用程序,效果不错,对于做课程设计有知道效果

资源截图

代码片段和文件信息

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;

namespace Douglas_Peucker
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private string filename;    //文件名

        //文件菜单中打开选项编辑
        private void 打开OToolStripMenuItem_Click(object sender EventArgs e)
        {
            this.openFileDialog1.ShowDialog();
            if (this.openFileDialog1.FileName != ““)
            {
                this.filename = this.openFileDialog1.FileName;
            }
        }

        private void douglasPeuckerToolStripMenuItem_Click(object sender EventArgs e)
        {

        }

        private void 绘图ToolStripMenuItem_Click(object sender EventArgs e)
        {
            //定义断行断句的标志常量字符
            char[] charSeparators1 = new char[] { ‘\n‘ };
            char[] charSeparators2 = new char[] { ‘‘ };//英语中的逗号
            //开始读取文件
            StreamReader streamReadfile = new StreamReader(this.filename);
            string data = streamReadfile.ReadToEnd();
            string[] strLine = data.Split(charSeparators1 StringSplitOptions.RemoveEmptyEntries);
            //点的个数
            int number = Convert.ToInt16(strLine[0]);
            
            //定义点的数组
            Point [] pointLoc = new Point[number];
            for (int a = 1; a <= number; a++)
            {
                string[] strTemp = strLine[a].Split(charSeparators2 StringSplitOptions.RemoveEmptyEntries);
                pointLoc[a - 1].X = Convert.ToInt16(strTemp[0]);
                pointLoc[a - 1].Y = Convert.ToInt16(strTemp[1]);
                //pointLoc[a - 1].X = 23-a;
                //pointLoc[a - 1].Y = 233+a;
            }

            double yuzhi = Convert.ToDouble(this.toolStripComboBox1.Text);

            //原始数据绘图
            Graphics myGraphics = this.CreateGraphics();
            myGraphics.DrawLines(new Pen(Color.Red) pointLoc);
            myGraphics.Dispose();

           // this.label1.Text = Convert.ToString(yuzhi);

            //程序主体
            //******************思路*********************
            //首先定义一个用于存储中间存在最远距离大于阈值的点的点组数组,unpoint_index,数据个数定为最坏情况大小
            //在定义一个用于存储中间已经不存在最远距离大于阈值的点的点组数组,alpoint_index,数据个数定为最坏情况大小
            //unfirst,unlast分别是正在处理中的点组角标
            //求最远点
            //然后基本是和书本等资料中表示的流程一样了
          
            int un = 0;
            int al = -1;
            int unfirst = 0;
            int unlast = number-1;
            
            int[] unpoint_index = new int[number*(number-1)/22];
            unpoint_index[0 0] = 0;
            unpoint_index[0 1] = number - 1;

            int[] alpoint_index = new int[number * (number - 1) / 2 2];
            int now = 0;

            double l_every = 0;//点线距

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件       8901  2010-10-29 18:58  Douglas-Peucker\实验数据.txt

     文件        935  2010-10-29 08:52  Douglas-Peucker\GIS_\GIS_Douglas-Peucker.sln

    ..A..H.     19456  2010-12-29 09:14  Douglas-Peucker\GIS_\GIS_Douglas-Peucker.suo

     文件       3776  2010-10-29 09:05  Douglas-Peucker\GIS_\Douglas-Peucker\Douglas-Peucker.csproj

     文件        496  2010-10-29 08:52  Douglas-Peucker\GIS_\Douglas-Peucker\Program.cs

     文件       7640  2010-11-26 20:47  Douglas-Peucker\GIS_\Douglas-Peucker\Form1.resx

     文件       9148  2010-11-26 20:47  Douglas-Peucker\GIS_\Douglas-Peucker\Form1.Designer.cs

     文件       8087  2010-11-26 20:48  Douglas-Peucker\GIS_\Douglas-Peucker\Form1.cs

     文件       1386  2010-10-29 08:52  Douglas-Peucker\GIS_\Douglas-Peucker\Properties\AssemblyInfo.cs

     文件       2880  2010-10-29 08:52  Douglas-Peucker\GIS_\Douglas-Peucker\Properties\Resources.Designer.cs

     文件       5612  2010-10-29 08:51  Douglas-Peucker\GIS_\Douglas-Peucker\Properties\Resources.resx

     文件       1100  2010-10-29 08:52  Douglas-Peucker\GIS_\Douglas-Peucker\Properties\Settings.Designer.cs

     文件        249  2010-10-29 08:51  Douglas-Peucker\GIS_\Douglas-Peucker\Properties\Settings.settings

     文件       3244  2010-12-29 09:04  Douglas-Peucker\GIS_\Douglas-Peucker\obj\Debug\Douglas-Peucker.csproj.FileListAbsolute.txt

     文件      14336  2010-11-26 20:49  Douglas-Peucker\GIS_\Douglas-Peucker\obj\Debug\Douglas-Peucker.exe

     文件      36352  2010-11-26 20:49  Douglas-Peucker\GIS_\Douglas-Peucker\obj\Debug\Douglas-Peucker.pdb

     文件       1244  2010-11-26 20:47  Douglas-Peucker\GIS_\Douglas-Peucker\obj\Debug\Douglas_Peucker.Form1.resources

     文件        180  2010-10-29 09:05  Douglas-Peucker\GIS_\Douglas-Peucker\obj\Debug\Douglas_Peucker.Properties.Resources.resources

     文件        847  2010-11-26 20:47  Douglas-Peucker\GIS_\Douglas-Peucker\obj\Debug\Douglas-Peucker.csproj.GenerateResource.Cache

     文件      14336  2010-11-26 20:49  Douglas-Peucker\GIS_\Douglas-Peucker\bin\Debug\Douglas-Peucker.exe

     文件      36352  2010-11-26 20:49  Douglas-Peucker\GIS_\Douglas-Peucker\bin\Debug\Douglas-Peucker.pdb

     文件      14328  2010-12-29 09:04  Douglas-Peucker\GIS_\Douglas-Peucker\bin\Debug\Douglas-Peucker.vshost.exe

     文件        490  2007-07-21 01:33  Douglas-Peucker\GIS_\Douglas-Peucker\bin\Debug\Douglas-Peucker.vshost.exe.manifest

     目录          0  2010-11-30 14:16  Douglas-Peucker\GIS_\Douglas-Peucker\obj\Debug\TempPE

     目录          0  2010-11-30 14:16  Douglas-Peucker\GIS_\Douglas-Peucker\obj\Debug

     目录          0  2010-11-30 14:16  Douglas-Peucker\GIS_\Douglas-Peucker\bin\Debug

     目录          0  2010-11-30 14:16  Douglas-Peucker\GIS_\Douglas-Peucker\Properties

     目录          0  2010-11-30 14:16  Douglas-Peucker\GIS_\Douglas-Peucker\obj

     目录          0  2010-11-30 14:16  Douglas-Peucker\GIS_\Douglas-Peucker\bin

     目录          0  2010-11-30 14:16  Douglas-Peucker\GIS_\Douglas-Peucker

............此处省略5个文件信息

评论

共有 条评论