|
From: <kin...@us...> - 2023-07-16 02:37:08
|
Revision: 7118
http://sourceforge.net/p/teem/code/7118
Author: kindlmann
Date: 2023-07-16 02:37:05 +0000 (Sun, 16 Jul 2023)
Log Message:
-----------
more use of existing AIR_INT(_) == AIR_CAST(int, _)
Modified Paths:
--------------
teem/trunk/src/hest/methodsHest.c
teem/trunk/src/nrrd/cc.c
teem/trunk/src/nrrd/encodingAscii.c
teem/trunk/src/nrrd/formatPNM.c
teem/trunk/src/nrrd/formatText.c
teem/trunk/src/nrrd/resampleContext.c
teem/trunk/src/nrrd/resampleNrrd.c
teem/trunk/src/nrrd/write.c
teem/trunk/src/ten/epireg.c
teem/trunk/src/ten/fiberMethods.c
teem/trunk/src/ten/tenModel.c
teem/trunk/src/ten/tendEllipse.c
teem/trunk/src/ten/tendFiber.c
teem/trunk/src/ten/tendFlotsam.c
teem/trunk/src/ten/tendPoint.c
Modified: teem/trunk/src/hest/methodsHest.c
===================================================================
--- teem/trunk/src/hest/methodsHest.c 2023-07-16 02:29:25 UTC (rev 7117)
+++ teem/trunk/src/hest/methodsHest.c 2023-07-16 02:37:05 UTC (rev 7118)
@@ -100,7 +100,7 @@
int max;
max = _hestMax(_max);
- if (!(AIR_CAST(int, min) <= max)) {
+ if (!(AIR_INT(min) <= max)) {
/* invalid */
return -1;
}
@@ -115,7 +115,7 @@
return 2;
}
- if (2 <= min && 2 <= max && AIR_CAST(int, min) == max) {
+ if (2 <= min && 2 <= max && AIR_INT(min) == max) {
/* multiple fixed parameters */
return 3;
}
Modified: teem/trunk/src/nrrd/cc.c
===================================================================
--- teem/trunk/src/nrrd/cc.c 2023-07-16 02:29:25 UTC (rev 7117)
+++ teem/trunk/src/nrrd/cc.c 2023-07-16 02:37:05 UTC (rev 7118)
@@ -84,13 +84,13 @@
sx = AIR_UINT(nin->axis[0].size);
sy = AIR_UINT(nin->axis[1].size);
#define GETV_2(x, y) \
- ((AIR_IN_CL(0, AIR_CAST(int, x), AIR_CAST(int, sx - 1)) \
- && AIR_IN_CL(0, AIR_CAST(int, y), AIR_CAST(int, sy - 1))) \
+ ((AIR_IN_CL(0, AIR_INT(x), AIR_INT(sx - 1)) \
+ && AIR_IN_CL(0, AIR_INT(y), AIR_INT(sy - 1))) \
? lup(nin->data, (x) + sx * (y)) \
: 0.5) /* value that can't come from an array of uints */
#define GETI_2(x, y) \
- ((AIR_IN_CL(0, AIR_CAST(int, x), AIR_CAST(int, sx - 1)) \
- && AIR_IN_CL(0, AIR_CAST(int, y), AIR_CAST(int, sy - 1))) \
+ ((AIR_IN_CL(0, AIR_INT(x), AIR_INT(sx - 1)) \
+ && AIR_IN_CL(0, AIR_INT(y), AIR_INT(sy - 1))) \
? out[(x) + sx * (y)] \
: AIR_UINT(-1)) /* CC index (probably!) never assigned */
@@ -178,15 +178,15 @@
sy = AIR_UINT(nin->axis[1].size);
sz = AIR_UINT(nin->axis[2].size);
#define GETV_3(x, y, z) \
- ((AIR_IN_CL(0, AIR_CAST(int, x), AIR_CAST(int, sx - 1)) \
- && AIR_IN_CL(0, AIR_CAST(int, y), AIR_CAST(int, sy - 1)) \
- && AIR_IN_CL(0, AIR_CAST(int, z), AIR_CAST(int, sz - 1))) \
+ ((AIR_IN_CL(0, AIR_INT(x), AIR_INT(sx - 1)) \
+ && AIR_IN_CL(0, AIR_INT(y), AIR_INT(sy - 1)) \
+ && AIR_IN_CL(0, AIR_INT(z), AIR_INT(sz - 1))) \
? lup(nin->data, (x) + sx * ((y) + sy * (z))) \
: 0.5)
#define GETI_3(x, y, z) \
- ((AIR_IN_CL(0, AIR_CAST(int, x), AIR_CAST(int, sx - 1)) \
- && AIR_IN_CL(0, AIR_CAST(int, y), AIR_CAST(int, sy - 1)) \
- && AIR_IN_CL(0, AIR_CAST(int, z), AIR_CAST(int, sz - 1))) \
+ ((AIR_IN_CL(0, AIR_INT(x), AIR_INT(sx - 1)) \
+ && AIR_IN_CL(0, AIR_INT(y), AIR_INT(sy - 1)) \
+ && AIR_IN_CL(0, AIR_INT(z), AIR_INT(sz - 1))) \
? out[(x) + sx * ((y) + sy * (z))] \
: AIR_UINT(-1))
@@ -751,7 +751,7 @@
if (j == _i) {
continue; /* we had no neighbors ?!?! */
}
- if (valDir && (AIR_CAST(int, val[bigi]) - AIR_CAST(int, val[i])) * valDir < 0) {
+ if (valDir && (AIR_INT(val[bigi]) - AIR_INT(val[i])) * valDir < 0) {
continue;
}
/* else all criteria for merging have been met */
Modified: teem/trunk/src/nrrd/encodingAscii.c
===================================================================
--- teem/trunk/src/nrrd/encodingAscii.c 2023-07-16 02:29:25 UTC (rev 7117)
+++ teem/trunk/src/nrrd/encodingAscii.c 2023-07-16 02:37:05 UTC (rev 7118)
@@ -133,7 +133,7 @@
fprintf(file, "%s\n", buff);
newlined = AIR_TRUE;
} else if (nrrd->dim == 2 && nrrd->axis[0].size <= nio->valsPerLine) {
- int nonewline = AIR_CAST(int, (I + 1) % (nrrd->axis[0].size));
+ int nonewline = AIR_INT((I + 1) % (nrrd->axis[0].size));
fprintf(file, "%s%c", buff, nonewline ? ' ' : '\n');
newlined = !nonewline;
} else {
Modified: teem/trunk/src/nrrd/formatPNM.c
===================================================================
--- teem/trunk/src/nrrd/formatPNM.c 2023-07-16 02:29:25 UTC (rev 7117)
+++ teem/trunk/src/nrrd/formatPNM.c 2023-07-16 02:37:05 UTC (rev 7118)
@@ -295,12 +295,12 @@
color = (3 == nrrd->dim);
if (!color) {
magic = (nrrdEncodingAscii == nio->encoding ? 2 : 5);
- sx = AIR_CAST(int, nrrd->axis[0].size);
- sy = AIR_CAST(int, nrrd->axis[1].size);
+ sx = AIR_INT(nrrd->axis[0].size);
+ sy = AIR_INT(nrrd->axis[1].size);
} else {
magic = (nrrdEncodingAscii == nio->encoding ? 3 : 6);
- sx = AIR_CAST(int, nrrd->axis[1].size);
- sy = AIR_CAST(int, nrrd->axis[2].size);
+ sx = AIR_INT(nrrd->axis[1].size);
+ sy = AIR_INT(nrrd->axis[2].size);
}
fprintf(file, "P%d\n", magic);
Modified: teem/trunk/src/nrrd/formatText.c
===================================================================
--- teem/trunk/src/nrrd/formatText.c 2023-07-16 02:29:25 UTC (rev 7117)
+++ teem/trunk/src/nrrd/formatText.c 2023-07-16 02:37:05 UTC (rev 7118)
@@ -97,7 +97,7 @@
/* first, we get through comments */
while (NRRD_COMMENT_CHAR == nio->line[0]) {
nio->pos = 1;
- nio->pos += AIR_CAST(int, strspn(nio->line + nio->pos, _nrrdFieldSep));
+ nio->pos += AIR_INT(strspn(nio->line + nio->pos, _nrrdFieldSep));
fidx = _nrrdReadNrrdParseField(nio, AIR_FALSE);
/* could we parse anything? */
if (!fidx) {
@@ -319,7 +319,7 @@
_nrrdFormatText_write(FILE *file, const Nrrd *nrrd, NrrdIoState *nio) {
char cmt[AIR_STRLEN_SMALL + 1], buff[AIR_STRLEN_SMALL + 1];
size_t I, dsz;
- int i, x, y, sx, sy;
+ int i, x, y, sx, sy; /* HEY unsigned? */
const void *data;
const char *cdata;
float val;
@@ -355,10 +355,10 @@
if (1 == nrrd->dim) {
sx = 1;
- sy = AIR_CAST(int, nrrd->axis[0].size);
+ sy = AIR_INT(nrrd->axis[0].size);
} else {
- sx = AIR_CAST(int, nrrd->axis[0].size);
- sy = AIR_CAST(int, nrrd->axis[1].size);
+ sx = AIR_INT(nrrd->axis[0].size);
+ sy = AIR_INT(nrrd->axis[1].size);
}
data = nrrd->data;
cdata = (const char *)nrrd->data;
Modified: teem/trunk/src/nrrd/resampleContext.c
===================================================================
--- teem/trunk/src/nrrd/resampleContext.c 2023-07-16 02:29:25 UTC (rev 7117)
+++ teem/trunk/src/nrrd/resampleContext.c 2023-07-16 02:37:05 UTC (rev 7118)
@@ -765,7 +765,7 @@
/* figure out what to do with the out-of-range indices */
for (dotIdx = 0; dotIdx < dotLen * axis->samples; dotIdx++) {
rawIdx = indexData[dotIdx];
- if (!AIR_IN_CL(0, rawIdx, AIR_CAST(int, axis->sizeIn) - 1)) {
+ if (!AIR_IN_CL(0, rawIdx, AIR_INT(axis->sizeIn) - 1)) {
switch (rsmc->boundary) {
case nrrdBoundaryPad:
case nrrdBoundaryWeight: /* this will be further handled later */
Modified: teem/trunk/src/nrrd/resampleNrrd.c
===================================================================
--- teem/trunk/src/nrrd/resampleNrrd.c 2023-07-16 02:29:25 UTC (rev 7117)
+++ teem/trunk/src/nrrd/resampleNrrd.c 2023-07-16 02:37:05 UTC (rev 7118)
@@ -308,8 +308,8 @@
}
center = _nrrdCenter(nin->axis[ai].center);
- sizeIn = AIR_CAST(int, nin->axis[ai].size);
- sizeOut = AIR_CAST(int, info->samples[ai]);
+ sizeIn = AIR_INT(nin->axis[ai].size);
+ sizeOut = AIR_INT(info->samples[ai]);
minIn = AIR_CAST(nrrdResample_t, nin->axis[ai].min);
maxIn = AIR_CAST(nrrdResample_t, nin->axis[ai].max);
minOut = AIR_CAST(nrrdResample_t, info->min[ai]);
@@ -680,8 +680,8 @@
numLines *= sz[pi][ai];
}
}
- sizeIn = AIR_CAST(int, sz[pi][topRax]);
- sizeOut = AIR_CAST(int, sz[pi + 1][botRax]);
+ sizeIn = AIR_INT(sz[pi][topRax]);
+ sizeOut = AIR_INT(sz[pi + 1][botRax]);
numOut = numLines * sizeOut;
/* for the rest of the loop body, d is the original "dimension"
for the axis being resampled */
Modified: teem/trunk/src/nrrd/write.c
===================================================================
--- teem/trunk/src/nrrd/write.c 2023-07-16 02:29:25 UTC (rev 7117)
+++ teem/trunk/src/nrrd/write.c 2023-07-16 02:37:05 UTC (rev 7118)
@@ -168,11 +168,11 @@
break;
case nrrdIoStateCharsPerLine:
/* HEY: this cast is a bad because nio->charsPerLine is unsigned */
- value = AIR_CAST(int, nio->charsPerLine);
+ value = AIR_INT(nio->charsPerLine);
break;
case nrrdIoStateValsPerLine:
/* HEY: this cast is a bad because nio->valsPerLine is unsigned */
- value = AIR_CAST(int, nio->valsPerLine);
+ value = AIR_INT(nio->valsPerLine);
break;
case nrrdIoStateSkipData:
value = !!nio->skipData;
Modified: teem/trunk/src/ten/epireg.c
===================================================================
--- teem/trunk/src/ten/epireg.c 2023-07-16 02:29:25 UTC (rev 7117)
+++ teem/trunk/src/ten/epireg.c 2023-07-16 02:37:05 UTC (rev 7118)
@@ -944,7 +944,7 @@
pf = pp - pb;
for (pi = 0; pi < 2 * supp; pi++) {
/* HEY GLK confused about signed-ness of this */
- idx[pi] = AIR_CAST(int, AIR_MIN(pb + pi - (supp - 1), sy - 1));
+ idx[pi] = AIR_INT(AIR_MIN(pb + pi - (supp - 1), sy - 1));
wght[pi] = pi - (supp - 1) - pf;
}
idx += 2 * supp;
Modified: teem/trunk/src/ten/fiberMethods.c
===================================================================
--- teem/trunk/src/ten/fiberMethods.c 2023-07-16 02:29:25 UTC (rev 7117)
+++ teem/trunk/src/ten/fiberMethods.c 2023-07-16 02:37:05 UTC (rev 7118)
@@ -777,7 +777,7 @@
tfx->wPunct = val;
break;
case tenFiberParmVerbose:
- tfx->verbose = AIR_CAST(int, val);
+ tfx->verbose = AIR_INT(val);
break;
default:
fprintf(stderr, "%s: WARNING!!! tenFiberParm %d not handled\n", me, parm);
Modified: teem/trunk/src/ten/tenModel.c
===================================================================
--- teem/trunk/src/ten/tenModel.c 2023-07-16 02:29:25 UTC (rev 7117)
+++ teem/trunk/src/ten/tenModel.c 2023-07-16 02:37:05 UTC (rev 7118)
@@ -275,7 +275,7 @@
/* allocate output (and set axmap) */
for (ii = 0; ii < nparm->dim; ii++) {
szOut[ii] = (!ii ? espec->imgNum : nparm->axis[ii].size);
- axmap[ii] = (!ii ? -1 : AIR_CAST(int, ii));
+ axmap[ii] = (!ii ? -1 : AIR_INT(ii));
}
if (nrrdMaybeAlloc_nva(ndwi, typeOut, nparm->dim, szOut)) {
biffMovef(TEN, NRRD, "%s: couldn't allocate output", me);
@@ -460,9 +460,9 @@
saveParmNum = saveB0 ? model->parmNum : model->parmNum - 1;
for (ii = 0; ii < ndwi->dim; ii++) {
szOut[ii] = (!ii ? saveParmNum : ndwi->axis[ii].size);
- axmap[ii] = (!ii ? -1 : AIR_CAST(int, ii));
+ axmap[ii] = (!ii ? -1 : AIR_INT(ii));
if (ii) {
- erraxmap[ii - 1] = AIR_CAST(int, ii);
+ erraxmap[ii - 1] = AIR_INT(ii);
}
}
if (nrrdMaybeAlloc_nva(nparm, typeOut, ndwi->dim, szOut)) {
@@ -730,7 +730,7 @@
parmNumSrc = AIR_UINT(nparmSrc->axis[0].size);
for (ii = 0; ii < nparmSrc->dim; ii++) {
szOut[ii] = (!ii ? parmNumDst : nparmSrc->axis[ii].size);
- axmap[ii] = (!ii ? -1 : AIR_CAST(int, ii));
+ axmap[ii] = (!ii ? -1 : AIR_INT(ii));
}
if (nrrdMaybeAlloc_nva(nparmDst, nparmSrc->type, nparmSrc->dim, szOut)) {
biffMovef(TEN, NRRD, "%s: couldn't allocate output", me);
Modified: teem/trunk/src/ten/tendEllipse.c
===================================================================
--- teem/trunk/src/ten/tendEllipse.c 2023-07-16 02:29:25 UTC (rev 7117)
+++ teem/trunk/src/ten/tendEllipse.c 2023-07-16 02:37:05 UTC (rev 7118)
@@ -73,9 +73,8 @@
fprintf(file, "%%%%Creator: tend ellipse\n");
fprintf(file, "%%%%Title: blah blah blah\n");
fprintf(file, "%%%%Pages: 1\n");
- fprintf(file, "%%%%BoundingBox: %d %d %d %d\n", AIR_CAST(int, floor(minX)),
- AIR_CAST(int, floor(minY)), AIR_CAST(int, ceil(maxX)),
- AIR_CAST(int, ceil(maxY)));
+ fprintf(file, "%%%%BoundingBox: %d %d %d %d\n", AIR_INT(floor(minX)),
+ AIR_INT(floor(minY)), AIR_INT(ceil(maxX)), AIR_INT(ceil(maxY)));
fprintf(file, "%%%%HiResBoundingBox: %g %g %g %g\n", minX, minY, maxX, maxY);
fprintf(file, "%%%%EndComments\n");
fprintf(file, "%%%%BeginProlog\n");
@@ -103,8 +102,8 @@
py = AIR_AFFINE(min[1], pdata[1], max[1], maxY, minY);
pdata += 2;
} else {
- x = AIR_CAST(int, ti % sx); /* HEY unsigned? */
- y = AIR_CAST(int, ti / sx);
+ x = AIR_INT(ti % sx); /* HEY unsigned? */
+ y = AIR_INT(ti / sx);
px = NRRD_CELL_POS(minX, maxX, sx, x);
py = NRRD_CELL_POS(minY, maxY, sy, sy - 1 - y);
}
@@ -147,8 +146,8 @@
py = AIR_AFFINE(min[1], pdata[1], max[1], maxY, minY);
pdata += 2;
} else {
- x = AIR_CAST(int, ti % sx); /* HEY unsigned? */
- y = AIR_CAST(int, ti / sx);
+ x = AIR_INT(ti % sx); /* HEY unsigned? */
+ y = AIR_INT(ti / sx);
px = NRRD_CELL_POS(minX, maxX, sx, x);
py = NRRD_CELL_POS(minY, maxY, sy, sy - 1 - y);
}
Modified: teem/trunk/src/ten/tendFiber.c
===================================================================
--- teem/trunk/src/ten/tendFiber.c 2023-07-16 02:29:25 UTC (rev 7117)
+++ teem/trunk/src/ten/tendFiber.c 2023-07-16 02:37:05 UTC (rev 7118)
@@ -152,10 +152,10 @@
E = 0;
for (si = 0, stop = _stop; si < stopLen; si++, stop += 3) {
int istop; /* not from Apple */
- istop = AIR_CAST(int, stop[0]);
+ istop = AIR_INT(stop[0]);
switch (istop) {
case tenFiberStopAniso:
- if (!E) E |= tenFiberStopSet(tfx, istop, AIR_CAST(int, stop[1]), stop[2]);
+ if (!E) E |= tenFiberStopSet(tfx, istop, AIR_INT(stop[1]), stop[2]);
break;
case tenFiberStopNumSteps:
case tenFiberStopMinNumSteps:
Modified: teem/trunk/src/ten/tendFlotsam.c
===================================================================
--- teem/trunk/src/ten/tendFlotsam.c 2023-07-16 02:29:25 UTC (rev 7117)
+++ teem/trunk/src/ten/tendFlotsam.c 2023-07-16 02:37:05 UTC (rev 7118)
@@ -68,13 +68,13 @@
}
*opt = '\0';
opt++;
- info[0] = AIR_CAST(int, airEnumVal(tenFiberStop, str));
- if (tenFiberStopUnknown == AIR_CAST(int, info[0])) {
+ info[0] = AIR_INT(airEnumVal(tenFiberStop, str));
+ if (tenFiberStopUnknown == AIR_INT(info[0])) {
sprintf(err, "%s: didn't recognize \"%s\" as %s", me, str, tenFiberStop->name);
airMopError(mop);
return 1;
}
- switch (AIR_CAST(int, info[0])) {
+ switch (AIR_INT(info[0])) {
case tenFiberStopAniso:
/* <aniso>,<level> : tenAniso,double */
opt2 = strchr(opt, ',');
@@ -85,8 +85,8 @@
}
*opt2 = '\0';
opt2++;
- info[1] = AIR_CAST(int, airEnumVal(tenAniso, opt));
- if (tenAnisoUnknown == AIR_CAST(int, info[1])) {
+ info[1] = AIR_INT(airEnumVal(tenAniso, opt));
+ if (tenAnisoUnknown == AIR_INT(info[1])) {
sprintf(err, "%s: didn't recognize \"%s\" as %s", me, opt, tenAniso->name);
airMopError(mop);
return 1;
@@ -98,7 +98,7 @@
}
/*
fprintf(stderr, "!%s: parsed aniso:%s,%g\n", me,
- airEnumStr(tenAniso, AIR_CAST(int, info[1])), info[2]);
+ airEnumStr(tenAniso, AIR_INT(info[1])), info[2]);
*/
break;
case tenFiberStopFraction:
@@ -109,13 +109,13 @@
/* all of these take a single double */
if (1 != sscanf(opt, "%lg", info + 1)) {
sprintf(err, "%s: couldn't parse %s \"%s\" as double", me,
- airEnumStr(tenFiberStop, AIR_CAST(int, info[0])), opt);
+ airEnumStr(tenFiberStop, AIR_INT(info[0])), opt);
airMopError(mop);
return 1;
}
/*
fprintf(stderr, "!%s: parse %s:%g\n", me,
- airEnumStr(tenFiberStop, AIR_CAST(int, info[0])),
+ airEnumStr(tenFiberStop, AIR_INT(info[0])),
info[1]);
*/
break;
@@ -134,7 +134,7 @@
/* moron */
break;
default:
- sprintf(err, "%s: stop method %d not supported", me, AIR_CAST(int, info[0]));
+ sprintf(err, "%s: stop method %d not supported", me, AIR_INT(info[0]));
airMopError(mop);
return 1;
break;
Modified: teem/trunk/src/ten/tendPoint.c
===================================================================
--- teem/trunk/src/ten/tendPoint.c 2023-07-16 02:29:25 UTC (rev 7117)
+++ teem/trunk/src/ten/tendPoint.c 2023-07-16 02:37:05 UTC (rev 7118)
@@ -53,9 +53,9 @@
airMopError(mop);
return 1;
}
- sx = AIR_CAST(int, nin->axis[1].size); /* HEY: unsigned? */
- sy = AIR_CAST(int, nin->axis[2].size);
- sz = AIR_CAST(int, nin->axis[3].size);
+ sx = AIR_INT(nin->axis[1].size); /* HEY: unsigned? */
+ sy = AIR_INT(nin->axis[2].size);
+ sz = AIR_INT(nin->axis[3].size);
if (!(AIR_IN_CL(0, loc[0], sx - 1) && AIR_IN_CL(0, loc[1], sy - 1)
&& AIR_IN_CL(0, loc[2], sz - 1))) {
fprintf(stderr,
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|