當前位置:編程學習大全網 - 編程語言 - 求壹計算機圖形學VB編程代碼,用Weiler-Atherton算法,隨便壹個例子就可以

求壹計算機圖形學VB編程代碼,用Weiler-Atherton算法,隨便壹個例子就可以

const int MAXVERT = 500;

const int MAXPOLYV = 50;

const int MAXH = 10;

struct Point2D

{float x,y;

};

typedef Point2D Vertices[MAXVERT];

enum VerType = {Polygon, Intersection};

typedef struct ClipListRec * ClipPtr;

struct ClipListRec

{ int Vindex;

ClipPtr next;

VerType Kind;

float t;

ClipPtr otherList;

}

struct Polygon

{ int nVertex;

int vert[MAXPOLYV];

ClipPtr list;

}

struct GenPolygon

{ Polygon exterior;

int numHoles;

Polygon Holes[MAXH];

}

GenPolygon Sub,Clip;

int entering[MAXVERT],exiting[MAXVERT];

Vertices V;

int numVertex = 0; // size of the array of verticies

int clipPoly[MAXVERT]; // a clip polygon

int readPoint();

{ cin >> inX; cin >> inY;

if (numVertex < MAXVERT)

{ V[numVertex].x = inX;

V[numVertex].y = inY;

idNo = numVertex;

numVertex++;

}

else

idNo = -1;

return idNo;

}

void readPolygon (GenPolygon p)

{ cin >> p.exterior.nVertex;

for (i = 0; i < p.exterior.nVertex; i++)

{ newId = readPoint();

if (newId < 0)

error

else

{ insertAtRear (p.exterior.list,newId);

p.exterior.vert[i] = newId;

}

}

// now do the holes basically the same way

. . .

}

// the "main" program loop would then be (pseudocode)

while (!EMPTY(entering))

{ nextInter = delete (entering);

SEARCH (SubjectPolygon,nextInter,ptr1);

AddToOutputList (ptr1->. . .)

StartPoint = ptr1->. . .

ptr1 = prt1->next;

while (ptr1->. . . != StartPoint)

{ AddToOutputList (ptr1->. . .);

if (ptr1-> . . == INTERSECTION)

ptr1 = prt1->otherList->next;

else

ptr1 = ptr1->next;

}

FixListForOutput();

DrawPolygon();

EmptyOutputList();

}

  • 上一篇:多核cpuload多核cpulinux
  • 下一篇:浙江數控銑床加工廠家哪個生產實力比較強?
  • copyright 2024編程學習大全網