计算机图形学 边界定义的8连通区域的种子填充算法源代码


计算机图形学 边界定义的8连通区域的种子填充算法源代码 计算机图形学 边界定义的8连通区域的种子填充算法源代码
资源截图
代码片段和文件信息
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
//#include 
using namespace std;

#define MaxNode 5000
#define MaxScreen 10000
#define INF 0x3f3f3f3f3

int screenh = 600;
int screenw = 800;
int dirx[] = { 1 1 0 -1 -1 -1 0 1 };
int diry[] = { 0 -1 -1 -1 0 1 1 1 };
bool hash[MaxScreen][MaxScreen];
int CountPoint;//  记录多边形点的个数
int mouse_type; //其实程序中没有用到 
bool flagPoly; // 标记多变形是不是画好



typedef struct TPoint {
double x;
double y;
} TPoiont;

typedef struct TSegment {
TPoint p1;
TPoint p2;
} TSegment;

typedef struct TPolygon {
TPoint point[MaxNode];
int n;
} TPolygon;


struct Node {
int x;
int y;
};
TPoint pfirst pinside;
TPolygon polygon;
queue Q Qtemp;
stack Stack;

void display();
#include  “Polygon.h“
#include “BresenhamLine.h“
#include “BFS.h“
#include “draw.h“
#include “drawCN.h“

void init() {
glClearColor(1.0 1.0 1.0 0.0);
glMatrixMode( GL_PROJECTION);
gluOrtho2D(0.0 screenw 0.0 screenh);
memset(hash false sizeof(hash));
CountPoint = 0;
flagPoly = false;
/*
printf(“ 操作指南
“);
printf(“ 1 先单击左键画多边形
“);
printf(“ 2 然后单击鼠标的中间键画多变形结束
“);
printf(“ 3 在多边形内右击鼠标选择一点
“);
*/

}



void display() {
glClear( GL_COLOR_BUFFER_BIT);


 selectFont(24 GB2312_CHARSET “楷体_GB2312“);
     glColor3f(1.0f 0.0f 0.0f);
 glRasterPos2f(0.0f double(screenh));
 drawCNString(“操作指南
“);
  glRasterPos2f(0.0f double(screenh - 24));
 drawCNString(“先单击左键画多边形“);
  glRasterPos2f(0.0f double(screenh - 48));
 drawCNString(“然后单击鼠标的中间键画多变形结束“);
  glRasterPos2f(0.0f double(screenh - 72));
 drawCNString(“在多边形内右击鼠标选择一点
“);
 if(CountPoint == 2  && flagPoly){
glRasterPos2f(0.0f double(screenh - 96));
drawCNString(“你输入的点不能组成多变形“);
flagPoly = false;
 }

glColor3f(0 0 0);
draw();

glutSwapBuffers();
}
void Reshape(int w int h) {
glViewport(0 0 w h);
glMatrixMode( GL_PROJECTION);
glLoadIdentity();

if(h == 0){
h = 1;
}
//cout << “Reshape:“ << w << h << endl;
screenh = h;
screenw = w;

gluOrtho2D(0.0 (GLfloat) w 0.0 (GLfloat) h);
glMatrixMode( GL_MODELVIEW);
glLoadIdentity();
glClear ( GL_COLOR_BUFFER_BIT);
}

void keyboard(unsigned char key int x int y) {
switch (key) {
case 27:
exit(0);
break;
case ‘a‘:
case ‘A‘:
break;
default:
if (key <= ‘z‘ && key >= ‘a‘ || key <= ‘Z‘ && key >= ‘A‘ || key <= ‘9‘
&& key >= ‘0‘) {
cout << char(key);
} else {
cout << “
字符码为 “ << static_cast (key);
display();
}
}
}

void mouseclick(int button int state int x int y) {
cout << “鼠标按下的坐标是x = “ << x << “ y = “ << y << endl;
switch (button) {
case GLUT_LEFT_BUTTON:
if (state == GLUT_DOWN) {
if(flagPol

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件        617  2011-04-08 11:39  homeBFS.h

     文件       1649  2011-04-25 17:59  homeBresenhamLine.h

     文件    2368512  2011-04-08 11:28  homeDebughome.bsc

     文件     606247  2011-04-08 11:28  homeDebughome.exe

     文件     937692  2011-04-08 11:28  homeDebughome.ilk

     文件    8138492  2011-04-08 11:12  homeDebughome.pch

     文件    1123328  2011-04-08 11:28  homeDebughome.pdb

     文件    2368512  2011-04-25 19:20  homeDebugMain.bsc

     文件     630848  2011-04-25 19:20  homeDebugMain.exe

     文件     948852  2011-04-25 19:20  homeDebugMain.ilk

     文件     233043  2011-04-25 19:20  homeDebugMain.obj

     文件    8142588  2011-04-25 19:18  homeDebugMain.pch

     文件    1139712  2011-04-25 19:20  homeDebugMain.pdb

     文件          0  2011-04-25 19:20  homeDebugMain.sbr

     文件     345088  2011-04-25 19:20  homeDebugvc60.idb

     文件     159744  2011-04-25 19:20  homeDebugvc60.pdb

     文件       1001  2011-04-25 19:06  homedraw.h

     文件       1186  2011-04-25 17:44  homedrawCN.h

     文件       4511  2011-04-08 11:39  homehome.dsp

     文件        531  2011-04-08 10:04  homehome.dsw

     文件      41984  2011-04-08 11:39  homehome.ncb

     文件      49664  2011-04-08 11:39  homehome.opt

     文件       1012  2011-04-08 11:28  homehome.plg

     文件       5887  2011-04-25 19:20  homeMain.cpp

     文件       3381  2011-04-25 19:20  homeMain.dsp

     文件        531  2011-04-25 19:20  homeMain.dsw

     文件      50176  2011-04-25 19:20  homeMain.ncb

     文件      49664  2011-04-25 19:20  homeMain.opt

     文件        878  2011-04-25 19:20  homeMain.plg

     文件       2576  2011-04-08 10:36  homePolygon.h

............此处省略5个文件信息

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件举报,一经查实,本站将立刻删除。

发表评论

评论列表(条)