GIS拓扑生成程序.doc_第1页
GIS拓扑生成程序.doc_第2页
GIS拓扑生成程序.doc_第3页
GIS拓扑生成程序.doc_第4页
GIS拓扑生成程序.doc_第5页
已阅读5页,还剩3页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

拓扑生成程序 罗宇 使用VisualC+6.0新建一个AppWizard MFC.exe项目,目名为tuopu。选择创建一个对话框类型的应用程序。第一,项界面设计。打开对话框资源IDD_TUOPU_DIALOG,界面设计如图1:添加完控件后,打开ClassWizard,针对IDD_MY_DIALOG所指向的类CMYDlg,添加DDX成员变量;CStringm_sPathName1;CStringm_sPathName2;CStringm_editshow;系统自动生成如下代码:void CTuopuDlg:DoDataExchange(CDataExchange* pDX)CDialog:DoDataExchange(pDX);/AFX_DATA_MAP(CTuopuDlg)DDX_Text(pDX, IDC_EDIT1, m_sPathName1);DDX_Text(pDX, IDC_EDIT2, m_sPathName2);DDX_Text(pDX, IDC_EDIT3, m_editshow);/AFX_DATA_MAP第二, 代码编写。在tuopuDlg.h定义如下结构体:typedef struct arArc/弧段的结构体int a; char Ns20;char Ne20;int Pl;int Pr;arArc;typedef struct Point/点的结构体 char p20;int po1,po2,po3;Point;typedef struct structp/多边形的结构体 int num;CArray arP;structp;arArc *arc;Point *point;structp *stp;利用类向导为控件添加功能函数:系统自动生成的消息路由为:BEGIN_MESSAGE_MAP(CMyDlg, CDialog)/AFX_MSG_MAP(CMyDlg)OON_BN_CLICKED(IDC_BUTTON_OPEN1, OnButtonOpen1)ON_BN_CLICKED(IDC_BUTTON_OPEN2, OnButtonOpen2)ON_BN_CLICKED(IDC_BUTTON_RUN, OnButtonRun)ON_COMMAND(ID_EXIT, OnExit)ON_COMMAND(IDM_USE, OnUse)ON_BN_CLICKED(IDC_PUTOUT, OnPutout)/AFX_MSG_MAPEND_MESSAGE_MAP()在tuopuDlg.cpp添加各个功能函数代码如下:void CTuopuDlg:OnButtonOpen1() /打开文件1:结点-弧拓扑关系/ TODO: Add your control notification handler code hereCFileDialog fdlg(true,NULL,NULL,OFN_OVERWRITEPROMPT,拓扑关系文件|*.dat;*.txt|,NULL);if(fdlg.DoModal()=IDOK)m_sPathName1=fdlg.GetPathName(); if(m_sPathName1= ) return;UpdateData(false);void CTuopuDlg:OnButtonOpen2() /打开文件2:弧-结点拓扑关系/ TODO: Add your control notification handler code hereCFileDialog fdlg(true,NULL,NULL,OFN_OVERWRITEPROMPT,拓扑关系文件|*.dat;*.txt|,NULL);if(fdlg.DoModal()=IDOK)m_sPathName2=fdlg.GetPathName(); if(m_sPathName2= ) return; (CButton*)GetDlgItem(IDC_BUTTON_RUN)-EnableWindow(true); UpdateData(false);void CTuopuDlg:GetherData()/读取文件UpdateData();int i;ifstream if1(m_sPathName1);point=new Point4;for(i=0;ipointi.ppointi.po1pointi.po2pointi.po3;ifstream if2(m_sPathName2);arc=new arArc6;for(i=0;iarci.aarci.Nsarci.Ne;arci.Pl=arci.Pr=0;void CTuopuDlg:OnButtonRun() /拓扑关系生成 UpdateData(); GetherData();/ TODO: Add your control notification handler code hereint i,j,Sc,S;CString datas11,datas21;CString str;char No20;char Nc20;stp=new structp6;int num=0;for(S=1;S=6;S+) Sc=S;if(arcSc-1.Pl!=0&arcSc-1.Pr!=0) continue;if(arcSc-1.Pl=0) num+; stpS-1.arP.RemoveAll(); stpS-1.arP.Add(Sc); arcSc-1.Pl=num; strcpy(No,arcSc-1.Ns); strcpy(Nc,arcSc-1.Ne); step1:if(!strcmp(No,Nc) continue; else i=0; while(i4) if(!strcmp(Nc,pointi.p) if(Sc=pointi.po3) Sc=pointi.po1; else if (Sc=pointi.po1) Sc=pointi.po2; else Sc=pointi.po3; i=4; i+; stpS-1.arP.Add(Sc); i=0; if(!strcmp(Nc,arcSc-1.Ns) arcSc-1.Pl=num; strcpy(Nc,arcSc-1.Ne); i=1; if(i=0&(!strcmp(Nc,arcSc-1.Ne) arcSc-1.Pr=num; strcpy(Nc,arcSc-1.Ns); goto step1; elseif(arcSc-1.Pr=0)num+; stpS-1.arP.RemoveAll(); stpS-1.arP.Add(Sc); arcSc-1.Pr=num; strcpy(No,arcSc-1.Ne); strcpy(Nc,arcSc-1.Ns); step2:if(!strcmp(No,Nc) continue; else i=0; while(i4) if(!strcmp(Nc,pointi.p) if(Sc=pointi.po3) Sc=pointi.po1; else if (Sc=pointi.po1) Sc=pointi.po2; else Sc=pointi.po3; i=4; i+; stpS-1.arP.Add(Sc); i=0; if(!strcmp(Nc,arcSc-1.Ns) arcSc-1.Pl=num; strcpy(Nc,arcSc-1.Ne); i=1; if(i=0&(!strcmp(Nc,arcSc-1.Ne) arcSc-1.Pr=num; strcpy(Nc,arcSc-1.Ns); goto step2; stp0.num=num;datas10=-面_弧拓扑-rn;datas10+=面 弧数 弧号 rn;for(i=0;inum;i+)int size=stpi.arP.GetSize();str.Format(%d %d ,i+1,size);datas10+=str;for(j=0;jsize;j+)str.Format(%d ,stpi.arP.GetAt(j);datas10+=str;datas10+=rn;datas10+=rn;m_editshow=datas10;datas20=-弧_多边形拓扑-rn;datas20+=弧段 左 右 rn;for(i=0;iEnableWindow(true);UpdateData(false);void CTuopuDlg:OnPutout() /将结果输出txt文件/ TODO: Add your control notification handler code hereint i,j; CString savePath;char szFilters=Data Files (*.txt)|*.txt|All Files(*.*)|*.*|;CFileDialog dlgFileSave(FALSE,0,0, /参数给为false即为save asOFN_FILEMUSTEXIST | OFN_PATHMUSTEXIST, (CString)szFilters, this);if(IDOK=dlgFileSave.DoModal()savePath = dlgFileSave.GetPathName()+.txt;/路径加文件名再加后缀UpdateData(FALSE);fstream outfile;outfile.open(savePath,ios:out|ios:app); outfile-面_弧拓扑-endl; outfile面 弧数 弧号 endl;for(i=0;istp0.num;i+)int size=stpi.arP.GetSize();outfile i+1 size;for(j=0;jsize;j+) outfile stpi.arP.GetAt(j);outfil

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

最新文档

评论

0/150

提交评论