|
From: <kin...@us...> - 2023-07-08 11:33:08
|
Revision: 7052
http://sourceforge.net/p/teem/code/7052
Author: kindlmann
Date: 2023-07-08 11:33:02 +0000 (Sat, 08 Jul 2023)
Log Message:
-----------
Propagating AIR_STRLEN --> AIR_STRLEN+1, with this API CHANGE to function:
int meetPullVolLeechable(const meetPullVol *lchr,
const meetPullVol *orig,
int *can,
char explain[AIR_STRLEN_HUGE + 1]);
Modified Paths:
--------------
teem/trunk/src/meet/enumall.c
teem/trunk/src/meet/meet.h
teem/trunk/src/meet/meetGage.c
teem/trunk/src/meet/meetPull.c
teem/trunk/src/meet/test/strace.c
Modified: teem/trunk/src/meet/enumall.c
===================================================================
--- teem/trunk/src/meet/enumall.c 2023-07-08 11:27:11 UTC (rev 7051)
+++ teem/trunk/src/meet/enumall.c 2023-07-08 11:33:02 UTC (rev 7052)
@@ -226,7 +226,7 @@
meetAirEnumAllCheck(void) {
static const char me[] = "meetAirEnumAllCheck";
const airEnum **enm, *ee;
- char err[AIR_STRLEN_LARGE];
+ char err[AIR_STRLEN_LARGE + 1];
unsigned int ei;
airArray *mop;
Modified: teem/trunk/src/meet/meet.h
===================================================================
--- teem/trunk/src/meet/meet.h 2023-07-08 11:27:11 UTC (rev 7051)
+++ teem/trunk/src/meet/meet.h 2023-07-08 11:33:02 UTC (rev 7052)
@@ -163,7 +163,7 @@
MEET_EXPORT int meetPullVolLeechable(const meetPullVol *lchr,
const meetPullVol *orig,
int *can,
- char explain[AIR_STRLEN_HUGE]);
+ char explain[AIR_STRLEN_HUGE + 1]);
MEET_EXPORT meetPullVol *meetPullVolNix(meetPullVol *pvol);
MEET_EXPORT const hestCB *const meetHestPullVol;
MEET_EXPORT int meetPullVolStackBlurParmFinishMulti(meetPullVol **mpv,
Modified: teem/trunk/src/meet/meetGage.c
===================================================================
--- teem/trunk/src/meet/meetGage.c 2023-07-08 11:27:11 UTC (rev 7051)
+++ teem/trunk/src/meet/meetGage.c 2023-07-08 11:33:02 UTC (rev 7052)
@@ -67,7 +67,7 @@
** which isn't const
*/
static int
-_meetHestConstGageKindParse(void *ptr, const char *str, char err[AIR_STRLEN_HUGE]) {
+_meetHestConstGageKindParse(void *ptr, const char *str, char err[AIR_STRLEN_HUGE + 1]) {
static const char me[] = "_meetHestGageConstKindParse";
const gageKind **kindP;
@@ -89,7 +89,7 @@
}
static int
-_meetHestGageKindParse(void *ptr, const char *str, char err[AIR_STRLEN_HUGE]) {
+_meetHestGageKindParse(void *ptr, const char *str, char err[AIR_STRLEN_HUGE + 1]) {
static const char me[] = "_meetHestGageKindParse";
gageKind **kindP;
Modified: teem/trunk/src/meet/meetPull.c
===================================================================
--- teem/trunk/src/meet/meetPull.c 2023-07-08 11:27:11 UTC (rev 7051)
+++ teem/trunk/src/meet/meetPull.c 2023-07-08 11:33:02 UTC (rev 7052)
@@ -235,7 +235,7 @@
}
static int
-meetHestPullVolParse(void *ptr, const char *str, char err[AIR_STRLEN_HUGE]) {
+meetHestPullVolParse(void *ptr, const char *str, char err[AIR_STRLEN_HUGE + 1]) {
static const char me[] = "meetHestPullVolParse";
meetPullVol *mpv, **mpvP;
airArray *mop;
@@ -252,7 +252,7 @@
if (meetPullVolParse(mpv, str)) {
char *ler;
airMopAdd(mop, ler = biffGetDone(MEET), airFree, airMopOnError);
- airStrcpy(err, AIR_STRLEN_HUGE, ler);
+ airStrcpy(err, AIR_STRLEN_HUGE + 1, ler);
airMopError(mop);
return 1;
}
@@ -306,15 +306,15 @@
******** meetPullVolLeechable
**
** indicates whether lchr can leech from orig (saved in *can), and if not,
-** explanation is saved in explain (if non-NULL). explain is size AIR_STRLEN_HUGE
+** explanation is saved in explain (if non-NULL). explain is size AIR_STRLEN_HUGE+1
** because it has to contain the subexplain from gageStackBlurParmCompare, which
-** is size AIR_STRLEN_LARGE (noted thanks to a gcc warning)
+** is size AIR_STRLEN_LARGE+1 (noted thanks to a gcc warning)
*/
int /* Biff: 1 */
meetPullVolLeechable(const meetPullVol *lchr, const meetPullVol *orig, int *can,
- char explain[AIR_STRLEN_HUGE]) {
+ char explain[AIR_STRLEN_HUGE + 1]) {
static const char me[] = "meetPullVolLeechable";
- char subexplain[AIR_STRLEN_LARGE];
+ char subexplain[AIR_STRLEN_LARGE + 1];
if (!(lchr && orig && can)) {
biffAddf(MEET, "%s: got NULL pointer (%p %p %p)", me, (const void *)lchr,
@@ -484,7 +484,7 @@
for (mpvIdx = 0; mpvIdx < mpvNum; mpvIdx++) {
unsigned int pvi;
int leechable;
- char explain[AIR_STRLEN_HUGE];
+ char explain[AIR_STRLEN_HUGE + 1];
vol = mpv[mpvIdx];
for (pvi = 0; pvi < mpvIdx; pvi++) {
if (meetPullVolLeechable(vol, mpv[pvi], &leechable, explain)) {
@@ -521,7 +521,7 @@
return 1;
}
if (vol->sbp) {
- char formatSS[AIR_STRLEN_LARGE];
+ char formatSS[AIR_STRLEN_LARGE + 1];
sprintf(formatSS, "%s/%s-%%03u-%03u.nrrd", cachePath, vol->volName, vol->sbp->num);
if (verbose) {
fprintf(stderr, "%s: managing %s ... \n", me, formatSS);
@@ -730,7 +730,7 @@
}
static int
-meetHestPullInfoParse(void *ptr, const char *str, char err[AIR_STRLEN_HUGE]) {
+meetHestPullInfoParse(void *ptr, const char *str, char err[AIR_STRLEN_HUGE + 1]) {
static const char me[] = "meetHestPullInfoParse";
airArray *mop;
meetPullInfo **minfP, *minf;
@@ -747,7 +747,7 @@
if (meetPullInfoParse(minf, str)) {
char *ler;
airMopAdd(mop, ler = biffGetDone(MEET), airFree, airMopOnError);
- airStrcpy(err, AIR_STRLEN_HUGE, ler);
+ airStrcpy(err, AIR_STRLEN_HUGE + 1, ler);
airMopError(mop);
return 1;
}
Modified: teem/trunk/src/meet/test/strace.c
===================================================================
--- teem/trunk/src/meet/test/strace.c 2023-07-08 11:27:11 UTC (rev 7051)
+++ teem/trunk/src/meet/test/strace.c 2023-07-08 11:33:02 UTC (rev 7052)
@@ -32,16 +32,12 @@
*/
int
-findAndTraceMorePoints(Nrrd *nplot,
- pullContext *pctx, pullVolume *scaleVol,
- int strengthUse,
- int smooth, int flatWght,
- double scaleStep, double scaleHalfLen,
- double orientTestLen,
- unsigned int traceArrIncr,
- pullTraceMulti *mtrc,
+findAndTraceMorePoints(Nrrd *nplot, pullContext *pctx, pullVolume *scaleVol,
+ int strengthUse, int smooth, int flatWght, double scaleStep,
+ double scaleHalfLen, double orientTestLen,
+ unsigned int traceArrIncr, pullTraceMulti *mtrc,
unsigned int pointNum) {
- static const char me[]="findAndTraceMorePoints";
+ static const char me[] = "findAndTraceMorePoints";
unsigned int pointsSoFar, idtagBase, pidx, addedNum;
pullTrace *trace;
pullPoint *point;
@@ -48,29 +44,29 @@
Nrrd *nPosOut;
airArray *mop;
double *pos;
- char doneStr[AIR_STRLEN_SMALL];
+ char doneStr[AIR_STRLEN_SMALL + 1];
mop = airMopNew();
pointsSoFar = pullPointNumber(pctx);
idtagBase = pctx->idtagNext;
point = NULL;
- printf("%s: adding %u new points (to %u; %s) . . . ",
- me, pointNum, pointsSoFar,
+ printf("%s: adding %u new points (to %u; %s) . . . ", me, pointNum, pointsSoFar,
airPrettySprintSize_t(doneStr, pullTraceMultiSizeof(mtrc)));
- for (pidx=0; pidx<pointNum; pidx++) {
- printf("%s", airDoneStr(0, pidx, pointNum, doneStr)); fflush(stdout);
+ for (pidx = 0; pidx < pointNum; pidx++) {
+ printf("%s", airDoneStr(0, pidx, pointNum, doneStr));
+ fflush(stdout);
if (!point) {
point = pullPointNew(pctx);
}
- if (pullPointInitializeRandomOrHalton(pctx, pidx + pointsSoFar,
- point, scaleVol)) {
- biffAddf(PULL, "%s: trouble trying point %u (id %u)", me,
- pidx, point->idtag);
- airMopError(mop); return 1;
+ if (pullPointInitializeRandomOrHalton(pctx, pidx + pointsSoFar, point, scaleVol)) {
+ biffAddf(PULL, "%s: trouble trying point %u (id %u)", me, pidx, point->idtag);
+ airMopError(mop);
+ return 1;
}
if (pullBinsPointAdd(pctx, point, NULL)) {
biffAddf(PULL, "%s: trouble binning point %u", me, point->idtag);
- airMopError(mop); return 1;
+ airMopError(mop);
+ return 1;
}
point = NULL;
}
@@ -84,28 +80,27 @@
nPosOut = nrrdNew();
airMopAdd(mop, nPosOut, (airMopper)nrrdNuke, airMopAlways);
- if (pullOutputGetFilter(nPosOut, NULL, NULL, NULL, 0.0,
- pctx, idtagBase, 0)) {
+ if (pullOutputGetFilter(nPosOut, NULL, NULL, NULL, 0.0, pctx, idtagBase, 0)) {
biffAddf(PULL, "%s: trouble A", me);
- airMopError(mop); return 1;
+ airMopError(mop);
+ return 1;
}
pos = AIR_CAST(double *, nPosOut->data);
addedNum = nPosOut->axis[1].size;
printf("%s: tracing . . . ", me);
- for (pidx=0; pidx<addedNum; pidx++) {
+ for (pidx = 0; pidx < addedNum; pidx++) {
double seedPos[4];
int added;
- printf("%s", airDoneStr(0, pidx, addedNum, doneStr)); fflush(stdout);
+ printf("%s", airDoneStr(0, pidx, addedNum, doneStr));
+ fflush(stdout);
trace = pullTraceNew();
- ELL_4V_COPY(seedPos, pos + 4*pidx);
- if (pullTraceSet(pctx, trace,
- AIR_TRUE /* recordStrength */,
- scaleStep, scaleHalfLen,
- orientTestLen,
- traceArrIncr, seedPos)
+ ELL_4V_COPY(seedPos, pos + 4 * pidx);
+ if (pullTraceSet(pctx, trace, AIR_TRUE /* recordStrength */, scaleStep, scaleHalfLen,
+ orientTestLen, traceArrIncr, seedPos)
|| pullTraceMultiAdd(mtrc, trace, &added)) {
biffAddf(PULL, "%s: trouble on point %u", me, pidx);
- airMopError(mop); return 1;
+ airMopError(mop);
+ return 1;
}
if (!added) {
trace = pullTraceNix(trace);
@@ -113,13 +108,11 @@
}
printf("%s\n", airDoneStr(0, pidx, pointNum, doneStr));
- if (pullTraceMultiPlotAdd(nplot, mtrc, NULL,
- strengthUse,
- smooth, flatWght,
- 0, 0,
- NULL, NULL)) {
+ if (pullTraceMultiPlotAdd(nplot, mtrc, NULL, strengthUse, smooth, flatWght, 0, 0, NULL,
+ NULL)) {
biffAddf(PULL, "%s: trouble w/ PlotAdd (A)", me);
- airMopError(mop); return 1;
+ airMopError(mop);
+ return 1;
}
airMopOkay(mop);
@@ -130,7 +123,7 @@
int
resamplePlot(Nrrd *nprob, const Nrrd *nplot) {
- static const char me[]="resamplePlot";
+ static const char me[] = "resamplePlot";
unsigned int ii, nn, sx, sy;
double scls[2] = {0.2, 0.2}, kparm[2] = {1.0, 0.0};
@@ -149,20 +142,20 @@
prob = AIR_CAST(double *, nprob->data);
sx = AIR_UINT(nprob->axis[0].size);
sy = AIR_UINT(nprob->axis[1].size);
- for (ii=0; ii<sx; ii++) {
+ for (ii = 0; ii < sx; ii++) {
/* zero out bottom line, useless crap piles up there */
- prob[ii + sx*(sy-1)] = 0;
+ prob[ii + sx * (sy - 1)] = 0;
}
sum = 0;
nn = AIR_UINT(nrrdElementNumber(nprob));
- for (ii=0; ii<nn; ii++) {
+ for (ii = 0; ii < nn; ii++) {
/* sum += log(LOFF+prob[ii]); why? */
sum += prob[ii];
}
if (sum) {
- for (ii=0; ii<nn; ii++) {
+ for (ii = 0; ii < nn; ii++) {
/* prob[ii] = log(LOFF+prob[ii])/sum; why? */
- prob[ii] = prob[ii]/sum;
+ prob[ii] = prob[ii] / sum;
}
}
return 0;
@@ -170,15 +163,15 @@
double
distanceProb(Nrrd *npp, Nrrd *nqq) {
- double *pp, *qq, dist=0.0;
+ double *pp, *qq, dist = 0.0;
unsigned int ii, nn;
nn = AIR_UINT(nrrdElementNumber(npp));
pp = AIR_CAST(double *, npp->data);
qq = AIR_CAST(double *, nqq->data);
- for (ii=0; ii<nn; ii++) {
+ for (ii = 0; ii < nn; ii++) {
if (qq[ii]) {
- dist += fabs(pp[ii]*log2(0.0000001+pp[ii]/qq[ii]));
+ dist += fabs(pp[ii] * log2(0.0000001 + pp[ii] / qq[ii]));
}
}
return dist;
@@ -186,14 +179,13 @@
void
savePlot(Nrrd *nout) {
- static const char me[]="saveProb";
- static int count=0;
+ static const char me[] = "saveProb";
+ static int count = 0;
char fname[128], *err;
sprintf(fname, "pdf-%03u.nrrd", count);
if (nrrdSave(fname, nout, NULL)) {
err = biffGetDone(NRRD);
- fprintf(stderr, "%s: HEY couldn't save pdf to %s; moving on ...\n",
- me, fname);
+ fprintf(stderr, "%s: HEY couldn't save pdf to %s; moving on ...\n", me, fname);
free(err);
}
count++;
@@ -204,44 +196,36 @@
int
main(int argc, const char **argv) {
- hestOpt *hopt=NULL;
+ hestOpt *hopt = NULL;
hestParm *hparm;
airArray *mop;
const char *me;
-
- char *err, *posOutS, *outS, *extraOutBaseS, *addLogS, *cachePathSS,
- *tracesInS, *tracesOutS, *trcListOutS=NULL, *trcVolOutS=NULL,
- *traceMaskPosOutS=NULL;
+ char *err, *posOutS, *outS, *extraOutBaseS, *addLogS, *cachePathSS, *tracesInS,
+ *tracesOutS, *trcListOutS = NULL, *trcVolOutS = NULL, *traceMaskPosOutS = NULL;
FILE *addLog, *tracesFile;
meetPullVol **vspec;
meetPullInfo **idef;
- Nrrd *nPosIn=NULL, *nPosOut, *nplot, *nplotA, *nplotB, *nfilt, *nTraceMaskIn,
- *nmaskedpos;
+ Nrrd *nPosIn = NULL, *nPosOut, *nplot, *nplotA, *nplotB, *nfilt, *nTraceMaskIn,
+ *nmaskedpos;
pullEnergySpec *enspR, *enspS, *enspWin;
NrrdKernelSpec *k00, *k11, *k22, *kSSrecon, *kSSblur;
NrrdBoundarySpec *bspec;
- pullContext *pctx=NULL;
- pullVolume *scaleVol=NULL;
- pullTraceMulti *mtrc=NULL;
- int ret=0;
+ pullContext *pctx = NULL;
+ pullVolume *scaleVol = NULL;
+ pullTraceMulti *mtrc = NULL;
+ int ret = 0;
unsigned int vspecNum, idefNum;
/* things that used to be set directly inside pullContext */
- int nixAtVolumeEdgeSpace, constraintBeforeSeedThresh,
- binSingle, liveThresholdOnInit, permuteOnRebin,
- noAdd, unequalShapesAllow,
- zeroZ, strnUse;
+ int nixAtVolumeEdgeSpace, constraintBeforeSeedThresh, binSingle, liveThresholdOnInit,
+ permuteOnRebin, noAdd, unequalShapesAllow, zeroZ, strnUse;
int verbose;
- int interType, allowCodimension3Constraints, scaleIsTau,
- smoothPlot, flatWght;
- unsigned int samplesAlongScaleNum, pointNumInitial, pointPerVoxel,
- ppvZRange[2], snap, stuckIterMax, constraintIterMax,
- rngSeed, progressBinMod,
- threadNum, tracePointNum, passNumMax,
- kssOpi, kssFinished, bspOpi, bspFinished;
- double jitter, stepInitial, constraintStepMin, radiusSpace, binWidthSpace,
- radiusScale, orientTestLen,
- backStepScale, opporStepScale, energyDecreaseMin, tpdThresh;
+ int interType, allowCodimension3Constraints, scaleIsTau, smoothPlot, flatWght;
+ unsigned int samplesAlongScaleNum, pointNumInitial, pointPerVoxel, ppvZRange[2], snap,
+ stuckIterMax, constraintIterMax, rngSeed, progressBinMod, threadNum, tracePointNum,
+ passNumMax, kssOpi, kssFinished, bspOpi, bspFinished;
+ double jitter, stepInitial, constraintStepMin, radiusSpace, binWidthSpace, radiusScale,
+ orientTestLen, backStepScale, opporStepScale, energyDecreaseMin, tpdThresh;
double sstep, sswin, ssrange[2];
unsigned int pres[2];
@@ -284,157 +268,125 @@
"always constrain Z=0, to process 2D images");
hestOptAdd(&hopt, "su", "bool", airTypeBool, 1, 1, &strnUse, "false",
"weigh contributions to traces with strength");
- hestOptAdd(&hopt, "nave", "bool", airTypeBool, 1, 1,
- &nixAtVolumeEdgeSpace, "false",
+ hestOptAdd(&hopt, "nave", "bool", airTypeBool, 1, 1, &nixAtVolumeEdgeSpace, "false",
"whether or not to nix points at edge of volume, where gage had "
"to invent values for kernel support");
- hestOptAdd(&hopt, "cbst", "bool", airTypeBool, 1, 1,
- &constraintBeforeSeedThresh, "false",
+ hestOptAdd(&hopt, "cbst", "bool", airTypeBool, 1, 1, &constraintBeforeSeedThresh,
+ "false",
"during initialization, try constraint satisfaction before "
"testing seedThresh");
- hestOptAdd(&hopt, "noadd", NULL, airTypeBool, 0, 0,
- &noAdd, NULL, "turn off adding during population control");
- hestOptAdd(&hopt, "usa", "bool", airTypeBool, 1, 1,
- &unequalShapesAllow, "false",
+ hestOptAdd(&hopt, "noadd", NULL, airTypeBool, 0, 0, &noAdd, NULL,
+ "turn off adding during population control");
+ hestOptAdd(&hopt, "usa", "bool", airTypeBool, 1, 1, &unequalShapesAllow, "false",
"allow volumes to have different shapes (false is safe as "
"different volume sizes are often accidental)");
- hestOptAdd(&hopt, "nobin", NULL, airTypeBool, 0, 0,
- &binSingle, NULL,
+ hestOptAdd(&hopt, "nobin", NULL, airTypeBool, 0, 0, &binSingle, NULL,
"turn off spatial binning (which prevents multi-threading "
"from being useful), for debugging or speed-up measurement");
- hestOptAdd(&hopt, "lti", "bool", airTypeBool, 1, 1,
- &liveThresholdOnInit, "true",
+ hestOptAdd(&hopt, "lti", "bool", airTypeBool, 1, 1, &liveThresholdOnInit, "true",
"impose liveThresh on initialization");
- hestOptAdd(&hopt, "por", "bool", airTypeBool, 1, 1,
- &permuteOnRebin, "true",
+ hestOptAdd(&hopt, "por", "bool", airTypeBool, 1, 1, &permuteOnRebin, "true",
"permute points during rebinning");
hestOptAdd(&hopt, "v", "verbosity", airTypeInt, 1, 1, &verbose, "1",
"verbosity level");
hestOptAdd(&hopt, "vol", "vol0 vol1", airTypeOther, 1, -1, &vspec, NULL,
- "input volumes, in format <filename>:<kind>:<volname>",
- &vspecNum, NULL, meetHestPullVol);
+ "input volumes, in format <filename>:<kind>:<volname>", &vspecNum, NULL,
+ meetHestPullVol);
hestOptAdd(&hopt, "info", "info0 info1", airTypeOther, 1, -1, &idef, NULL,
"info definitions, in format "
"<info>[-c]:<volname>:<item>[:<zero>:<scale>]",
&idefNum, NULL, meetHestPullInfo);
- hestOptAdd(&hopt, "k00", "kern00", airTypeOther, 1, 1, &k00,
- "cubic:1,0", "kernel for gageKernel00",
- NULL, NULL, nrrdHestKernelSpec);
- hestOptAdd(&hopt, "k11", "kern11", airTypeOther, 1, 1, &k11,
- "cubicd:1,0", "kernel for gageKernel11",
- NULL, NULL, nrrdHestKernelSpec);
- hestOptAdd(&hopt, "k22", "kern22", airTypeOther, 1, 1, &k22,
- "cubicdd:1,0", "kernel for gageKernel22",
- NULL, NULL, nrrdHestKernelSpec);
+ hestOptAdd(&hopt, "k00", "kern00", airTypeOther, 1, 1, &k00, "cubic:1,0",
+ "kernel for gageKernel00", NULL, NULL, nrrdHestKernelSpec);
+ hestOptAdd(&hopt, "k11", "kern11", airTypeOther, 1, 1, &k11, "cubicd:1,0",
+ "kernel for gageKernel11", NULL, NULL, nrrdHestKernelSpec);
+ hestOptAdd(&hopt, "k22", "kern22", airTypeOther, 1, 1, &k22, "cubicdd:1,0",
+ "kernel for gageKernel22", NULL, NULL, nrrdHestKernelSpec);
hestOptAdd(&hopt, "sscp", "path", airTypeString, 1, 1, &cachePathSS, "./",
"path (without trailing /) for where to read/write "
"pre-blurred volumes for scale-space");
- kssOpi =
- hestOptAdd(&hopt, "kssb", "kernel", airTypeOther, 1, 1, &kSSblur,
- "ds:1,5", "default blurring kernel, to sample scale space",
- NULL, NULL, nrrdHestKernelSpec);
- bspOpi =
- hestOptAdd(&hopt, "bsp", "boundary", airTypeOther, 1, 1, &bspec,
- "wrap", "default boundary behavior of scale-space blurring",
- NULL, NULL, nrrdHestBoundarySpec);
- hestOptAdd(&hopt, "kssr", "kernel", airTypeOther, 1, 1, &kSSrecon,
- "hermite", "kernel for reconstructing from scale space samples",
- NULL, NULL, nrrdHestKernelSpec);
- hestOptAdd(&hopt, "nss", "# scl smpls", airTypeUInt, 1, 1,
- &samplesAlongScaleNum, "1",
+ kssOpi = hestOptAdd(&hopt, "kssb", "kernel", airTypeOther, 1, 1, &kSSblur, "ds:1,5",
+ "default blurring kernel, to sample scale space", NULL, NULL,
+ nrrdHestKernelSpec);
+ bspOpi = hestOptAdd(&hopt, "bsp", "boundary", airTypeOther, 1, 1, &bspec, "wrap",
+ "default boundary behavior of scale-space blurring", NULL, NULL,
+ nrrdHestBoundarySpec);
+ hestOptAdd(&hopt, "kssr", "kernel", airTypeOther, 1, 1, &kSSrecon, "hermite",
+ "kernel for reconstructing from scale space samples", NULL, NULL,
+ nrrdHestKernelSpec);
+ hestOptAdd(&hopt, "nss", "# scl smpls", airTypeUInt, 1, 1, &samplesAlongScaleNum, "1",
"if using \"-ppv\", number of samples along scale axis "
"for each spatial position");
- hestOptAdd(&hopt, "np", "# points", airTypeUInt, 1, 1,
- &pointNumInitial, "1000",
+ hestOptAdd(&hopt, "np", "# points", airTypeUInt, 1, 1, &pointNumInitial, "1000",
"number of points to initialize with");
- hestOptAdd(&hopt, "tnp", "# points", airTypeUInt, 1, 1,
- &tracePointNum, "1000",
+ hestOptAdd(&hopt, "tnp", "# points", airTypeUInt, 1, 1, &tracePointNum, "1000",
"number of points to add in each iteration of "
"estimation of plot");
- hestOptAdd(&hopt, "pnm", "# passes", airTypeUInt, 1, 1,
- &passNumMax, "10",
+ hestOptAdd(&hopt, "pnm", "# passes", airTypeUInt, 1, 1, &passNumMax, "10",
"max number of passes in plot estimation");
- hestOptAdd(&hopt, "tpdt", "thresh", airTypeDouble, 1, 1,
- &tpdThresh, "1.0", "KL-distance threshold");
- hestOptAdd(&hopt, "ti", "fname", airTypeString, 1, 1,
- &tracesInS, "", "input file of *pre-computed* traces");
- hestOptAdd(&hopt, "to", "fname", airTypeString, 1, 1,
- &tracesOutS, "", "file for saving out *computed* traces");
+ hestOptAdd(&hopt, "tpdt", "thresh", airTypeDouble, 1, 1, &tpdThresh, "1.0",
+ "KL-distance threshold");
+ hestOptAdd(&hopt, "ti", "fname", airTypeString, 1, 1, &tracesInS, "",
+ "input file of *pre-computed* traces");
+ hestOptAdd(&hopt, "to", "fname", airTypeString, 1, 1, &tracesOutS, "",
+ "file for saving out *computed* traces");
- hestOptAdd(&hopt, "ppv", "# pnts/vox", airTypeUInt, 1, 1,
- &pointPerVoxel, "0",
+ hestOptAdd(&hopt, "ppv", "# pnts/vox", airTypeUInt, 1, 1, &pointPerVoxel, "0",
"number of points per voxel to start in simulation "
"(need to have a seed thresh vol, overrides \"-np\")");
- hestOptAdd(&hopt, "ppvzr", "z range", airTypeUInt, 2, 2,
- ppvZRange, "1 0",
+ hestOptAdd(&hopt, "ppvzr", "z range", airTypeUInt, 2, 2, ppvZRange, "1 0",
"range of Z slices (1st num < 2nd num) to do ppv in, or, "
"\"1 0\" for whole volume");
- hestOptAdd(&hopt, "jit", "jitter", airTypeDouble, 1, 1,
- &jitter, "0",
+ hestOptAdd(&hopt, "jit", "jitter", airTypeDouble, 1, 1, &jitter, "0",
"amount of jittering to do with ppv");
hestOptAdd(&hopt, "pi", "npos", airTypeOther, 1, 1, &nPosIn, "",
- "4-by-N array of positions to start at (overrides \"-np\")",
- NULL, NULL, nrrdHestNrrd);
- hestOptAdd(&hopt, "step", "step", airTypeDouble, 1, 1,
- &stepInitial, "1",
+ "4-by-N array of positions to start at (overrides \"-np\")", NULL, NULL,
+ nrrdHestNrrd);
+ hestOptAdd(&hopt, "step", "step", airTypeDouble, 1, 1, &stepInitial, "1",
"initial step size for gradient descent");
- hestOptAdd(&hopt, "csm", "step", airTypeDouble, 1, 1,
- &constraintStepMin, "0.0001",
+ hestOptAdd(&hopt, "csm", "step", airTypeDouble, 1, 1, &constraintStepMin, "0.0001",
"convergence criterion for constraint satisfaction");
- hestOptAdd(&hopt, "snap", "# iters", airTypeUInt, 1, 1,
- &snap, "0",
+ hestOptAdd(&hopt, "snap", "# iters", airTypeUInt, 1, 1, &snap, "0",
"if non-zero, # iters between saved snapshots");
- hestOptAdd(&hopt, "stim", "# iters", airTypeUInt, 1, 1,
- &stuckIterMax, "5",
+ hestOptAdd(&hopt, "stim", "# iters", airTypeUInt, 1, 1, &stuckIterMax, "5",
"if non-zero, max # iterations to allow a particle "
" to be stuck before nixing");
- hestOptAdd(&hopt, "maxci", "# iters", airTypeUInt, 1, 1,
- &constraintIterMax, "15",
+ hestOptAdd(&hopt, "maxci", "# iters", airTypeUInt, 1, 1, &constraintIterMax, "15",
"if non-zero, max # iterations for contraint enforcement");
- hestOptAdd(&hopt, "irad", "scale", airTypeDouble, 1, 1,
- &radiusSpace, "1",
+ hestOptAdd(&hopt, "irad", "scale", airTypeDouble, 1, 1, &radiusSpace, "1",
"particle radius in spatial domain");
- hestOptAdd(&hopt, "srad", "scale", airTypeDouble, 1, 1,
- &radiusScale, "1",
+ hestOptAdd(&hopt, "srad", "scale", airTypeDouble, 1, 1, &radiusScale, "1",
"particle radius in scale domain");
- hestOptAdd(&hopt, "bws", "bin width", airTypeDouble, 1, 1,
- &binWidthSpace, "1.001",
+ hestOptAdd(&hopt, "bws", "bin width", airTypeDouble, 1, 1, &binWidthSpace, "1.001",
"spatial bin width as multiple of spatial radius");
- hestOptAdd(&hopt, "ess", "scl", airTypeDouble, 1, 1,
- &backStepScale, "0.5",
+ hestOptAdd(&hopt, "ess", "scl", airTypeDouble, 1, 1, &backStepScale, "0.5",
"when energy goes up instead of down, scale step "
"size by this");
- hestOptAdd(&hopt, "oss", "scl", airTypeDouble, 1, 1,
- &opporStepScale, "1.0",
+ hestOptAdd(&hopt, "oss", "scl", airTypeDouble, 1, 1, &opporStepScale, "1.0",
"opportunistic scaling (hopefully up, >1) of step size "
"on every iteration");
- hestOptAdd(&hopt, "edmin", "frac", airTypeDouble, 1, 1,
- &energyDecreaseMin, "0.0001",
+ hestOptAdd(&hopt, "edmin", "frac", airTypeDouble, 1, 1, &energyDecreaseMin, "0.0001",
"convergence threshold: stop when fractional improvement "
"(decrease) in energy dips below this");
- hestOptAdd(&hopt, "ac3c", "ac3c", airTypeBool, 1, 1,
- &allowCodimension3Constraints, "false",
- "allow codimensions 3 constraints");
+ hestOptAdd(&hopt, "ac3c", "ac3c", airTypeBool, 1, 1, &allowCodimension3Constraints,
+ "false", "allow codimensions 3 constraints");
hestOptAdd(&hopt, "sit", "sit", airTypeBool, 1, 1, &scaleIsTau, "false",
"scale is tau");
- hestOptAdd(&hopt, "rng", "seed", airTypeUInt, 1, 1,
- &rngSeed, "42",
+ hestOptAdd(&hopt, "rng", "seed", airTypeUInt, 1, 1, &rngSeed, "42",
"base seed value for RNGs (and as a hack, start index for "
"Halton-based sampling)");
- hestOptAdd(&hopt, "pbm", "mod", airTypeUInt, 1, 1,
- &progressBinMod, "50",
+ hestOptAdd(&hopt, "pbm", "mod", airTypeUInt, 1, 1, &progressBinMod, "50",
"progress bin mod");
- hestOptAdd(&hopt, "nt", "# threads", airTypeInt, 1, 1,
- &threadNum, "1",
+ hestOptAdd(&hopt, "nt", "# threads", airTypeInt, 1, 1, &threadNum, "1",
(airThreadCapable
- ? "number of threads to use"
- : "IF threads had beeen enabled in this Teem build (but "
- "they are NOT), this is how you would control the number "
- "of threads to use"));
+ ? "number of threads to use"
+ : "IF threads had beeen enabled in this Teem build (but "
+ "they are NOT), this is how you would control the number "
+ "of threads to use"));
hestOptAdd(&hopt, "addlog", "fname", airTypeString, 1, 1, &addLogS, "",
"name of file in which to log all particle additions");
hestOptAdd(&hopt, "po", "nout", airTypeString, 1, 1, &posOutS, "",
@@ -479,8 +431,8 @@
hestOptAdd(&hopt, "tvo", "fname", airTypeString, 1, 1, &trcVolOutS, "",
"output filename for rasterized trace of scale-space volume");
- hestParseOrDie(hopt, argc-1, argv+1, hparm,
- me, info, AIR_TRUE, AIR_TRUE, AIR_TRUE);
+ hestParseOrDie(hopt, argc - 1, argv + 1, hparm, me, info, AIR_TRUE, AIR_TRUE,
+ AIR_TRUE);
airMopAdd(mop, hopt, (airMopper)hestOptFree, airMopAlways);
airMopAdd(mop, hopt, (airMopper)hestParseFree, airMopAlways);
@@ -491,7 +443,8 @@
if (airStrlen(addLogS)) {
if (!(addLog = airFopen(addLogS, stdout, "w"))) {
fprintf(stderr, "%s: couldn't open %s for writing\n", me, addLogS);
- airMopError(mop); return 1;
+ airMopError(mop);
+ return 1;
}
airMopAdd(mop, addLog, (airMopper)airFclose, airMopAlways);
} else {
@@ -507,8 +460,7 @@
pctx = pullContextNew();
airMopAdd(mop, pctx, (airMopper)pullContextNix, airMopAlways);
- if (pullVerboseSet(pctx, verbose)
- || pullFlagSet(pctx, pullFlagZeroZ, zeroZ)
+ if (pullVerboseSet(pctx, verbose) || pullFlagSet(pctx, pullFlagZeroZ, zeroZ)
|| pullFlagSet(pctx, pullFlagNixAtVolumeEdgeSpace, nixAtVolumeEdgeSpace)
|| pullFlagSet(pctx, pullFlagConstraintBeforeSeedThresh,
constraintBeforeSeedThresh)
@@ -529,12 +481,10 @@
|| pullSysParmSet(pctx, pullSysParmRadiusSpace, radiusSpace)
|| pullSysParmSet(pctx, pullSysParmRadiusScale, radiusScale)
|| pullSysParmSet(pctx, pullSysParmBinWidthSpace, binWidthSpace)
- || pullSysParmSet(pctx, pullSysParmEnergyDecreaseMin,
- energyDecreaseMin)
+ || pullSysParmSet(pctx, pullSysParmEnergyDecreaseMin, energyDecreaseMin)
|| pullSysParmSet(pctx, pullSysParmBackStepScale, backStepScale)
|| pullSysParmSet(pctx, pullSysParmOpporStepScale, opporStepScale)
- || pullRngSeedSet(pctx, rngSeed)
- || pullProgressBinModSet(pctx, progressBinMod)
+ || pullRngSeedSet(pctx, rngSeed) || pullProgressBinModSet(pctx, progressBinMod)
|| pullThreadNumSet(pctx, threadNum)
|| pullInterEnergySet(pctx, interType, enspR, enspS, enspWin)
|| pullInitLiveThreshUseSet(pctx, liveThresholdOnInit)
@@ -541,34 +491,37 @@
|| pullLogAddSet(pctx, addLog)) {
airMopAdd(mop, err = biffGetDone(PULL), airFree, airMopAlways);
fprintf(stderr, "%s: trouble with flags:\n%s", me, err);
- airMopError(mop); return 1;
+ airMopError(mop);
+ return 1;
}
if (pullInitHaltonSet(pctx, pointNumInitial, rngSeed)) {
airMopAdd(mop, err = biffGetDone(PULL), airFree, airMopAlways);
fprintf(stderr, "%s: trouble setting halton:\n%s", me, err);
- airMopError(mop); return 1;
+ airMopError(mop);
+ return 1;
}
- if (meetPullVolStackBlurParmFinishMulti(vspec, vspecNum,
- &kssFinished, &bspFinished,
+ if (meetPullVolStackBlurParmFinishMulti(vspec, vspecNum, &kssFinished, &bspFinished,
kSSblur, bspec)
|| meetPullVolLoadMulti(vspec, vspecNum, cachePathSS, verbose)
- || meetPullVolAddMulti(pctx, vspec, vspecNum,
- k00, k11, k22, kSSrecon)
+ || meetPullVolAddMulti(pctx, vspec, vspecNum, k00, k11, k22, kSSrecon)
|| meetPullInfoAddMulti(pctx, idef, idefNum)) {
airMopAdd(mop, err = biffGetDone(MEET), airFree, airMopAlways);
fprintf(stderr, "%s: trouble with volumes or infos:\n%s", me, err);
- airMopError(mop); return 1;
+ airMopError(mop);
+ return 1;
}
if (!kssFinished && hestSourceUser == hopt[kssOpi].source) {
- fprintf(stderr, "\n\n%s: WARNING! Used the -%s flag, but the "
- "meetPullVol specified blurring kernels\n\n\n", me,
- hopt[kssOpi].flag);
+ fprintf(stderr,
+ "\n\n%s: WARNING! Used the -%s flag, but the "
+ "meetPullVol specified blurring kernels\n\n\n",
+ me, hopt[kssOpi].flag);
}
if (!bspFinished && hestSourceUser == hopt[bspOpi].source) {
- fprintf(stderr, "\n\n%s: WARNING! Used the -%s flag, but the "
- "meetPullVol specified boundary specs\n\n\n", me,
- hopt[bspOpi].flag);
+ fprintf(stderr,
+ "\n\n%s: WARNING! Used the -%s flag, but the "
+ "meetPullVol specified boundary specs\n\n\n",
+ me, hopt[bspOpi].flag);
}
if (airStrlen(tracesInS)) {
@@ -584,25 +537,26 @@
if (pullStart(pctx)) {
airMopAdd(mop, err = biffGetDone(PULL), airFree, airMopAlways);
fprintf(stderr, "%s: trouble starting system:\n%s", me, err);
- airMopError(mop); return 1;
+ airMopError(mop);
+ return 1;
}
- if (nrrdMaybeAlloc_va(nplotA, nrrdTypeDouble, 2,
- AIR_CAST(size_t, pres[0]),
+ if (nrrdMaybeAlloc_va(nplotA, nrrdTypeDouble, 2, AIR_CAST(size_t, pres[0]),
AIR_CAST(size_t, pres[1]))) {
airMopAdd(mop, err = biffGetDone(NRRD), airFree, airMopAlways);
fprintf(stderr, "%s: trouble creating output:\n%s", me, err);
- airMopError(mop); return 1;
+ airMopError(mop);
+ return 1;
}
if (pullConstraintScaleRange(pctx, ssrange)) {
airMopAdd(mop, err = biffGetDone(PULL), airFree, airMopAlways);
fprintf(stderr, "%s: trouble C:\n%s", me, err);
- airMopError(mop); return 1;
+ airMopError(mop);
+ return 1;
}
- fprintf(stderr, "!%s: ================== ssrange %g %g\n", me,
- ssrange[0], ssrange[1]);
+ fprintf(stderr, "!%s: ================== ssrange %g %g\n", me, ssrange[0], ssrange[1]);
if (vspec[0]->sbp) {
- char stmp[AIR_STRLEN_LARGE];
+ char stmp[AIR_STRLEN_LARGE + 1];
gageStackBlurParmSprint(stmp, vspec[0]->sbp, NULL, NULL);
fprintf(stderr, "!%s: ======== %s\n", me, stmp);
}
@@ -614,12 +568,14 @@
if (airStrlen(tracesInS)) {
if (!(tracesFile = airFopen(tracesInS, stdin, "rb"))) {
fprintf(stderr, "%s: couldn't open %s for reading\n", me, tracesInS);
- airMopError(mop); return 1;
+ airMopError(mop);
+ return 1;
}
if (pullTraceMultiRead(mtrc, tracesFile)) {
airMopAdd(mop, err = biffGetDone(PULL), airFree, airMopAlways);
fprintf(stderr, "%s: trouble reading:\n%s", me, err);
- airMopError(mop); return 1;
+ airMopError(mop);
+ return 1;
}
airFclose(tracesFile);
goto plotting;
@@ -628,12 +584,13 @@
if (!pctx->constraint) {
fprintf(stderr, "%s: this programs requires a constraint\n", me);
- airMopError(mop); return 1;
+ airMopError(mop);
+ return 1;
}
scaleVol = NULL;
{
unsigned int ii;
- for (ii=0; ii<pctx->volNum; ii++) {
+ for (ii = 0; ii < pctx->volNum; ii++) {
if (pctx->vol[ii]->ninScale) {
scaleVol = pctx->vol[ii];
break;
@@ -642,13 +599,15 @@
}
if (!scaleVol) {
fprintf(stderr, "%s: this program requires scale-space\n", me);
- airMopError(mop); return 1;
+ airMopError(mop);
+ return 1;
}
if (pullOutputGet(nPosOut, NULL, NULL, NULL, 0.0, pctx)) {
airMopAdd(mop, err = biffGetDone(PULL), airFree, airMopAlways);
fprintf(stderr, "%s: trouble D:\n%s", me, err);
- airMopError(mop); return 1;
+ airMopError(mop);
+ return 1;
}
if (airStrlen(posOutS)) {
nrrdSave(posOutS, nPosOut, NULL);
@@ -655,11 +614,11 @@
}
{
- double *pos, seedPos[4], scaleWin, scaleStep, dist=0;
+ double *pos, seedPos[4], scaleWin, scaleStep, dist = 0;
unsigned int pidx, pnum, passIdx;
pullTrace *pts;
Nrrd *nsplot, *nprogA, *nprogB, *nlsplot;
- char doneStr[AIR_STRLEN_SMALL];
+ char doneStr[AIR_STRLEN_SMALL + 1];
pos = AIR_CAST(double *, nPosOut->data);
nlsplot = nrrdNew();
@@ -670,32 +629,30 @@
airMopAdd(mop, nprogA, (airMopper)nrrdNuke, airMopAlways);
nprogB = nrrdNew();
airMopAdd(mop, nprogB, (airMopper)nrrdNuke, airMopAlways);
- if (nrrdCopy(nprogA, nplotA)
- || nrrdCopy(nprogB, nplotA)) {
+ if (nrrdCopy(nprogA, nplotA) || nrrdCopy(nprogB, nplotA)) {
airMopAdd(mop, err = biffGetDone(NRRD), airFree, airMopAlways);
fprintf(stderr, "%s: trouble creating nprogs:\n%s", me, err);
- airMopError(mop); return 1;
+ airMopError(mop);
+ return 1;
}
- scaleWin = sswin*(ssrange[1]-ssrange[0]);
- scaleStep = sstep*(ssrange[1]-ssrange[0]);
+ scaleWin = sswin * (ssrange[1] - ssrange[0]);
+ scaleStep = sstep * (ssrange[1] - ssrange[0]);
pnum = nPosOut->axis[1].size;
printf("!%s: tracing initial %u points . . . ", me, pnum);
- for (pidx=0; pidx<pnum; pidx++) {
+ for (pidx = 0; pidx < pnum; pidx++) {
int added;
- printf("%s", airDoneStr(0, pidx, pnum, doneStr)); fflush(stdout);
+ printf("%s", airDoneStr(0, pidx, pnum, doneStr));
+ fflush(stdout);
pts = pullTraceNew();
- ELL_4V_COPY(seedPos, pos + 4*pidx);
- if (pullTraceSet(pctx, pts,
- AIR_TRUE /* recordStrength */,
- scaleStep, scaleWin/2,
- orientTestLen,
- AIR_UINT((scaleWin/2)/scaleStep),
- seedPos)
+ ELL_4V_COPY(seedPos, pos + 4 * pidx);
+ if (pullTraceSet(pctx, pts, AIR_TRUE /* recordStrength */, scaleStep, scaleWin / 2,
+ orientTestLen, AIR_UINT((scaleWin / 2) / scaleStep), seedPos)
|| pullTraceMultiAdd(mtrc, pts, &added)) {
airMopAdd(mop, err = biffGetDone(PULL), airFree, airMopAlways);
fprintf(stderr, "%s: trouble on point %u:\n%s", me, pidx, err);
- airMopError(mop); return 1;
+ airMopError(mop);
+ return 1;
}
if (!added) {
/*
@@ -716,36 +673,35 @@
printf("%s\n", airDoneStr(0, pidx, pnum, doneStr));
if (!mtrc->traceNum) {
fprintf(stderr, "%s: %u initial points led to zero traces\n", me, pnum);
- airMopError(mop); return 1;
+ airMopError(mop);
+ return 1;
}
- if (pullTraceMultiPlotAdd(nprogA, mtrc, NULL,
- strnUse, smoothPlot, flatWght,
- 0, 0, NULL, NULL)) {
+ if (pullTraceMultiPlotAdd(nprogA, mtrc, NULL, strnUse, smoothPlot, flatWght, 0, 0,
+ NULL, NULL)) {
airMopAdd(mop, err = biffGetDone(PULL), airFree, airMopAlways);
fprintf(stderr, "%s: trouble PlotAdd'ing (B):\n%s", me, err);
- airMopError(mop); return 1;
+ airMopError(mop);
+ return 1;
}
resamplePlot(nlsplot, nprogA);
/* savePlot(nlsplot); */
- for (passIdx=0; passIdx<passNumMax; passIdx++) {
+ for (passIdx = 0; passIdx < passNumMax; passIdx++) {
double dd;
- fprintf(stderr, "!%s: pass %u/%u ==================\n",
- me, passIdx, passNumMax);
+ fprintf(stderr, "!%s: pass %u/%u ==================\n", me, passIdx, passNumMax);
nrrdZeroSet(nprogB);
- if (findAndTraceMorePoints(nprogB, pctx, scaleVol,
- strnUse, smoothPlot, flatWght,
- scaleStep, scaleWin/2,
- orientTestLen,
- AIR_UINT((scaleWin/2)/scaleStep),
- mtrc, tracePointNum)
+ if (findAndTraceMorePoints(nprogB, pctx, scaleVol, strnUse, smoothPlot, flatWght,
+ scaleStep, scaleWin / 2, orientTestLen,
+ AIR_UINT((scaleWin / 2) / scaleStep), mtrc,
+ tracePointNum)
|| resamplePlot(nsplot, nprogB)) {
airMopAdd(mop, err = biffGetDone(PULL), airFree, airMopAlways);
fprintf(stderr, "%s: trouble on pass %u:\n%s", me, passIdx, err);
- airMopError(mop); return 1;
+ airMopError(mop);
+ return 1;
}
/* savePlot(nsplot); */
- dd = distanceProb(nsplot, nlsplot)/tracePointNum;
+ dd = distanceProb(nsplot, nlsplot) / tracePointNum;
if (!passIdx) {
dist = dd;
} else {
@@ -752,17 +708,16 @@
dist = AIR_LERP(0.9, dist, dd);
}
fprintf(stderr, "%s: dd = %g -> dist = %g (%s %g)\n", me, dd, dist,
- dist < tpdThresh ? "<" : ">=", tpdThresh);
+ dist < tpdThresh ? "<" : ">=", tpdThresh);
nrrdCopy(nlsplot, nsplot);
if (dist < tpdThresh) {
- fprintf(stderr, "%s: converged: dist %g < thresh %g\n",
- me, dist, tpdThresh);
+ fprintf(stderr, "%s: converged: dist %g < thresh %g\n", me, dist, tpdThresh);
break;
}
}
- if (dist >= tpdThresh) {
- fprintf(stderr, "%s: WARNING did NOT converge: dist %g >= thresh %g\n",
- me, dist, tpdThresh);
+ if (dist >= tpdThresh) {
+ fprintf(stderr, "%s: WARNING did NOT converge: dist %g >= thresh %g\n", me, dist,
+ tpdThresh);
}
if (airStrlen(tracesOutS) && !airStrlen(tracesInS)) {
tracesFile = airFopen(tracesOutS, stdout, "wb");
@@ -769,7 +724,8 @@
if (pullTraceMultiWrite(tracesFile, mtrc)) {
airMopAdd(mop, err = biffGetDone(PULL), airFree, airMopAlways);
fprintf(stderr, "%s: trouble writing:\n%s", me, err);
- airMopError(mop); return 1;
+ airMopError(mop);
+ return 1;
}
fclose(tracesFile);
}
@@ -781,11 +737,11 @@
*/
Nrrd *ntlo;
double *tlo;
- size_t sx=9, totn=0, toti=0;
+ size_t sx = 9, totn = 0, toti = 0;
pullTrace *trc;
pullPoint *lpnt;
unsigned int ti;
- for (ti=0; ti<mtrc->traceNum; ti++) {
+ for (ti = 0; ti < mtrc->traceNum; ti++) {
trc = mtrc->trace[ti];
fprintf(stderr, "!%s: ti %u/%u : stab (%d-D) %u %u\n", me, ti, mtrc->traceNum,
trc->nstab->dim, AIR_UINT(trc->nstab->axis[0].size),
@@ -797,11 +753,12 @@
if (nrrdMaybeAlloc_va(ntlo, nrrdTypeDouble, 2, sx, totn)) {
airMopAdd(mop, err = biffGetDone(NRRD), airFree, airMopAlways);
fprintf(stderr, "%s: couldn't alloc output:\n%s", me, err);
- airMopError(mop); return 1;
+ airMopError(mop);
+ return 1;
}
airMopAdd(mop, ntlo, (airMopper)nrrdNuke, airMopAlways);
tlo = AIR_CAST(double *, ntlo->data);
- for (ti=0; ti<mtrc->traceNum; ti++) {
+ for (ti = 0; ti < mtrc->traceNum; ti++) {
unsigned int vi, vn;
double *vert, *stab, *strn, qual;
trc = mtrc->trace[ti];
@@ -808,14 +765,12 @@
vn = AIR_UINT(trc->nstab->axis[0].size);
vert = AIR_CAST(double *, trc->nvert->data);
stab = AIR_CAST(double *, trc->nstab->data);
- strn = AIR_CAST(double *, (trc->nstrn
- ? trc->nstrn->data
- : NULL));
- for (vi=0; vi<vn; vi++) {
- tlo[sx*toti + 0] = AIR_CAST(double, ti);
- tlo[sx*toti + 1] = (vi == trc->seedIdx);
- ELL_4V_COPY(tlo + sx*toti + 2, vert + 4*vi);
- ELL_4V_COPY(lpnt->pos, vert + 4*vi);
+ strn = AIR_CAST(double *, (trc->nstrn ? trc->nstrn->data : NULL));
+ for (vi = 0; vi < vn; vi++) {
+ tlo[sx * toti + 0] = AIR_CAST(double, ti);
+ tlo[sx * toti + 1] = (vi == trc->seedIdx);
+ ELL_4V_COPY(tlo + sx * toti + 2, vert + 4 * vi);
+ ELL_4V_COPY(lpnt->pos, vert + 4 * vi);
if (pctx->ispec[pullInfoQuality]) {
pullProbe(pctx->task[0], lpnt);
qual = pullPointScalar(pctx, lpnt, pullInfoQuality, NULL, NULL);
@@ -822,9 +777,9 @@
} else {
qual = 0.0;
}
- tlo[sx*toti + 6] = stab[vi];
- tlo[sx*toti + 7] = strn ? strn[vi] : 0.0;
- tlo[sx*toti + 8] = qual;
+ tlo[sx * toti + 6] = stab[vi];
+ tlo[sx * toti + 7] = strn ? strn[vi] : 0.0;
+ tlo[sx * toti + 8] = qual;
toti++;
}
}
@@ -831,7 +786,8 @@
if (nrrdSave(trcListOutS, ntlo, NULL)) {
airMopAdd(mop, err = biffGetDone(NRRD), airFree, airMopAlways);
fprintf(stderr, "%s: couldn't save output:\n%s", me, err);
- airMopError(mop); return 1;
+ airMopError(mop);
+ return 1;
}
}
if (airStrlen(trcVolOutS)) {
@@ -846,10 +802,11 @@
(*ins)(void *v, size_t I, double d);
/* HEY this will segfault around here if the mask volume is
first, because of the following line of code */
- if (!( mpv = meetPullVolCopy(vspec[0]) )) {
+ if (!(mpv = meetPullVolCopy(vspec[0]))) {
airMopAdd(mop, err = biffGetDone(MEET), airFree, airMopAlways);
fprintf(stderr, "%s: couldn't copy volume:\n%s", me, err);
- airMopError(mop); return 1;
+ airMopError(mop);
+ return 1;
}
airMopAdd(mop, mpv, (airMopper)meetPullVolNix, airMopAlways);
/* at this point we actually have to hijack the mpv in case its
@@ -859,14 +816,15 @@
Nrrd *nslice;
nslice = nrrdNew();
airMopAdd(mop, nslice, (airMopper)nrrdNuke, airMopAlways);
- fprintf(stderr, "!%s: slicing %u %s vols to %s\n", me,
- mpv->sbp->num, mpv->kind->name, gageKindScl->name);
- for (ni=0; ni<mpv->sbp->num; ni++) {
+ fprintf(stderr, "!%s: slicing %u %s vols to %s\n", me, mpv->sbp->num,
+ mpv->kind->name, gageKindScl->name);
+ for (ni = 0; ni < mpv->sbp->num; ni++) {
if (nrrdSlice(nslice, mpv->ninSS[ni], 0, 0)
|| nrrdCopy(mpv->ninSS[ni], nslice)) {
airMopAdd(mop, err = biffGetDone(NRRD), airFree, airMopAlways);
fprintf(stderr, "%s: couldn't slice volume %u:\n%s", me, ni, err);
- airMopError(mop); return 1;
+ airMopError(mop);
+ return 1;
}
}
/* can we just do this? */
@@ -879,7 +837,7 @@
printf("!%s: size = (%u,%u,%u,%u)\n", me, size[0], size[1], size[2], size[3]);
lpnt = pullPointNew(pctx);
airMopAdd(mop, lpnt, (airMopper)pullPointNix, airMopAlways);
- for (si=0; si<size[3]; si++) {
+ for (si = 0; si < size[3]; si++) {
nrrdZeroSet(mpv->ninSS[si]);
}
lup = nrrdDLookup[mpv->ninSS[0]->type];
@@ -886,7 +844,7 @@
ins = nrrdDInsert[mpv->ninSS[0]->type];
/* HEY here also assuming scale-space volume is first volume */
pnt = &(pctx->task[0]->vol[0]->gctx->point);
- for (ti=0; ti<mtrc->traceNum; ti++) {
+ for (ti = 0; ti < mtrc->traceNum; ti++) {
unsigned int vi, vn, orn, ori;
double *vert, *stab, *strn, *orin, wght;
trc = mtrc->trace[ti];
@@ -894,23 +852,22 @@
vert = AIR_CAST(double *, trc->nvert->data);
stab = AIR_CAST(double *, trc->nstab->data);
orin = AIR_CAST(double *, trc->norin->data);
- strn = AIR_CAST(double *, (strnUse && trc->nstrn
- ? trc->nstrn->data
- : NULL));
+ strn = AIR_CAST(double *, (strnUse && trc->nstrn ? trc->nstrn->data : NULL));
/* orn = (orin ? 20 : 1); */
orn = 1;
- for (vi=0; vi<vn; vi++) {
- for (ori=0; ori < orn; ori++) {
- ELL_4V_COPY(lpnt->pos, vert + 4*vi);
+ for (vi = 0; vi < vn; vi++) {
+ for (ori = 0; ori < orn; ori++) {
+ ELL_4V_COPY(lpnt->pos, vert + 4 * vi);
if (orn > 1) {
/* hack to draw a dotted line along tangent */
- double oscl = AIR_AFFINE(0, ori, orn-1, -100, 100);
- lpnt->pos[0] += oscl*(orin + 3*vi)[0];
- lpnt->pos[1] += oscl*(orin + 3*vi)[1];
+ double oscl = AIR_AFFINE(0, ori, orn - 1, -100, 100);
+ lpnt->pos[0] += oscl * (orin + 3 * vi)[0];
+ lpnt->pos[1] += oscl * (orin + 3 * vi)[1];
}
if (zeroZ && lpnt->pos[2] != 0) {
fprintf(stderr, "%s: zeroZ violated\n", me);
- airMopError(mop); return 1;
+ airMopError(mop);
+ return 1;
}
wght = stab[vi];
if (strn) {
@@ -920,16 +877,17 @@
if (pullProbe(pctx->task[0], lpnt)) {
airMopAdd(mop, err = biffGetDone(PULL), airFree, airMopAlways);
fprintf(stderr, "%s: couldn't probe:\n%s", me, err);
- airMopError(mop); return 1;
+ airMopError(mop);
+ return 1;
}
ELL_4V_ADD2(idxd, pnt->frac, pnt->idx);
/* because of gage subtlety that gagePoint->idx is index
of upper, not lower, corner, idxd is too big by 1 */
- idx[0] = airIndexClamp(-0.5, idxd[0]-1, size[0]-0.5, size[0]);
- idx[1] = airIndexClamp(-0.5, idxd[1]-1, size[1]-0.5, size[1]);
- idx[2] = airIndexClamp(-0.5, idxd[2]-1, size[2]-0.5, size[2]);
- idx[3] = airIndexClamp(0, idxd[3], size[3]-1, size[3]);
- iii = idx[0] + size[0]*(idx[1] + size[1]*idx[2]);
+ idx[0] = airIndexClamp(-0.5, idxd[0] - 1, size[0] - 0.5, size[0]);
+ idx[1] = airIndexClamp(-0.5, idxd[1] - 1, size[1] - 0.5, size[1]);
+ idx[2] = airIndexClamp(-0.5, idxd[2] - 1, size[2] - 0.5, size[2]);
+ idx[3] = airIndexClamp(0, idxd[3], size[3] - 1, size[3]);
+ iii = idx[0] + size[0] * (idx[1] + size[1] * idx[2]);
val = lup(mpv->ninSS[idx[3]]->data, iii);
ins(mpv->ninSS[idx[3]]->data, iii, wght + val);
/*
@@ -943,25 +901,25 @@
}
nout = nrrdNew();
airMopAdd(mop, nout, (airMopper)nrrdNuke, airMopAlways);
- if (nrrdJoin(nout, AIR_CAST(const Nrrd *const *, mpv->ninSS),
- size[3], 3, AIR_FALSE)
+ if (nrrdJoin(nout, AIR_CAST(const Nrrd *const *, mpv->ninSS), size[3], 3,
+ AIR_FALSE)
|| nrrdSave(trcVolOutS, nout, NULL)) {
airMopAdd(mop, err = biffGetDone(NRRD), airFree, airMopAlways);
fprintf(stderr, "%s: couldn't join or save SS output:\n%s", me, err);
- airMopError(mop); return 1;
+ airMopError(mop);
+ return 1;
}
}
- if (pullTraceMultiPlotAdd(nplotA, mtrc, NULL,
- strnUse, smoothPlot, flatWght,
- 0, 0, nmaskedpos, nTraceMaskIn)
+ if (pullTraceMultiPlotAdd(nplotA, mtrc, NULL, strnUse, smoothPlot, flatWght, 0, 0,
+ nmaskedpos, nTraceMaskIn)
/* || pullTraceMultiFilterConcaveDown(nfilt, mtrc, 0.05) */
/* The filter concave down idea didn't really work */
- || pullTraceMultiPlotAdd(nplotB, mtrc, NULL /* nfilt */,
- AIR_TRUE, smoothPlot, flatWght,
- 0, 0, NULL, NULL)) {
+ || pullTraceMultiPlotAdd(nplotB, mtrc, NULL /* nfilt */, AIR_TRUE, smoothPlot,
+ flatWght, 0, 0, NULL, NULL)) {
airMopAdd(mop, err = biffGetDone(PULL), airFree, airMopAlways);
fprintf(stderr, "%s: trouble PlotAdd'ing (C):\n%s", me, err);
- airMopError(mop); return 1;
+ airMopError(mop);
+ return 1;
}
{
const Nrrd *nin[2];
@@ -970,19 +928,22 @@
if (nrrdJoin(nplot, nin, 2, 0, AIR_TRUE)) {
airMopAdd(mop, err = biffGetDone(NRRD), airFree, airMopAlways);
fprintf(stderr, "%s: trouble E:\n%s", me, err);
- airMopError(mop); return 1;
+ airMopError(mop);
+ return 1;
}
}
if (nrrdSave(outS, nplot, NULL)) {
airMopAdd(mop, err = biffGetDone(NRRD), airFree, airMopAlways);
fprintf(stderr, "%s: trouble F:\n%s", me, err);
- airMopError(mop); return 1;
+ airMopError(mop);
+ return 1;
}
if (nmaskedpos && nmaskedpos->data && airStrlen(traceMaskPosOutS)) {
if (nrrdSave(traceMaskPosOutS, nmaskedpos, NULL)) {
airMopAdd(mop, err = biffGetDone(NRRD), airFree, airMopAlways);
fprintf(stderr, "%s: trouble G:\n%s", me, err);
- airMopError(mop); return 1;
+ airMopError(mop);
+ return 1;
}
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|