|
From: <kin...@us...> - 2003-11-18 10:04:58
|
Update of /cvsroot/teem/teem/src/ten
In directory sc8-pr-cvs1:/tmp/cvs-serv6230/ten
Modified Files:
glyph.c ten.h tendGlyph.c
Log Message:
added ability to show slice of arbitrary data (not just anisotropy)
Index: glyph.c
===================================================================
RCS file: /cvsroot/teem/teem/src/ten/glyph.c,v
retrieving revision 1.28
retrieving revision 1.29
diff -C2 -d -r1.28 -r1.29
*** glyph.c 17 Nov 2003 15:15:06 -0000 1.28
--- glyph.c 18 Nov 2003 10:04:54 -0000 1.29
***************
*** 52,56 ****
parm->sliceAnisoType = tenAnisoUnknown;
parm->sliceOffset = 0.0;
! parm->sliceAnisoGamma = 1.0;
}
return parm;
--- 52,56 ----
parm->sliceAnisoType = tenAnisoUnknown;
parm->sliceOffset = 0.0;
! parm->sliceGamma = 1.0;
}
return parm;
***************
*** 64,69 ****
int
! tenGlyphParmCheck(tenGlyphParm *parm, Nrrd *nten, Nrrd *npos) {
char me[]="tenGlyphParmCheck", err[AIR_STRLEN_MED];
if (!(parm && nten)) {
--- 64,70 ----
int
! tenGlyphParmCheck(tenGlyphParm *parm, Nrrd *nten, Nrrd *npos, Nrrd *nslc) {
char me[]="tenGlyphParmCheck", err[AIR_STRLEN_MED];
+ int duh, tenSize[3];
if (!(parm && nten)) {
***************
*** 127,134 ****
biffAdd(TEN, err); return 1;
}
! if (airEnumValCheck(tenAniso, parm->sliceAnisoType)) {
! sprintf(err, "%s: unset (or invalid) sliceAnisoType (%d)",
! me, parm->sliceAnisoType);
! biffAdd(TEN, err); return 1;
}
}
--- 128,155 ----
biffAdd(TEN, err); return 1;
}
! if (nslc) {
! if (2 != nslc->dim) {
! sprintf(err, "%s: explicit slice must be 2-D (not %d)", me, nslc->dim);
! biffAdd(TEN, err); return 1;
! }
! tenSize[0] = nten->axis[1].size;
! tenSize[1] = nten->axis[2].size;
! tenSize[2] = nten->axis[3].size;
! for (duh=parm->sliceAxis; duh<2; duh++) {
! tenSize[duh] = tenSize[duh+1];
! }
! if (!( tenSize[0] == nslc->axis[0].size
! && tenSize[1] == nslc->axis[1].size )) {
! sprintf(err, "%s: axis %d slice of %dx%dx%d volume is not %dx%d", me,
! parm->sliceAxis, nten->axis[1].size, nten->axis[2].size,
! nten->axis[3].size, nslc->axis[0].size, nslc->axis[1].size);
! biffAdd(TEN, err); return 1;
! }
! } else {
! if (airEnumValCheck(tenAniso, parm->sliceAnisoType)) {
! sprintf(err, "%s: unset (or invalid) sliceAnisoType (%d)",
! me, parm->sliceAnisoType);
! biffAdd(TEN, err); return 1;
! }
}
}
***************
*** 138,142 ****
int
tenGlyphGen(limnObj *glyphsLimn, echoScene *glyphsEcho,
! Nrrd *nten, Nrrd *npos, tenGlyphParm *parm) {
char me[]="tenGlyphGen", err[AIR_STRLEN_MED];
gageShape *shape;
--- 159,163 ----
int
tenGlyphGen(limnObj *glyphsLimn, echoScene *glyphsEcho,
! tenGlyphParm *parm, Nrrd *nten, Nrrd *npos, Nrrd *nslc) {
char me[]="tenGlyphGen", err[AIR_STRLEN_MED];
gageShape *shape;
***************
*** 145,150 ****
float cl, cp, *tdata, evec[9], eval[3], *cvec,
aniso[TEN_ANISO_MAX+1], sRot[16], mA[16], mB[16],
! R, G, B, qA, qB, glyphAniso, sliceAniso;
! int idx, _idx=0, ri, axis, si=0, numGlyphs;
limnPart *lglyph;
limnSP *sp;
--- 166,171 ----
float cl, cp, *tdata, evec[9], eval[3], *cvec,
aniso[TEN_ANISO_MAX+1], sRot[16], mA[16], mB[16],
! R, G, B, qA, qB, glyphAniso, sliceGray;
! int slcCoord[3], slcIdx, idx, _idx=0, ri, axis, spi=0, numGlyphs, duh;
limnPart *lglyph;
limnSP *sp;
***************
*** 187,191 ****
}
}
! if (tenGlyphParmCheck(parm, nten, npos)) {
sprintf(err, "%s: trouble", me);
biffAdd(TEN, err); airMopError(mop); return 1;
--- 208,212 ----
}
}
! if (tenGlyphParmCheck(parm, nten, npos, nslc)) {
sprintf(err, "%s: trouble", me);
biffAdd(TEN, err); airMopError(mop); return 1;
***************
*** 221,230 ****
if (glyphsLimn) {
/* create limnSPs for diffuse (#0) and flat (#1) shading */
! si = airArrayIncrLen(glyphsLimn->sA, 2);
! sp = glyphsLimn->s + si + 0;
ELL_4V_SET(sp->rgba, 1, 1, 1, 1);
ELL_3V_SET(sp->k, 0, 1, 0);
sp->spec = 0;
! sp = glyphsLimn->s + si + 1;
ELL_4V_SET(sp->rgba, 1, 1, 1, 1);
ELL_3V_SET(sp->k, 1, 0, 0);
--- 242,251 ----
if (glyphsLimn) {
/* create limnSPs for diffuse (#0) and flat (#1) shading */
! spi = airArrayIncrLen(glyphsLimn->sA, 2);
! sp = glyphsLimn->s + spi + 0;
ELL_4V_SET(sp->rgba, 1, 1, 1, 1);
ELL_3V_SET(sp->k, 0, 1, 0);
sp->spec = 0;
! sp = glyphsLimn->s + spi + 1;
ELL_4V_SET(sp->rgba, 1, 1, 1, 1);
ELL_3V_SET(sp->k, 1, 0, 0);
***************
*** 252,278 ****
}
}
- if (!( tdata[0] >= parm->confThresh ))
- continue;
tenEigensolve(eval, evec, tdata);
- if (parm->onlyPositive) {
- if (eval[2] < 0) {
- /* didn't have all positive eigenvalues, its outta here */
- continue;
- }
- }
tenAnisoCalc(aniso, eval);
if (parm->doSlice
&& pI[parm->sliceAxis] == parm->slicePos) {
! sliceAniso = aniso[parm->sliceAnisoType];
! /* HEY: look, a visualization parameter (0.03) that is not
! exposed anywhere in an API, just super ... */
! sliceAniso = AIR_AFFINE(0, sliceAniso, 1, 0.03, 1);
! if (parm->sliceAnisoGamma > 0) {
! sliceAniso = pow(sliceAniso, 1.0/parm->sliceAnisoGamma);
} else {
! sliceAniso = 1.0 - pow(sliceAniso, -1.0/parm->sliceAnisoGamma);
}
if (glyphsLimn) {
! ri = limnObjSquareAdd(glyphsLimn, si + 1);
ELL_4M_IDENTITY_SET(mA);
ell_4m_post_mul_f(mA, sRot);
--- 273,308 ----
}
}
tenEigensolve(eval, evec, tdata);
tenAnisoCalc(aniso, eval);
if (parm->doSlice
&& pI[parm->sliceAxis] == parm->slicePos) {
! /* set sliceGray */
! if (nslc) {
! /* we aren't masked by confidence, as anisotropy slice is */
! for (duh=0; duh<parm->sliceAxis; duh++) {
! slcCoord[duh] = pI[duh];
! }
! for (duh=duh<parm->sliceAxis; duh<2; duh++) {
! slcCoord[duh] = pI[duh+1];
! }
! ELL_3V_COPY(slcCoord, pI);
! slcIdx = slcCoord[0] + nslc->axis[0].size*slcCoord[1];
! sliceGray = nrrdFLookup[nslc->type](nslc->data, slcIdx);
} else {
! if (!( tdata[0] >= parm->confThresh ))
! continue;
! sliceGray = aniso[parm->sliceAnisoType];
! /* HEY: look, a visualization parameter (0.03) that is not
! exposed anywhere in an API, just super ... */
! sliceGray = AIR_AFFINE(0, sliceGray, 1, 0.03, 1);
! }
! if (parm->sliceGamma > 0) {
! sliceGray = pow(sliceGray, 1.0/parm->sliceGamma);
! } else {
! sliceGray = 1.0 - pow(sliceGray, -1.0/parm->sliceGamma);
}
+ /* make slice contribution */
if (glyphsLimn) {
! ri = limnObjSquareAdd(glyphsLimn, spi + 1);
ELL_4M_IDENTITY_SET(mA);
ell_4m_post_mul_f(mA, sRot);
***************
*** 292,296 ****
ell_4m_post_mul_f(mA, mB);
lglyph = glyphsLimn->r + ri;
! ELL_4V_SET(lglyph->rgba, sliceAniso, sliceAniso, sliceAniso, 1);
limnObjPartTransform(glyphsLimn, ri, mA);
}
--- 322,326 ----
ell_4m_post_mul_f(mA, mB);
lglyph = glyphsLimn->r + ri;
! ELL_4V_SET(lglyph->rgba, sliceGray, sliceGray, sliceGray, 1);
limnObjPartTransform(glyphsLimn, ri, mA);
}
***************
*** 300,308 ****
ELL_3V_COPY(((echoRectangle*)esquare)->edge0, edge0);
ELL_3V_COPY(((echoRectangle*)esquare)->edge1, edge1);
! echoColorSet(esquare, sliceAniso, sliceAniso, sliceAniso, 1);
echoMatterPhongSet(glyphsEcho, esquare, 1, 0, 0, 40);
echoListAdd(list, esquare);
}
}
if (!( aniso[parm->anisoType] >= parm->anisoThresh ))
continue;
--- 330,346 ----
ELL_3V_COPY(((echoRectangle*)esquare)->edge0, edge0);
ELL_3V_COPY(((echoRectangle*)esquare)->edge1, edge1);
! echoColorSet(esquare, sliceGray, sliceGray, sliceGray, 1);
echoMatterPhongSet(glyphsEcho, esquare, 1, 0, 0, 40);
echoListAdd(list, esquare);
}
}
+ if (parm->onlyPositive) {
+ if (eval[2] < 0) {
+ /* didn't have all positive eigenvalues, its outta here */
+ continue;
+ }
+ }
+ if (!( tdata[0] >= parm->confThresh ))
+ continue;
if (!( aniso[parm->anisoType] >= parm->anisoThresh ))
continue;
***************
*** 369,384 ****
switch(parm->glyphType) {
case tenGlyphTypeBox:
! ri = limnObjCubeAdd(glyphsLimn, si + 0);
break;
case tenGlyphTypeSphere:
! ri = limnObjPolarSphereAdd(glyphsLimn, si + 0, axis,
2*parm->facetRes, parm->facetRes);
break;
case tenGlyphTypeCylinder:
! ri = limnObjCylinderAdd(glyphsLimn, si + 0, axis, parm->facetRes);
break;
case tenGlyphTypeSuperquad:
default:
! ri = limnObjPolarSuperquadAdd(glyphsLimn, si + 0, axis, qA, qB,
2*parm->facetRes, parm->facetRes);
break;
--- 407,422 ----
switch(parm->glyphType) {
case tenGlyphTypeBox:
! ri = limnObjCubeAdd(glyphsLimn, spi + 0);
break;
case tenGlyphTypeSphere:
! ri = limnObjPolarSphereAdd(glyphsLimn, spi + 0, axis,
2*parm->facetRes, parm->facetRes);
break;
case tenGlyphTypeCylinder:
! ri = limnObjCylinderAdd(glyphsLimn, spi + 0, axis, parm->facetRes);
break;
case tenGlyphTypeSuperquad:
default:
! ri = limnObjPolarSuperquadAdd(glyphsLimn, spi + 0, axis, qA, qB,
2*parm->facetRes, parm->facetRes);
break;
Index: ten.h
===================================================================
RCS file: /cvsroot/teem/teem/src/ten/ten.h,v
retrieving revision 1.65
retrieving revision 1.66
diff -C2 -d -r1.65 -r1.66
*** ten.h 17 Nov 2003 07:10:43 -0000 1.65
--- ten.h 18 Nov 2003 10:04:54 -0000 1.66
***************
*** 125,132 ****
with glyphs, these are thresholded by confThresh and maskThresh
(but not anisoThresh). Things can be lightened up with a
! sliceAnisoGamma > 1. The squares will be at their corresponding
sample locations, but offset by sliceOffset */
int doSlice, sliceAxis, slicePos, sliceAnisoType;
! float sliceOffset, sliceAnisoGamma;
} tenGlyphParm;
--- 125,132 ----
with glyphs, these are thresholded by confThresh and maskThresh
(but not anisoThresh). Things can be lightened up with a
! sliceGamma > 1. The squares will be at their corresponding
sample locations, but offset by sliceOffset */
int doSlice, sliceAxis, slicePos, sliceAnisoType;
! float sliceOffset, sliceGamma;
} tenGlyphParm;
***************
*** 351,357 ****
extern tenGlyphParm *tenGlyphParmNew();
extern tenGlyphParm *tenGlyphParmNix(tenGlyphParm *parm);
! extern int tenGlyphParmCheck(tenGlyphParm *parm, Nrrd *nten, Nrrd *npos);
extern int tenGlyphGen(limnObj *glyphs, echoScene *scene,
! Nrrd *nten, Nrrd *npos, tenGlyphParm *parm);
/* tensor.c */
--- 351,359 ----
extern tenGlyphParm *tenGlyphParmNew();
extern tenGlyphParm *tenGlyphParmNix(tenGlyphParm *parm);
! extern int tenGlyphParmCheck(tenGlyphParm *parm,
! Nrrd *nten, Nrrd *npos, Nrrd *nslc);
extern int tenGlyphGen(limnObj *glyphs, echoScene *scene,
! tenGlyphParm *parm,
! Nrrd *nten, Nrrd *npos, Nrrd *nslc);
/* tensor.c */
Index: tendGlyph.c
===================================================================
RCS file: /cvsroot/teem/teem/src/ten/tendGlyph.c,v
retrieving revision 1.18
retrieving revision 1.19
diff -C2 -d -r1.18 -r1.19
*** tendGlyph.c 17 Nov 2003 15:15:06 -0000 1.18
--- tendGlyph.c 18 Nov 2003 10:04:55 -0000 1.19
***************
*** 42,46 ****
airArray *mop;
! Nrrd *nten, *emap, *nraw, *npos;
char *outS;
limnCamera *cam;
--- 42,46 ----
airArray *mop;
! Nrrd *nten, *emap, *nraw, *npos, *nslc;
char *outS;
limnCamera *cam;
***************
*** 152,155 ****
--- 152,159 ----
"and position along which to slice. Use \"-1 -1\" to signify "
"that no slice should be shown");
+ hestOptAdd(&hopt, "si", "slice image", airTypeOther, 1, 1, &nslc, "",
+ "Instead of showing a slice of the anisotropy used to cull "
+ "glyphs, show something else. ", NULL, NULL,
+ nrrdHestNrrd);
hestOptAdd(&hopt, "off", "slice offset", airTypeFloat, 1, 1,
&(gparm->sliceOffset), "0.0",
***************
*** 157,162 ****
"doesn't occlude glyphs).");
hestOptAdd(&hopt, "sg", "slice gamma", airTypeFloat, 1, 1,
! &(gparm->sliceAnisoGamma), "1.7",
! "Gamma to apply to anisotropy values on slice.");
/* camera */
--- 161,166 ----
"doesn't occlude glyphs).");
hestOptAdd(&hopt, "sg", "slice gamma", airTypeFloat, 1, 1,
! &(gparm->sliceGamma), "1.7",
! "Gamma to apply to values on slice.");
/* camera */
***************
*** 224,228 ****
if (tenGlyphGen(doRT ? NULL : glyph,
doRT ? scene : NULL,
! nten, npos, gparm)) {
airMopAdd(mop, err = biffGetDone(TEN), airFree, airMopAlways);
fprintf(stderr, "%s: trouble generating glyphs:\n%s\n", me, err);
--- 228,233 ----
if (tenGlyphGen(doRT ? NULL : glyph,
doRT ? scene : NULL,
! gparm,
! nten, npos, nslc)) {
airMopAdd(mop, err = biffGetDone(TEN), airFree, airMopAlways);
fprintf(stderr, "%s: trouble generating glyphs:\n%s\n", me, err);
|