資源簡介
該程序點擊鼠標左鍵是為多邊形添加頂點,頂點添加完成后點擊右鍵即可填充!目前個人已經測試可以填充凹多邊形,如果下載的朋友發現什么地方運行不對請及時回復本人(希望能夠把運行不對時候整個屏幕拷下來,這樣方便本人查找問題,謝謝)!
代碼片段和文件信息
//?Edge.cpp:?implementation?of?the?CEdge?class.
//
//////////////////////////////////////////////////////////////////////
#include?“stdafx.h“
#include?“MulFillRect.h“
#include?“Edge.h“
#ifdef?_DEBUG
#undef?THIS_FILE
static?char?THIS_FILE[]=__FILE__;
#define?new?DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
//?Construction/Destruction
//////////////////////////////////////////////////////////////////////
CEdge::CEdge()
{
x=0;
ymax=0;
deltax=0;
HLine=FALSE;
nextEdge=NULL;
}
/*CEdge::Edge(CEdge&edge)
{
}*/
CEdge::~CEdge()
{
/*int?i=GetLength(this);
for(;i>0;i--)
DelEdge(thisi);*/
}
BOOL?CEdge::AddEdge(CEdge*headCEdge*edge)
//在分類鏈表中添加一條邊對每一條邊按x的值進行排序
{
CEdge?*s=new?CEdge();
//CEdge?*s=edge;
s->deltax=edge->deltax;
s->HLine=edge->HLine;
s->x=edge->x;
s->ymax=edge->ymax;
/*s=edge;*/
CEdge?*p=head;
while(NULL!=p->nextEdge?&&?s->x>=p->nextEdge->x)
{
p=p->nextEdge;
}
if(NULL==p->nextEdge)
p->nextEdge=s;
else
{
s->nextEdge=p->nextEdge;
p->nextEdge=s;
}
return?true;
}
BOOL?CEdge::InsertEdge(CEdge*headint?nCEdge*edge)
//在分類鏈表中插入一條邊
{
return?true;
}
BOOL?CEdge::DelEdge(CEdge*headint?n)
//從分類鏈表中刪除一條邊
{
int?j=1;
if(n<1?||?n>GetLength(head)+1)
return?FALSE;
CEdge?*p*q;
p=head;
for(;j p=p->nextEdge;
q=p->nextEdge;
p->nextEdge=q->nextEdge;
delete?q;
return?true;
}
CEdge??*CEdge::DelEdge(CEdge?*headCEdge?*edge)
{
CEdge?*p*q;
p=head;
for(;p->nextEdge!=NULL;)
{
if(p->nextEdge->x==edge->x?
&&?p->nextEdge->ymax==(edge->ymax))
{
q=p->nextEdge;
break;
}
else
p=p->nextEdge;
}//在鏈表中查找該結點
if(NULL==p->nextEdge)
return?NULL;
p->nextEdge=q->nextEdge;
delete?q;
return?p->nextEdge;
}
BOOL?CEdge::ListSort(CEdge*head)
//按x的值給鏈表排序
//使用冒泡排序方法
{
int?i=GetLength(head);
CEdge?*temp1;
temp1=head;
CEdge?*temp2;
temp2=temp1->nextEdge;
if(temp2==NULL)
return?true;
CEdge?*temp3;
temp3=temp2->nextEdge;
CEdge?*temp5;
CEdge?*temp4;
temp4=head;
temp5=head;
int?check=0;
for(int?j=0;j {
while(temp3!=NULL)
{
if(temp3->xx)
{
check++;
temp4=temp3;//先記下要前移的結點
temp5=temp3;
temp2->nextEdge=temp5->nextEdge;
temp4->nextEdge=temp2;
temp1->nextEdge=temp4;
//通過鏈表的指針移動進行排序
}
temp1=temp1->nextEdge;
temp2=temp1->nextEdge;
temp3=temp2->nextEdge;
//臨時變量均向指向下一個結點
}
temp1=head;
//一次冒泡排序結束,進行下一次排序
if(0==check)
break;
else?check=0;
}
return?true;
}
int?CEdge::GetLength(CEdge*head)
//得到鏈表的長度
{
//得到鏈表長度有問題
int?i=0;
CEdge?*p=head->nextEdge;
while(p!=NULL)
{
i++;
p=p->nextEdge;
}
return?i;
}
int?CEdge::OnCreate(CPoint?begPointCPoint?endPoint)
//根據起點和終點構建條邊,返回邊的下端點
{
int?ymin=0;
HLine=FALSE;
nextEdge=NULL;
CPoint?tempPoint;
if(begPoint.y>endPoint.y)
{
tempPoint=b
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件????????403??2009-04-07?19:21??多邊形填充掃描線算法\res\MulFillRect.rc2
?????文件???????1078??2009-04-07?19:21??多邊形填充掃描線算法\res\MulFillRectDoc.ico
?????文件???????1078??2009-04-07?19:21??多邊形填充掃描線算法\res\MulFillRect.ico
?????文件???????1078??2009-04-07?19:21??多邊形填充掃描線算法\res\Toolbar.bmp
?????文件???????4221??2009-04-16?19:31??多邊形填充掃描線算法\Edge.cpp
?????文件???????1512??2009-04-16?18:25??多邊形填充掃描線算法\Edge.h
?????文件???????6023??2009-04-16?19:51??多邊形填充掃描線算法\EdgeNet.cpp
?????文件???????1156??2009-04-08?19:29??多邊形填充掃描線算法\EdgeNet.h
?????文件???????2512??2009-04-07?19:21??多邊形填充掃描線算法\MainFrm.cpp
?????文件???????1581??2009-04-07?19:21??多邊形填充掃描線算法\MainFrm.h
?????文件??????28880??2009-04-09?20:18??多邊形填充掃描線算法\MulFillRect.aps
?????文件???????2301??2009-04-09?20:54??多邊形填充掃描線算法\MulFillRect.clw
?????文件???????4382??2009-05-24?00:22??多邊形填充掃描線算法\MulFillRect.cpp
?????文件???????5034??2009-04-07?22:37??多邊形填充掃描線算法\MulFillRect.dsp
?????文件????????530??2009-04-07?19:21??多邊形填充掃描線算法\MulFillRect.dsw
?????文件???????1411??2009-04-07?19:21??多邊形填充掃描線算法\MulFillRect.h
?????文件?????230400??2009-05-24?00:24??多邊形填充掃描線算法\MulFillRect.ncb
?????文件??????49664??2009-05-24?00:24??多邊形填充掃描線算法\MulFillRect.opt
?????文件???????4044??2009-05-24?00:23??多邊形填充掃描線算法\MulFillRect.plg
?????文件??????10623??2009-04-07?19:21??多邊形填充掃描線算法\MulFillRect.rc
?????文件???????1842??2009-04-07?19:21??多邊形填充掃描線算法\MulFillRectDoc.cpp
?????文件???????1530??2009-04-07?19:21??多邊形填充掃描線算法\MulFillRectDoc.h
?????文件???????7938??2009-05-05?11:03??多邊形填充掃描線算法\MulFillRectView.cpp
?????文件???????2305??2009-05-05?10:36??多邊形填充掃描線算法\MulFillRectView.h
?????文件???????2376??2009-04-09?08:07??多邊形填充掃描線算法\MulPoint.cpp
?????文件???????1024??2009-04-07?21:09??多邊形填充掃描線算法\MulPoint.h
?????文件???????4431??2009-04-07?19:21??多邊形填充掃描線算法\ReadMe.txt
?????文件????????499??2009-04-07?19:21??多邊形填充掃描線算法\Resource.h
?????文件????????213??2009-04-07?19:21??多邊形填充掃描線算法\StdAfx.cpp
?????文件???????1054??2009-04-07?19:21??多邊形填充掃描線算法\StdAfx.h
............此處省略6個文件信息
- 上一篇:c語言編寫的貨郎擔算法
- 下一篇:用C語言實現高效日志
評論
共有 條評論