/* Test program for C code from An Introduction to NURBS by David F. Rogers. Copyright (C) 2000 David F. Rogers, All rights reserved. Name: tbsurfu.c Purpose: Test program for periodic B-spline surface generator Language: C Subroutines called: bspsurfu.c Book reference: Chapter 6, Section 6.5, Alg. p. 304 */ main(){ int i; int npts,mpts; int k,l; int p1,p2; float b[61]; float q[301]; /* Data for the standard test control net. Comment out to use file input. */ npts = 4; mpts = 4; k = 4; l = 3; p1 = 5; p2 = 5; /* printf("k,l,npts,mpts,p1,p2 = %d %d %d %d %d %d \n",k,l,npts,mpts,p1,p2); */ for (i = 1; i <= 3*npts; i++){ b[i] = 0.; } for (i = 1; i <= 3*p1*p2; i++){ q[i] = 0.; } /* This is a standard test control polygon from Ex. 6.1, p. 184 Comment out to use file input .pnp */ b[1] = -15.; b[2] = 0.; b[3] = 15.; b[4] = -15.; b[5] = 5.; b[6] = 5.; b[7] = -15.; b[8] = 5.; b[9] = -5.; b[10] = -15.; b[11] = 0.; b[12] = -15.; b[13] = -5.; b[14] = 5.; b[15] = 15.; b[16] = -5.; b[17] = 10.; b[18] = 5.; b[19] = -5.; b[20] = 10.; b[21] = -5.; b[22] = -5.; b[23] = 5.; b[24] = -15.; b[25] = 5.; b[26] = 5.; b[27] = 15.; b[28] = 5.; b[29] = 10.; b[30] = 5.; b[31] = 5.; b[32] = 10.; b[33] = -5.; b[34] = 5.; b[35] = 0.; b[36] = -15.; b[37] = 15.; b[38] = 0.; b[39] = 15.; b[40] = 15.; b[41] = 5.; b[42] = 5.; b[43] = 15.; b[44] = 5.; b[45] = -5.; b[46] = 15.; b[47] = 0.; b[48] = -15.; /* Uncomment the file input statement below and comment out the standard control net data above to use file input. */ /* get polygon netpoint file */ /* rdpnp(header,&hdrlen,&k,&l,&npts,&mpts,b); */ bspsurfu(b,k,l,npts,mpts,p1,p2,q); /* Use the next two lines for getting performance timings and comment out the line above. */ /* for (i=1; i <=1000; i++){ bsplsurfu(b,k,l,npts,mpts,p1,p2,q); } */ printf("\nPolygon points\n\n"); for (i = 1; i <= 3*npts*mpts; i=i+3){ printf(" %f %f %f \n",b[i],b[i+1],b[i+2]); } printf("\nSurface points\n\n"); for (i = 1; i <= 3*p1*p2; i=i+3){ printf(" %f %f %f \n",q[i],q[i+1],q[i+2]); } }