Вы находитесь на странице: 1из 12

World's most popular travel blog for travel bloggers.

Ce site utilise des cookies provenant de Google pour fournir ses services et analyser le trafic. Votre adresse IP
et votre user-agent, ainsi que des statistiques relatives aux performances et à la sécurité, sont transmis à
Google afin d'assurer un service de qualité, de générer des statistiques d'utilisation, et de détecter et de
résoudre les problèmes d'abus.
MCA IGNOU EN SAVOIR PLUS OK
GROUP

Write a program in C/C++ to implement Scan-Line Polygon Filling Algorithm.

typedef struct tEdge


{
int yUpper;
float xIntersect, dxPerScan;
struct tEdge * next;
} Edge;
typedef struct tdcPt
{
int x;
int y;
} dcPt;
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);
}
}
/* Free edge records that have been malloc’ed ... */
}
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);
}
}
/* Free edge records that have been malloc’ed ... */
}
void buildEdgeList (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)
{
/* nonhorizontal line */
edge = (Edge *) malloc (sizeof (Edge));
if (v1.y < v2.y) /* up-going edge */
makeEdgeRec (v1, v2, yNext (i, cnt, pts), edge, edges);
else /* down-going edge */
makeEdgeRec (v2, v1, yPrev, edge, edges);
}
yPrev = v1.y;
v1 = v2;
}
}
/* For an index, return y-coordinate of next nonhorizontal line */
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 buildEdgeList (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)
{
/* nonhorizontal line */
edge = (Edge *) malloc (sizeof (Edge));
if (v1.y < v2.y) /* up-going edge */
makeEdgeRec (v1, v2, yNext (i, cnt, pts), edge, edges);
else /* down-going edge */
makeEdgeRec (v2, v1, yPrev, edge, edges);
}
}
}
/* Store lower-y coordinate and inverse slope for each edge. Adjust
and store upper-y coordinate for edges that are the lower member
of a monotically increasing or decreasing pair of edges */
void makeEdgeRec
(dcPt lower, dcPt upper, int yComp, Edge * edge, 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;
else
edge->yUpper = upper.y;
insertEdge (edges[lower.y], edge);
}
/* Inserts edge into list in order of increasing xIntersect field. */
void insertEdge (Edge * list, Edge * edge)
{
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;
}
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);
}
}
/* Free edge records that have been malloc’ed ... */
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 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);
}
}
/* Free edge records that have been malloc’ed ... */
}
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 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);
}
}
/* Free edge records that have been malloc’ed ... */
}
/* Delete completed edges. Update ’xIntersect’ field for others */
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 deleteAfter (Edge * q)
{
Edge * p = q->next;
q->next = p->next;
free (p);
}
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);
}
}
/* Free edge records that have been malloc’ed ... */
}
void resortActiveList (Edge * active)
{
Edge * q, * p = active->next;
active->next = NULL;
while (p)
{
q = p->next;
insertEdge (active, p);
p = q;
}
}

— Share It —
R E L A T E D P O S T S

L i s t a n d e x p a i n t h e c h a r a c t e r i s t i c s o f M O d e r n

M C A 5 t h S e m e s t e r A s s i g n m e n t 2 0 1 6 - 2 0 1 7

M C S L 0 5 4 s o l u t i o n 3

M C S L - 0 5 4 J a v a l a b s s o l u t i o n 1

C r e a t e a n X M L d o c u m e n t f o r M e d i c i n e s i n a m e d

D e v e l o p a c wo en bd u p c a t gi en g f oa r n p or o
n g
l ir na em m
t ei n
s tg . f o r j s p

« Newer Post Older Post »

0 Comments:

Post A Comment

Let us know your responses and feedback

Enter your comment...

Comment as: Google Account

Publish Preview

Links To This Post

Create a Link
S E A R C H B Y C O U R S E
C O D E

Search

S P O N S O R E D
L I N K S

Employment Screening

Best Employment Screening

B L O G
A R C H I V E

► 2019 (10)

► 2018 (230)

▼ 2017 (6763)
► December (35)

► November (4)

► October (9)

► September (58)

▼ August (244)
With the aid of a diagram, describe what happens d...

Draw an E-R diagram and its related normalized tab...

Draw Data Flow Diagrams(level 0, level 1)

Develop SRS

For the Internet Banking problem discussed in a se...

Draw a state transition diagram

Draw a simple object model

De ne all classes and a class diagram of Internet...

Draw use case diagram

