图形学实验四_Sutherland-Hodgman多边形裁剪算法实验报告

整理文档很辛苦,赏杯茶钱您下走!

免费阅读已结束,点击下载阅读编辑剩下 ...

阅读已结束,您可以下载文档离线阅读编辑

资源描述

《计算机图形学》实验报告《裁剪算法实验》姓名闫学森学号3013216087专业计算机班级3班天津大学计算机科学与技术学院2015年12月1日一、实验目的实现Sutherland-Hodgman多边形裁剪算法二、实验内容自定义裁剪窗口和待裁剪直线段(或多边形),采用不同颜色突出显示裁剪结果三、实验结果四、实验分析和总结Sutherland-Hodgman多边形裁剪算法是将原多边形进行左右下上四次裁剪。其中进行两次分解•第一次分解:将多边形关于矩形窗口的裁剪分解为它关于窗口四条边所在直线的裁剪;•第二次分解:将多边形关于一条直线的裁剪分解为多边形各边关于该直线的裁剪。四次裁剪相似,只要修改部分变量即可。但是第一次修改时没有完全改掉,出来的图像不正确。通过这次试验使我了解到如何运用计算机程序对窗口进行剪裁,了解到编码剪裁算法直观方便,速度较快,中点分割剪裁算法不用进行乘除运算,剪裁效率高,Sutherland-Hodgman直线裁剪算法更快。五、源代码//PolygonClipDemo.cpp:Definestheclassbehaviorsfortheapplication.//#includestdafx.h#includePolygonClipDemo.h#includeMainFrm.h#ifdef_DEBUG#definenewDEBUG_NEW#endif//CPolygonClipDemoAppBEGIN_MESSAGE_MAP(CPolygonClipDemoApp,CWinApp)ON_COMMAND(ID_APP_ABOUT,OnAppAbout)END_MESSAGE_MAP()//CPolygonClipDemoAppconstructionCPolygonClipDemoApp::CPolygonClipDemoApp(){//TODO:addconstructioncodehere,//PlaceallsignificantinitializationinInitInstance}//TheoneandonlyCPolygonClipDemoAppobjectCPolygonClipDemoApptheApp;//CPolygonClipDemoAppinitializationBOOLCPolygonClipDemoApp::InitInstance(){//InitCommonControls()isrequiredonWindowsXPifanapplication//manifestspecifiesuseofComCtl32.dllversion6orlatertoenable//visualstyles.Otherwise,anywindowcreationwillfail.InitCommonControls();CWinApp::InitInstance();//Standardinitialization//Ifyouarenotusingthesefeaturesandwishtoreducethesize//ofyourfinalexecutable,youshouldremovefromthefollowing//thespecificinitializationroutinesyoudonotneed//Changetheregistrykeyunderwhichoursettingsarestored//TODO:Youshouldmodifythisstringtobesomethingappropriate//suchasthenameofyourcompanyororganizationSetRegistryKey(_T(LocalAppWizard-GeneratedApplications));//Tocreatethemainwindow,thiscodecreatesanewframewindow//objectandthensetsitastheapplication'smainwindowobjectCMainFrame*pFrame=newCMainFrame;m_pMainWnd=pFrame;//createandloadtheframewithitsresourcespFrame-LoadFrame(IDR_MAINFRAME,WS_OVERLAPPEDWINDOW|FWS_ADDTOTITLE,NULL,NULL);//Theoneandonlywindowhasbeeninitialized,soshowandupdateitpFrame-ShowWindow(SW_SHOW);pFrame-UpdateWindow();//callDragAcceptFilesonlyifthere'sasuffix//InanSDIapp,thisshouldoccurafterProcessShellCommandreturnTRUE;}//CPolygonClipDemoAppmessagehandlers//CAboutDlgdialogusedforAppAboutclassCAboutDlg:publicCDialog{public:CAboutDlg();//DialogDataenum{IDD=IDD_ABOUTBOX};protected:virtualvoidDoDataExchange(CDataExchange*pDX);//DDX/DDVsupport//Implementationprotected:DECLARE_MESSAGE_MAP()};CAboutDlg::CAboutDlg():CDialog(CAboutDlg::IDD){}voidCAboutDlg::DoDataExchange(CDataExchange*pDX){CDialog::DoDataExchange(pDX);}BEGIN_MESSAGE_MAP(CAboutDlg,CDialog)END_MESSAGE_MAP()//AppcommandtorunthedialogvoidCPolygonClipDemoApp::OnAppAbout(){CAboutDlgaboutDlg;aboutDlg.DoModal();}//CPolygonClipDemoAppmessagehandlers

1 / 5
下载文档,编辑使用

©2015-2020 m.777doc.com 三七文档.

备案号:鲁ICP备2024069028号-1 客服联系 QQ:2149211541

×
保存成功