Turbo-C
C++Builder  |  Delphi  |  FireMonkey  |  C/C++  |  Free Pascal  |  Firebird
볼랜드포럼 BorlandForum
 경고! 게시물 작성자의 사전 허락없는 메일주소 추출행위 절대 금지
터보-C 포럼
Q & A
FAQ
팁&트릭
강좌/문서
자료실
Lua 게시판
볼랜드포럼 홈
헤드라인 뉴스
IT 뉴스
공지사항
자유게시판
해피 브레이크
공동 프로젝트
구인/구직
회원 장터
건의사항
운영진 게시판
회원 메뉴
북마크
볼랜드포럼 광고 모집

C/C++ Q/A
[3075] 아시는 분들은 답변 해주세요..
morion [] 1336 읽음    2003-10-31 01:07
include 시키는 파일중에 device.h과 graphics.h 파일의 용도와 혹시 이 파일을 가지고 계신 분들은
업로드 좀 시켜주세요..
책에 있는 소스를 실행했더니 에러가 엄청 나네요,, 아무래도 헤더파일이 없어서 그런거 같은데..
제가 친 소스입니다.. 분석도 잘 안되고... 답답하네요.. 주사선 다각형 채우기 알고리즘인데......
혹시 아시는 분들은 도와주세요..


#include<device.h>



typedef struct tEdge{
    int yUpperl;
    float xIntersect, dcPerScan;
    struct tEdge *next;
}Edge;


void insertEdge (Edge *list, Edge *ege)
{
    Edge *p, *q=list;


    p=q->next;
    while(p!=NULL){
        if (edge->xIntersect<p->xIntersect)
            p=NULL;
        else {
            q = p;
            p=p->next;
        }
    }


    edge->next=q->next;
    q->next = edge;

}


int yNext(int k, int cnt, dcpt *pts)
{
    int j;

    if((k+1) > (cnt-1))
        j = 0;
    else
        j= k + 1;
    while (pts[k].y == pts[j].y)
    if ((j+1) > (cnt-1))
        j=0;
    else
        j++;
    return (pts[j].y);
}





void makeEdgeRec(dept lower, dcpt upper, int yComp, Edge *edges[])
{
    edge->dxperScan=(float) (upper.x - lower.x) / (upper.y - lower.y);

    edge->xIntersect=lower.x;

    if(upper.y<yComp)
        edge->yUpper=upper.y-1;
    insertEdge(edges [lower.y], edge);
}

void buildEdeList(int cnt, dcpt *pts, Edge *edges[])
{
    Edge *edge;
    dcpt v1,v2;
    int i, yPrev=pts[cnt-2].y;

    v1.x=pts[cnt-1].x;
    v1.y=pts[cnt-1].y;

    for(i=0 i,cnt;i++){
        v2=pts[i];
        if(v1.y != v2.y){
            edge=(Edge*) malloc (sizeof(Edge));
            if(v1.y < v2.y)
                makeEdgeRec(v1, v2, yNext(i,cnt,pts), edge,edges);
            else
                makeEdgeRec(v2, v1, yPrev, edge, edges);
        }

        yPrev=v1.y;
        v1=v2;
    }

}



void buildActiveList(int scan, Edge *active, Edge *edges[])
{
    Edge *p, *q;

    p=edges[scan]->next;
    while(p){
        q=p->next;
        insertEdge(active, p);
        p=q;
    }
}



void fillScan(int scan, Edge *active)
{

    Edge *p1, *p2;
    int i;

    p1=active->next;
    while(p1){
        p2=p1->next;
        for(i=p1->xIntersect; i<p2->xIntersect; i++)
            setPixel ((int) i, scan);
        p1=p2->next;
    }
}



void deleteAfter(Edge *q)
{

    Edge *p=q->next;

    q->next=p->next;
    free(p);
}




void UpdateActiveList(int scan, Edge *active)
{
    Edge *q=active, *p=active->next;

    while(p)
        if(scan >= p->yUpper){
           p=p->next;
           deleteAfter(q);
        }
        else {
            p->xIntersect=p->xIntersect+p->dxPerScan;
        }    q=p;
        p=p->next;
}
   
}


void resortActiveList(Edge *active)
{
    Edge *q, *p=active->next;

    active->next=NULL;
    while(p){
        q=p->next;
        insertEdge(active,p);
        p=q;
    }
}



void scanFill(int cnt, dcpt *pts)
{
    Edge *edges [WINDOW_HEIGHT], *active;
    int i, scan;

    for(i=0; i<WINDOW_HEIGHT; i++){
        edges[i]=(Edge*)malloc(sizeof)Edge));
        edges[i]->next=NULL;
    }


    buildEdgeList(cnt, pts, edges);
    active=(Edge*)malloc(sizeof(edge));
    active->next=NULL;


    for(scan=0; scan<WINDOW_HEIGHT; scan++){
        buildActiveList(scan, active, edges);
        if(active->next){
            fillscan(scan,active);
            updateActiveList(scan,active);
            resortActiveList(active);
        }
    }

}

+ -

관련 글 리스트
3075 아시는 분들은 답변 해주세요.. morion 1336 2003/10/31
Google
Copyright © 1999-2015, borlandforum.com. All right reserved.