#include #include #include #include #include "parseTokens.h" /* THIS FUNCTION FINDS THE MIN/MAX WINDOW FOR A MIM STR OR PGX AND RETURNS THE COORDINATES IN A X/Y ARRAYS, INDEXED FOR NUMBER OF CYCLES, AND NUMBER OF POINTS WITHIN EACH CYCLE. */ void mimft_coord(FILE *inFile, char text_in[], float xa[], float ya[], long int npt[], long int *ncycle, float *minx, float *maxx, float *miny, float *maxy) { char text[255]; long int idpoly2, numToks; short int debug=0; short int i,j,k,n,numpolys; *minx=99999999999.; *miny=99999999999.; *maxx=-99999999999.; *maxy=-99999999999.; if(debug)printf("MIMFT GETS: %s\n",text_in); numToks = parseTokens(text_in); if (strncmp(tokenStrPtrs[0],"*str",4) == 0) { j = atoi(tokenStrPtrs[1]); if(debug)printf("process str with pts: %d\n",j); n=0; npt[0]=j; *ncycle=1; while (j > 0) { fgets(text,255,inFile); if(debug)printf("get line: %d %s\n",j, text); numToks = parseTokens(text); for(i=0;i*maxx)*maxx=xa[n]; if(ya[n]>*maxy)*maxy=ya[n]; n=n+1; } j = j - (numToks/2); } /* foot of j while */ } else if (strncmp(tokenStrPtrs[0],"*pgX",4) == 0) { numpolys = atoi(tokenStrPtrs[1]); k = numpolys; n=0; *ncycle=0; while (k > 0) { if(k == numpolys) { j = atoi(tokenStrPtrs[2]); } else { fgets(text,255,inFile); numToks = parseTokens(text); j = atoi(tokenStrPtrs[1]); } npt[*ncycle]=j; *ncycle=*ncycle+1; while (j > 0) { fgets(text,255,inFile); numToks = parseTokens(text); for(i=0;i*maxx)*maxx=xa[n]; if(ya[n]>*maxy)*maxy=ya[n]; n=n+1; } j = j - (numToks/2); } /* foot of j while */ k -= 1; } /* foot of k while */ } else { printf("bad feature type %s\n",text_in); } if(debug)printf("min/max x: %f %f\n",*minx,*maxx); if(debug)printf("min/max y: %f %f\n",*miny,*maxy); }