From: Gordon K. <kin...@us...> - 2004-04-04 21:38:43
|
Update of /cvsroot/teem/teem/src/nrrd In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20500/nrrd Modified Files: apply1D.c nrrd.h Log Message: unused variable, better usage info Index: nrrd.h =================================================================== RCS file: /cvsroot/teem/teem/src/nrrd/nrrd.h,v retrieving revision 1.137 retrieving revision 1.138 diff -C2 -d -r1.137 -r1.138 *** nrrd.h 30 Mar 2004 19:25:09 -0000 1.137 --- nrrd.h 4 Apr 2004 21:26:11 -0000 1.138 *************** *** 711,717 **** --- 711,723 ---- const Nrrd *nin, const NrrdRange *range, const Nrrd *nlut, int typeOut, int rescale); + TEEM_API int nrrdApplyMulti1DLut(Nrrd *nout, const Nrrd *nin, + const NrrdRange *_range, const Nrrd *nmlut, + int typeOut, int rescale); TEEM_API int nrrdApply1DRegMap(Nrrd *nout, const Nrrd *nin, const NrrdRange *range, const Nrrd *nmap, int typeOut, int rescale); + TEEM_API int nrrdApplyMulti1DRegMap(Nrrd *nout, const Nrrd *nin, + const NrrdRange *_range, const Nrrd *nmmap, + int typeOut, int rescale); TEEM_API int nrrd1DIrregMapCheck(const Nrrd *nmap); TEEM_API int nrrd1DIrregAclGenerate(Nrrd *nacl, const Nrrd *nmap, int aclLen); Index: apply1D.c =================================================================== RCS file: /cvsroot/teem/teem/src/nrrd/apply1D.c,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** apply1D.c 27 Feb 2004 19:10:31 -0000 1.24 --- apply1D.c 4 Apr 2004 21:26:11 -0000 1.25 *************** *** 49,57 **** double ! _nrrdApply1DDomainMin(const Nrrd *nmap, int ramps) { double ret; - int mapAxis; - mapAxis = nmap->dim-1; ret = nmap->axis[mapAxis].min; ret = AIR_EXISTS(ret) ? ret : 0; --- 49,55 ---- double ! _nrrdApply1DDomainMin(const Nrrd *nmap, int ramps, int mapAxis) { double ret; ret = nmap->axis[mapAxis].min; ret = AIR_EXISTS(ret) ? ret : 0; *************** *** 60,68 **** double ! _nrrdApply1DDomainMax(const Nrrd *nmap, int ramps) { double ret; - int mapAxis; - mapAxis = nmap->dim-1; ret = nmap->axis[mapAxis].max; if (!AIR_EXISTS(ret)) { --- 58,64 ---- double ! _nrrdApply1DDomainMax(const Nrrd *nmap, int ramps, int mapAxis) { double ret; ret = nmap->axis[mapAxis].max; if (!AIR_EXISTS(ret)) { *************** *** 88,100 **** int _nrrdApply1DSetUp(Nrrd *nout, const Nrrd *nin, const NrrdRange *range, ! const Nrrd *nmap, int kind, int typeOut, int rescale) { char me[]="_nrrdApply1DSetUp", err[AIR_STRLEN_MED], *mapcnt; char nounStr[][AIR_STRLEN_SMALL]={"lut", "regular map", "irregular map"}; char verbStr[][AIR_STRLEN_SMALL]={"lut", "rmap", "imap"}; ! int mapAxis, size[NRRD_DIM_MAX], axisMap[NRRD_DIM_MAX], d, colLen; double domMin, domMax; --- 84,104 ---- int _nrrdApply1DSetUp(Nrrd *nout, const Nrrd *nin, const NrrdRange *range, ! const Nrrd *nmap, int kind, int typeOut, ! int rescale, int multi) { char me[]="_nrrdApply1DSetUp", err[AIR_STRLEN_MED], *mapcnt; char nounStr[][AIR_STRLEN_SMALL]={"lut", "regular map", "irregular map"}; + char mnounStr[][AIR_STRLEN_SMALL]={"multi lut", + "multi regular map", + "multi irregular map"}; + /* wishful thinking */ char verbStr[][AIR_STRLEN_SMALL]={"lut", "rmap", "imap"}; ! char mverbStr[][AIR_STRLEN_SMALL]={"mlut", ! "mrmap", ! "mimap"}; /* wishful thinking */ ! int mapAxis, ax, size[NRRD_DIM_MAX], axisMap[NRRD_DIM_MAX], d, colLen; double domMin, domMax; *************** *** 120,131 **** } if (kindLut == kind || kindRmap == kind) { ! mapAxis = nmap->dim - 1; ! if (!(0 == mapAxis || 1 == mapAxis)) { ! sprintf(err, "%s: dimension of %s should be 1 or 2, not %d", ! me, nounStr[kind], nmap->dim); ! biffAdd(NRRD, err); return 1; } ! domMin = _nrrdApply1DDomainMin(nmap, AIR_FALSE); ! domMax = _nrrdApply1DDomainMax(nmap, AIR_FALSE); if (!( domMin < domMax )) { sprintf(err, "%s: (axis %d) domain min (%g) not less than max (%g)", me, --- 124,155 ---- } if (kindLut == kind || kindRmap == kind) { ! if (!multi) { ! mapAxis = nmap->dim - 1; ! if (!(0 == mapAxis || 1 == mapAxis)) { ! sprintf(err, "%s: dimension of %s should be 1 or 2, not %d", ! me, nounStr[kind], nmap->dim); ! biffAdd(NRRD, err); return 1; ! } ! } else { ! mapAxis = nmap->dim - nin->dim - 1; ! if (!(0 == mapAxis || 1 == mapAxis)) { ! sprintf(err, "%s: dimension of %s should be %d or %d, not %d", ! me, mnounStr[kind], ! nin->dim + 1, nin->dim + 2, nmap->dim); ! biffAdd(NRRD, err); return 1; ! } ! /* need to make sure the relevant sizes match */ ! for (ax=0; ax<nin->dim; ax++) { ! if (nin->axis[ax].size != nmap->axis[mapAxis + 1 + ax].size) { ! sprintf(err, "%s: input and mmap don't have compatible sizes: " ! "nin->axis[%d].size (%d) != nmap->axis[%d].size (%d): ", ! me, ax, nin->axis[ax].size, ! mapAxis + 1 + ax, nmap->axis[mapAxis + 1 + ax].size); ! biffAdd(NRRD, err); return 1; ! } ! } } ! domMin = _nrrdApply1DDomainMin(nmap, AIR_FALSE, mapAxis); ! domMax = _nrrdApply1DDomainMax(nmap, AIR_FALSE, mapAxis); if (!( domMin < domMax )) { sprintf(err, "%s: (axis %d) domain min (%g) not less than max (%g)", me, *************** *** 135,143 **** if (nrrdHasNonExist(nmap)) { sprintf(err, "%s: %s nrrd has non-existent values", ! me, nounStr[kind]); biffAdd(NRRD, err); return 1; } colLen = mapAxis ? nmap->axis[0].size : 1; } else { /* its an irregular map */ if (nrrd1DIrregMapCheck(nmap)) { --- 159,171 ---- if (nrrdHasNonExist(nmap)) { sprintf(err, "%s: %s nrrd has non-existent values", ! me, multi ? mnounStr[kind] : nounStr[kind]); biffAdd(NRRD, err); return 1; } colLen = mapAxis ? nmap->axis[0].size : 1; } else { + if (multi) { + sprintf(err, "%s: sorry, multi irregular maps not implemented", me); + biffAdd(NRRD, err); return 1; + } /* its an irregular map */ if (nrrd1DIrregMapCheck(nmap)) { *************** *** 152,156 **** sprintf(err, "%s: input nrrd dim %d through non-scalar %s exceeds " "NRRD_DIM_MAX %d", ! me, nin->dim, nounStr[kind], NRRD_DIM_MAX); biffAdd(NRRD, err); return 1; } --- 180,185 ---- sprintf(err, "%s: input nrrd dim %d through non-scalar %s exceeds " "NRRD_DIM_MAX %d", ! me, nin->dim, ! multi ? mnounStr[kind] : nounStr[kind], NRRD_DIM_MAX); biffAdd(NRRD, err); return 1; } *************** *** 193,197 **** } mapcnt = _nrrdContentGet(nmap); ! if (nrrdContentSet(nout, verbStr[kind], nin, "%s", mapcnt)) { sprintf(err, "%s:", me); biffAdd(NRRD, err); free(mapcnt); return 1; --- 222,227 ---- } mapcnt = _nrrdContentGet(nmap); ! if (nrrdContentSet(nout, multi ? mverbStr[kind] : verbStr[kind], ! nin, "%s", mapcnt)) { sprintf(err, "%s:", me); biffAdd(NRRD, err); free(mapcnt); return 1; *************** *** 224,228 **** int _nrrdApply1DLutOrRegMap(Nrrd *nout, const Nrrd *nin, const NrrdRange *range, ! const Nrrd *nmap, int ramps, int rescale) { /* char me[]="_nrrdApply1DLutOrRegMap"; */ char *inData, *outData, *mapData, *entData0, *entData1; --- 254,258 ---- int _nrrdApply1DLutOrRegMap(Nrrd *nout, const Nrrd *nin, const NrrdRange *range, ! const Nrrd *nmap, int ramps, int rescale, int multi) { /* char me[]="_nrrdApply1DLutOrRegMap"; */ char *inData, *outData, *mapData, *entData0, *entData1; *************** *** 233,242 **** int i, mapAxis, mapLen, mapIdx, entSize, entLen, inSize, outSize; ! mapAxis = nmap->dim - 1; /* axis of nmap containing entries */ mapData = nmap->data; /* map data, as char* */ /* low end of map domain */ ! domMin = _nrrdApply1DDomainMin(nmap, ramps); /* high end of map domain */ ! domMax = _nrrdApply1DDomainMax(nmap, ramps); mapLen = nmap->axis[mapAxis].size; /* number of entries in map */ mapLup = nrrdDLookup[nmap->type]; /* how to get doubles out of map */ --- 263,276 ---- int i, mapAxis, mapLen, mapIdx, entSize, entLen, inSize, outSize; ! if (!multi) { ! mapAxis = nmap->dim - 1; /* axis of nmap containing entries */ ! } else { ! mapAxis = nmap->dim - nin->dim - 1; ! } mapData = nmap->data; /* map data, as char* */ /* low end of map domain */ ! domMin = _nrrdApply1DDomainMin(nmap, ramps, mapAxis); /* high end of map domain */ ! domMax = _nrrdApply1DDomainMax(nmap, ramps, mapAxis); mapLen = nmap->axis[mapAxis].size; /* number of entries in map */ mapLup = nrrdDLookup[nmap->type]; /* how to get doubles out of map */ *************** *** 291,294 **** --- 325,331 ---- inData += inSize; outData += outSize; + if (multi) { + mapData += mapLen*entSize; + } } } else { *************** *** 313,316 **** --- 350,356 ---- inData += inSize; outData += outSize; + if (multi) { + mapData += mapLen*entSize; + } } } *************** *** 356,361 **** } airMopAdd(mop, range, (airMopper)nrrdRangeNix, airMopAlways); ! if (_nrrdApply1DSetUp(nout, nin, range, nlut, kindLut, typeOut, rescale) ! || _nrrdApply1DLutOrRegMap(nout, nin, range, nlut, AIR_FALSE, rescale)) { sprintf(err, "%s:", me); biffAdd(NRRD, err); airMopError(mop); return 1; --- 396,434 ---- } airMopAdd(mop, range, (airMopper)nrrdRangeNix, airMopAlways); ! if (_nrrdApply1DSetUp(nout, nin, range, nlut, kindLut, typeOut, ! rescale, AIR_FALSE) ! || _nrrdApply1DLutOrRegMap(nout, nin, range, nlut, AIR_FALSE, ! rescale, AIR_FALSE)) { ! sprintf(err, "%s:", me); ! biffAdd(NRRD, err); airMopError(mop); return 1; ! } ! airMopOkay(mop); ! return 0; ! } ! ! int ! nrrdApplyMulti1DLut(Nrrd *nout, const Nrrd *nin, ! const NrrdRange *_range, const Nrrd *nmlut, ! int typeOut, int rescale) { ! char me[]="nrrdApplyMulti1DLut", err[AIR_STRLEN_MED]; ! NrrdRange *range; ! airArray *mop; ! ! if (!(nout && nmlut && nin)) { ! sprintf(err, "%s: got NULL pointer", me); ! biffAdd(NRRD, err); return 1; ! } ! mop = airMopNew(); ! if (_range) { ! range = nrrdRangeCopy(_range); ! nrrdRangeSafeSet(range, nin, nrrdBlind8BitRangeState); ! } else { ! range = nrrdRangeNewSet(nin, nrrdBlind8BitRangeState); ! } ! airMopAdd(mop, range, (airMopper)nrrdRangeNix, airMopAlways); ! if (_nrrdApply1DSetUp(nout, nin, range, nmlut, kindLut, typeOut, ! rescale, AIR_TRUE) ! || _nrrdApply1DLutOrRegMap(nout, nin, range, nmlut, AIR_FALSE, ! rescale, AIR_TRUE)) { sprintf(err, "%s:", me); biffAdd(NRRD, err); airMopError(mop); return 1; *************** *** 412,417 **** } airMopAdd(mop, range, (airMopper)nrrdRangeNix, airMopAlways); ! if (_nrrdApply1DSetUp(nout, nin, range, nmap, kindRmap, typeOut, rescale) ! || _nrrdApply1DLutOrRegMap(nout, nin, range, nmap, AIR_TRUE, rescale)) { sprintf(err, "%s:", me); biffAdd(NRRD, err); airMopError(mop); return 1; --- 485,523 ---- } airMopAdd(mop, range, (airMopper)nrrdRangeNix, airMopAlways); ! if (_nrrdApply1DSetUp(nout, nin, range, nmap, kindRmap, typeOut, ! rescale, AIR_FALSE) ! || _nrrdApply1DLutOrRegMap(nout, nin, range, nmap, AIR_TRUE, ! rescale, AIR_FALSE)) { ! sprintf(err, "%s:", me); ! biffAdd(NRRD, err); airMopError(mop); return 1; ! } ! airMopOkay(mop); ! return 0; ! } ! ! int ! nrrdApplyMulti1DRegMap(Nrrd *nout, const Nrrd *nin, ! const NrrdRange *_range, const Nrrd *nmmap, ! int typeOut, int rescale) { ! char me[]="nrrdApplyMulti1DRegMap", err[AIR_STRLEN_MED]; ! NrrdRange *range; ! airArray *mop; ! ! if (!(nout && nmmap && nin)) { ! sprintf(err, "%s: got NULL pointer", me); ! biffAdd(NRRD, err); return 1; ! } ! mop = airMopNew(); ! if (_range) { ! range = nrrdRangeCopy(_range); ! nrrdRangeSafeSet(range, nin, nrrdBlind8BitRangeState); ! } else { ! range = nrrdRangeNewSet(nin, nrrdBlind8BitRangeState); ! } ! airMopAdd(mop, range, (airMopper)nrrdRangeNix, airMopAlways); ! if (_nrrdApply1DSetUp(nout, nin, range, nmmap, kindRmap, typeOut, ! rescale, AIR_TRUE) ! || _nrrdApply1DLutOrRegMap(nout, nin, range, nmmap, AIR_TRUE, ! rescale, AIR_TRUE)) { sprintf(err, "%s:", me); biffAdd(NRRD, err); airMopError(mop); return 1; *************** *** 734,738 **** airMopAdd(mop, range, (airMopper)nrrdRangeNix, airMopAlways); if (_nrrdApply1DSetUp(nout, nin, range, nmap, ! kindImap, typeOut, rescale)) { sprintf(err, "%s:", me); biffAdd(NRRD, err); airMopError(mop); return 1; --- 840,844 ---- airMopAdd(mop, range, (airMopper)nrrdRangeNix, airMopAlways); if (_nrrdApply1DSetUp(nout, nin, range, nmap, ! kindImap, typeOut, rescale, AIR_FALSE)) { sprintf(err, "%s:", me); biffAdd(NRRD, err); airMopError(mop); return 1; |