Internet banking is an electronic payment system t...

Write short notes on the following:

Brie y Comment on the following:

Distinguish between the following:

The board of directors recommends dividend on pref...

Income Tax is to be provided for @35%

Value of inventory on 31.03.2006 is Rs. 1,35,000

Doubtful debts are to be provided for Rs. 3,000


Bills receivable Rs. 25,000 were dishonoured. E e...

Interest on term loan is due for six month

20% of preliminary expenses are to be written o ....

Depreciation is to be provided for @ 10% on premis...

Issued share capital of the company is as under

Authorised share capital of the company is as unde...

List out and explain the important methods of inve...

What are the objectives and functions of nancial...

Develop SRS using IEEE format.

Estimate e ort.

Estimate cost.

List the functional and non-functional requirement...

Which SDLC paradigm will be selected. Justify your...

Assume that you are assigned responsibility of dev...

[MCS-033 Solved Assignments] Explain the Partition...

Explain the Combinatorial Identities

Exponential Generating Function

[MCS-033 Solved Assignments] Determine the number ...

[MCS-033 Solved Assignments] Whether Ore’s theorem...

[MCS-033 Solved Assignments] Whether Dirac’s theor...

What are the practical application of Hamilton pat...

The population of tigers increases 4 percent per y...

Write whether or not each recurrence relation in t...

Write generic formulae for a linear homogenous rec...

