/************************************************************************** M I S C . C ***************************************************************************/ /***************************************************************************** FILENAME : misc.c PURPOSE :miscellan stuff *****************************************************************************/ #include #include #include "isthdefs.h" #include "piece.h" extern WINDOW *funcwin; extern int image[512][512]; extern int border_y[512][512]; extern int maxgreyy,maxgrey; extern int inverse_isthmus; extern int file_create; extern int currpiece; extern char strg[79]; /***************************************************************************** TEST *****************************************************************************/ test (y1,x1, y2,x2, y3,x3, y4,x4, minx, miny) int y1,x1, y2,x2, y3,x3, y4,x4, minx, miny; { int x,y; int px[15]; int py[15]; x = x2; y = y1; px[1] = image[y1][x1]; py[1] = border_y[y1][x1]; px[2] = image[y2][x2]; py[2] = border_y[y2][x2]; px[3] = image[y3][x3]; py[3] = border_y[y3][x3]; px[4] = image[y4][x4]; py[4] = border_y[y4][x4]; printf ("x: %d y: %d\n", x, y); printf ("px[1]: %d py[1]: %d\n", px[1], py[1]); printf ("px[2]: %d py[2]: %d\n", px[2], py[2]); printf ("px[3]: %d py[3]: %d\n", px[3], py[3]); printf ("px[4]: %d py[4]: %d\n", px[4], py[4]); accenthoriz (x + minx, y + miny, 255); } /****************************************************************************** This procedure is passed in a string. It prints the string in the function window. *****************************************************************************/ printit(strg) char strg[79]; { wmove(funcwin,17,2); waddstr(funcwin," "); wrefresh(funcwin); wmove(funcwin,17,2); wstandout(funcwin); waddstr(funcwin,strg); wrefresh(funcwin); wstandend(funcwin); } /************************************************************************** This procedure will move the highlited cursor up one row in the command window. If the cursor is already at the top of the command list, calling this procedure will cause the cursor to wrap around to the bottom of the command list. **************************************************************************/ /***************************************************************************** WAITFORKEY *****************************************************************************/ waitforkey() { char c; c = getc(stdin); /*c = wgetch(funcwin); wrefresh(funcwin); */ } /*-------------------------------- localmax ---------------------------------*/ localmax(x,y) int x,y; /* checks all 8 points around the input pixel and determines if there are any neighboring pixels with a greater grey shade. */ { int i, j, grey; grey = VIS$GET_PIXEL(x,y); j = y-1; for (i=x-1; i<=x+1; i++) if (VIS$GET_PIXEL(i,j) > grey) return(0); if (VIS$GET_PIXEL(x-1,y) > grey) return (0); if (VIS$GET_PIXEL(x+1,y) > grey) return (0); j = y+1; for (i=x-1; i<=x+1; i++) if (VIS$GET_PIXEL(i,j) > grey) return(0); return(1); } /***************************************************************************** newmin *****************************************************************************/ newmin (a,b,c) int a,b,c; { if (min (a,b) > c) { return (c); } else { return (min(a,b)); } } /***************************************************************************** min4 *****************************************************************************/ min4 (w,n,nw,ne) int w,n,nw,ne; { if (min (w,n) <= min(nw,ne)) return (min(w,n) + 5); else return (min(ne,nw) + 7); } /***************************************************************************** GET_NEXT_NEIGHBOR *****************************************************************************/ get_next_neighbor (num, i, j, x, y) int num, i, j, *x, *y; { switch (num) { case 1 : *x = i+1; *y = j-1; break; case 2 : *x = i-1; *y = j-1; break; case 3 : *x = i-1; *y = j+1; break; case 4 : *x = i+1; *y = j+1; break; case 5 : *x = i; *y = j-1; break; case 7 : *x = i-1; *y = j; break; case 6 : *x = i; *y = j+1; break; case 8 : *x = i+1; *y = j; break; } } /* end function */ /*************************************************************************/ /* G E T - X Y */ /*************************************************************************/ get_xy (s, x, y, lookx, looky) int s, x, y, *lookx, *looky; { switch (s) { case 0 : *lookx = x + 1; *looky = y; break; case 1 : *lookx = x + 1; *looky = y - 1; break; case 2 : *lookx = x; *looky = y - 1; break; case 3 : *lookx = x - 1; *looky = y - 1; break; case 4 : *lookx = x - 1; *looky = y; break; case 5 : *lookx = x - 1; *looky = y + 1; break; case 6 : *lookx = x; *looky = y + 1; break; case 7 : *lookx = x + 1; *looky = y + 1; break; default : break; } /* end case */ /* printf ("x: %d y %d s>>>>> %d \n", x, y, s); printf ("lookx: %d looky %d\n", *lookx, *looky); */ } /* end function get_xy */ /***************************************************************************** E N D P R O G R A M *****************************************************************************/ #ifdef ROGER /***************************************************************************** TRY_XY *****************************************************************************/ try_xy (minx, miny) int minx, miny; { int i,j; do { printf ("x:\n"); scanf ("%d", &i); printf ("y:\n"); scanf ("%d", &j); getchar(); test (j,i-1,j-1,i, j-1,i-1, j-1,i+1, minx, miny); if (check_euclidean (j,i)) printf ("is ok \n"); else printf ("not theta ok \n"); } while (i != 0); } /* end try */ #endif