資源簡介
利用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個文件信息
- 上一篇:用C#寫的松下MEWTOCOL通訊協議
- 下一篇:c#編寫的桌面管理系統源代碼
評論
共有 條評論