您好,欢迎访问三七文档
当前位置:首页 > 商业/管理/HR > 公司方案 > 数字高程模型作业_DEM编程
此次作业主要采用C++语言编写程序,同时利用了matlab进行格网点以及DEM三维显示。主要程序如下:#includeStdAfx.h#includeIDW.h#includeIDWDlg.h#includemath.h#ifdef_DEBUG#definenewDEBUG_NEW#undefTHIS_FILEstaticcharTHIS_FILE[]=__FILE__;#endif/***************************************************************//*CAboutDlgdialogusedforAppAbout*//**************************************************************/classCAboutDlg:publicCDialog{public:CAboutDlg();//DialogData//{{AFX_DATA(CAboutDlg)enum{IDD=IDD_ABOUTBOX};//}}AFX_DATA//ClassWizardgeneratedvirtualfunctionoverrides//{{AFX_VIRTUAL(CAboutDlg)protected:virtualvoidDoDataExchange(CDataExchange*pDX);//DDX/DDVsupport//}}AFX_VIRTUAL//Implementationprotected://{{AFX_MSG(CAboutDlg)//}}AFX_MSGDECLARE_MESSAGE_MAP()};CAboutDlg::CAboutDlg():CDialog(CAboutDlg::IDD){//{{AFX_DATA_INIT(CAboutDlg)//}}AFX_DATA_INIT}voidCAboutDlg::DoDataExchange(CDataExchange*pDX){CDialog::DoDataExchange(pDX);//{{AFX_DATA_MAP(CAboutDlg)//}}AFX_DATA_MAP}BEGIN_MESSAGE_MAP(CAboutDlg,CDialog)//{{AFX_MSG_MAP(CAboutDlg)//Nomessagehandlers//}}AFX_MSG_MAPEND_MESSAGE_MAP()/*************************************************************//*CIDWDlgdialog*//*************************************************************/CIDWDlg::CIDWDlg(CWnd*pParent/*=NULL*/):CDialog(CIDWDlg::IDD,pParent){//{{AFX_DATA_INIT(CIDWDlg)m_strOpenFileName=_T();m_strSaveFileName=_T();m_maxX=0;m_maxY=0;m_minX=0;m_minY=0;m_rad=100.0f;m_stepDis=100.0f;//}}AFX_DATA_INIT//NotethatLoadIcondoesnotrequireasubsequentDestroyIconinWin32m_hIcon=AfxGetApp()-LoadIcon(IDR_MAINFRAME);}voidCIDWDlg::DoDataExchange(CDataExchange*pDX){CDialog::DoDataExchange(pDX);//{{AFX_DATA_MAP(CIDWDlg)DDX_Control(pDX,IDC_PROGRESS1,m_ctrProgress);DDX_Text(pDX,IDC_OPEN_FILE,m_strOpenFileName);DDX_Text(pDX,IDC_SAVE_FILE,m_strSaveFileName);DDX_Text(pDX,IDC_EDIT_MAX_X,m_maxX);DDX_Text(pDX,IDC_EDIT_MAX_Y,m_maxY);DDX_Text(pDX,IDC_EDIT_MIN_X,m_minX);DDX_Text(pDX,IDC_EDIT_MIN_Y,m_minY);DDX_Text(pDX,IDC_EDIT_RAD,m_rad);DDX_Text(pDX,IDC_EDIT_STEP_DIS,m_stepDis);//}}AFX_DATA_MAP}BEGIN_MESSAGE_MAP(CIDWDlg,CDialog)//{{AFX_MSG_MAP(CIDWDlg)ON_WM_SYSCOMMAND()ON_WM_PAINT()ON_WM_QUERYDRAGICON()ON_BN_CLICKED(IDB_SOURCE_FILE,OnSourceFile)ON_BN_CLICKED(IDB_OUTPUT,OnOutput)ON_BN_CLICKED(IDB_AIM_FILE,OnAimFile)ON_EN_CHANGE(IDC_EDIT_RAD,OnChangeEditRad)ON_EN_CHANGE(IDC_EDIT_STEP_DIS,OnChangeEditStepDis)ON_EN_CHANGE(IDC_EDIT_MIN_X,OnChangeEditMinX)ON_EN_CHANGE(IDC_EDIT_MAX_X,OnChangeEditMaxX)ON_EN_CHANGE(IDC_EDIT_MIN_Y,OnChangeEditMinY)ON_EN_CHANGE(IDC_EDIT_MAX_Y,OnChangeEditMaxY)ON_BN_CLICKED(IDC_BUTTON1,Onmean_weigth)ON_BN_CLICKED(IDC_BUTTON2,Onmean)ON_EN_CHANGE(IDC_OPEN_FILE,OnChangeOpenFile)ON_EN_CHANGE(IDC_SAVE_FILE,OnChangeSaveFile)//}}AFX_MSG_MAPEND_MESSAGE_MAP()/**************************************************************//*CIDWDlgmessagehandlers*//**************************************************************/BOOLCIDWDlg::OnInitDialog(){CDialog::OnInitDialog();//AddAbout...menuitemtosystemmenu.//IDM_ABOUTBOXmustbeinthesystemcommandrange.ASSERT((IDM_ABOUTBOX&0xFFF0)==IDM_ABOUTBOX);ASSERT(IDM_ABOUTBOX0xF000);CMenu*pSysMenu=GetSystemMenu(FALSE);if(pSysMenu!=NULL){CStringstrAboutMenu;strAboutMenu.LoadString(IDS_ABOUTBOX);if(!strAboutMenu.IsEmpty()){pSysMenu-AppendMenu(MF_SEPARATOR);pSysMenu-AppendMenu(MF_STRING,IDM_ABOUTBOX,strAboutMenu);}}//Settheiconforthisdialog.Theframeworkdoesthisautomatically//whentheapplication'smainwindowisnotadialogSetIcon(m_hIcon,TRUE);//SetbigiconSetIcon(m_hIcon,FALSE);//Setsmallicon//TODO:Addextrainitializationherem_maxX=0;m_minX=0;m_maxY=0;m_minY=0;m_rad=100;m_stepDis=100;UpdateData(FALSE);m_ctrProgress.SetPos(0);returnTRUE;//returnTRUEunlessyousetthefocustoacontrol}voidCIDWDlg::OnSysCommand(UINTnID,LPARAMlParam){if((nID&0xFFF0)==IDM_ABOUTBOX){CAboutDlgdlgAbout;dlgAbout.DoModal();}else{CDialog::OnSysCommand(nID,lParam);}}//Ifyouaddaminimizebuttontoyourdialog,youwillneedthecodebelow//todrawtheicon.ForMFCapplicationsusingthedocument/viewmodel,//thisisautomaticallydoneforyoubytheframework.voidCIDWDlg::OnPaint(){if(IsIconic()){CPaintDCdc(this);//devicecontextforpaintingSendMessage(WM_ICONERASEBKGND,(WPARAM)dc.GetSafeHdc(),0);//CentericoninclientrectangleintcxIcon=GetSystemMetrics(SM_CXICON);intcyIcon=GetSystemMetrics(SM_CYICON);CRectrect;GetClientRect(&rect);intx=(rect.Width()-cxIcon+1)/2;inty=(rect.Height()-cyIcon+1)/2;//Drawtheicondc.DrawIcon(x,y,m_hIcon);}else{CDialog::OnPaint();}}//thesystemcallsthistoobtainthecursortodisplaywhiletheuserdrags//theminimizedwindow.HCURSORCIDWDlg::OnQueryDragIcon(){return(HCURSOR)m_hIcon;}voidCIDWDlg::OnSourceFile(){CFileDialogFileDlg(TRUE,*.txt,NULL,OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT,源数据文件(*.txt)|*.txt|Allfiles(*.*)|*.*||);if(FileDlg.DoModal()==IDOK){m_strOpenFileName=FileDlg.GetPathName();UpdateData(false);}elsereturn;/************************************************************//*openfileandreaddata*//*************************************************************/FILE*pInputFile;if((pInputFile=fopen(m_strOpenFileName,r))==NULL)AfxMessageBox(打开文件失败!);ptptTemp;while(!feof
本文标题:数字高程模型作业_DEM编程
链接地址:https://www.777doc.com/doc-2331422 .html