Write short note on followings (minimum in 300 wor...

Draw a DFD for Online Admission System of an Unive...

Explain relation of functional model with object ...

What is dynamic modeling? Explain its advantages.

What is inheritance ? Explain its advantages.

Draw a sequence diagram for Online Movie Ticket Bo...

Explain advantage of use case diagram? Draw use ca...

What is class diagram ? Draw class diagram for Onl...

What is OOAD? Explain concepts of generalization a...

Independent set problem

K-colourability problem

Post correspondence problem

Rice theorem

Halting problem

Construct a Turing Machine (TM) that copies a give...

If L 1and L 2, are context free languages then, pr...

Explain the Chomsky's Classi cation of grammars. ...

Write the nite automata corresponding to the reg...

Write a context free grammar to generate palindrom...

Write Prim’s Algorithm. How Prim’s algorithm di e...

Write pseudo code for DFS and calculate its time c...
De ne Knapsack Problem and cite one instance of t...

Explain the essential idea of Dynamic Programming....

Explain the meaning of Big O notation with suitabl...

Di erentiate Between (i) Greedy technique and D...

Explain how dynamic programming reduces the comple...

Write Quick Sort Algorithm. How is it Di erent fr...

Give a divide and conquer based algorithm (Write a...

Write Insertion sort algorithm. Determine its comp...

Write a program in Java that connects to a databas...

Write a program in Java for the multiplication of ...

Create a database consisting of Name of Regional C...

Your PC is on a network. Make necessary settings i...

Write a shell script in Linux/Unix that accepts a ...

Write a program in C language that will accept a G...

Write a program in C language for multiplication o...

What is servlet ? Explain GET and POST methods of ...

Explain sending UDP Datagrams with the help of an ...

What is proxy server? Explain URL class and its me...

Explain StringBu er class and its various methods...

Explain di erent stream classes in java.

What is object serialization? Explain working of o...

Create an Applet which take name and address of a ...

What is multithreading? Explain various applicatio...

Explain the situations in which constructors are o...

What is an exception? Explain various causes of ex...

What is interface? How it is di erent from abstra...

Explain concept of polymorphism with the help of e...

Explain the need of package in Java. Explain acces...

What is inheritance? How it provides exibility i...

Write a java program to create Date class with pro...

Write a java program to demonstrate handling of mu...

Explain with an example, how array of objects are ...

Write a java program to create an Account class an...

What are di erent data types in java? Explain bri...

Explain why java is platform independent.

What is information hiding? Explain its advantages...

What is Object Oriented Programming? Explain conce...

(a) Discuss the advantages and disadvantages of h...

► July (1)

► June (75)

► May (247)

► April (1170)

► March (1129)

► February (1870)

► January (1921)
► 2016 (273)

► 2015 (103)

► 2013 (4)

► 2012 (1)

P O P U L A R
P O S T S

What are the advantages and disadvantages of using DDA algorithm for line generation? List the steps of the algorithm. Use this algorithm
to draw a line with endpoints (2, 3) and (9, 8). Compare DDA algorithm and Bresenham Line generation Algorithm? Show step by step
execution of Bresenham Line Generation algorithm for drawing a line having endpoints (2, 3) and (9, 8).

Draw the DFDs upto 3rd level for Study Center Management System for an Open University.

SRS of Railway Reservation System

Write an algorithm, draw a ow chart and write its corresponding C program to convert a decimal number to its
equivalent hexadecimal number.

Develop SRS for Study Center Management System for an Open University.SRS should be as per IEEE standard SRS template. Make
necessary assumptions.

Cab Management System SRS

Draw ERD for Study Center Management System for an Open University. Make necessary assumptions.

Draw a sequence diagram for payment using Mobile Wallet for shopping in a retail store.

Develop SRS for Online Admission System for a University. MCS-014 Assignment 1

Draw a DFD upto 2nd level for Online Examination System of an University. Make necessary assumptions required.
L A B E L
C L O U D

#JAVA (4) 2012 (2) 2016-17 (2) 2017-18 (8) 2018-2019 (1) ADDER (1) ADVANCE JAVA (6) ASSIGNMENTS (109) B.ED RESULT (1) BASIC JAVA (46) BED RESUTL (1)

C (1) C# (1) DATA AND FILE STRUCTURES (4) DATA TYPES (1) DNS (1) EMU8086 (2) EXAM DATE SHEET (1) EXAMS (10) FIREWALL (1) IGNOU (1)

IGNOU MCA 1ST SEMESTER MCS012 (1) IGNOU MCA 5TH SEM (1) IGNOU MCA FIFTH SEMESTER ASSIGNMENT FREE DOWNLOAD (3)

IGNOU MCS-014 SOLVED ASSIGNMENT (1) IGNOU MCS-051 SOLVED ASSIGNMENT (3) IGNOU MCS-052 SOLVED ASSIGNMENT (9) IGNOU MCS-053 SOLVED ASSIGNMENT (7)

IGNOU MCSE-11 SOLVED ASSIGNMENT (2) IGNOU RESULTS (1) INTRODUCTION TO DATABASE MANAGEMENT SYSTEMS (1) JAVA (24) JAVA PROGRAMMING (5)

JAVA-PROGRAMMING (1) LAB MANUALS (3) LAB SCHEDULE (4) LEARN JAVA (12) LINUX OS (2) MCA (1) MCS-011 (9) MCS-012 (23) MCS-013 (23) MCS-014 (5)

MCS-015 (6) MCS-021 (7) MCS-022 (18) MCS-023 (12) MCS-024 (24) MCS-031 (20) MCS-032 (26) MCS-033 (10) MCS-034 (6) MCS-035 (23) MCS-041 (7)

MCS-041 SOLVED ASSIGNMENT (4) MCS-042 (13) MCS-043 (16) MCS-044 (11) MCS-052 (2) MCS-34 (4) MCS011 (16) MCS012 (11) MCS012 PARITY BIT (1) MCS013 (17)

MCS014 (19) MCS015 (15) MCS016 (11) MCS021 (18) MCS022 (8) MCS023 (2) MCS024 (4) MCS031 (28) MCS032 (19) MCS033 (5) MCS034 (21) MCS035 (8)

MCS041 (10) MCS042 (1) MCS043 (6) MCS044 (10) MCS045 (1) MCS051 (18) MCS052 (13) MCS053 (11) MCSE-003 (11) MCSE-004 (11) MCSE-011 (11) MCSE003 (1)

MCSL-016 (2) MCSL-025 (7) MCSL-036 (11) MCSL-045 (4) MCSL-054 (10) MCSL017 (11) MCSL054 (2) MCSP-044 (1) MINI PROJECT (23) NETWORK (1)

NETWORKING (3) OPENMAT RESULTS (1) OS (2) PROBLEM SOLVING AND PROGRAMMING (1) PROJECT ANALYSIS (2) REMOTE ACCESS (1) SECURITY (2) SESSION (4)

SHELL SCRIPT (1) SOLUTION (1) SOLVED (115) SOLVED ASSIGNMENTS (32) SOLVED QUESTION PAPER (35) SORT NOTES (1) SRS (5) TEE (17) UML (3) UNIX (1)

UPPER CASEM LINUX (1) VIVA (2) WINDOWSOS (2) ZONES (1)

Powered by Blogger.

A D S B Y G O O G L E

A D
B L O C K E R

Copyright © 2018 • MCA IGNOU GROUP | Crafted by VeeThemes.com

Вам также может понравиться