/* Name: rdpnp.c - b-spline net point input Author: David F. Rogers (Linda A. Adlum) Date: 10 August 1987 ( C Version 19 May 89) System: Silicon Graphics Iris Language: C Purpose: To input a B-Spline net. Method: Read from file input. Subroutines called: none Variable list: hdstr = alphanumeric string for file header c1 = order of b-spline surface in u direction c2 = order of b-spline surface in w direction n1 = number polygon net lines in u direction n2 = number polygon net lines in w direction netpts = n1n2 b = array containing the b-spline net b(i) = x-componet b(i+1) = y-componet b(i+2) = z-componet for fixed u - w varies, thus the first 3*n1 values are for the first value of u etc. */ #include rdpnp(header,hdrlen,c1,c2,n1,n2,b) char *header; int *hdrlen,*c1,*c2,*n1,*n2; float b[]; { FILE *pnpfile; char pnpname[80]; int i; int netpts; /* Get the name of the pnp file to use and open it */ fprintf(stderr,"Enter data file name in the form *.pnp "); scanf("%s",pnpname); if((pnpfile = fopen(pnpname,"r")) == NULL) { fprintf(stderr,"\tThe file: %s\n",pnpname); fprintf(stderr,"\tDoes not exist in the current directory.\n"); fprintf(stderr,"\tThe current directory is: "); system("pwd"); exit(-1); } fprintf(stderr,"Reading from file %s\n", pnpname); /* Read header string from file */ if(NULL == fgets(header, hdrlen, pnpfile)) { fprintf(stderr,"No header string in preliminary net point file\n"); fprintf(stderr,"or file is empty.\n"); exit(-1); } /* Output header string */ fprintf(stderr,"%s",header); /* Read order c1,c2 and number of net points n1,n2 */ if (NULL == fscanf(pnpfile," %d, %d \n", c1, c2) ) { fprintf(stderr,"Missing net order; exit\n"); return; } if (NULL == fscanf(pnpfile," %d, %d \n", n1, n2) ) { fprintf(stderr,"Missing net order; exit\n"); return; } /* Output order and net points */ fprintf(stderr,"Order %dx%d Net points %dx%d\n",*c1,*c2,*n1,*n2); fprintf(stderr,"Read net points\n"); /* read the net points */ netpts = (*n1) * (*n2); for (i=1; i <= (3 * netpts); i+=3) { if (NULL == fscanf(pnpfile," %f, %f, %f \n", &b[i],&b[i+1],&b[i+2]) ) { fprintf(stderr,"Missing point data\n"); return; } fprintf(stderr," %f, %f, %f\n", b[i],b[i+1],b[i+2]); } fprintf(stderr,"Net points read - return to main\n"); }