|
From: <kin...@us...> - 2004-02-09 07:08:46
|
Update of /cvsroot/teem/teem/src/limn/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28513/test Modified Files: soid.c Log Message: now outputs an OFF file, instead of doing the rendering itself Index: soid.c =================================================================== RCS file: /cvsroot/teem/teem/src/limn/test/soid.c,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** soid.c 7 Jan 2004 15:34:30 -0000 1.5 --- soid.c 9 Feb 2004 07:05:33 -0000 1.6 *************** *** 21,25 **** #include "../limn.h" ! char *info = ("Render a single ellipsoid in postscript."); void --- 21,25 ---- #include "../limn.h" ! char *info = ("Save a single ellipsoid or superquadric into an OFF file."); void *************** *** 53,57 **** main(int argc, char *argv[]) { char *me, *err, *outS; - limnCamera *cam; float p[3], q[4], mR[9], eval[3], len, sh, cl, cp, qA, qB; float matA[16], matB[16], os, sc[3], rad, edgeWidth[5]; --- 53,56 ---- *************** *** 61,92 **** limnSP *sp; limnPart *r; - limnWin *win; int ri, si, res, axis, sphere; ! Nrrd *nmap; mop = airMopNew(); - cam = limnCameraNew(); - airMopAdd(mop, cam, (airMopper)limnCameraNix, airMopAlways); edgeWidth[0] = 0; edgeWidth[1] = 0; me = argv[0]; - hestOptAdd(&hopt, "fr", "from point", airTypeDouble, 3, 3, cam->from,"4 4 4", - "position of camera, used to determine view vector"); - hestOptAdd(&hopt, "at", "at point", airTypeDouble, 3, 3, cam->at, "0 0 0", - "camera look-at point, used to determine view vector"); - hestOptAdd(&hopt, "up", "up vector", airTypeDouble, 3, 3, cam->up, "0 0 1", - "camera pseudo-up vector, used to determine view coordinates"); - hestOptAdd(&hopt, "rh", NULL, airTypeInt, 0, 0, &(cam->rightHanded), NULL, - "use a right-handed UVN frame (V points down)"); - hestOptAdd(&hopt, "or", NULL, airTypeInt, 0, 0, &(cam->orthographic), NULL, - "use orthogonal projection"); - hestOptAdd(&hopt, "ur", "uMin uMax", airTypeDouble, 2, 2, cam->uRange, - "-1 1", "range in U direction of image plane"); - hestOptAdd(&hopt, "vr", "vMin vMax", airTypeDouble, 2, 2, cam->vRange, - "-1 1", "range in V direction of image plane"); - hestOptAdd(&hopt, "e", "envmap", airTypeOther, 1, 1, &nmap, NULL, - "16checker-based environment map", - NULL, NULL, nrrdHestNrrd); hestOptAdd(&hopt, "sc", "scalings", airTypeFloat, 3, 3, sc, "1 1 1", "axis-aligned scaling to do on ellipsoid"); --- 60,71 ---- limnSP *sp; limnPart *r; int ri, si, res, axis, sphere; ! FILE *file; mop = airMopNew(); edgeWidth[0] = 0; edgeWidth[1] = 0; me = argv[0]; hestOptAdd(&hopt, "sc", "scalings", airTypeFloat, 3, 3, sc, "1 1 1", "axis-aligned scaling to do on ellipsoid"); *************** *** 97,101 **** "function of differences between eigenvalues"); hestOptAdd(&hopt, "sphere", NULL, airTypeInt, 0, 0, &sphere, NULL, ! "none of this superquadric crap: use a sphere, dammit"); hestOptAdd(&hopt, "p", "x y z", airTypeFloat, 3, 3, p, "0 0 0", "location in quaternion quotient space"); --- 76,80 ---- "function of differences between eigenvalues"); hestOptAdd(&hopt, "sphere", NULL, airTypeInt, 0, 0, &sphere, NULL, ! "use a sphere instead of a superquadric"); hestOptAdd(&hopt, "p", "x y z", airTypeFloat, 3, 3, p, "0 0 0", "location in quaternion quotient space"); *************** *** 104,113 **** hestOptAdd(&hopt, "res", "resolution", airTypeInt, 1, 1, &res, "25", "tesselation resolution for both glyph and axis cylinders"); ! hestOptAdd(&hopt, "wd", "3 widths", airTypeFloat, 3, 3, edgeWidth + 2, ! "1.5 0.7 0.0", ! "width of edges drawn for three kinds of " ! "edges: silohuette, crease, non-crease"); ! hestOptAdd(&hopt, "o", "output PS", airTypeString, 1, 1, &outS, "out.ps", ! "output file to render postscript into"); hestParseOrDie(hopt, argc-1, argv+1, NULL, me, info, AIR_TRUE, AIR_TRUE, AIR_TRUE); --- 83,88 ---- hestOptAdd(&hopt, "res", "resolution", airTypeInt, 1, 1, &res, "25", "tesselation resolution for both glyph and axis cylinders"); ! hestOptAdd(&hopt, "o", "output OFF", airTypeString, 1, 1, &outS, "out.off", ! "output file to save OFF into"); hestParseOrDie(hopt, argc-1, argv+1, NULL, me, info, AIR_TRUE, AIR_TRUE, AIR_TRUE); *************** *** 115,128 **** airMopAdd(mop, hopt, (airMopper)hestParseFree, airMopAlways); - cam->neer = -0.000000001; - cam->dist = 0; - cam->faar = 0.0000000001; - cam->atRelative = AIR_TRUE; - - if (limnCameraUpdate(cam)) { - fprintf(stderr, "%s: trouble:\n%s\n", me, err = biffGet(LIMN)); - free(err); - return 1; - } obj = limnObjNew(10, AIR_TRUE); airMopAdd(mop, obj, (airMopper)limnObjNix, airMopAlways); --- 90,93 ---- *************** *** 131,139 **** si = airArrayIncrLen(obj->sA, 2); sp = obj->s + si + 0; ! ELL_4V_SET(sp->rgba, 1, 1, 1, 1); /* this is kind of silly */ ELL_3V_SET(sp->k, 0.2, 0.8, 0); sp->spec = 0; sp = obj->s + si + 1; ! ELL_4V_SET(sp->rgba, 1, 1, 1, 1); /* this is kind of silly */ ELL_3V_SET(sp->k, 1, 0, 0); sp->spec = 0; --- 96,104 ---- si = airArrayIncrLen(obj->sA, 2); sp = obj->s + si + 0; ! ELL_4V_SET(sp->rgba, 1, 1, 1, 1); ELL_3V_SET(sp->k, 0.2, 0.8, 0); sp->spec = 0; sp = obj->s + si + 1; ! ELL_4V_SET(sp->rgba, 0, 0, 0, 1); ELL_3V_SET(sp->k, 1, 0, 0); sp->spec = 0; *************** *** 169,173 **** ri = limnObjPolarSuperquadAdd(obj, 0, axis, qA, qB, 2*res, res); } ! r = obj->r + ri; ELL_4V_SET(r->rgba, 1, 1, 1, 1); ELL_4M_IDENTITY_SET(matA); ELL_4M_SCALE_SET(matB, sc[0], sc[1], sc[2]); --- 134,138 ---- ri = limnObjPolarSuperquadAdd(obj, 0, axis, qA, qB, 2*res, res); } ! r = obj->r + ri; ELL_4M_IDENTITY_SET(matA); ELL_4M_SCALE_SET(matB, sc[0], sc[1], sc[2]); *************** *** 179,183 **** if (rad) { ri = limnObjCylinderAdd(obj, 1, 0, res); ! r = obj->r + ri; ELL_4V_SET(r->rgba, 0, 0, 0, 1); ELL_4M_IDENTITY_SET(matA); ELL_4M_SCALE_SET(matB, (1-sc[0])/2, rad, rad); --- 144,148 ---- if (rad) { ri = limnObjCylinderAdd(obj, 1, 0, res); ! r = obj->r + ri; ELL_4M_IDENTITY_SET(matA); ELL_4M_SCALE_SET(matB, (1-sc[0])/2, rad, rad); *************** *** 188,192 **** ri = limnObjCylinderAdd(obj, 1, 0, res); ! r = obj->r + ri; ELL_4V_SET(r->rgba, 0, 0, 0, 1); ELL_4M_IDENTITY_SET(matA); ELL_4M_SCALE_SET(matB, (1-sc[0])/2, rad, rad); --- 153,157 ---- ri = limnObjCylinderAdd(obj, 1, 0, res); ! r = obj->r + ri; ELL_4M_IDENTITY_SET(matA); ELL_4M_SCALE_SET(matB, (1-sc[0])/2, rad, rad); *************** *** 198,202 **** ri = limnObjCylinderAdd(obj, 1, 1, res); ! r = obj->r + ri; ELL_4V_SET(r->rgba, 0, 0, 0, 1); ELL_4M_IDENTITY_SET(matA); ELL_4M_SCALE_SET(matB, rad, (1-sc[1])/2, rad); --- 163,167 ---- ri = limnObjCylinderAdd(obj, 1, 1, res); ! r = obj->r + ri; ELL_4M_IDENTITY_SET(matA); ELL_4M_SCALE_SET(matB, rad, (1-sc[1])/2, rad); *************** *** 207,211 **** ri = limnObjCylinderAdd(obj, 1, 1, res); ! r = obj->r + ri; ELL_4V_SET(r->rgba, 0, 0, 0, 1); ELL_4M_IDENTITY_SET(matA); ELL_4M_SCALE_SET(matB, rad, (1-sc[1])/2, rad); --- 172,176 ---- ri = limnObjCylinderAdd(obj, 1, 1, res); ! r = obj->r + ri; ELL_4M_IDENTITY_SET(matA); ELL_4M_SCALE_SET(matB, rad, (1-sc[1])/2, rad); *************** *** 215,221 **** limnObjPartTransform(obj, ri, matA); - ri = limnObjCylinderAdd(obj, 1, 2, res); ! r = obj->r + ri; ELL_4V_SET(r->rgba, 0, 0, 0, 1); ELL_4M_IDENTITY_SET(matA); ELL_4M_SCALE_SET(matB, rad, rad, (1-sc[2])/2); --- 180,185 ---- limnObjPartTransform(obj, ri, matA); ri = limnObjCylinderAdd(obj, 1, 2, res); ! r = obj->r + ri; ELL_4M_IDENTITY_SET(matA); ELL_4M_SCALE_SET(matB, rad, rad, (1-sc[2])/2); *************** *** 226,230 **** ri = limnObjCylinderAdd(obj, 1, 2, res); ! r = obj->r + ri; ELL_4V_SET(r->rgba, 0, 0, 0, 1); ELL_4M_IDENTITY_SET(matA); ELL_4M_SCALE_SET(matB, rad, rad, (1-sc[2])/2); --- 190,194 ---- ri = limnObjCylinderAdd(obj, 1, 2, res); ! r = obj->r + ri; ELL_4M_IDENTITY_SET(matA); ELL_4M_SCALE_SET(matB, rad, rad, (1-sc[2])/2); *************** *** 235,252 **** } ! win = limnWinNew(limnDevicePS); ! ELL_5V_COPY(win->ps.edgeWidth, edgeWidth); ! win->scale = 200; ! ! win->file = fopen(outS, "w"); ! airMopAdd(mop, win, (airMopper)limnWinNix, airMopAlways); ! if (limnObjRender(obj, cam, win) ! || limnObjPSDraw(obj, cam, nmap, win)) { airMopAdd(mop, err = biffGetDone(LIMN), airFree, airMopAlways); fprintf(stderr, "%s: trouble:\n%s\n", me, err); airMopError(mop); return 1; } - fclose(win->file); airMopOkay(mop); --- 199,210 ---- } ! file = airFopen(outS, stdout, "w"); ! airMopAdd(mop, file, (airMopper)airFclose, airMopAlways); ! if (limnObjOFFWrite(file, obj)) { airMopAdd(mop, err = biffGetDone(LIMN), airFree, airMopAlways); fprintf(stderr, "%s: trouble:\n%s\n", me, err); airMopError(mop); return 1; } airMopOkay(mop); |