|
From: <kin...@us...> - 2004-03-04 14:17:30
|
Update of /cvsroot/teem/teem/src/mite In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12816 Modified Files: kindnot.c mite.h ray.c renderMite.c thread.c txf.c user.c Log Message: refined semantics of normal specification, and added storage of ray depth when opacity reaches muu->opacMatters Index: kindnot.c =================================================================== RCS file: /cvsroot/teem/teem/src/mite/kindnot.c,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** kindnot.c 29 Feb 2004 13:42:41 -0000 1.2 --- kindnot.c 4 Mar 2004 14:04:07 -0000 1.3 *************** *** 32,39 **** "Tw", "Ti", "NdotV", "NdotL", - "GTdotV", "VrefN", "VdefT", "VdefTdotV" --- 32,41 ---- "Tw", "Ti", + "V", + "N", "NdotV", "NdotL", "VrefN", + "GTdotV", "VdefT", "VdefTdotV" *************** *** 51,58 **** miteValTw, miteValTi, miteValNdotV, miteValNdotL, - miteValGTdotV, miteValVrefN, miteValVdefT, miteValVdefTdotV --- 53,62 ---- miteValTw, miteValTi, + miteValView, + miteValNormal, miteValNdotV, miteValNdotL, miteValVrefN, + miteValGTdotV, miteValVdefT, miteValVdefTdotV *************** *** 69,76 **** "tw", "ti", "ndotv", "vdotn", "ndotl", "ldotn", - "gtdotv", "vrefn", "vdeft", "vdeftdotv" --- 73,82 ---- "tw", "ti", + "view", "v", + "normal", "n", "ndotv", "vdotn", "ndotl", "ldotn", "vrefn", + "gtdotv", "vdeft", "vdeftdotv" *************** *** 88,95 **** miteValTw, miteValTi, miteValNdotV, miteValNdotV, miteValNdotL, miteValNdotL, - miteValGTdotV, miteValVrefN, miteValVdefT, miteValVdefTdotV --- 94,103 ---- miteValTw, miteValTi, + miteValView, miteValView, + miteValNormal, miteValNormal, miteValNdotV, miteValNdotV, miteValNdotL, miteValNdotL, miteValVrefN, + miteValGTdotV, miteValVdefT, miteValVdefTdotV *************** *** 125,132 **** {miteValTw, 1, 0, {-1, -1, -1, -1, -1}, -1, -1}, {miteValTi, 1, 0, {-1, -1, -1, -1, -1}, -1, -1}, {miteValNdotV, 1, 0, {-1, -1, -1, -1, -1}, -1, -1}, {miteValNdotL, 1, 0, {-1, -1, -1, -1, -1}, -1, -1}, - {miteValGTdotV, 1, 0, {-1, -1, -1, -1, -1}, -1, -1}, {miteValVrefN, 3, 0, {-1, -1, -1, -1, -1}, -1, -1}, {miteValVdefT, 3, 0, {-1, -1, -1, -1, -1}, -1, -1}, {miteValVdefTdotV, 1, 0, {-1, -1, -1, -1, -1}, -1, -1} --- 133,142 ---- {miteValTw, 1, 0, {-1, -1, -1, -1, -1}, -1, -1}, {miteValTi, 1, 0, {-1, -1, -1, -1, -1}, -1, -1}, + {miteValView, 3, 0, {-1, -1, -1, -1, -1}, -1, -1}, + {miteValNormal, 3, 0, {-1, -1, -1, -1, -1}, -1, -1}, {miteValNdotV, 1, 0, {-1, -1, -1, -1, -1}, -1, -1}, {miteValNdotL, 1, 0, {-1, -1, -1, -1, -1}, -1, -1}, {miteValVrefN, 3, 0, {-1, -1, -1, -1, -1}, -1, -1}, + {miteValGTdotV, 1, 0, {-1, -1, -1, -1, -1}, -1, -1}, {miteValVdefT, 3, 0, {-1, -1, -1, -1, -1}, -1, -1}, {miteValVdefTdotV, 1, 0, {-1, -1, -1, -1, -1}, -1, -1} Index: mite.h =================================================================== RCS file: /cvsroot/teem/teem/src/mite/mite.h,v retrieving revision 1.28 retrieving revision 1.29 diff -C2 -d -r1.28 -r1.29 *** mite.h 29 Feb 2004 13:42:41 -0000 1.28 --- mite.h 4 Mar 2004 14:04:08 -0000 1.29 *************** *** 120,124 **** any of the ntxf[i] */ int ntxfNum; /* allocated and valid length of ntxf[] */ ! char shadeStr[AIR_STRLEN_MED]; /* how to do shading */ /* for each possible element of the txf range, what value should it start at prior to rendering. Mainly needed to store non-unity values --- 120,140 ---- any of the ntxf[i] */ int ntxfNum; /* allocated and valid length of ntxf[] */ ! /* the issue of regular shading, txf-based shading, and surface normals: ! phong and lit-tensor shading ("regular shading") methods need to specify ! one or more vectors that are used for shading calculations. These will ! be parsed from muu->shadeStr into mrr->shadeSpec, which in turn will ! determine the pointer values of mtt->shade{Vec,Scl}{0,1}. ! ENTIRELY SEPERATE FROM THIS, a "surface normal" can be specified in ! muu->normalStr, which (if non-empty), will be parsed into mrr->normalSpec, ! which in turn will determine the pointer values of mtt->normal. This ! normal is used for the miteVal quantities involving "N". ! Both shading and normal specifications can be given, since they are ! used in seperate computations. If the user wants to do miteVal-based ! stuff with the same quantity specified in (say) a phong shading ! specification, its up to them to verify that the normalStr and the ! shadeStr refer to the same vector. ! */ ! char shadeStr[AIR_STRLEN_MED], /* how to do shading */ ! normalStr[AIR_STRLEN_MED]; /* what is the "surface normal" */ /* for each possible element of the txf range, what value should it start at prior to rendering. Mainly needed to store non-unity values *************** *** 218,222 **** volumes in the gageContext's array of gagePerVolumes. Probably a hack */ ! miteShadeSpec *shpec; /* information based on muu->shadeStr */ double time0; /* rendering start time */ gageQuery queryMite; /* record of the miteVal quantities which --- 234,239 ---- volumes in the gageContext's array of gagePerVolumes. Probably a hack */ ! miteShadeSpec *shadeSpec; /* information based on muu->shadeStr */ ! gageItemSpec *normalSpec; /* information based on muu->normalStr */ double time0; /* rendering start time */ gageQuery queryMite; /* record of the miteVal quantities which *************** *** 236,251 **** ******** miteStageOp* enum ** ! ** the kinds of things we can do per txf to modify the range variables. ! ** previously mite only supported seperable transfer functions (i.e., ! ** multiplication only) */ enum { ! miteStageOpUnknown, ! miteStageOpMin, ! miteStageOpMax, ! miteStageOpAdd, ! miteStageOpMultiply, miteStageOpLast }; typedef struct { --- 253,276 ---- ******** miteStageOp* enum ** ! ** the kinds of things we can do per txf to modify the range ! ** variables. previously mite only supported seperable transfer ! ** functions (i.e., multiplication only). It is tempting to use all ! ** the operations available as nrrdBinaryOps, but that would lead to ! ** goofy ones like Mod and GreaterThan, which either require or create ! ** integral values which aren't of much use in transfer functions. ! ** More generality in how opacities and colors are assigned will ! ** likely be supported by some simple programmability, supported by ! ** the likes of the funk library, which will be entirely seperate from ! ** the miteStageOp mechanism. */ enum { ! miteStageOpUnknown, /* 0 */ ! miteStageOpMin, /* 1 */ ! miteStageOpMax, /* 2 */ ! miteStageOpAdd, /* 3 */ ! miteStageOpMultiply, /* 4 */ miteStageOpLast }; + #define MITE_STAGE_OP_MAX 4 typedef struct { *************** *** 295,315 **** miteValTw, /* 6: "Tw", ray position (gage_t[1]) */ miteValTi, /* 7: "Ti", ray index (ray sample #) (gage_t[1]) */ ! miteValNdotV, /* 8: "NdotV", surface normal dotted w/ view vector ! (towards eye) (gage_t[1]) */ ! miteValNdotL, /* 9: "NdotL", surface normal dotted w/ light vector ! (towards the light source) (gage_t[1]) */ ! miteValGTdotV, /* 10: "GTdotV", normal curvature in view direction, ! the contraction of the geometry tensor along ! the view vector (gage_t[1]) */ ! miteValVrefN, /* 11: "VrefN", view vector (towards eye) reflected ! across surface normal (gage_t[3]) */ ! miteValVdefT, /* 12: "VdefT", view direction, deflected by tensor, then normalized (gage_t[3]) */ ! miteValVdefTdotV, /* 13: "VdefTdotV", VdefT dotted back with V, not the same as the tensor contraction along V, (gage_t[1]) */ miteValLast }; ! #define MITE_VAL_ITEM_MAX 13 /* --- 320,345 ---- miteValTw, /* 6: "Tw", ray position (gage_t[1]) */ miteValTi, /* 7: "Ti", ray index (ray sample #) (gage_t[1]) */ ! miteValView, /* 8: "V", the view vector (gage_t[3]) */ ! miteValNormal, /* 9: "N", the nominal surface normal, as measured ! by a scalar, vector, or tensor kind, and then ! determined by the semantics of ! muu->normalSide */ ! miteValNdotV, /* 10: "NdotV", surface normal dotted w/ view vector ! (towards eye) (gage_t[1]) */ ! miteValNdotL, /* 11: "NdotL", surface normal dotted w/ light vector ! (towards the light source) (gage_t[1]) */ ! miteValVrefN, /* 12: "VrefN", view vector reflected across normal ! (gage_t[3]) */ ! miteValGTdotV, /* 13: "GTdotV", normal curvature in view direction, ! the contraction of the geometry tensor along ! he view vector (gage_t[1]) */ ! miteValVdefT, /* 14: "defT", view direction, deflected by tensor, then normalized (gage_t[3]) */ ! miteValVdefTdotV, /* 15: "VdefTdotV", VdefT dotted back with V, not the same as the tensor contraction along V, (gage_t[1]) */ miteValLast }; ! #define MITE_VAL_ITEM_MAX 15 /* *************** *** 328,331 **** --- 358,365 ---- mite instead of by gage */ **directAnsMiteVal, /* pointers into ansMiteVal */ + *_normal, /* pointer into ans{Scl,Vec,Ten} array above, + (NOT ansMiteVal); this will determine the + value of miteValNormal according to the + semantics of muu->normalSide */ *shadeVec0, *shadeVec1, *shadeScl0, *shadeScl1; /* pointers into the ans* arrays above, *************** *** 344,348 **** each ray to enable sampling on planes) */ V[3], /* per-ray view direction */ ! RR, GG, BB, TT; /* per-ray composited values */ } miteThread; --- 378,384 ---- each ray to enable sampling on planes) */ V[3], /* per-ray view direction */ ! RR, GG, BB, TT, /* per-ray composited values */ ! ZZ; /* for storing ray-depth when opacity passed ! muu->opacMatters */ } miteThread; *************** *** 360,363 **** --- 396,400 ---- /* txf.c */ + TEEM_API airEnum *miteStageOp; TEEM_API char miteRangeChar[MITE_RANGE_NUM]; TEEM_API int miteVariableParse(gageItemSpec *isp, const char *label); Index: ray.c =================================================================== RCS file: /cvsroot/teem/teem/src/mite/ray.c,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** ray.c 29 Feb 2004 13:42:41 -0000 1.19 --- ray.c 4 Mar 2004 14:04:08 -0000 1.20 *************** *** 39,42 **** --- 39,43 ---- mtt->RR = mtt->GG = mtt->BB = 0.0; mtt->TT = 1.0; + mtt->ZZ = -1.0; ELL_3V_SCALE(mtt->V, -1, rayDirWorld); *************** *** 62,78 **** ks = mtt->range[miteRangeKs]; ELL_3V_SCALE(ad, ka, muu->lit->amb); ! switch (mrr->shpec->method) { case miteShadeMethodNone: /* nothing to do */ break; case miteShadeMethodPhong: - /* this is dicey- we're *writing* to the answer buffer */ if (kd || ks) { ! ELL_3V_NORM(mtt->shadeVec0, mtt->shadeVec0, tmp); ! if (muu->normalSide) { ! ELL_3V_SCALE(N, -muu->normalSide, mtt->shadeVec0); ! } else { ! ELL_3V_COPY(N, mtt->shadeVec0); } if (kd) { LdotN = ELL_3V_DOT(muu->lit->dir[0], N); --- 63,78 ---- ks = mtt->range[miteRangeKs]; ELL_3V_SCALE(ad, ka, muu->lit->amb); ! switch (mrr->shadeSpec->method) { case miteShadeMethodNone: /* nothing to do */ break; case miteShadeMethodPhong: if (kd || ks) { ! ELL_3V_NORM(N, mtt->shadeVec0, tmp); ! if (1 == muu->normalSide) { ! ELL_3V_SCALE(N, -1, N); } + /* else -1==side --> N = -1*-1*N = N + or 0==side --> N = N, so there's nothing to do */ if (kd) { LdotN = ELL_3V_DOT(muu->lit->dir[0], N); *************** *** 104,108 **** default: fprintf(stderr, "!%s: PANIC, shadeMethod %d unimplemented\n", ! me, mrr->shpec->method); exit(1); break; --- 104,108 ---- default: fprintf(stderr, "!%s: PANIC, shadeMethod %d unimplemented\n", ! me, mrr->shadeSpec->method); exit(1); break; *************** *** 132,136 **** char me[]="miteSample", err[AIR_STRLEN_MED]; mite_t R, G, B, A; ! double kn[3], knd[3], len; if (!inside) { --- 132,137 ---- char me[]="miteSample", err[AIR_STRLEN_MED]; mite_t R, G, B, A; ! gage_t *NN; ! double NdotV, kn[3], knd[3], ref[3], len; if (!inside) { *************** *** 152,155 **** --- 153,157 ---- biffAdd(MITE, err); return AIR_NAN; } + if (mrr->queryMiteNonzero) { /* There is some optimal trade-off between slowing things down *************** *** 165,182 **** mtt->directAnsMiteVal[miteValTw][0] = rayT; mtt->directAnsMiteVal[miteValTi][0] = num; ! if (mtt->shadeVec0 && ! (GAGE_QUERY_ITEM_TEST(mrr->queryMite, miteValNdotV) ! || GAGE_QUERY_ITEM_TEST(mrr->queryMite, miteValNdotL))) { mtt->directAnsMiteVal[miteValNdotV][0] = ! -muu->normalSide*ELL_3V_DOT(mtt->shadeVec0, mtt->V); mtt->directAnsMiteVal[miteValNdotL][0] = ! -muu->normalSide*ELL_3V_DOT(mtt->shadeVec0, muu->lit->dir[0]); if (!muu->normalSide) { ! mtt->directAnsMiteVal[miteValNdotV][0] = AIR_ABS(mtt->directAnsMiteVal[miteValNdotV][0]); mtt->directAnsMiteVal[miteValNdotL][0] = AIR_ABS(mtt->directAnsMiteVal[miteValNdotL][0]); } } --- 167,194 ---- mtt->directAnsMiteVal[miteValTw][0] = rayT; mtt->directAnsMiteVal[miteValTi][0] = num; + ELL_3V_COPY(mtt->directAnsMiteVal[miteValView], mtt->V); + NN = mtt->directAnsMiteVal[miteValNormal]; + if (1 == muu->normalSide) { + ELL_3V_SCALE(NN, -1, mtt->_normal); + } else { + ELL_3V_COPY(NN, mtt->_normal); + } ! if ((GAGE_QUERY_ITEM_TEST(mrr->queryMite, miteValNdotV) ! || GAGE_QUERY_ITEM_TEST(mrr->queryMite, miteValNdotL) ! || GAGE_QUERY_ITEM_TEST(mrr->queryMite, miteValVrefN))) { mtt->directAnsMiteVal[miteValNdotV][0] = ! ELL_3V_DOT(NN, mtt->V); mtt->directAnsMiteVal[miteValNdotL][0] = ! ELL_3V_DOT(NN, muu->lit->dir[0]); if (!muu->normalSide) { ! mtt->directAnsMiteVal[miteValNdotV][0] = AIR_ABS(mtt->directAnsMiteVal[miteValNdotV][0]); mtt->directAnsMiteVal[miteValNdotL][0] = AIR_ABS(mtt->directAnsMiteVal[miteValNdotL][0]); } + NdotV = mtt->directAnsMiteVal[miteValNdotV][0]; + ELL_3V_SCALE_ADD2(ref, 2*NdotV, NN, -1, mtt->V); + ELL_3V_NORM(mtt->directAnsMiteVal[miteValVrefN], ref, len); } *************** *** 185,189 **** ELL_3V_NORM(kn, kn, len); ELL_3MV_MUL(knd, mtt->geomTens, kn); ! mtt->ansMiteVal[miteValGTdotV] = ELL_3V_DOT(knd, kn); } } --- 197,201 ---- ELL_3V_NORM(kn, kn, len); ELL_3MV_MUL(knd, mtt->geomTens, kn); ! mtt->directAnsMiteVal[miteValGTdotV][0] = ELL_3V_DOT(knd, kn); } } *************** *** 212,215 **** --- 224,232 ---- } + /* set Z if it hasn't been set already */ + if (1-mtt->TT >= muu->opacMatters && mtt->ZZ < 0) { + mtt->ZZ = rayT; + } + return mtt->rayStep; } *************** *** 218,222 **** miteRayEnd(miteThread *mtt, miteRender *mrr, miteUser *muu) { int idx; ! mite_t *imgData, A; idx = mtt->ui + (muu->nout->axis[1].size)*mtt->vi; --- 235,240 ---- miteRayEnd(miteThread *mtt, miteRender *mrr, miteUser *muu) { int idx; ! mite_t *imgData; ! double A; idx = mtt->ui + (muu->nout->axis[1].size)*mtt->vi; *************** *** 224,230 **** A = 1 - mtt->TT; if (A) { ! ELL_4V_SET(imgData + 5*idx, mtt->RR/A, mtt->GG/A, mtt->BB/A, A); } else { ! ELL_4V_SET(imgData + 5*idx, 0, 0, 0, 0); } return 0; --- 242,249 ---- A = 1 - mtt->TT; if (A) { ! ELL_5V_SET(imgData + 5*idx, mtt->RR/A, mtt->GG/A, mtt->BB/A, ! A, mtt->ZZ); } else { ! ELL_5V_SET(imgData + 5*idx, 0, 0, 0, 0, -1); } return 0; Index: renderMite.c =================================================================== RCS file: /cvsroot/teem/teem/src/mite/renderMite.c,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** renderMite.c 29 Feb 2004 13:42:41 -0000 1.12 --- renderMite.c 4 Mar 2004 14:04:08 -0000 1.13 *************** *** 37,42 **** mrr->vecPvlIdx = -1; mrr->tenPvlIdx = -1; ! mrr->shpec = miteShadeSpecNew(); ! airMopAdd(mrr->rmop, mrr->shpec, (airMopper)miteShadeSpecNix, airMopAlways); mrr->time0 = AIR_NAN; --- 37,45 ---- mrr->vecPvlIdx = -1; mrr->tenPvlIdx = -1; ! mrr->normalSpec = gageItemSpecNew(); ! airMopAdd(mrr->rmop, mrr->normalSpec, ! (airMopper)gageItemSpecNix, airMopAlways); ! mrr->shadeSpec = miteShadeSpecNew(); ! airMopAdd(mrr->rmop, mrr->shadeSpec, (airMopper)miteShadeSpecNix, airMopAlways); mrr->time0 = AIR_NAN; *************** *** 92,98 **** } } ! miteShadeSpecParse((*mrrP)->shpec, muu->shadeStr); miteShadeSpecQueryAdd(queryScl, queryVec, queryTen, (*mrrP)->queryMite, ! (*mrrP)->shpec); (*mrrP)->queryMiteNonzero = GAGE_QUERY_NONZERO((*mrrP)->queryMite); --- 95,104 ---- } } ! miteVariableParse((*mrrP)->normalSpec, muu->normalStr); ! miteQueryAdd(queryScl, queryVec, queryTen, (*mrrP)->queryMite, ! (*mrrP)->normalSpec); ! miteShadeSpecParse((*mrrP)->shadeSpec, muu->shadeStr); miteShadeSpecQueryAdd(queryScl, queryVec, queryTen, (*mrrP)->queryMite, ! (*mrrP)->shadeSpec); (*mrrP)->queryMiteNonzero = GAGE_QUERY_NONZERO((*mrrP)->queryMite); Index: thread.c =================================================================== RCS file: /cvsroot/teem/teem/src/mite/thread.c,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** thread.c 29 Feb 2004 15:49:10 -0000 1.12 --- thread.c 4 Mar 2004 14:04:08 -0000 1.13 *************** *** 35,38 **** --- 35,39 ---- mtt->gctx = NULL; mtt->ansScl = mtt->ansVec = mtt->ansTen = NULL; + mtt->_normal = NULL; mtt->shadeVec0 = NULL; mtt->shadeVec1 = NULL; *************** *** 119,140 **** (*mttP)->samples = 0; (*mttP)->verbose = 0; /* set up shading answers */ ! switch(mrr->shpec->method) { case miteShadeMethodNone: /* nothing to do */ break; case miteShadeMethodPhong: ! (*mttP)->shadeVec0 = _miteAnswerPointer(*mttP, mrr->shpec->vec0); break; case miteShadeMethodLitTen: ! (*mttP)->shadeVec0 = _miteAnswerPointer(*mttP, mrr->shpec->vec0); ! (*mttP)->shadeVec1 = _miteAnswerPointer(*mttP, mrr->shpec->vec1); ! (*mttP)->shadeScl0 = _miteAnswerPointer(*mttP, mrr->shpec->scl0); ! (*mttP)->shadeScl1 = _miteAnswerPointer(*mttP, mrr->shpec->scl1); break; default: sprintf(err, "%s: shade method %d not implemented!", ! me, mrr->shpec->method); biffAdd(MITE, err); return 1; break; --- 120,142 ---- (*mttP)->samples = 0; (*mttP)->verbose = 0; + (*mttP)->_normal = _miteAnswerPointer(*mttP, mrr->normalSpec); /* set up shading answers */ ! switch(mrr->shadeSpec->method) { case miteShadeMethodNone: /* nothing to do */ break; case miteShadeMethodPhong: ! (*mttP)->shadeVec0 = _miteAnswerPointer(*mttP, mrr->shadeSpec->vec0); break; case miteShadeMethodLitTen: ! (*mttP)->shadeVec0 = _miteAnswerPointer(*mttP, mrr->shadeSpec->vec0); ! (*mttP)->shadeVec1 = _miteAnswerPointer(*mttP, mrr->shadeSpec->vec1); ! (*mttP)->shadeScl0 = _miteAnswerPointer(*mttP, mrr->shadeSpec->scl0); ! (*mttP)->shadeScl1 = _miteAnswerPointer(*mttP, mrr->shadeSpec->scl1); break; default: sprintf(err, "%s: shade method %d not implemented!", ! me, mrr->shadeSpec->method); biffAdd(MITE, err); return 1; break; Index: txf.c =================================================================== RCS file: /cvsroot/teem/teem/src/mite/txf.c,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** txf.c 3 Mar 2004 13:14:08 -0000 1.19 --- txf.c 4 Mar 2004 14:04:08 -0000 1.20 *************** *** 29,32 **** --- 29,79 ---- miteRangeChar[MITE_RANGE_NUM] = "ARGBEadsp"; + char + _miteStageOpStr[][AIR_STRLEN_SMALL] = { + "(unknown miteStageOp)", + "min", + "max", + "add", + "multiply" + }; + + int + _miteStageOpVal[] = { + miteStageOpUnknown, + miteStageOpMin, + miteStageOpMax, + miteStageOpAdd, + miteStageOpMultiply + }; + + char + _miteStageOpStrEqv[][AIR_STRLEN_SMALL] = { + "min", + "max", + "add", "+", + "multiply", "*", "x" + }; + + int + _miteStageOpValEqv[] = { + miteStageOpUnknown, + miteStageOpMin, + miteStageOpMax, + miteStageOpAdd, miteStageOpAdd, + miteStageOpMultiply, miteStageOpMultiply, miteStageOpMultiply + }; + + airEnum + _miteStageOp = { + "miteStageOp", + MITE_STAGE_OP_MAX+1, + _miteStageOpStr, _miteStageOpVal, + NULL, + _miteStageOpStrEqv, _miteStageOpValEqv, + AIR_FALSE + }; + airEnum * + miteStageOp = &_miteStageOp; + /* ******** miteVariableParse() *************** *** 36,39 **** --- 83,87 ---- ** kind and item). The valid formats are: ** + ** "" : NULL kind, -1 item ** <item> : miteValGageKind (DEPRECATED) ** mite(<item>) : miteValGageKind *************** *** 57,60 **** --- 105,116 ---- biffAdd(MITE, err); return 1; } + if (0 == strlen(label)) { + /* nothing was specified; we try to indicate that by mimicing + the return of gageItemSpecNew() */ + isp->item = -1; + isp->kind = NULL; + return 0; + } + /* else given string was non-empty */ mop = airMopNew(); buff = airStrdup(label); *************** *** 144,151 **** miteVariablePrint(char *buff, const gageItemSpec *isp) { char me[]="miteVariablePrint"; ! ! if (gageKindScl == isp->kind ! || gageKindVec == isp->kind ! || tenGageKind == isp->kind) { sprintf(buff, "gage(%s:%s)", isp->kind->name, airEnumStr(isp->kind->enm, isp->item)); --- 200,209 ---- miteVariablePrint(char *buff, const gageItemSpec *isp) { char me[]="miteVariablePrint"; ! ! if (!(isp->kind)) { ! strcpy(buff, ""); ! } else if (gageKindScl == isp->kind ! || gageKindVec == isp->kind ! || tenGageKind == isp->kind) { sprintf(buff, "gage(%s:%s)", isp->kind->name, airEnumStr(isp->kind->enm, isp->item)); *************** *** 281,285 **** char me[]="miteQueryAdd"; ! if (gageKindScl == isp->kind) { GAGE_QUERY_ITEM_ON(queryScl, isp->item); } else if (gageKindVec == isp->kind) { --- 339,345 ---- char me[]="miteQueryAdd"; ! if (NULL == isp->kind) { ! /* nothing to add */ ! } else if (gageKindScl == isp->kind) { GAGE_QUERY_ITEM_ON(queryScl, isp->item); } else if (gageKindVec == isp->kind) { *************** *** 298,313 **** (for instance, using the gradient of fractional anisotropy) */ switch(isp->item) { case miteValNdotV: - GAGE_QUERY_ITEM_ON(queryScl, gageSclNormal); - break; case miteValNdotL: ! GAGE_QUERY_ITEM_ON(queryScl, gageSclNormal); break; case miteValGTdotV: GAGE_QUERY_ITEM_ON(queryScl, gageSclGeomTens); break; - case miteValVrefN: - GAGE_QUERY_ITEM_ON(queryScl, gageSclNormal); - break; case miteValVdefT: GAGE_QUERY_ITEM_ON(queryTen, tenGageTensor); --- 358,372 ---- (for instance, using the gradient of fractional anisotropy) */ switch(isp->item) { + case miteValVrefN: case miteValNdotV: case miteValNdotL: ! /* the "N" can be a normalized vector from any of the ! available kinds (except miteValGageKind!), and its ! associated query will be handled elsewhere, so there's ! nothing to add here */ break; case miteValGTdotV: GAGE_QUERY_ITEM_ON(queryScl, gageSclGeomTens); break; case miteValVdefT: GAGE_QUERY_ITEM_ON(queryTen, tenGageTensor); *************** *** 317,321 **** } } else { ! fprintf(stderr, "%s: PANIC: unrecognized non-null gageKind\n", me); exit(1); } --- 376,380 ---- } } else { ! fprintf(stderr, "%s: PANIC: unrecognized non-NULL gageKind\n", me); exit(1); } *************** *** 350,356 **** --- 409,418 ---- biffAdd(MITE, err); return 1; } + /* note that key/values need to be copied for the sake of + identifying a non-default miteStageOp */ switch(muu->ntxf[ni]->type) { case nrrdTypeUChar: if (!E) E |= nrrdUnquantize(mrr->ntxf[ni], muu->ntxf[ni], nrrdTypeUChar); + if (!E) E |= nrrdKeyValueCopy(mrr->ntxf[ni], muu->ntxf[ni]); break; case mite_nt: *************** *** 359,362 **** --- 421,425 ---- default: /* will be either float or double (whatever mite_nt isn't) */ if (!E) E |= nrrdConvert(mrr->ntxf[ni], muu->ntxf[ni], mite_nt); + if (!E) E |= nrrdKeyValueCopy(mrr->ntxf[ni], muu->ntxf[ni]); break; } *************** *** 434,437 **** --- 497,506 ---- gage_t *ret; + if (!isp->kind) { + /* we got a NULL kind (as happens with output of + gageItemSpecNew()); only NULL return is sensible */ + return NULL; + } + if (gageKindScl == isp->kind) { ret = mtt->ansScl; *************** *** 457,461 **** int _miteStageSet(miteThread *mtt, miteRender *mrr) { ! char me[]="_miteStageSet", err[AIR_STRLEN_MED]; int ni, di, stageIdx, rii, stageNum, log2; Nrrd *ntxf; --- 526,530 ---- int _miteStageSet(miteThread *mtt, miteRender *mrr) { ! char me[]="_miteStageSet", err[AIR_STRLEN_MED], *value; int ni, di, stageIdx, rii, stageNum, log2; Nrrd *ntxf; *************** *** 492,496 **** } else { stage->data = ntxf->data; ! stage->op = miteStageOpMultiply; if (1 == isp.kind->table[isp.item].answerLength) { stage->qn = NULL; --- 561,573 ---- } else { stage->data = ntxf->data; ! value = nrrdKeyValueGet(ntxf, "miteStageOp"); ! if (value) { ! stage->op = airEnumVal(miteStageOp, value); ! if (miteStageOpUnknown == stage->op) { ! stage->op = miteStageOpMultiply; ! } ! } else { ! stage->op = miteStageOpMultiply; ! } if (1 == isp.kind->table[isp.item].answerLength) { stage->qn = NULL; Index: user.c =================================================================== RCS file: /cvsroot/teem/teem/src/mite/user.c,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** user.c 29 Feb 2004 13:42:42 -0000 1.16 --- user.c 4 Mar 2004 14:04:08 -0000 1.17 *************** *** 38,41 **** --- 38,42 ---- muu->ntxfNum = 0; muu->shadeStr[0] = 0; + muu->normalStr[0] = 0; for (i=0; i<MITE_RANGE_NUM; i++) { muu->rangeInit[i] = 1.0; *************** *** 96,99 **** --- 97,102 ---- GAGE_QUERY_RESET(queryTen); GAGE_QUERY_RESET(queryMite); /* not actually used here */ + + /* add on all queries associated with transfer functions */ for (T=0; T<muu->ntxfNum; T++) { if (miteNtxfCheck(muu->ntxf[T])) { *************** *** 117,120 **** --- 120,141 ---- "************************\n\n\n", me); } + + /* add on "normal"-based queries */ + if (airStrlen(muu->normalStr)) { + miteVariableParse(&isp, muu->normalStr); + if (miteValGageKind == isp.kind) { + sprintf(err, "%s: normalStr \"%s\" refers to a miteVal " + "(normal must be data-intrinsic)", me, muu->normalStr); + biffAdd(MITE, err); airMopError(mop); return 1; + } + if (3 != isp.kind->table[isp.item].answerLength) { + sprintf(err, "%s: %s not a vector: can't be used as normal", + me, muu->normalStr); + biffAdd(MITE, err); return 1; + } + miteQueryAdd(queryScl, queryVec, queryTen, queryMite, &isp); + } + + /* add on shading-based queries */ shpec = miteShadeSpecNew(); airMopAdd(mop, shpec, (airMopper)miteShadeSpecNix, airMopAlways); *************** *** 125,128 **** --- 146,162 ---- } miteShadeSpecQueryAdd(queryScl, queryVec, queryTen, queryMite, shpec); + + /* see if anyone asked for an unspecified normal */ + if ((GAGE_QUERY_ITEM_TEST(queryMite, miteValNdotV) + || GAGE_QUERY_ITEM_TEST(queryMite, miteValNdotL) + || GAGE_QUERY_ITEM_TEST(queryMite, miteValVrefN)) + && !airStrlen(muu->normalStr)) { + sprintf(err, "%s: txf or shading requested a miteVal's use of the " + "\"normal\", but one has not been specified in muu->normalStr", + me); + biffAdd(MITE, err); airMopError(mop); return 1; + } + + /* see if we have volumes for requested queries */ if (GAGE_QUERY_NONZERO(queryScl) && !(muu->nsin)) { sprintf(err, "%s: txf or shading require %s volume, but don't have one", *************** *** 140,147 **** biffAdd(MITE, err); airMopError(mop); return 1; } ! if (!muu->nout) { ! sprintf(err, "%s: rendered image nrrd is NULL", me); ! biffAdd(MITE, err); airMopError(mop); return 1; ! } if (muu->nsin) { if (gageVolumeCheck(muu->gctx0, muu->nsin, gageKindScl)) { --- 174,179 ---- biffAdd(MITE, err); airMopError(mop); return 1; } ! ! /* check appropriateness of given volumes */ if (muu->nsin) { if (gageVolumeCheck(muu->gctx0, muu->nsin, gageKindScl)) { *************** *** 165,168 **** --- 197,205 ---- } } + + if (!muu->nout) { + sprintf(err, "%s: rendered image nrrd is NULL", me); + biffAdd(MITE, err); airMopError(mop); return 1; + } airMopOkay(mop); return 0; |