/* Octshell is a procedure that builds a SIF triangle mesh over a half-slice --typically one octant-- of a spherical surface. It starts at the North Pole and creates detail+1 ribs top down which linearly increase in size from 1 to detail+1 vertices. Parameters are: Radius; starting and ending longitudes; as well as detail of the generated mesh */ #include #define HLFPI 1.570796327 int i, j, d, VN, VX, VY, VZ; float R, u, us, ue, v, vs; extern double sin(); extern double cos(); void main() { d = 4; /* detail */ us = 0.0; /* start angle */ ue = HLFPI; /* end angle */ vs = HLFPI; /* top angle */ R = 10000.0; /* sphere radius */ /* print out SIF header stuff */ printf( "(SIF_SFF 0 5\n (body\n (lump\n (shell\n"); /* print out north pole separately to avoid /0 */ VN = 0; VX = 0; VY = 0; VZ = R/1; printf( "(v %d %d %d %d)\n", VN, VX, VY, VZ); /* do all the other vertices */ for (j=1; j<=d; j++) { v = vs - (float)(j)*vs/(float)(d); for (i=0; i<=j; i++) { u = (float)(i)*(ue-us)/(float)(j) + us; VN = j*(j+1)/2 +i; VX = (R*cos(u)*cos(v)+0.5)/1; VY = (R*sin(u)*cos(v)+0.5)/1; VZ = (R*sin(v)+0.5)/1; printf( "(v %d %d %d %d)\n", VN, VX, VY, VZ); } } /* print out the triangle mesh command */ printf( "(tm \n"); /* keyword */ for (j=0; j<=d; j++) { printf( " (r "); /* start a row */ for (i=0; i<=j; i++) printf( " %d", j*(j+1)/2 +i ); printf( ")\n"); /* close off row */ } printf( ")\n"); /* close off mesh command */ printf( " )\n )\n )\n)\n"); /* close off SIF file */ } /*end main*/ ============================================================== ...and the result it produces: (SIF_SFF 0 5 (body (lump (shell (v 0 0 0 10000) (v 1 3827 0 9239) (v 2 0 3827 9239) (v 3 7071 0 7071) (v 4 5000 5000 7071) (v 5 0 7071 7071) (v 6 9239 0 3827) (v 7 8001 4619 3827) (v 8 4619 8001 3827) (v 9 0 9239 3827) (v 10 10000 0 0) (v 11 9239 3827 0) (v 12 7071 7071 0) (v 13 3827 9239 0) (v 14 0 10000 0) (tm (r 0) (r 1 2) (r 3 4 5) (r 6 7 8 9) (r 10 11 12 13 14) ) ) ) ) ) ==============================================================