y-x有效邊表填充算法_第1頁
y-x有效邊表填充算法_第2頁
y-x有效邊表填充算法_第3頁
y-x有效邊表填充算法_第4頁
y-x有效邊表填充算法_第5頁
已閱讀5頁,還剩9頁未讀, 繼續(xù)免費閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報或認(rèn)領(lǐng)

文檔簡介

1、y-x有效邊表填充算法無效邊表挖充算法一、真驗?zāi)繕?biāo)取請求:計劃無效邊表節(jié)面以及邊表節(jié)面數(shù)據(jù)布局2、真驗形容:利用無效邊算法挖充示例多邊形3、真驗了局:4、算法計劃:創(chuàng)立菜單欄,加減函數(shù)。正在VC+的class view 界里,新建兩個類,VET以及Bucket。個中AET類用于創(chuàng)建無效邊表以及邊表節(jié)面,Bucket類用去創(chuàng)建桶節(jié)面。AET.h文件。class AETpublic:AET();virtual AET();double x;int yMax;double k;AET *next;Bucket.h文件#include AET.hclass Bucketpublic:Bucket();

2、virtual Bucket();int ScanLine;AET *p;Bucket *next;CExp2View.h文件。個中加減了成員變量以及函數(shù)的申明,和庫的導(dǎo)進(jìn)。#include AET.h#include Bucket.h#define Number 7加減的成員變量以及函數(shù)申明以下:public:void PolygonFill();void CreatBucket();void Et();void AddEdge(AET *);void EdgeOrder();protected:COLORREF GetColor;CPoint Point7;Bucket *HeadB,*C

3、urrentB;AET ENumber,*HeadE,*CurrentE,*T1,*T2;CExp2View.cpp文件。包孕機(jī)關(guān)圓法、OnDraw圓法以及其余成員圓法的形容#define ROUND(a) int(a+0.5)CExp2View:CExp2View()/ TODO: add construction code herePoint0 = CPoint(500,400);Point1 = CPoint(350,600);Point2 = CPoint(250,350);Point3 = CPoint(350,50);Point4 = CPoint(500,250);Point5

4、= CPoint(600,50);Point6 = CPoint(800,450);void CExp2View:OnDraw(CDC* pDC)CExp2Doc* pDoc = GetDocument();ASSERT_VALID(pDoc);/ TODO: add draw code for native data herepDC-TextOut(505,410,P0);pDC-TextOut(340,600,P1);pDC-TextOut(230,350,P2);pDC-TextOut(360,50,P3);pDC-TextOut(490,225,P4);pDC-TextOut(610,

5、50,P5);pDC-TextOut(800,450,P6);void CExp2View:OnMenuAET()/ TODO: Add your command handler code hereAfxGetMainWnd()-SetWindowText(?D?3?oDD?);CColorDialog ccd(GetColor);if(ccd.DoModal() = IDOK)GetColor = ccd.GetColor();RedrawWindow();CreatBucket();Et();PolygonFill();void CExp2View:CreatBucket()int Sca

6、nMin,ScanMax;ScanMax = ScanMin = Point0.y;for(int i=1;iif(Pointi.yScanMin = Pointi.y;if(Pointi.yScanMax)ScanMax = Pointi.y;for(i=ScanMin;iif(ScanMin = i)HeadB = new Bucket;CurrentB = HeadB;CurrentB-ScanLine = ScanMin;CurrentB-p = NULL;CurrentB-next = NULL;elseCurrentB-next = new Bucket;CurrentB = Cu

7、rrentB-next;CurrentB-ScanLine = i;CurrentB-p = NULL;CurrentB-next = NULL;void CExp2View:Et()for(int i=0;iCurrentB = HeadB;int j=i+1;if(j=Number)j=0;if(Pointj.yPointi.y)while(CurrentB-ScanLine != Pointi.y)CurrentB = CurrentB-next;Ei.x = Pointi.x;Ei.yMax = Pointj.y;Ei.k = double(Pointj.x-Pointi.x)/(Po

8、intj.y-Pointi.y);Ei.next = NULL;CurrentE = CurrentB-p;if(CurrentB-p = NULL)CurrentE = &Ei;CurrentB-p = CurrentE;elsewhile(CurrentE-next != NULL)CurrentE = CurrentE-next;CurrentE-next = &Ei;if(Pointj.y while(CurrentB-ScanLine != Pointj.y)CurrentB = CurrentB-next;Ei.x = Pointj.x;Ei.yMax = Pointi.y;Ei.

9、k = double(Pointi.x-Pointj.x)/(Pointi.y-Pointj.y);Ei.next = NULL;CurrentE = CurrentB-p;if(CurrentE = NULL)CurrentE = &Ei;CurrentB-p = CurrentE;elsewhile(CurrentE-next != NULL)CurrentE = CurrentE-next;CurrentE-next = &Ei;CurrentB = NULL;CurrentE = NULL;void CExp2View:AddEdge(AET *NewEdge)T1 = HeadE;i

10、f(T1 = NULL)T1 = NewEdge;HeadE = T1;elsewhile(T1-next != NULL)T1 = T1-next;T1-next = NewEdge;void CExp2View:EdgeOrder()T1 = HeadE;if(T1 =NULL)return;if(T1-next = NULL)return;elseif(T1-next-x T2 = T1-next;T1-next = T2-next;T2-next = T1;HeadE = T2;T2 = HeadE;T1 = HeadE-next;while(T1-next != NULL)if(T1

11、-next-x T2-next = T1-next;T1-next = T1-next-next;T2-next-next = T1;T2 = T2-next;elseT2 = T1;T1 = T1-next;void CExp2View:PolygonFill()HeadE = NULL;for(CurrentB=HeadB; CurrentB!=NULL; CurrentB=CurrentB-next)for(CurrentE=CurrentB-p; CurrentE != NULL;CurrentE = CurrentE-next)AET *TempEdge = new AET;Temp

12、Edge-x = CurrentE-x;TempEdge-yMax = CurrentE-yMax;TempEdge-k = CurrentE-k;TempEdge-next = NULL;AddEdge(TempEdge);EdgeOrder();T1 = HeadE;if(T1 = NULL)return;while(CurrentB-ScanLine = T1-yMax)T1 = T1-next;HeadE = T1;if(HeadE = NULL)return;if(T1-next != NULL)T2 = T1;T1 = T2-next;while(T1 != NULL)if(CurrentB-ScanLine = T1-yMax)T2-next = T1-next;T1-next = NULL;T1 = T2-next;elseT2 = T1;T1 = T2-next;BOOL In = false;double xb,xe;for(T1=HeadE; T1!=NULL; T1=T1-next)if(In = false)xb = T1-x;In = true;elsexe = T1-x-1;CClientDC dc(this);for(double x=xb; xdc.SetPixel(ROUND(x),CurrentB-

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

最新文檔

評論

0/150

提交評論