World's most popular travel blog for travel bloggers.
Showing posts with label MCSL-054. Show all posts
Showing posts with label MCSL-054. Show all posts

Xml for a medical store

Create a servlet to print schedule of mcsl-054

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;
}
}

#include <Windows.h>
#include <GL/glu.h>
#include <GL/glut.h>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

float X1=200, Y1=2, X2=200, Y2=200;

float round_value(float v)
{
return v;// floor(v + 0.5);
}
void LineDDA(void)
{
float dx = (X2 - X1);
float dy = (Y2 - Y1);
float steps;
float xInc, yInc, x = X1, y = Y1;

steps = ((dx)>(dy)) ? ((dx)) : ((dy));
xInc = dx / (float)steps;
yInc = dy / (float)steps;

/* Clears buffers to preset values */
glClear(GL_COLOR_BUFFER_BIT);

/* Plot the points */
glBegin(GL_POINTS);
/* Plot the first point */
glVertex2d(x, y);
int k;
/* For every step, find an intermediate vertex */
for (k = 0; k<steps; k++)
{
x += xInc;
y += yInc;
/* printf("%0.6lf %0.6lf\n",floor(x), floor(y)); */
glVertex2d(round_value(x), round_value(y));
}
glEnd();

glFlush();
}
void Init()
{
/* Set clear color to white */
glClearColor(0.0, 0.0, 0.0, 0);
/* Set fill color to black */
glColor3f(1.0, 1.0, 0.0);
/* glViewport(0 , 0 , 640 , 480); */
/* glMatrixMode(GL_PROJECTION); */
/* glLoadIdentity(); */
gluOrtho2D(0, 640, 0, 480);
}
void main(int argc, char **argv)
{


glutInit(&argc, argv);
/* Set the initial display mode */
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
/* Set the initial window position and size */
glutInitWindowPosition(0, 0);
glutInitWindowSize(640, 480);
/* Create the window with title "DDA_Line" */
glutCreateWindow("DDA_Line");
/* Initialize drawing colors */
Init();
/* Call the displaying function */
glutDisplayFunc(LineDDA);
/* Keep displaying untill the program is closed */
glutMainLoop();
}


Try this code, run before writing.. Thanks

#include <windows.h> // for MS Windows #include <GL/glut.h> // GLUT, include glu.h and gl.h #include <math.h> // Global variable GLfloat angle = 0.0f; // Current rotational angle of the shapes /* Initialize OpenGL Graphics */ void initGL() { // Set "clearing" or background color glClearColor(0.0f, 0.0f, 0.0f, 1.0f); // Black and opaque } /* Called back when there is no other event to be handled */ void idle() { glutPostRedisplay(); // Post a re-paint request to activate display() } /* Handler for window-repaint event. Call back when the window first appears and whenever the window needs to be re-painted. */ void display() { glClear(GL_COLOR_BUFFER_BIT); // Clear the color buffer glMatrixMode(GL_MODELVIEW); // To operate on Model-View matrix glLoadIdentity(); // Reset the model-view matrix float radius = 0.80; glColor3ub(255, 0, 0); double twicePi = 2.0 * 3.142; int i, x, y; radius = radius + angle; x = 0, y = 0; glPushMatrix(); // Save model-view matrix setting glBegin(GL_TRIANGLE_FAN); //BEGIN CIRCLE glVertex2f(x, y); // center of circle for (i = 0; i <= 200; i++) { glVertex2f( (x - (radius * cos(i * twicePi / 200))), (y - (radius * sin(i * twicePi / 200))) ); } glEnd(); glPopMatrix(); // Restore the model-view matrix glutSwapBuffers(); // Double buffered - swap the front and back buffers angle -= 0.0001f; } /* Handler for window re-size event. Called back when the window first appears and whenever the window is re-sized with its new width and height */ void reshape(GLsizei width, GLsizei height) { // GLsizei for non-negative integer // Compute aspect ratio of the new window if (height == 0) height = 1; // To prevent divide by 0 GLfloat aspect = (GLfloat)width / (GLfloat)height; // Set the viewport to cover the new window glViewport(0, 0, width, height); // Set the aspect ratio of the clipping area to match the viewport glMatrixMode(GL_PROJECTION); // To operate on the Projection matrix glLoadIdentity(); if (width >= height) { // aspect >= 1, set the height from -1 to 1, with larger width gluOrtho2D(-1.0 * aspect, 1.0 * aspect, -1.0, 1.0); } else { // aspect < 1, set the width to -1 to 1, with larger height gluOrtho2D(-1.0, 1.0, -1.0 / aspect, 1.0 / aspect); } } /* Main function: GLUT runs as a console application starting at main() */ int main(int argc, char** argv) { glutInit(&argc, argv); // Initialize GLUT glutInitDisplayMode(GLUT_DOUBLE); // Enable double buffered mode glutInitWindowSize(840, 680); // Set the window's initial width & height - non-square glutInitWindowPosition(50, 50); // Position the window's initial top-left corner glutCreateWindow("Animation via Idle Function"); // Create window with the given title glutDisplayFunc(display); // Register callback handler for window re-paint event glutReshapeFunc(reshape); // Register callback handler for window re-size event glutIdleFunc(idle); // Register callback handler if no other event initGL(); // Our own OpenGL initialization glutMainLoop(); // Enter the infinite event-processing loop return 0; }