You can subscribe to this list here.
| 2003 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(19) |
Nov
(45) |
Dec
(80) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2004 |
Jan
(58) |
Feb
(127) |
Mar
(74) |
Apr
(34) |
May
(117) |
Jun
(14) |
Jul
(26) |
Aug
(13) |
Sep
(1) |
Oct
(38) |
Nov
(13) |
Dec
(5) |
| 2005 |
Jan
(108) |
Feb
(134) |
Mar
(54) |
Apr
(133) |
May
(16) |
Jun
(54) |
Jul
(128) |
Aug
(99) |
Sep
(157) |
Oct
(182) |
Nov
(236) |
Dec
(212) |
| 2006 |
Jan
(86) |
Feb
(76) |
Mar
(121) |
Apr
(27) |
May
(7) |
Jun
(1) |
Jul
(6) |
Aug
(28) |
Sep
(1) |
Oct
(27) |
Nov
(5) |
Dec
|
| 2007 |
Jan
(32) |
Feb
(22) |
Mar
(22) |
Apr
(11) |
May
(3) |
Jun
(12) |
Jul
(11) |
Aug
(9) |
Sep
(37) |
Oct
(4) |
Nov
(9) |
Dec
(51) |
| 2008 |
Jan
(7) |
Feb
(31) |
Mar
(46) |
Apr
(31) |
May
(5) |
Jun
(27) |
Jul
(12) |
Aug
(5) |
Sep
(13) |
Oct
(24) |
Nov
(112) |
Dec
(15) |
| 2009 |
Jan
(6) |
Feb
(103) |
Mar
(66) |
Apr
(9) |
May
(8) |
Jun
(1) |
Jul
(20) |
Aug
(9) |
Sep
(2) |
Oct
(81) |
Nov
(88) |
Dec
(30) |
| 2010 |
Jan
(65) |
Feb
(57) |
Mar
(22) |
Apr
(12) |
May
(4) |
Jun
(12) |
Jul
(43) |
Aug
(6) |
Sep
(6) |
Oct
(4) |
Nov
(6) |
Dec
(3) |
| 2011 |
Jan
(10) |
Feb
(27) |
Mar
(11) |
Apr
(9) |
May
(69) |
Jun
(73) |
Jul
(67) |
Aug
(116) |
Sep
(40) |
Oct
(11) |
Nov
(34) |
Dec
(19) |
| 2012 |
Jan
|
Feb
(4) |
Mar
(28) |
Apr
(18) |
May
(9) |
Jun
(7) |
Jul
(4) |
Aug
(155) |
Sep
(264) |
Oct
(172) |
Nov
(15) |
Dec
(40) |
| 2013 |
Jan
(1) |
Feb
(2) |
Mar
|
Apr
|
May
|
Jun
(20) |
Jul
(76) |
Aug
(67) |
Sep
(49) |
Oct
(27) |
Nov
(3) |
Dec
(3) |
| 2014 |
Jan
(7) |
Feb
(7) |
Mar
(16) |
Apr
|
May
(4) |
Jun
(1) |
Jul
(18) |
Aug
|
Sep
|
Oct
|
Nov
(1) |
Dec
|
| 2015 |
Jan
(6) |
Feb
(5) |
Mar
(3) |
Apr
(23) |
May
(5) |
Jun
|
Jul
(2) |
Aug
(4) |
Sep
|
Oct
|
Nov
(2) |
Dec
(4) |
| 2016 |
Jan
(2) |
Feb
(7) |
Mar
(2) |
Apr
(1) |
May
(14) |
Jun
(3) |
Jul
|
Aug
(3) |
Sep
|
Oct
|
Nov
(1) |
Dec
(3) |
| 2017 |
Jan
(6) |
Feb
|
Mar
(3) |
Apr
|
May
|
Jun
|
Jul
|
Aug
(12) |
Sep
(6) |
Oct
|
Nov
(3) |
Dec
|
| 2018 |
Jan
(4) |
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(1) |
Aug
(8) |
Sep
|
Oct
|
Nov
|
Dec
(1) |
| 2019 |
Jan
|
Feb
|
Mar
(4) |
Apr
|
May
|
Jun
|
Jul
|
Aug
(3) |
Sep
(8) |
Oct
|
Nov
(2) |
Dec
(25) |
| 2020 |
Jan
|
Feb
(3) |
Mar
|
Apr
|
May
(1) |
Jun
|
Jul
|
Aug
|
Sep
(3) |
Oct
(53) |
Nov
(33) |
Dec
|
| 2021 |
Jan
(2) |
Feb
|
Mar
|
Apr
|
May
|
Jun
(2) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(4) |
Dec
(5) |
| 2022 |
Jan
(1) |
Feb
|
Mar
|
Apr
|
May
|
Jun
(5) |
Jul
(93) |
Aug
(206) |
Sep
(39) |
Oct
(19) |
Nov
(11) |
Dec
|
| 2023 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(2) |
Jun
(150) |
Jul
(124) |
Aug
(14) |
Sep
(5) |
Oct
|
Nov
(1) |
Dec
|
| 2024 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(12) |
Jul
(62) |
Aug
|
Sep
(7) |
Oct
|
Nov
(7) |
Dec
|
| 2025 |
Jan
|
Feb
|
Mar
|
Apr
(14) |
May
(3) |
Jun
|
Jul
|
Aug
(76) |
Sep
(214) |
Oct
(6) |
Nov
|
Dec
|
|
From: <kin...@us...> - 2023-07-13 12:00:02
|
Revision: 7086
http://sourceforge.net/p/teem/code/7086
Author: kindlmann
Date: 2023-07-13 11:59:58 +0000 (Thu, 13 Jul 2023)
Log Message:
-----------
fixing wording in comment
Modified Paths:
--------------
teem/trunk/src/bin/puller-with-Deft.c
Modified: teem/trunk/src/bin/puller-with-Deft.c
===================================================================
--- teem/trunk/src/bin/puller-with-Deft.c 2023-07-13 11:59:32 UTC (rev 7085)
+++ teem/trunk/src/bin/puller-with-Deft.c 2023-07-13 11:59:58 UTC (rev 7086)
@@ -20,7 +20,7 @@
*/
/* for Teem v2 the Deft stuff was removed from puller.c; but this
- file preserves them for posterity. */
+ file preserves it for posterity. */
/*
** NOTE: all the "#ifdef DEFT" directives refer to an FLTK2-based GUI
** for some parts of Teem called "Deft". Unfortunately FLTK2 has been
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <kin...@us...> - 2023-07-13 11:59:34
|
Revision: 7085
http://sourceforge.net/p/teem/code/7085
Author: kindlmann
Date: 2023-07-13 11:59:32 +0000 (Thu, 13 Jul 2023)
Log Message:
-----------
removing Deft code and updating hest usage
Modified Paths:
--------------
teem/trunk/src/bin/puller.c
Modified: teem/trunk/src/bin/puller.c
===================================================================
--- teem/trunk/src/bin/puller.c 2023-07-13 11:41:02 UTC (rev 7084)
+++ teem/trunk/src/bin/puller.c 2023-07-13 11:59:32 UTC (rev 7085)
@@ -19,26 +19,9 @@
Fifth Floor, Boston, MA 02110-1301 USA
*/
-/*
-** NOTE: all the "#ifdef DEFT" directives refer to an FLTK2-based GUI
-** for some parts of Teem called "Deft". Unfortunately FLTK2 has been
-** abandoned, and Deft is not released or supported in any way. The
-** Deft-related code is preserved for legacy purposes.
-*/
+/* for Teem v2 the Deft stuff was removed from this file; see
+ puller-with-Deft.c for that code */
-#ifdef DEFT
-# include "Deft.h"
-# include "Contour.h"
-# include "Viewer.h"
-# include "ViewerUI.h"
-# include "TensorGlyph.h"
-# include "TensorGlyphUI.h"
-# include "Slider.h"
-# include "TriPlane.h"
-# include "TriPlaneUI.h"
-
-#endif
-
#include <teem/pull.h>
#include <teem/meet.h>
@@ -52,645 +35,6 @@
"\t\tParticles. IEEE Trans. on Visualization and Computer Graphics,\n "
"\t\t15(6):1415-1424 (2009).");
-#ifdef DEFT
-typedef struct {
- fltk::FloatInput *scaleVecInput[3];
- fltk::ValueInput *glyphScaleRadInput;
- Deft::Slider *isoval;
- Deft::Slider *strength;
- Deft::Slider *quality;
- Deft::Slider *alpha, *beta, *cwell, *gamma;
- /* Deft::Slider *height; */
- Deft::Slider *ccSelect, *rho, *sclMean, *sclWind;
- fltk::CheckButton *ccSingle;
- Deft::Contour *contour;
- Deft::Scene *scene;
- Deft::Viewer *viewer;
- Deft::TensorGlyph *glyph, *hedge;
- fltk::IntInput *iters;
- fltk::FloatInput *radius;
- fltk::ValueInput *verbose;
- pullContext *pctx;
- Nrrd *nPosOut, *nTenOut, *nFrcOut, *nten, *ntmp, *nenr, *nscl, *nidcc, *nstrn, *nqual,
- *ncovar, *ntcovar, *nstab, *nintern, *nstuck, *nfrcOld, *nfrcNew, *nposOld, *nposNew,
- *nrgb, *nccrgb, *ncval, *ncmap, *ncmapOut, *nblur;
- NrrdResampleContext *rsmc;
- const Nrrd *norig;
- NrrdRange *cvalRange;
- limnPolyData *phistLine, *phistTube;
- Deft::PolyData *phistSurf;
- double icvalr[2], sclMin, sclMax, strnMin, qualMin, scaleVec[3], glyphScaleRad,
- energyIncreasePermitFrac;
-} pullBag;
-
-void
-verbose_cb(fltk::Widget *widget, pullBag *bag) {
- fltk::ValueInput *val;
-
- val = (fltk::ValueInput *)widget;
- pullVerboseSet(bag->pctx, (int)val->value());
-}
-/* ... DEFT ... */
-void
-isovalue_cb(fltk::Widget *widget, pullBag *bag) {
- Deft::Slider *slider;
-
- slider = (Deft::Slider *)widget;
- if (bag->contour) {
- bag->contour->extract(slider->value());
- }
- bag->viewer->redraw();
-}
-
-void
-outputGet(pullBag *bag) {
- static const char me[] = "outputGet";
- char *err;
- size_t cropMin[2], cropMax[2];
-
- if (pullOutputGet(bag->nPosOut, bag->nTenOut, bag->nstrn, /* may be NULL */
- bag->scaleVec, bag->glyphScaleRad, bag->pctx)
- || pullPropGet(bag->nscl, pullPropScale, bag->pctx)
- || (bag->pctx->ispec[pullInfoQuality]
- ? pullInfoGet(bag->nqual, pullInfoQuality, bag->pctx)
- : 0)
- || pullPropGet(bag->nenr, pullPropEnergy, bag->pctx)
- || pullPropGet(bag->nidcc, pullPropIdCC, bag->pctx)
- || pullPropGet(bag->nstuck, pullPropStuck, bag->pctx)
- || pullPropGet(bag->ncovar, pullPropNeighCovar7Ten, bag->pctx)
-# if PULL_TANCOVAR
- || pullPropGet(bag->ntcovar, pullPropNeighTanCovar, bag->pctx)
-# endif
- || pullPropGet(bag->nstab, pullPropStability, bag->pctx)
- || pullPropGet(bag->nintern, pullPropNeighInterNum, bag->pctx)
- || pullPropGet(bag->nFrcOut, pullPropForce, bag->pctx)
- || (pullPhistEnabled ? pullPositionHistoryGet(bag->phistLine, bag->pctx) : 0)) {
- err = biffGetDone(PULL);
- fprintf(stderr, "%s: error getting pull output:\n%s\n", me, err);
- free(err);
- exit(1);
- }
- /* ... DEFT ... */
- cropMin[0] = 0;
- cropMin[1] = 0;
- cropMax[0] = 2;
- cropMax[1] = bag->nPosOut->axis[1].size - 1;
- if ((!bag->pctx->iter ? 0
- : (nrrdCopy(bag->nfrcOld, bag->nfrcNew)
- || nrrdCopy(bag->nposOld, bag->nposNew)))
- || nrrdConvert(bag->nten, bag->nTenOut, nrrdTypeFloat)
- /* hacks to visualize the (tan) covariance tensors
- || nrrdCopy(bag->nten, bag->ncovar)
- || nrrdCopy(bag->nten, bag->ntcovar)
- */
- || nrrdCrop(bag->ntmp, bag->nPosOut, cropMin, cropMax)
- || nrrdConvert(bag->nposNew, bag->ntmp, nrrdTypeFloat)
- || nrrdCrop(bag->ntmp, bag->nFrcOut, cropMin, cropMax)
- || nrrdConvert(bag->nfrcNew, bag->ntmp, nrrdTypeFloat)
- || (!bag->pctx->iter ? (nrrdCopy(bag->nfrcOld, bag->nfrcNew)
- || nrrdCopy(bag->nposOld, bag->nposNew))
- : 0)) {
- err = biffGetDone(NRRD);
- fprintf(stderr, "%s: another error 0\n%s\n", me, err);
- free(err);
- exit(1);
- }
-}
-/* ... DEFT ... */
-void
-outputShow(pullBag *bag) {
- static const char me[] = "outputShow";
- char *err;
- float *rgb;
- unsigned int ii, nn, *idcc;
- unsigned char *stuck;
- int first;
- double *cval, emean, estdv, *pos;
-
- /*
- if (limnPolyDataSpiralTubeWrap(bag->phistTube, bag->phistLine,
- (1 << limnPolyDataInfoRGBA)
- | (1 << limnPolyDataInfoNorm),
- NULL,
- 8, 8, bag->glyph->glyphScale()/5)) {
- err = biffGetDone(LIMN);
- fprintf(stderr, "%s: another error 1\n%s\n", me, err);
- free(err);
- exit(1);
- }
- */
-
- if (pullPhistEnabled) {
- bag->phistSurf->changed();
- }
-
- bag->ncval = bag->nenr;
- /* bag->ncval = bag->nstrn; */
- /* bag->ncval = bag->nstuck; */
- /* bag->ncval = bag->nscl; */
-
- /* ... DEFT ... */
- if (bag->ncval) {
- nrrdRangeSet(bag->cvalRange, bag->ncval, AIR_FALSE);
- } else {
- bag->cvalRange->min = AIR_NAN;
- bag->cvalRange->max = AIR_NAN;
- }
- if (bag->ncval) {
- cval = AIR_CAST(double *, bag->ncval->data);
- } else {
- cval = NULL;
- }
- if (cval) {
- nn = bag->ncval->axis[0].size;
- emean = 0;
- for (ii = 0; ii < nn; ii++) {
- emean += cval[ii];
- }
- emean /= nn;
- estdv = 0;
- for (ii = 0; ii < nn; ii++) {
- estdv += (emean - cval[ii]) * (emean - cval[ii]);
- }
- estdv = sqrt(estdv / nn);
- if (bag->cvalRange->hasNonExist) {
- fprintf(stderr, "!%s: cval range %g -- %g (%s), mean %g, stdv %g\n", me,
- bag->cvalRange->min, bag->cvalRange->max,
- bag->cvalRange->hasNonExist ? "HAS non-exist" : "no non-exist", emean,
- estdv);
- }
- bag->cvalRange->min = AIR_LERP(0.7, bag->cvalRange->min, emean - 2 * estdv);
- bag->cvalRange->max = AIR_LERP(0.7, bag->cvalRange->max, emean + 2 * estdv);
- }
- /* ... DEFT ... */
- float *cmapOut;
- if (bag->ncmap && bag->ncval && AIR_EXISTS(bag->cvalRange->min)
- && AIR_EXISTS(bag->cvalRange->max)) {
- /* double mmin, mmax; */
- fprintf(stderr, "!%s: cval cmap range %g %g ----------- \n", me, bag->cvalRange->min,
- bag->cvalRange->max);
- /*
- mmin = -0.0342937;
- mmax = -0.0105725;
- */
- /* */
- /*
- bag->cvalRange->min = AIR_LERP(0.05, mmin, mmax);
- bag->cvalRange->max = AIR_LERP(0.3, mmin, mmax);
- */
- /* */
- if (nrrdApply1DRegMap(bag->ncmapOut, bag->ncval, bag->cvalRange, bag->ncmap,
- nrrdTypeFloat, AIR_TRUE)) {
- err = biffGetDone(NRRD);
- fprintf(stderr, "%s: cmap error\n%s\n", me, err);
- free(err);
- exit(1);
- }
- cmapOut = AIR_CAST(float *, bag->ncmapOut->data);
- } else {
- cmapOut = NULL;
- }
-
- /* ... DEFT ... */
-
- idcc = AIR_CAST(unsigned int *, bag->nidcc->data);
- stuck = AIR_CAST(unsigned char *, bag->nstuck->data);
- nn = bag->nPosOut->axis[1].size;
- pos = AIR_CAST(double *, bag->nPosOut->data);
-
- first = bag->nrgb->axis[1].size != bag->nPosOut->axis[1].size;
- /*
- fprintf(stderr, "!%s: %u %u -> %d\n", me,
- AIR_UINT(bag->nrgb->axis[1].size),
- AIR_UINT(bag->nPosOut->axis[1].size), first);
- */
- if (first) {
- if (nrrdMaybeAlloc_va(bag->nrgb, nrrdTypeFloat, 2, AIR_CAST(size_t, 3),
- bag->nPosOut->axis[1].size)) {
- err = biffGetDone(NRRD);
- fprintf(stderr, "%s: error creating RGB:\n%s\n", me, err);
- free(err);
- exit(1);
- }
- }
- bag->icvalr[0] = bag->cvalRange->min;
- bag->icvalr[1] = bag->cvalRange->max;
-
- /* ... DEFT ... */
-
- double *strnOut;
- strnOut = (bag->nstrn ? AIR_CAST(double *, bag->nstrn->data) : NULL);
- double *qualOut;
- qualOut = (bag->nqual ? AIR_CAST(double *, bag->nqual->data) : NULL);
- rgb = (float *)bag->nrgb->data;
- for (ii = 0; ii < nn; ii++) {
- float ee, *ccrgb;
- ccrgb = (float *)bag->nccrgb->data;
- /* ee = bag->cvalRange->min - (bag->icvalr[1] - bag->icvalr[0])/50;*/
- ee = bag->cvalRange->min;
- if (bag->pctx->CCNum && ccrgb) {
- rgb[0 + 3 * ii] = ccrgb[0 + 3 * idcc[ii]];
- rgb[1 + 3 * ii] = ccrgb[1 + 3 * idcc[ii]];
- rgb[2 + 3 * ii] = ccrgb[2 + 3 * idcc[ii]];
- } else if (cmapOut) {
- ELL_3V_COPY(rgb + 3 * ii, cmapOut + 3 * ii);
- } else {
- ELL_3V_SET(rgb + 3 * ii, 0.95, 0.95, 0.95);
- /*
- if (AIR_EXISTS(cval[ii])) {
- rgb[1 + 3*ii] = AIR_AFFINE(ee, cval[ii], bag->cvalRange->max, 0, 1);
- rgb[1 + 3*ii] = sqrt(rgb[1 + 3*ii]);
- rgb[0 + 3*ii] = rgb[1 + 3*ii];
- } else {
- rgb[1 + 3*ii] = 0;
- rgb[0 + 3*ii] = 1;
- }
- rgb[2 + 3*ii] = stuck[ii];
- */
- }
- }
-
- /* ... DEFT ... */
-
- if (1) {
- float *ten, *pos;
- double *posOut;
- ten = AIR_CAST(float *, bag->nten->data);
- posOut = AIR_CAST(double *, bag->nPosOut->data);
- pos = AIR_CAST(float *, bag->nposNew->data);
- for (ii = 0; ii < nn; ii++) {
- if (!(AIR_IN_CL(bag->sclMin - 0.00001, posOut[3], bag->sclMax + 0.00001))) {
- ten[0] = 0;
- } else if (strnOut && strnOut[ii] < bag->strnMin) {
- ten[0] = 0;
- } else if (qualOut && qualOut[ii] < bag->qualMin - 0.000001) {
- ten[0] = 0;
- } else if (bag->pctx->CCNum
- && (bag->ccSingle->value() ? idcc[ii] != bag->ccSelect->value()
- : idcc[ii] > bag->ccSelect->value())) {
- ten[0] = 0;
- } else {
- ten[0] = 1;
- }
- /*
- if (4589 == ii) {
- fprintf(stderr, "!%s: point %u/%u at (%g,%g,%g)=(%g,%g,%g,%g) got ten[0] %g\n",
- me, ii, nn,
- pos[0], pos[1], pos[1],
- posOut[0], posOut[1], posOut[2], posOut[3],
- ten[0]);
- }
- */
- pos += 3;
- posOut += 4;
- ten += 7;
- }
- }
-
- /* ... DEFT ... */
-
- if (bag->nPosOut->axis[1].size) {
- bag->glyph->dataSet(bag->nPosOut->axis[1].size, (float *)bag->nten->data, 7,
- (float *)bag->nposNew->data, 3, rgb, 3, NULL);
- bag->glyph->update();
- /*
- bag->hedge->dataSet(bag->nPosOut->axis[1].size,
- (float*)bag->nfrcNew->data, 3,
- (float*)bag->nposOld->data, 3, rgb, 3, NULL);
- bag->hedge->update();
- */
- bag->viewer->redraw();
- fltk::flush();
- } else {
- fprintf(stderr, "!%s: got zero tensors out!\n", me);
- }
- return;
-}
-
-void
-iter_cb(void *_bag) {
- pullBag *bag;
- bag = AIR_CAST(pullBag *, _bag);
- outputGet(bag);
- outputShow(bag);
-}
-
-/* ... DEFT ... */
-
-void
-step_cb(fltk::Widget *, pullBag *bag) {
- /* static double lastthresh = -42; */
- static const char me[] = "step_cb";
- char *err;
- static unsigned int itersTotal = 0;
-
- unsigned int iters = bag->iters->ivalue();
- bag->pctx->iterParm.max += iters;
- if (pullRun(bag->pctx)) {
- err = biffGetDone(PULL);
- fprintf(stderr, "%s: error running pull:\n%s\n", me, err);
- free(err);
- exit(1);
- }
- itersTotal += iters;
- fprintf(stderr, "!%s: enr = %g; time = %g sec; %u iters (%g iters/sec)\n", me,
- bag->pctx->energy, bag->pctx->timeRun, itersTotal,
- itersTotal / bag->pctx->timeRun);
- outputGet(bag);
- outputShow(bag);
- for (unsigned int ci = pullCountUnknown + 1; ci < pullCountLast; ci++) {
- if (bag->pctx->count[ci]) {
- fprintf(stderr, " %u: %s\n", bag->pctx->count[ci], airEnumStr(pullCount, ci));
- }
- }
-}
-
-/* ... DEFT ... */
-
-void
-gammaSet_cb(fltk::Widget *, pullBag *bag) {
- static const char me[] = "gammaSet_cb";
-
- if (pullGammaLearn(bag->pctx)) {
- char *err = biffGetDone(PULL);
- fprintf(stderr, "%s: problem learning gamma:\n%s", me, err);
- free(err);
- }
- if (bag->pctx->sysParm.gamma > bag->gamma->maximum()) {
- bag->gamma->maximum(2 * bag->pctx->sysParm.gamma);
- }
- bag->gamma->value(bag->pctx->sysParm.gamma);
-}
-
-/* ... DEFT ... */
-
-void
-cc_cb(fltk::Widget *, pullBag *bag) {
- static const char me[] = "cc_cb";
- unsigned int cc;
- float *rgb;
-
- if (pullCCFind(bag->pctx)
- || pullCCSort(bag->pctx, (bag->pctx->ispec[pullInfoQuality] ? pullInfoQuality : 0),
- bag->rho->value())) {
- char *err = biffGetDone(PULL);
- fprintf(stderr, "%s: problem finding/sorting CCs:\n%s", me, err);
- free(err);
- }
- printf("%s: found %u CCs\n", me, bag->pctx->CCNum);
- bag->ccSelect->range(0, bag->pctx->CCNum - 1);
- if (bag->nccrgb->axis[1].size != bag->pctx->CCNum) {
- airSrandMT(AIR_UINT(airTime()));
- if (nrrdMaybeAlloc_va(bag->nccrgb, nrrdTypeFloat, 2, AIR_CAST(size_t, 3),
- AIR_CAST(size_t, bag->pctx->CCNum))) {
- char *err = biffGetDone(NRRD);
- fprintf(stderr, "%s: problem alloc'ing cc rgb:\n%s", me, err);
- free(err);
- }
- rgb = (float *)bag->nccrgb->data;
- ELL_3V_SET(rgb + 0 * 3, 0.95, 0.95, 0.95);
- for (cc = 0; cc < bag->pctx->CCNum; cc++) {
- rgb[0 + 3 * cc] = AIR_AFFINE(0, airDrandMT(), 1, 0.3, 1.0);
- rgb[1 + 3 * cc] = AIR_AFFINE(0, airDrandMT(), 1, 0.3, 1.0);
- rgb[2 + 3 * cc] = AIR_AFFINE(0, airDrandMT(), 1, 0.3, 1.0);
- }
- }
- outputGet(bag);
- outputShow(bag);
-}
-
-/* ... DEFT ... */
-
-void
-ccSelect_cb(fltk::Widget *, pullBag *bag) {
-
- outputShow(bag);
-}
-
-void
-scaleGlyph_cb(fltk::Widget *, pullBag *bag) {
-
- bag->scaleVec[0] = bag->scaleVecInput[0]->fvalue();
- bag->scaleVec[1] = bag->scaleVecInput[1]->fvalue();
- bag->scaleVec[2] = bag->scaleVecInput[2]->fvalue();
- bag->glyphScaleRad = bag->glyphScaleRadInput->value();
- outputGet(bag);
- outputShow(bag);
-}
-
-/* ... DEFT ... */
-
-void
-reblur_cb(fltk::Widget *, pullBag *bag) {
- static const char me[] = "reblur_cb";
- double kparm[NRRD_KERNEL_PARMS_NUM], scl;
- int E;
-
- if (!bag->pctx->haveScale) {
- return;
- }
- scl = bag->sclMean->value();
- if (bag->pctx->flag.scaleIsTau) {
- kparm[0] = gageSigOfTau(scl);
- printf("!%s: tau = %g ---> sigma = %g\n", me, scl, kparm[0]);
- } else {
- kparm[0] = scl;
- printf("!%s: sigma = %g\n", me, kparm[0]);
- }
- kparm[1] = 3;
- E = 0;
- for (unsigned int axi = 0; axi < 3; axi++) {
- if (!E)
- E |= nrrdResampleKernelSet(bag->rsmc, axi, nrrdKernelDiscreteGaussian, kparm);
- }
- if (!E) E |= nrrdResampleExecute(bag->rsmc, bag->nblur);
- if (E) {
- char *err = biffGetDone(NRRD);
- fprintf(stderr, "%s: problem resampling to scale %g:\n%s", me, bag->sclMean->value(),
- err);
- free(err);
- }
- outputShow(bag);
- return;
-}
-
-/* ... DEFT ... */
-
-void
-scale_cb(fltk::Widget *, pullBag *bag) {
- double sclMean, sclWind;
-
- if (bag->pctx->haveScale) {
- sclMean = bag->sclMean->value();
- sclWind = bag->sclWind->value();
- bag->sclMin = sclMean - sclWind / 2;
- bag->sclMax = sclMean + sclWind / 2;
- } else {
- bag->sclMin = 0;
- bag->sclMax = 0;
- }
- outputShow(bag);
- return;
-}
-
-void
-alpha_cb(fltk::Widget *, pullBag *bag) {
-
- pullSysParmSet(bag->pctx, pullSysParmAlpha, bag->alpha->value());
-}
-
-void
-beta_cb(fltk::Widget *, pullBag *bag) {
-
- pullSysParmSet(bag->pctx, pullSysParmBeta, bag->beta->value());
-}
-
-/* ... DEFT ... */
-
-void
-cwell_cb(fltk::Widget *, pullBag *bag) {
- double *parm;
-
- parm = bag->pctx->energySpecR->parm;
- parm[1] = bag->cwell->value();
- pullSysParmSet(bag->pctx, pullSysParmEnergyIncreasePermit,
- bag->energyIncreasePermitFrac * bag->cwell->value());
- {
- unsigned int ii, nn;
- double xx, yy, de;
- FILE *file;
-
- if ((file = fopen("eplot.txt", "w"))) {
- nn = 800;
- for (ii = 0; ii < nn; ii++) {
- xx = AIR_AFFINE(0, ii, nn - 1, 0.0, 1.0);
- yy = bag->pctx->energySpecR->energy->eval(&de, xx, parm);
- fprintf(file, "%f %f\n", xx, yy);
- }
- fclose(file);
- }
- }
-}
-
-void
-gamma_cb(fltk::Widget *, pullBag *bag) {
-
- pullSysParmSet(bag->pctx, pullSysParmGamma, bag->gamma->value());
-}
-
-/* ... DEFT ... */
-
-void
-strength_cb(fltk::Widget *, pullBag *bag) {
-
- bag->strnMin = bag->strength->value();
- outputShow(bag);
-}
-
-void
-quality_cb(fltk::Widget *, pullBag *bag) {
-
- bag->qualMin = bag->quality->value();
- outputShow(bag);
-}
-
-void
-save_cb(fltk::Widget *, pullBag *bag) {
- static const char me[] = "save_cb";
- unsigned int ii, nn, count;
- float *ten;
- Nrrd *nPosSel, *nStrnSel;
- double *posSel, *posAll, *strnSel, *strnAll;
-
- if (!(0.0 == ELL_3V_LEN(bag->scaleVec))) {
- fprintf(stderr, "%s: refusing to save with non-zero scaleVec %g %g %g\n", me,
- bag->scaleVec[0], bag->scaleVec[1], bag->scaleVec[2]);
- return;
- }
-
- /* ... DEFT ... */
-
- nPosSel = nrrdNew();
- if (bag->nstrn) {
- nStrnSel = nrrdNew();
- } else {
- nStrnSel = NULL;
- }
- outputGet(bag);
- outputShow(bag); /* will exploit its masking of ten[0] */
- count = 0;
- nn = bag->nPosOut->axis[1].size;
- ten = AIR_CAST(float *, bag->nten->data);
- for (ii = 0; ii < nn; ii++) {
- count += !!ten[0];
- ten += 7;
- }
- nrrdMaybeAlloc_va(nPosSel, nrrdTypeDouble, 2, AIR_CAST(size_t, 4),
- AIR_CAST(size_t, count));
- posAll = AIR_CAST(double *, bag->nPosOut->data);
- posSel = AIR_CAST(double *, nPosSel->data);
- if (bag->nstrn) {
- nrrdMaybeAlloc_va(nStrnSel, nrrdTypeDouble, 1, AIR_CAST(size_t, count));
- strnAll = AIR_CAST(double *, bag->nstrn->data);
- strnSel = AIR_CAST(double *, nStrnSel->data);
- } else {
- strnSel = NULL;
- strnAll = NULL;
- }
- ten = AIR_CAST(float *, bag->nten->data);
- count = 0;
- for (ii = 0; ii < nn; ii++) {
- if (ten[0]) {
- ELL_4V_COPY(posSel, posAll);
- if (strnSel && strnAll) {
- strnSel[count] = strnAll[ii];
- }
- posSel += 4;
- count++;
- }
- posAll += 4;
- ten += 7;
- }
-
- /* ... DEFT ... */
-
- nrrdSave("pos-all.nrrd", bag->nPosOut, NULL);
- if (0) {
- nrrdSave("pos-sel.nrrd", nPosSel, NULL);
- } else {
- char fname[512];
- FILE *ff;
- unsigned int ii = 0;
-
- for (ii = 0, ff = NULL; AIR_TRUE; ii++) {
- ff = airFclose(ff);
- sprintf(fname, "pos-sel-%03u.nrrd", ii);
- if (!(ff = fopen(fname, "rb"))) {
- break;
- }
- }
- ff = airFclose(ff);
- nrrdSave(fname, nPosSel, NULL);
- }
- nrrdSave("covar-all.nrrd", bag->ncovar, NULL);
-# if PULL_TANCOVAR
- nrrdSave("tcovar-all.nrrd", bag->ntcovar, NULL);
-# endif
- nrrdSave("stab-all.nrrd", bag->nstab, NULL);
- nrrdSave("intern-all.nrrd", bag->nintern, NULL);
- if (bag->nstrn) {
- nrrdSave("strn-all.nrrd", bag->nstrn, NULL);
- nrrdSave("strn-sel.nrrd", nStrnSel, NULL);
- }
- nrrdNuke(nPosSel);
- if (bag->nstrn) {
- nrrdNuke(nStrnSel);
- }
- return;
-}
-
-#endif /* DEFT */
-
int
main(int argc, const char **argv) {
hestOpt *hopt = NULL;
@@ -698,17 +42,6 @@
airArray *mop;
const char *me;
-#ifdef DEFT
- float fr[3], at[3], up[3], fovy, neer, faar, dist, bg[3];
- int imgSize[2], ortho, rght, atrel, camkeep;
-
- float anisoThresh, anisoThreshMin, glyphScale, haloTraceBound, glyphHaloWidth,
- glyphNormPow, glyphEvalPow, sqdSharp;
- int glyphType, glyphFacetRes, aniso;
- double ssrange[2];
- pullBag bag;
-#endif
-
char *err, *outS, *extraOutBaseS, *addLogS, *cachePathSS;
FILE *addLog;
meetPullVol **vspec;
@@ -747,287 +80,188 @@
hparm->respectDashDashHelp = AIR_TRUE;
me = argv[0];
-#ifdef DEFT
- unsigned int baryRes;
- int saveAndQuit, fog;
+ hestOptAdd_1_Enum(&hopt, "int", "int", &interType, "justr",
+ "inter-particle energy type", pullInterType);
+ hestOptAdd_1_Other(&hopt, "enr", "spec", &enspR, "cotan",
+ "inter-particle energy, radial component", pullHestEnergySpec);
+ hestOptAdd_1_Other(&hopt, "ens", "spec", &enspS, "zero",
+ "inter-particle energy, scale component", pullHestEnergySpec);
+ hestOptAdd_1_Other(&hopt, "enw", "spec", &enspWin, "butter:16,0.8",
+ "windowing to create locality with additive "
+ "scale-space interaction (\"-int add\")",
+ pullHestEnergySpec);
+ hestOptAdd_1_Bool(&hopt, "zz", "bool", &zeroZ, "false",
+ "always constrain Z=0, to process 2D images");
+ hestOptAdd_1_Bool(&hopt, "efs", "bool", &energyFromStrength, "false",
+ "whether or not strength contributes to particle-image energy");
+ hestOptAdd_1_Bool(&hopt, "nave", "bool", &nixAtVolumeEdgeSpace, "false",
+ "whether or not to nix points at edge of volume, where gage had "
+ "to invent values for kernel support");
+ hestOptAdd_1_Bool(&hopt, "cbst", "bool", &constraintBeforeSeedThresh, "false",
+ "during initialization, try constraint satisfaction before "
+ "testing seedThresh");
+ hestOptAdd_Flag(&hopt, "noadd", &noAdd, "turn off adding during population control");
+ hestOptAdd_1_Bool(&hopt, "usa", "bool", &unequalShapesAllow, "false",
+ "allow volumes to have different shapes (false is safe as "
+ "different volume sizes are often accidental)");
+ hestOptAdd_1_Bool(&hopt, "pcet", "bool", &popCntlEnoughTest, "true",
+ "use neighbor-counting \"enough\" heuristic to "
+ "bail out of pop cntl");
+ hestOptAdd_1_Bool(&hopt, "cipc", "bool", &convergenceIgnoresPopCntl, "false",
+ "convergence test doesn't care if there has been "
+ "recent changes due to population control");
+ hestOptAdd_Flag(&hopt, "nobin", &binSingle,
+ "turn off spatial binning (which prevents multi-threading "
+ "from being useful), for debugging or speed-up measurement");
+ hestOptAdd_1_Bool(&hopt, "lti", "bool", &liveThresholdOnInit, "true",
+ "impose liveThresh on initialization");
+ hestOptAdd_1_Bool(&hopt, "por", "bool", &permuteOnRebin, "true",
+ "permute points during rebinning");
+ hestOptAdd_1_Bool(&hopt, "npcwza", "bool", &noPopCntlWithZeroAlpha, "false",
+ "no pop cntl with zero alpha");
+ hestOptAdd_1_Bool(&hopt, "ubfgl", "bool", &useBetaForGammaLearn, "false",
+ "use beta for gamma learning");
+ hestOptAdd_1_Bool(&hopt, "ratb", "bool", &restrictiveAddToBins, "true",
+ "be choosy when adding points to bins to avoid overlap");
+ hestOptAdd_3_Double(&hopt, "svec", "vec", scaleVec, "0 0 0",
+ "if non-zero (length), vector to use for displaying scale "
+ "in 3-space");
+ hestOptAdd_1_Double(&hopt, "gssr", "rad", &glyphScaleRad, "0.0",
+ "if non-zero (length), scaling of scale to cylindrical tensors");
+ hestOptAdd_1_Int(&hopt, "v", "verbosity", &verbose, "1", "verbosity level");
+ hestOptAdd_Nv_Other(&hopt, "vol", "vol0 vol1", 1, -1, &vspec, NULL,
+ "input volumes, in format <filename>:<kind>:<volname>", &vspecNum,
+ meetHestPullVol);
+ hestOptAdd_Nv_Other(&hopt, "info", "info0 info1", 1, -1, &idef, NULL,
+ "info definitions, in format "
+ "<info>[-c]:<volname>:<item>[:<zero>:<scale>]",
+ &idefNum, meetHestPullInfo);
- hestOptAdd(&hopt, "csqvmm", "min max", airTypeDouble, 2, 2,
- Deft::colorSclQuantityValueMinMax, "nan nan",
- "min/max values for cutting planes of scalar values");
- hestOptAdd(&hopt, "saq", "save & quit", airTypeInt, 0, 0, &saveAndQuit, NULL,
- "save image and quit, for batch processing");
- hestOptAdd(&hopt, "cmap", "nin", airTypeOther, 1, 1, &(bag.ncmap), "",
- "colormap for particles", NULL, NULL, nrrdHestNrrd);
- hestOptAdd(&hopt, "fr", "from point", airTypeFloat, 3, 3, fr, "3 4 5",
- "position of camera, used to determine view vector");
- hestOptAdd(&hopt, "at", "at point", airTypeFloat, 3, 3, at, "0 0 0",
- "camera look-at point, used to determine view vector");
- hestOptAdd(&hopt, "up", "up vector", airTypeFloat, 3, 3, up, "0 0 1",
- "camera pseudo-up vector, used to determine view coordinates");
- hestOptAdd(&hopt, "rh", NULL, airTypeInt, 0, 0, &rght, NULL,
- "normally, use a right-handed UVN frame (V points down), "
- "but in Deft this is always true");
- hestOptAdd(&hopt, "fv", "fov", airTypeFloat, 1, 1, &fovy, "20",
- "vertical field-of-view, in degrees");
- hestOptAdd(&hopt, "or", NULL, airTypeInt, 0, 0, &ortho, NULL,
- "use orthogonal projection instead of perspective");
- hestOptAdd(&hopt, "dn", "near clip", airTypeFloat, 1, 1, &neer, "-2",
- "position of near clipping plane, relative to look-at point");
- hestOptAdd(&hopt, "di", "image", airTypeFloat, 1, 1, &dist, "0.0",
- "normally, distance to image plane, "
- "but in Deft this is always 0.0");
- hestOptAdd(&hopt, "df", "far clip", airTypeFloat, 1, 1, &faar, "2",
- "position of far clipping plane, relative to look-at point");
- hestOptAdd(&hopt, "ar", NULL, airTypeInt, 0, 0, &atrel, NULL,
- "normally: near, image, and far plane distances are relative to "
- "the *at* point, instead of the eye point, "
- "but for Deft, this is always true");
- hestOptAdd(&hopt, "usecam", NULL, airTypeInt, 0, 0, &camkeep, NULL,
- "hack: by default, a camera reset is done to put the volume "
- "in view. Use this to say that the camera specified by the "
- "flags above should be preserved and used");
- hestOptAdd(&hopt, "bg", "R G B", airTypeFloat, 3, 3, bg, "0.2 0.3 0.4",
- "background color");
- hestOptAdd(&hopt, "fog", NULL, airTypeInt, 0, 0, &fog, NULL, "hack: turn on fog");
- hestOptAdd(&hopt, "is", "su sv", airTypeInt, 2, 2, imgSize, "640 480",
- "initial window size");
- /* ... DEFT ... */
- /* this tensor stuff is here because we're hijacking the tensor glyph
- object for doing the particle display ... */
- hestOptAdd(&hopt, "a", "aniso", airTypeEnum, 1, 1, &aniso, NULL,
- "anisotropy metric to make volume of", NULL, tenAniso);
- hestOptAdd(&hopt, "atr", "aniso thresh", airTypeFloat, 1, 1, &anisoThresh, "0.85",
- "Glyphs will be drawn only for tensors with anisotropy "
- "greater than this threshold");
- hestOptAdd(&hopt, "atrm", "aniso thresh min", airTypeFloat, 1, 1, &anisoThreshMin,
- "0.4", "lower bound on aniso thresh");
- hestOptAdd(&hopt, "g", "glyph shape", airTypeEnum, 1, 1, &glyphType, "sqd",
- "shape of glyph to use for display. Possibilities "
- "include \"box\", \"sphere\"=\"sph\", \"cylinder\"=\"cyl\", and "
- "\"superquad\"=\"sqd\"",
- NULL, tenGlyphType);
- hestOptAdd(&hopt, "gsc", "scale", airTypeFloat, 1, 1, &glyphScale, "0.25",
- "over-all glyph size");
- hestOptAdd(&hopt, "htb", "trace", airTypeFloat, 1, 1, &haloTraceBound, "1.0",
- "halo trace bound");
- hestOptAdd(&hopt, "ghw", "hwidth", airTypeFloat, 1, 1, &glyphHaloWidth, "0.0",
- "glyph halo width");
- hestOptAdd(&hopt, "gnp", "npow", airTypeFloat, 1, 1, &glyphNormPow, "1.0",
- "pow() exponent for compressing range of norms");
- hestOptAdd(&hopt, "gep", "epow", airTypeFloat, 1, 1, &glyphEvalPow, "1.0",
- "pow() exponent for compressing single eigenvalues");
- hestOptAdd(&hopt, "br", "barycentric res", airTypeInt, 1, 1, &baryRes, "50",
- "resolution of sampling of tensor shape palette");
- hestOptAdd(&hopt, "gr", "glyph res", airTypeInt, 1, 1, &glyphFacetRes, "7",
- "resolution of polygonalization of glyphs (other than box)");
- hestOptAdd(&hopt, "sh", "sharpness", airTypeFloat, 1, 1, &sqdSharp, "2.5",
- "for superquadric glyphs, how much to sharp edges form as a "
- "function of differences between eigenvalues. Higher values "
- "mean that edges form more easily");
-#endif /* DEFT */
+ hestOptAdd_1_Other(&hopt, "k00", "kern00", &k00, "cubic:1,0",
+ "kernel for gageKernel00", nrrdHestKernelSpec);
+ hestOptAdd_1_Other(&hopt, "k11", "kern11", &k11, "cubicd:1,0",
+ "kernel for gageKernel11", nrrdHestKernelSpec);
+ hestOptAdd_1_Other(&hopt, "k22", "kern22", &k22, "cubicdd:1,0",
+ "kernel for gageKernel22", nrrdHestKernelSpec);
- hestOptAdd(&hopt, "int", "int", airTypeEnum, 1, 1, &interType, "justr",
- "inter-particle energy type", NULL, pullInterType);
- hestOptAdd(&hopt, "enr", "spec", airTypeOther, 1, 1, &enspR, "cotan",
- "inter-particle energy, radial component", NULL, NULL, pullHestEnergySpec);
- hestOptAdd(&hopt, "ens", "spec", airTypeOther, 1, 1, &enspS, "zero",
- "inter-particle energy, scale component", NULL, NULL, pullHestEnergySpec);
- hestOptAdd(&hopt, "enw", "spec", airTypeOther, 1, 1, &enspWin, "butter:16,0.8",
- "windowing to create locality with additive "
- "scale-space interaction (\"-int add\")",
- NULL, NULL, pullHestEnergySpec);
- hestOptAdd(&hopt, "zz", "bool", airTypeBool, 1, 1, &zeroZ, "false",
- "always constrain Z=0, to process 2D images");
- hestOptAdd(&hopt, "efs", "bool", airTypeBool, 1, 1, &energyFromStrength, "false",
- "whether or not strength contributes to particle-image energy");
- 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",
- "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",
- "allow volumes to have different shapes (false is safe as "
- "different volume sizes are often accidental)");
- hestOptAdd(&hopt, "pcet", "bool", airTypeBool, 1, 1, &popCntlEnoughTest, "true",
- "use neighbor-counting \"enough\" heuristic to "
- "bail out of pop cntl");
- hestOptAdd(&hopt, "cipc", "bool", airTypeBool, 1, 1, &convergenceIgnoresPopCntl,
- "false",
- "convergence test doesn't care if there has been "
- "recent changes due to population control");
- 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",
- "impose liveThresh on initialization");
- hestOptAdd(&hopt, "por", "bool", airTypeBool, 1, 1, &permuteOnRebin, "true",
- "permute points during rebinning");
- hestOptAdd(&hopt, "npcwza", "bool", airTypeBool, 1, 1, &noPopCntlWithZeroAlpha,
- "false", "no pop cntl with zero alpha");
- hestOptAdd(&hopt, "ubfgl", "bool", airTypeBool, 1, 1, &useBetaForGammaLearn, "false",
- "use beta for gamma learning");
- hestOptAdd(&hopt, "ratb", "bool", airTypeBool, 1, 1, &restrictiveAddToBins, "true",
- "be choosy when adding points to bins to avoid overlap");
- hestOptAdd(&hopt, "svec", "vec", airTypeDouble, 3, 3, scaleVec, "0 0 0",
- "if non-zero (length), vector to use for displaying scale "
- "in 3-space");
- hestOptAdd(&hopt, "gssr", "rad", airTypeDouble, 1, 1, &glyphScaleRad, "0.0",
- "if non-zero (length), scaling of scale to cylindrical tensors");
- 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);
- hestOptAdd(&hopt, "info", "info0 info1", airTypeOther, 1, -1, &idef, NULL,
- "info definitions, in format "
- "<info>[-c]:<volname>:<item>[:<zero>:<scale>]",
- &idefNum, NULL, meetHestPullInfo);
+ hestOptAdd_1_String(&hopt, "sscp", "path", &cachePathSS, "./",
+ "path (without trailing /) for where to read/write "
+ "pre-blurred volumes for scale-space");
+ kssOpi = hestOptAdd_1_Other(&hopt, "kssb", "kernel", &kSSblur, "dgauss:1,5",
+ "default blurring kernel, to sample scale space",
+ nrrdHestKernelSpec);
+ bspOpi = hestOptAdd_1_Other(&hopt, "bsp", "boundary", &bspec, "wrap",
+ "default boundary behavior of scale-space blurring",
+ nrrdHestBoundarySpec);
+ hestOptAdd_1_Other(&hopt, "kssr", "kernel", &kSSrecon, "hermite",
+ "kernel for reconstructing from scale space samples",
+ nrrdHestKernelSpec);
+ hestOptAdd_1_UInt(&hopt, "nss", "# scl smpls", &samplesAlongScaleNum, "1",
+ "if using \"-ppv\", number of samples along scale axis "
+ "for each spatial position");
- 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_1_UInt(&hopt, "np", "# points", &pointNumInitial, "1000",
+ "number of points to start in system");
+ hestOptAdd_Flag(&hopt, "halton", &useHalton,
+ "use Halton sequence initialization instead of "
+ "uniform random");
+ /* really signed; see pull.h */
+ hestOptAdd_1_Int(&hopt, "ppv", "# pnts/vox", &pointPerVoxel, "0",
+ "number of points per voxel to start in simulation "
+ "(need to have a seed thresh vol, overrides \"-np\")");
+ hestOptAdd_2_UInt(&hopt, "ppvzr", "z range", ppvZRange, "1 0",
+ "range of Z slices (1st num < 2nd num) to do ppv in, or, "
+ "\"1 0\" for whole volume");
+ hestOptAdd_1_Double(&hopt, "jit", "jitter", &jitter, "0",
+ "amount of jittering to do with ppv");
+ hestOptAdd_1_Other(&hopt, "pi", "npos", &nPosIn, "",
+ "4-by-N array of positions to start at (overrides \"-np\")",
+ nrrdHestNrrd);
+ hestOptAdd_1_Double(&hopt, "step", "step", &stepInitial, "1",
+ "initial step size for gradient descent");
+ hestOptAdd_1_Double(&hopt, "csm", "step", &constraintStepMin, "0.0001",
+ "convergence criterion for constraint satisfaction");
+ hestOptAdd_1_UInt(&hopt, "snap", "# iters", &snap, "0",
+ "if non-zero, # iters between saved snapshots");
+ hestOptAdd_1_UInt(&hopt, "maxi", "# iters", &iterMax, "0",
+ "if non-zero, max # iterations to run whole system");
+ hestOptAdd_1_UInt(&hopt, "stim", "# iters", &stuckIterMax, "5",
+ "if non-zero, max # iterations to allow a particle "
+ " to be stuck before nixing");
+ hestOptAdd_1_UInt(&hopt, "maxci", "# iters", &constraintIterMax, "15",
+ "if non-zero, max # iterations for contraint enforcement");
+ hestOptAdd_1_Double(&hopt, "irad", "scale", &radiusSpace, "1",
+ "particle radius in spatial domain");
+ hestOptAdd_1_Double(&hopt, "srad", "scale", &radiusScale, "1",
+ "particle radius in scale domain");
+ hestOptAdd_1_Double(&hopt, "bws", "bin width", &binWidthSpace, "1.001",
+ "spatial bin width as multiple of spatial radius");
+ hestOptAdd_1_Double(&hopt, "alpha", "alpha", &alpha, "0.5",
+ "blend between particle-image (alpha=0) and "
+ "inter-particle (alpha=1) energies");
+ hestOptAdd_1_Double(&hopt, "beta", "beta", &beta, "1.0",
+ "when using Phi2 energy, blend between pure "
+ "space repulsion (beta=0) and "
+ "scale attraction (beta=1)");
+ hestOptAdd_1_Double(&hopt, "gamma", "gamma", &_gamma, "1.0",
+ "scaling factor on energy from strength");
+ hestOptAdd_1_Double(&hopt, "wall", "k", &wall, "0.0", "spring constant on walls");
+ hestOptAdd_1_Double(&hopt, "eip", "k", &energyIncreasePermit, "0.0",
+ "amount by which its okay for *per-particle* energy to increase "
+ "during gradient descent process");
+ hestOptAdd_1_Double(&hopt, "ess", "scl", &backStepScale, "0.5",
+ "when energy goes up instead of down, scale step "
+ "size by this");
+ hestOptAdd_1_Double(&hopt, "oss", "scl", &opporStepScale, "1.0",
+ "opportunistic scaling (hopefully up, >1) of step size "
+ "on every iteration");
+ hestOptAdd_1_Double(&hopt, "edmin", "frac", &energyDecreaseMin, "0.0001",
+ "convergence threshold: stop when fractional improvement "
+ "(decrease) in energy dips below this");
+ hestOptAdd_1_Double(&hopt, "edpcmin", "frac", &energyDecreasePopCntlMin, "0.01",
+ "population control is triggered when energy improvement "
+ "goes below this threshold");
+ hestOptAdd_1_Double(&hopt, "fnnm", "frac", &fracNeighNixedMax, "0.25",
+ "don't nix if this fraction (or more) of neighbors "
+ "have been nixed");
+ hestOptAdd_1_UInt(&hopt, "pcp", "period", &popCntlPeriod, "20",
+ "# iters to wait between attempts at population control");
+ hestOptAdd_1_UInt(&hopt, "iad", "# iters", &addDescent, "10",
+ "# iters to run descent on tentative new points during PC");
+ hestOptAdd_1_UInt(&hopt, "icb", "# iters", &iterCallback, "1",
+ "periodicity of calling rendering callback");
- 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,
- "dgauss: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_1_Bool(&hopt, "ac3c", "ac3c", &allowCodimension3Constraints, "false",
+ "allow codimensions 3 constraints");
+ hestOptAdd_1_Bool(&hopt, "sit", "sit", &scaleIsTau, "false", "scale is tau");
+ hestOptAdd_1_UInt(&hopt, "rng", "seed", &rngSeed, "42", "base seed value for RNGs");
+ hestOptAdd_1_UInt(&hopt, "pbm", "mod", &progressBinMod, "50", "progress bin mod");
+ hestOptAdd_1_UInt(&hopt, "eiphl", "hl", &eipHalfLife, "0",
+ "half-life of energyIncreasePermute (\"-eip\")");
+ hestOptAdd_1_UInt(&hopt, "nt", "# threads", &threadNum, "1",
+ (airThreadCapable
+ ? "number of threads hoover should use"
+ : "if threads where enabled in this Teem build, this is how "
+ "you would control the number of threads to use"));
+ hestOptAdd_1_Double(&hopt, "nprob", "prob", &neighborTrueProb, "1.0",
+ "do full neighbor discovery with this probability");
+ hestOptAdd_1_Double(&hopt, "pprob", "prob", &probeProb, "1.0",
+ "probe local image values with this probability");
- hestOptAdd(&hopt, "np", "# points", airTypeUInt, 1, 1, &pointNumInitial, "1000",
- "number of points to start in system");
- hestOptAdd(&hopt, "halton", NULL, airTypeInt, 0, 0, &useHalton, NULL,
- "use Halton sequence initialization instead of "
- "uniform random");
- hestOptAdd(&hopt, "ppv", "# pnts/vox", airTypeInt, 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",
- "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",
- "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",
- "initial step size for gradient descent");
- hestOptAdd(&hopt, "csm", "step", airTypeDouble, 1, 1, &constraintStepMin, "0.0001",
- "convergence criterion for constraint satisfaction");
- hestOptAdd(&hopt, "snap", "# iters", airTypeUInt, 1, 1, &snap, "0",
- "if non-zero, # iters between saved snapshots");
- hestOptAdd(&hopt, "maxi", "# iters", airTypeUInt, 1, 1, &iterMax, "0",
- "if non-zero, max # iterations to run whole system");
- 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",
- "if non-zero, max # iterations for contraint enforcement");
- hestOptAdd(&hopt, "irad", "scale", airTypeDouble, 1, 1, &radiusSpace, "1",
- "particle radius in spatial domain");
- 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",
- "spatial bin width as multiple of spatial radius");
- hestOptAdd(&hopt, "alpha", "alpha", airTypeDouble, 1, 1, &alpha, "0.5",
- "blend between particle-image (alpha=0) and "
- "inter-particle (alpha=1) energies");
- hestOptAdd(&hopt, "beta", "beta", airTypeDouble, 1, 1, &beta, "1.0",
- "when using Phi2 energy, blend between pure "
- "space repulsion (beta=0) and "
- "scale attraction (beta=1)");
- hestOptAdd(&hopt, "gamma", "gamma", airTypeDouble, 1, 1, &_gamma, "1.0",
- "scaling factor on energy from strength");
- hestOptAdd(&hopt, "wall", "k", airTypeDouble, 1, 1, &wall, "0.0",
- "spring constant on walls");
- hestOptAdd(&hopt, "eip", "k", airTypeDouble, 1, 1, &energyIncreasePermit, "0.0",
- "amount by which its okay for *per-particle* energy to increase "
- "during gradient descent process");
- 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",
- "opportunistic scaling (hopefully up, >1) of step size "
- "on every iteration");
- hestOptAdd(&hopt, "edmin", "frac", airTypeDouble, 1, 1, &energyDecreaseMin, "0.0001",
- "convergence threshold: stop when fractional improvement "
- "(decrease) in energy dips below this");
- hestOptAdd(&hopt, "edpcmin", "frac", airTypeDouble, 1, 1, &energyDecreasePopCntlMin,
- "0.01",
- "population control is triggered when energy improvement "
- "goes below this threshold");
- hestOptAdd(&hopt, "fnnm", "frac", airTypeDouble, 1, 1, &fracNeighNixedMax, "0.25",
- "don't nix if this fraction (or more) of neighbors "
- "have been nixed");
- hestOptAdd(&hopt, "pcp", "period", airTypeUInt, 1, 1, &popCntlPeriod, "20",
- "# iters to wait between attempts at population control");
- hestOptAdd(&hopt, "iad", "# iters", airTypeUInt, 1, 1, &addDescent, "10",
- "# iters to run descent on tentative new points during PC");
- hestOptAdd(&hopt, "icb", "# iters", airTypeUInt, 1, 1, &iterCallback, "1",
- "periodicity of calling rendering callback");
+ hestOptAdd_1_String(&hopt, "addlog", "fname", &addLogS, "",
+ "name of file in which to log all particle additions");
+ hestOptAdd_1_String(&hopt, "o", "nout", &outS, "-",
+ "filename for saving computed positions");
+ hestOptAdd_1_String(&hopt, "eob", "base", &extraOutBaseS, "",
+ "save extra info (besides position), and use this string as "
+ "the base of the filenames. Not using this means the extra "
+ "info is not saved.");
- 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",
- "base seed value for RNGs");
- hestOptAdd(&hopt, "pbm", "mod", airTypeUInt, 1, 1, &progressBinMod, "50",
- "progress bin mod");
- hestOptAdd(&hopt, "eiphl", "hl", airTypeUInt, 1, 1, &eipHalfLife, "0",
- "half-life of energyIncreasePermute (\"-eip\")");
- hestOptAdd(&hopt, "nt", "# threads", airTypeInt, 1, 1, &threadNum, "1",
- (airThreadCapable
- ? "number of threads hoover should use"
- : "if threads where enabled in this Teem build, this is how "
- "you would control the number of threads to use"));
- hestOptAdd(&hopt, "nprob", "prob", airTypeDouble, 1, 1, &neighborTrueProb, "1.0",
- "do full neighbor discovery with this probability");
- hestOptAdd(&hopt, "pprob", "prob", airTypeDouble, 1, 1, &probeProb, "1.0",
- "probe local image values with this probability");
-
- hestOptAdd(&hopt, "addlog", "fname", airTypeString, 1, 1, &addLogS, "",
- "name of file in which to log all particle additions");
- hestOptAdd(&hopt, "o", "nout", airTypeString, 1, 1, &outS, "-",
- "filename for saving computed positions");
- hestOptAdd(&hopt, "eob", "base", airTypeString, 1, 1, &extraOutBaseS, "",
- "save extra info (besides position), and use this string as "
- "the base of the filenames. Not using this means the extra "
- "info is not saved.");
-
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);
-#ifdef DEFT
- if (const char *envS = getenv("DEFT_HOME")) {
- strcpy(Deft::homeDir, envS);
- strcat(Deft::homeDir, "/");
- } else {
- fprintf(stderr,
- "%s: WARNING: \"DEFT_HOME\" environment variable "
- "not set; assuming \".\"\n",
- me);
- strcpy(Deft::homeDir, "./");
- }
-#endif
/*
airEnumPrint(stderr, gageScl);
exit(0);
@@ -1157,495 +391,6 @@
* all lines: +1 evec0 evec1 -1
*/
-#ifdef DEFT
- ssrange[0] = FLT_MAX;
- ssrange[1] = -FLT_MAX;
- for (vsi = 0; vsi < vspecNum; vsi++) {
- meetPullVol *vol;
- vol = vspec[vsi];
- if (vol->numSS) {
- ssrange[0] = AIR_MIN(ssrange[0], vol->rangeSS[0]);
- ssrange[1] = AIR_MAX(ssrange[1], vol->rangeSS[1]);
- }
- }
- if (pctx->flag.scaleIsTau) {
- ssrange[0] = gageTauOfSig(ssrange[0]);
- ssrange[1] = gageTauOfSig(ssrange[1]);
- }
- /* -------------------------------------------------- */
- /* initialize bag and its UI */
- bag.pctx = pctx;
- bag.nPosOut = nrrdNew();
- bag.nTenOut = nrrdNew();
- bag.nFrcOut = nrrdNew();
- bag.nposOld = nrrdNew();
- bag.nposNew = nrrdNew();
- bag.nten = nrrdNew();
- bag.ntmp = nrrdNew();
- bag.nenr = nrrdNew();
- bag.nscl = nrrdNew();
- bag.nidcc = nrrdNew();
- bag.ncovar = nrrdNew();
-# if PULL_TANCOVAR
- bag.ntcovar = nrrdNew();
-# endif
- bag.nstab = nrrdNew();
- bag.nintern = nrrdNew();
- if (pctx->ispec[pullInfoStrength]) {
- printf("!%s: trouble creating strength nrrd\n", me);
- bag.nstrn = nrrdNew();
- } else {
- bag.nstrn = NULL;
- }
- if (pctx->ispec[pullInfoQuality]) {
- printf("!%s: trouble creating quality nrrd\n", me);
- bag.nqual = nrrdNew();
- } else {
- bag.nqual = NULL;
- }
- bag.nstuck = nrrdNew();
- bag.nfrcOld = nrrdNew();
- bag.nfrcNew = nrrdNew();
- bag.nrgb = nrrdNew();
- bag.nccrgb = nrrdNew();
- bag.ncmapOut = nrrdNew();
- bag.nblur = nrrdNew();
- bag.norig = vspec[0]->nin;
- nrrdCopy(bag.nblur, bag.norig);
- bag.rsmc = nrrdResampleContextNew();
- E = 0;
- if (!E) E |= nrrdResampleDefaultCenterSet(bag.rsmc, nrrdDefaultCenter);
- if (!E) E |= nrrdResampleInputSet(bag.rsmc, bag.norig);
- for (unsigned int axi = 0; axi < 3; axi++) {
- if (!E) E |= nrrdResampleSamplesSet(bag.rsmc, axi, bag.norig->axis[axi].size);
- if (!E) E |= nrrdResampleRangeFullSet(bag.rsmc, axi);
- }
- if (!E) E |= nrrdResampleBoundarySet(bag.rsmc, nrrdBoundaryBleed);
- if (!E) E |= nrrdResampleTypeOutSet(bag.rsmc, nrrdTypeDefault);
- if (!E) E |= nrrdResampleRenormalizeSet(bag.rsmc, AIR_TRUE);
- if (E) {
- airMopAdd(mop, err = biffGetDone(NRRD), airFree, airMopAlways);
- fprintf(stderr, "%s: trouble setting up resampler:\n%s", me, err);
- airMopError(mop);
- return 1;
- }
- /* bag.ncval is just a pointer to other nrrds */
- bag.cvalRange = nrrdRangeNew(AIR_NAN, AIR_NAN);
- ELL_3V_COPY(bag.scaleVec, scaleVec);
- bag.glyphScaleRad = glyphScaleRad;
-
- bag.scene = new Deft::Scene();
- bag.scene->bgColor(bg[0], bg[1], bg[2]);
-
- int winy = 10;
- int incy;
- fltk::Window *win = new fltk::Window(400, 600, "pull UI");
- win->begin();
- fltk::Button *stepButton = new fltk::Button(10, winy, 50, incy = 20, "step");
- stepButton->callback((fltk::Callback *)step_cb, &bag);
-
- bag.verbose = new fltk::ValueInput(100, winy, 30, 20, "verb");
- bag.verbose->value(pctx->verbose);
- bag.verbose->callback((fltk::Callback *)verbose_cb, &bag);
-
- bag.iters = new fltk::IntInput(200, winy, 50, 20, "# iters");
- bag.iters->value(1);
-
- if (ssrange[1] > ssrange[0]) {
- fltk::Button *gamButton = new fltk::Button(260, winy, 50, 20, "gamma");
- gamButton->callback((fltk::Callback *)gammaSet_cb, &bag);
- }
- fltk::Button *ccButton = new fltk::Button(360, winy, 30, 20, "CC");
- ccButton->callback((fltk::Callback *)cc_cb, &bag);
-
- winy += incy + 5;
- fltk::Button *saveButton = new fltk::Button(10, winy, 50, 20, "save");
- saveButton->callback((fltk::Callback *)save_cb, &bag);
-
- bag.scaleVecInput[0] = new fltk::FloatInput(120, winy, 35, 20, "scaleVec");
- bag.scaleVecInput[1] = new fltk::FloatInput(160, winy, 35, 20, "");
- bag.scaleVecInput[2] = new fltk::FloatInput(200, winy, 35, 20, "");
- bag.scaleVecInput[0]->value(scaleVec[0]);
- bag.scaleVecInput[1]->value(scaleVec[1]);
- bag.scaleVecInput[2]->value(scaleVec[2]);
- bag.scaleVecInput[0]->callback((fltk::Callback *)scaleGlyph_cb, &bag);
- bag.scaleVecInput[1]->callback((fltk::Callback *)scaleGlyph_cb, &bag);
- bag.scaleVecInput[2]->callback((fltk::Callback *)scaleGlyph_cb, &bag);
-
- bag.glyphScaleRadInput = new fltk::ValueInput(300, winy, 45, 20, "gssr");
- bag.glyphScaleRadInput->range(0.0, 100.0);
- bag.glyphScaleRadInput->step(0.1);
- bag.glyphScaleRadInput->linesize(0.1);
- bag.glyphScaleRadInput->value(glyphScaleRad);
- bag.glyphScaleRadInput->callback((fltk::Callback *)scaleGlyph_cb, &bag);
-
- winy += incy;
- bag.alpha = new Deft::Slider(0, winy, win->w(), incy = 55, "alpha");
- bag.alpha->align(fltk::ALIGN_LEFT);
- bag.alpha->range(0, 1);
- bag.alpha->value(pctx->sysParm.alpha);
- bag.alpha->fastUpdate(1);
- bag.alpha->callback((fltk::Callback *)alpha_cb, &bag);
-
- if (pullInterTypeAdditive == pctx->interType) {
- winy += incy;
- bag.beta = new Deft::Slider(0, winy, win->w(), incy = 55, "beta");
- bag.beta->align(fltk::ALIGN_LEFT);
- bag.beta->range(0, 1);
- bag.beta->value(pctx->sysParm.beta);
- bag.beta->fastUpdate(1);
- bag.beta->callback((fltk::Callback *)beta_cb, &bag);
- }
-
- if (pullEnergyCubicWell == pctx->energySpecR->energy
- || pullEnergyBetterCubicWell == pctx->energySpecR->energy) {
- winy += incy;
- bag.cwell = new Deft::Slider(0, winy, win->w(), incy = 55, "well depth");
- bag.cwell->align(fltk::ALIGN_LEFT);
- bag.cwell->range(-0.04, 0);
- bag.cwell->value(bag.pctx->energySpecR->parm[1]);
- bag.cwell->fastUpdate(1);
- bag.cwell->callback((fltk::Callback *)cwell_cb, &bag);
- /* remember eip as fraction of well depth */
- bag.energyIncreasePermitFrac = energyIncreasePermit / bag.pctx->energySpecR->parm[1];
- } else {
- bag.energyIncreasePermitFrac = AIR_NAN;
- }
-
- winy += incy;
- bag.gamma = new Deft::Slider(0, winy, win->w(), incy = 55, "gamma");
- bag.gamma->align(fltk::ALIGN_LEFT);
- bag.gamma->range(0, 2 * pctx->sysParm.gamma);
- bag.gamma->value(pctx->sysParm.gamma);
- bag.gamma->fastUpdate(1);
- bag.gamma->callback((fltk::Callback *)gamma_cb, &bag);
-
- winy += incy;
- bag.ccSelect = new Deft::Slider(0, winy, win->w(), incy = 55, "CC Select");
- bag.ccSelect->align(fltk::ALIGN_LEFT);
- bag.ccSelect->range(0, 0);
- bag.ccSelect->step(1);
- bag.ccSelect->value(0);
- bag.ccSelect->fastUpdate(1);
- bag.ccSelect->callback((fltk::Callback *)ccSelect_cb, &bag);
-
- bag.ccSingle = new fltk::CheckButton(130, winy + 4, 50, 20, "Single");
- bag.ccSingle->value(0);
- bag.ccSingle->callback((fltk::Callback *)ccSelect_cb, &bag);
-
- winy += incy;
- bag.rho = new Deft::Slider(0, winy, win->w(), incy = 55, "rho");
- bag.rho->align(fltk::ALIGN_LEFT);
- bag.rho->range(0, 1.0);
- bag.rho->value(0.5);
- bag.rho->fastUpdate(1);
- bag.rho->callback((fltk::Callback *)cc_cb, &bag);
-
- if (ssrange[1] > ssrange[0]) {
- winy += incy;
- bag.sclMean = new Deft::Slider(0, winy, win->w(), incy = 55, "scale mean");
- bag.sclMean->align(fltk::ALIGN_LEFT);
- bag.sclMean->range(ssrange[0], ssrange[1]);
- bag.sclMean->value((ssrange[0] + ssrange[1]) / 2);
- bag.sclMean->fastUpdate(1);
- bag.sclMean->callback((fltk::Callback *)scale_cb, &bag);
-
- fltk::Button *reblurButton = new fltk::Button(130, winy + 4, 50, 20, "reblur");
- reblurButton->callback((fltk::Callback *)reblur_cb, &bag);
-
- winy += incy;
- bag.sclWind = new Deft::Slider(0, winy, win->w(), incy = 55, "scale window");
- bag.sclWind->align(fltk::ALIGN_LEFT);
- bag.sclWind->range(0, ssrange[1] - ssrange[0]);
- bag.sclWind->value(ssrange[1] - ssrange[0]);
- bag.sclWind->fastUpdate(1);
- bag.sclWind->callback((fltk::Callback *)scale_cb, &bag);
- scale_cb(NULL, &bag);
- } else {
- bag.sclMin = bag.sclMax = 0;
- }
-
- if (pctx->ispec[pullInfoStrength]) {
- winy += incy;
- bag.strength = new Deft::Slider(0, winy, win->w(), incy = 55, "strength");
- bag.strength->align(fltk::ALIGN_LEFT);
- bag.strength->range(0, 1);
- bag.strength->callback((fltk::Callback *)strength_cb, &bag);
- bag.strength->fastUpdate(1);
- bag.strength->value(0);
- } else {
- bag.strnMin = 0;
- }
- if (pctx->ispec[pullInfoQuality]) {
- winy += incy;
- bag.quality = new Deft::Slider(0, winy, win->w(), incy = 55, "quality");
- bag.quality->align(fltk::ALIGN_LEFT);
- bag.quality->range(-0.1, 1);
- bag.quality->callback((fltk::Callback *)quality_cb, &bag);
- bag.quality->fastUpdate(1);
- bag.quality->value(-0.1);
- } else {
- bag.qualMin = 0;
- }
-
- /*
- winy += incy;
- bag.height = new Deft::Slider(0, winy, win->w(), incy=55, "height");
- bag.height->align(fltk::ALIGN_LEFT);
- bag.height->range(0, 10);
- bag.height->value(10);
- bag.height->fastUpdate(1);
- bag.height->callback((fltk::Callback*)strength_cb, &bag);
- */
-
- win->end();
- win->show();
-
- /* -------------------------------------------------- */
- bag.viewer = new Deft::Viewer(bag.scene, imgSize[0], imgSize[1]);
- if (camkeep) {
- bag.viewer->camera(fr[0], fr[1], fr[2], at[0], at[1], at[2], up[0], up[1], up[2],
- fovy, neer, faar);
- }
- bag.viewer->resizable(bag.viewer);
- bag.viewer->end();
- const char *fakeArgv[2] = {"Deft_pull", NULL};
- bag.viewer->show(1, (char **)fakeArgv);
- if (ortho) {
- /* total hack */
- bag.viewer->keyboard('p', 0, 0);
- }
- /* bag.viewer->helpPrint(); */
- Deft::ViewerUI *viewerUI = new Deft::ViewerUI(bag.viewer);
- viewerUI->show();
- fltk::flush();
-
- /* -------------------------------------------------- */
- if (gageKindScl == vspec[0]->kind) {
- bag.contour = new Deft::Contour();
- bag.contour->volumeSet(bag.nblur);
- bag.contour->twoSided(true);
- bag.scene->objectAdd(bag.contour);
- } else {
- bag.contour = NULL;
- }
-
- /* -------------------------------------------------- */
- Deft::TensorGlyph *glyph = new Deft::TensorGlyph();
- glyph->dynamic(true);
- glyph->twoSided(true);
- glyph->anisoType(aniso);
- glyph->anisoThreshMin(anisoThreshMin);
- glyph->anisoThresh(anisoThresh);
- glyph->glyphType(glyphType);
- glyph->superquadSharpness(sqdSharp);
- glyph->glyphResolution(glyphFacetRes);
- if (tenGlyphTypeBetterquad) {
- glyph->barycentricResolution(baryRes);
- } else {
- glyph->barycentricResolution(20);
- }
- glyph->glyphScale(glyphScale);
- glyph->glyphHaloWidth(glyphHaloWidth);
- glyph->haloTraceBound(haloTraceBound);
- glyph->glyphNormPow(glyphNormPow);
- glyph->glyphEvalPow(glyphEvalPow);
- glyph->rgbEvecParmSet(tenAniso_Cl2, 0, 0.7, 1.0, 2.3, 1.0);
- glyph->rgbEvecParmSet(tenAniso_Cl2, 0, 0, 1.0, 1, 0.0);
- glyph->maskThresh(0.5);
- /*
- void rgbParmSet(int aniso, unsigned int evec,
- double maxSat, double isoGray,
- double gamma, do...
[truncated message content] |
|
From: <kin...@us...> - 2023-07-13 11:41:04
|
Revision: 7084
http://sourceforge.net/p/teem/code/7084
Author: kindlmann
Date: 2023-07-13 11:41:02 +0000 (Thu, 13 Jul 2023)
Log Message:
-----------
preserving for posterity version of puller with the Deft UI code
Added Paths:
-----------
teem/trunk/src/bin/puller-with-Deft.c
Added: teem/trunk/src/bin/puller-with-Deft.c
===================================================================
--- teem/trunk/src/bin/puller-with-Deft.c (rev 0)
+++ teem/trunk/src/bin/puller-with-Deft.c 2023-07-13 11:41:02 UTC (rev 7084)
@@ -0,0 +1,1654 @@
+/*
+ Teem: Tools to process and visualize scientific data and images
+ Copyright (C) 2009--2023 University of Chicago
+ Copyright (C) 2005--2008 Gordon Kindlmann
+ Copyright (C) 1998--2004 University of Utah
+
+ This library is free software; you can redistribute it and/or modify it under the terms
+ of the GNU Lesser General Public License (LGPL) as published by the Free Software
+ Foundation; either version 2.1 of the License, or (at your option) any later version.
+ The terms of redistributing and/or modifying this software also include exceptions to
+ the LGPL that facilitate static linking.
+
+ This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License along with
+ this library; if not, write to Free Software Foundation, Inc., 51 Franklin Street,
+ Fifth Floor, Boston, MA 02110-1301 USA
+*/
+
+/* for Teem v2 the Deft stuff was removed from puller.c; but this
+ file preserves them for posterity. */
+/*
+** NOTE: all the "#ifdef DEFT" directives refer to an FLTK2-based GUI
+** for some parts of Teem called "Deft". Unfortunately FLTK2 has been
+** abandoned, and Deft is not released or supported in any way. The
+** Deft-related code is preserved for legacy purposes.
+*/
+
+#ifdef DEFT
+# include "Deft.h"
+# include "Contour.h"
+# include "Viewer.h"
+# include "ViewerUI.h"
+# include "TensorGlyph.h"
+# include "TensorGlyphUI.h"
+# include "Slider.h"
+# include "TriPlane.h"
+# include "TriPlaneUI.h"
+
+#endif
+
+#include <teem/pull.h>
+#include <teem/meet.h>
+
+static const char *info
+ = ("Command-line interface to the \"pull\" library. "
+ "Published research using this tool or the \"pull\" library "
+ "should cite the paper: \n "
+ "\t\tGordon L. Kindlmann, Ra{\\'u}l San Jos{\\'e} Est{\\'e}par, Stephen M. "
+ "Smith,\n "
+ "\t\tCarl-Fredrik Westin. Sampling and Visualizing Creases with Scale-Space\n "
+ "\t\tParticles. IEEE Trans. on Visualization and Computer Graphics,\n "
+ "\t\t15(6):1415-1424 (2009).");
+
+#ifdef DEFT
+typedef struct {
+ fltk::FloatInput *scaleVecInput[3];
+ fltk::ValueInput *glyphScaleRadInput;
+ Deft::Slider *isoval;
+ Deft::Slider *strength;
+ Deft::Slider *quality;
+ Deft::Slider *alpha, *beta, *cwell, *gamma;
+ /* Deft::Slider *height; */
+ Deft::Slider *ccSelect, *rho, *sclMean, *sclWind;
+ fltk::CheckButton *ccSingle;
+ Deft::Contour *contour;
+ Deft::Scene *scene;
+ Deft::Viewer *viewer;
+ Deft::TensorGlyph *glyph, *hedge;
+ fltk::IntInput *iters;
+ fltk::FloatInput *radius;
+ fltk::ValueInput *verbose;
+ pullContext *pctx;
+ Nrrd *nPosOut, *nTenOut, *nFrcOut, *nten, *ntmp, *nenr, *nscl, *nidcc, *nstrn, *nqual,
+ *ncovar, *ntcovar, *nstab, *nintern, *nstuck, *nfrcOld, *nfrcNew, *nposOld, *nposNew,
+ *nrgb, *nccrgb, *ncval, *ncmap, *ncmapOut, *nblur;
+ NrrdResampleContext *rsmc;
+ const Nrrd *norig;
+ NrrdRange *cvalRange;
+ limnPolyData *phistLine, *phistTube;
+ Deft::PolyData *phistSurf;
+ double icvalr[2], sclMin, sclMax, strnMin, qualMin, scaleVec[3], glyphScaleRad,
+ energyIncreasePermitFrac;
+} pullBag;
+
+void
+verbose_cb(fltk::Widget *widget, pullBag *bag) {
+ fltk::ValueInput *val;
+
+ val = (fltk::ValueInput *)widget;
+ pullVerboseSet(bag->pctx, (int)val->value());
+}
+/* ... DEFT ... */
+void
+isovalue_cb(fltk::Widget *widget, pullBag *bag) {
+ Deft::Slider *slider;
+
+ slider = (Deft::Slider *)widget;
+ if (bag->contour) {
+ bag->contour->extract(slider->value());
+ }
+ bag->viewer->redraw();
+}
+
+void
+outputGet(pullBag *bag) {
+ static const char me[] = "outputGet";
+ char *err;
+ size_t cropMin[2], cropMax[2];
+
+ if (pullOutputGet(bag->nPosOut, bag->nTenOut, bag->nstrn, /* may be NULL */
+ bag->scaleVec, bag->glyphScaleRad, bag->pctx)
+ || pullPropGet(bag->nscl, pullPropScale, bag->pctx)
+ || (bag->pctx->ispec[pullInfoQuality]
+ ? pullInfoGet(bag->nqual, pullInfoQuality, bag->pctx)
+ : 0)
+ || pullPropGet(bag->nenr, pullPropEnergy, bag->pctx)
+ || pullPropGet(bag->nidcc, pullPropIdCC, bag->pctx)
+ || pullPropGet(bag->nstuck, pullPropStuck, bag->pctx)
+ || pullPropGet(bag->ncovar, pullPropNeighCovar7Ten, bag->pctx)
+# if PULL_TANCOVAR
+ || pullPropGet(bag->ntcovar, pullPropNeighTanCovar, bag->pctx)
+# endif
+ || pullPropGet(bag->nstab, pullPropStability, bag->pctx)
+ || pullPropGet(bag->nintern, pullPropNeighInterNum, bag->pctx)
+ || pullPropGet(bag->nFrcOut, pullPropForce, bag->pctx)
+ || (pullPhistEnabled ? pullPositionHistoryGet(bag->phistLine, bag->pctx) : 0)) {
+ err = biffGetDone(PULL);
+ fprintf(stderr, "%s: error getting pull output:\n%s\n", me, err);
+ free(err);
+ exit(1);
+ }
+ /* ... DEFT ... */
+ cropMin[0] = 0;
+ cropMin[1] = 0;
+ cropMax[0] = 2;
+ cropMax[1] = bag->nPosOut->axis[1].size - 1;
+ if ((!bag->pctx->iter ? 0
+ : (nrrdCopy(bag->nfrcOld, bag->nfrcNew)
+ || nrrdCopy(bag->nposOld, bag->nposNew)))
+ || nrrdConvert(bag->nten, bag->nTenOut, nrrdTypeFloat)
+ /* hacks to visualize the (tan) covariance tensors
+ || nrrdCopy(bag->nten, bag->ncovar)
+ || nrrdCopy(bag->nten, bag->ntcovar)
+ */
+ || nrrdCrop(bag->ntmp, bag->nPosOut, cropMin, cropMax)
+ || nrrdConvert(bag->nposNew, bag->ntmp, nrrdTypeFloat)
+ || nrrdCrop(bag->ntmp, bag->nFrcOut, cropMin, cropMax)
+ || nrrdConvert(bag->nfrcNew, bag->ntmp, nrrdTypeFloat)
+ || (!bag->pctx->iter ? (nrrdCopy(bag->nfrcOld, bag->nfrcNew)
+ || nrrdCopy(bag->nposOld, bag->nposNew))
+ : 0)) {
+ err = biffGetDone(NRRD);
+ fprintf(stderr, "%s: another error 0\n%s\n", me, err);
+ free(err);
+ exit(1);
+ }
+}
+/* ... DEFT ... */
+void
+outputShow(pullBag *bag) {
+ static const char me[] = "outputShow";
+ char *err;
+ float *rgb;
+ unsigned int ii, nn, *idcc;
+ unsigned char *stuck;
+ int first;
+ double *cval, emean, estdv, *pos;
+
+ /*
+ if (limnPolyDataSpiralTubeWrap(bag->phistTube, bag->phistLine,
+ (1 << limnPolyDataInfoRGBA)
+ | (1 << limnPolyDataInfoNorm),
+ NULL,
+ 8, 8, bag->glyph->glyphScale()/5)) {
+ err = biffGetDone(LIMN);
+ fprintf(stderr, "%s: another error 1\n%s\n", me, err);
+ free(err);
+ exit(1);
+ }
+ */
+
+ if (pullPhistEnabled) {
+ bag->phistSurf->changed();
+ }
+
+ bag->ncval = bag->nenr;
+ /* bag->ncval = bag->nstrn; */
+ /* bag->ncval = bag->nstuck; */
+ /* bag->ncval = bag->nscl; */
+
+ /* ... DEFT ... */
+ if (bag->ncval) {
+ nrrdRangeSet(bag->cvalRange, bag->ncval, AIR_FALSE);
+ } else {
+ bag->cvalRange->min = AIR_NAN;
+ bag->cvalRange->max = AIR_NAN;
+ }
+ if (bag->ncval) {
+ cval = AIR_CAST(double *, bag->ncval->data);
+ } else {
+ cval = NULL;
+ }
+ if (cval) {
+ nn = bag->ncval->axis[0].size;
+ emean = 0;
+ for (ii = 0; ii < nn; ii++) {
+ emean += cval[ii];
+ }
+ emean /= nn;
+ estdv = 0;
+ for (ii = 0; ii < nn; ii++) {
+ estdv += (emean - cval[ii]) * (emean - cval[ii]);
+ }
+ estdv = sqrt(estdv / nn);
+ if (bag->cvalRange->hasNonExist) {
+ fprintf(stderr, "!%s: cval range %g -- %g (%s), mean %g, stdv %g\n", me,
+ bag->cvalRange->min, bag->cvalRange->max,
+ bag->cvalRange->hasNonExist ? "HAS non-exist" : "no non-exist", emean,
+ estdv);
+ }
+ bag->cvalRange->min = AIR_LERP(0.7, bag->cvalRange->min, emean - 2 * estdv);
+ bag->cvalRange->max = AIR_LERP(0.7, bag->cvalRange->max, emean + 2 * estdv);
+ }
+ /* ... DEFT ... */
+ float *cmapOut;
+ if (bag->ncmap && bag->ncval && AIR_EXISTS(bag->cvalRange->min)
+ && AIR_EXISTS(bag->cvalRange->max)) {
+ /* double mmin, mmax; */
+ fprintf(stderr, "!%s: cval cmap range %g %g ----------- \n", me, bag->cvalRange->min,
+ bag->cvalRange->max);
+ /*
+ mmin = -0.0342937;
+ mmax = -0.0105725;
+ */
+ /* */
+ /*
+ bag->cvalRange->min = AIR_LERP(0.05, mmin, mmax);
+ bag->cvalRange->max = AIR_LERP(0.3, mmin, mmax);
+ */
+ /* */
+ if (nrrdApply1DRegMap(bag->ncmapOut, bag->ncval, bag->cvalRange, bag->ncmap,
+ nrrdTypeFloat, AIR_TRUE)) {
+ err = biffGetDone(NRRD);
+ fprintf(stderr, "%s: cmap error\n%s\n", me, err);
+ free(err);
+ exit(1);
+ }
+ cmapOut = AIR_CAST(float *, bag->ncmapOut->data);
+ } else {
+ cmapOut = NULL;
+ }
+
+ /* ... DEFT ... */
+
+ idcc = AIR_CAST(unsigned int *, bag->nidcc->data);
+ stuck = AIR_CAST(unsigned char *, bag->nstuck->data);
+ nn = bag->nPosOut->axis[1].size;
+ pos = AIR_CAST(double *, bag->nPosOut->data);
+
+ first = bag->nrgb->axis[1].size != bag->nPosOut->axis[1].size;
+ /*
+ fprintf(stderr, "!%s: %u %u -> %d\n", me,
+ AIR_UINT(bag->nrgb->axis[1].size),
+ AIR_UINT(bag->nPosOut->axis[1].size), first);
+ */
+ if (first) {
+ if (nrrdMaybeAlloc_va(bag->nrgb, nrrdTypeFloat, 2, AIR_CAST(size_t, 3),
+ bag->nPosOut->axis[1].size)) {
+ err = biffGetDone(NRRD);
+ fprintf(stderr, "%s: error creating RGB:\n%s\n", me, err);
+ free(err);
+ exit(1);
+ }
+ }
+ bag->icvalr[0] = bag->cvalRange->min;
+ bag->icvalr[1] = bag->cvalRange->max;
+
+ /* ... DEFT ... */
+
+ double *strnOut;
+ strnOut = (bag->nstrn ? AIR_CAST(double *, bag->nstrn->data) : NULL);
+ double *qualOut;
+ qualOut = (bag->nqual ? AIR_CAST(double *, bag->nqual->data) : NULL);
+ rgb = (float *)bag->nrgb->data;
+ for (ii = 0; ii < nn; ii++) {
+ float ee, *ccrgb;
+ ccrgb = (float *)bag->nccrgb->data;
+ /* ee = bag->cvalRange->min - (bag->icvalr[1] - bag->icvalr[0])/50;*/
+ ee = bag->cvalRange->min;
+ if (bag->pctx->CCNum && ccrgb) {
+ rgb[0 + 3 * ii] = ccrgb[0 + 3 * idcc[ii]];
+ rgb[1 + 3 * ii] = ccrgb[1 + 3 * idcc[ii]];
+ rgb[2 + 3 * ii] = ccrgb[2 + 3 * idcc[ii]];
+ } else if (cmapOut) {
+ ELL_3V_COPY(rgb + 3 * ii, cmapOut + 3 * ii);
+ } else {
+ ELL_3V_SET(rgb + 3 * ii, 0.95, 0.95, 0.95);
+ /*
+ if (AIR_EXISTS(cval[ii])) {
+ rgb[1 + 3*ii] = AIR_AFFINE(ee, cval[ii], bag->cvalRange->max, 0, 1);
+ rgb[1 + 3*ii] = sqrt(rgb[1 + 3*ii]);
+ rgb[0 + 3*ii] = rgb[1 + 3*ii];
+ } else {
+ rgb[1 + 3*ii] = 0;
+ rgb[0 + 3*ii] = 1;
+ }
+ rgb[2 + 3*ii] = stuck[ii];
+ */
+ }
+ }
+
+ /* ... DEFT ... */
+
+ if (1) {
+ float *ten, *pos;
+ double *posOut;
+ ten = AIR_CAST(float *, bag->nten->data);
+ posOut = AIR_CAST(double *, bag->nPosOut->data);
+ pos = AIR_CAST(float *, bag->nposNew->data);
+ for (ii = 0; ii < nn; ii++) {
+ if (!(AIR_IN_CL(bag->sclMin - 0.00001, posOut[3], bag->sclMax + 0.00001))) {
+ ten[0] = 0;
+ } else if (strnOut && strnOut[ii] < bag->strnMin) {
+ ten[0] = 0;
+ } else if (qualOut && qualOut[ii] < bag->qualMin - 0.000001) {
+ ten[0] = 0;
+ } else if (bag->pctx->CCNum
+ && (bag->ccSingle->value() ? idcc[ii] != bag->ccSelect->value()
+ : idcc[ii] > bag->ccSelect->value())) {
+ ten[0] = 0;
+ } else {
+ ten[0] = 1;
+ }
+ /*
+ if (4589 == ii) {
+ fprintf(stderr, "!%s: point %u/%u at (%g,%g,%g)=(%g,%g,%g,%g) got ten[0] %g\n",
+ me, ii, nn,
+ pos[0], pos[1], pos[1],
+ posOut[0], posOut[1], posOut[2], posOut[3],
+ ten[0]);
+ }
+ */
+ pos += 3;
+ posOut += 4;
+ ten += 7;
+ }
+ }
+
+ /* ... DEFT ... */
+
+ if (bag->nPosOut->axis[1].size) {
+ bag->glyph->dataSet(bag->nPosOut->axis[1].size, (float *)bag->nten->data, 7,
+ (float *)bag->nposNew->data, 3, rgb, 3, NULL);
+ bag->glyph->update();
+ /*
+ bag->hedge->dataSet(bag->nPosOut->axis[1].size,
+ (float*)bag->nfrcNew->data, 3,
+ (float*)bag->nposOld->data, 3, rgb, 3, NULL);
+ bag->hedge->update();
+ */
+ bag->viewer->redraw();
+ fltk::flush();
+ } else {
+ fprintf(stderr, "!%s: got zero tensors out!\n", me);
+ }
+ return;
+}
+
+void
+iter_cb(void *_bag) {
+ pullBag *bag;
+ bag = AIR_CAST(pullBag *, _bag);
+ outputGet(bag);
+ outputShow(bag);
+}
+
+/* ... DEFT ... */
+
+void
+step_cb(fltk::Widget *, pullBag *bag) {
+ /* static double lastthresh = -42; */
+ static const char me[] = "step_cb";
+ char *err;
+ static unsigned int itersTotal = 0;
+
+ unsigned int iters = bag->iters->ivalue();
+ bag->pctx->iterParm.max += iters;
+ if (pullRun(bag->pctx)) {
+ err = biffGetDone(PULL);
+ fprintf(stderr, "%s: error running pull:\n%s\n", me, err);
+ free(err);
+ exit(1);
+ }
+ itersTotal += iters;
+ fprintf(stderr, "!%s: enr = %g; time = %g sec; %u iters (%g iters/sec)\n", me,
+ bag->pctx->energy, bag->pctx->timeRun, itersTotal,
+ itersTotal / bag->pctx->timeRun);
+ outputGet(bag);
+ outputShow(bag);
+ for (unsigned int ci = pullCountUnknown + 1; ci < pullCountLast; ci++) {
+ if (bag->pctx->count[ci]) {
+ fprintf(stderr, " %u: %s\n", bag->pctx->count[ci], airEnumStr(pullCount, ci));
+ }
+ }
+}
+
+/* ... DEFT ... */
+
+void
+gammaSet_cb(fltk::Widget *, pullBag *bag) {
+ static const char me[] = "gammaSet_cb";
+
+ if (pullGammaLearn(bag->pctx)) {
+ char *err = biffGetDone(PULL);
+ fprintf(stderr, "%s: problem learning gamma:\n%s", me, err);
+ free(err);
+ }
+ if (bag->pctx->sysParm.gamma > bag->gamma->maximum()) {
+ bag->gamma->maximum(2 * bag->pctx->sysParm.gamma);
+ }
+ bag->gamma->value(bag->pctx->sysParm.gamma);
+}
+
+/* ... DEFT ... */
+
+void
+cc_cb(fltk::Widget *, pullBag *bag) {
+ static const char me[] = "cc_cb";
+ unsigned int cc;
+ float *rgb;
+
+ if (pullCCFind(bag->pctx)
+ || pullCCSort(bag->pctx, (bag->pctx->ispec[pullInfoQuality] ? pullInfoQuality : 0),
+ bag->rho->value())) {
+ char *err = biffGetDone(PULL);
+ fprintf(stderr, "%s: problem finding/sorting CCs:\n%s", me, err);
+ free(err);
+ }
+ printf("%s: found %u CCs\n", me, bag->pctx->CCNum);
+ bag->ccSelect->range(0, bag->pctx->CCNum - 1);
+ if (bag->nccrgb->axis[1].size != bag->pctx->CCNum) {
+ airSrandMT(AIR_UINT(airTime()));
+ if (nrrdMaybeAlloc_va(bag->nccrgb, nrrdTypeFloat, 2, AIR_CAST(size_t, 3),
+ AIR_CAST(size_t, bag->pctx->CCNum))) {
+ char *err = biffGetDone(NRRD);
+ fprintf(stderr, "%s: problem alloc'ing cc rgb:\n%s", me, err);
+ free(err);
+ }
+ rgb = (float *)bag->nccrgb->data;
+ ELL_3V_SET(rgb + 0 * 3, 0.95, 0.95, 0.95);
+ for (cc = 0; cc < bag->pctx->CCNum; cc++) {
+ rgb[0 + 3 * cc] = AIR_AFFINE(0, airDrandMT(), 1, 0.3, 1.0);
+ rgb[1 + 3 * cc] = AIR_AFFINE(0, airDrandMT(), 1, 0.3, 1.0);
+ rgb[2 + 3 * cc] = AIR_AFFINE(0, airDrandMT(), 1, 0.3, 1.0);
+ }
+ }
+ outputGet(bag);
+ outputShow(bag);
+}
+
+/* ... DEFT ... */
+
+void
+ccSelect_cb(fltk::Widget *, pullBag *bag) {
+
+ outputShow(bag);
+}
+
+void
+scaleGlyph_cb(fltk::Widget *, pullBag *bag) {
+
+ bag->scaleVec[0] = bag->scaleVecInput[0]->fvalue();
+ bag->scaleVec[1] = bag->scaleVecInput[1]->fvalue();
+ bag->scaleVec[2] = bag->scaleVecInput[2]->fvalue();
+ bag->glyphScaleRad = bag->glyphScaleRadInput->value();
+ outputGet(bag);
+ outputShow(bag);
+}
+
+/* ... DEFT ... */
+
+void
+reblur_cb(fltk::Widget *, pullBag *bag) {
+ static const char me[] = "reblur_cb";
+ double kparm[NRRD_KERNEL_PARMS_NUM], scl;
+ int E;
+
+ if (!bag->pctx->haveScale) {
+ return;
+ }
+ scl = bag->sclMean->value();
+ if (bag->pctx->flag.scaleIsTau) {
+ kparm[0] = gageSigOfTau(scl);
+ printf("!%s: tau = %g ---> sigma = %g\n", me, scl, kparm[0]);
+ } else {
+ kparm[0] = scl;
+ printf("!%s: sigma = %g\n", me, kparm[0]);
+ }
+ kparm[1] = 3;
+ E = 0;
+ for (unsigned int axi = 0; axi < 3; axi++) {
+ if (!E)
+ E |= nrrdResampleKernelSet(bag->rsmc, axi, nrrdKernelDiscreteGaussian, kparm);
+ }
+ if (!E) E |= nrrdResampleExecute(bag->rsmc, bag->nblur);
+ if (E) {
+ char *err = biffGetDone(NRRD);
+ fprintf(stderr, "%s: problem resampling to scale %g:\n%s", me, bag->sclMean->value(),
+ err);
+ free(err);
+ }
+ outputShow(bag);
+ return;
+}
+
+/* ... DEFT ... */
+
+void
+scale_cb(fltk::Widget *, pullBag *bag) {
+ double sclMean, sclWind;
+
+ if (bag->pctx->haveScale) {
+ sclMean = bag->sclMean->value();
+ sclWind = bag->sclWind->value();
+ bag->sclMin = sclMean - sclWind / 2;
+ bag->sclMax = sclMean + sclWind / 2;
+ } else {
+ bag->sclMin = 0;
+ bag->sclMax = 0;
+ }
+ outputShow(bag);
+ return;
+}
+
+void
+alpha_cb(fltk::Widget *, pullBag *bag) {
+
+ pullSysParmSet(bag->pctx, pullSysParmAlpha, bag->alpha->value());
+}
+
+void
+beta_cb(fltk::Widget *, pullBag *bag) {
+
+ pullSysParmSet(bag->pctx, pullSysParmBeta, bag->beta->value());
+}
+
+/* ... DEFT ... */
+
+void
+cwell_cb(fltk::Widget *, pullBag *bag) {
+ double *parm;
+
+ parm = bag->pctx->energySpecR->parm;
+ parm[1] = bag->cwell->value();
+ pullSysParmSet(bag->pctx, pullSysParmEnergyIncreasePermit,
+ bag->energyIncreasePermitFrac * bag->cwell->value());
+ {
+ unsigned int ii, nn;
+ double xx, yy, de;
+ FILE *file;
+
+ if ((file = fopen("eplot.txt", "w"))) {
+ nn = 800;
+ for (ii = 0; ii < nn; ii++) {
+ xx = AIR_AFFINE(0, ii, nn - 1, 0.0, 1.0);
+ yy = bag->pctx->energySpecR->energy->eval(&de, xx, parm);
+ fprintf(file, "%f %f\n", xx, yy);
+ }
+ fclose(file);
+ }
+ }
+}
+
+void
+gamma_cb(fltk::Widget *, pullBag *bag) {
+
+ pullSysParmSet(bag->pctx, pullSysParmGamma, bag->gamma->value());
+}
+
+/* ... DEFT ... */
+
+void
+strength_cb(fltk::Widget *, pullBag *bag) {
+
+ bag->strnMin = bag->strength->value();
+ outputShow(bag);
+}
+
+void
+quality_cb(fltk::Widget *, pullBag *bag) {
+
+ bag->qualMin = bag->quality->value();
+ outputShow(bag);
+}
+
+void
+save_cb(fltk::Widget *, pullBag *bag) {
+ static const char me[] = "save_cb";
+ unsigned int ii, nn, count;
+ float *ten;
+ Nrrd *nPosSel, *nStrnSel;
+ double *posSel, *posAll, *strnSel, *strnAll;
+
+ if (!(0.0 == ELL_3V_LEN(bag->scaleVec))) {
+ fprintf(stderr, "%s: refusing to save with non-zero scaleVec %g %g %g\n", me,
+ bag->scaleVec[0], bag->scaleVec[1], bag->scaleVec[2]);
+ return;
+ }
+
+ /* ... DEFT ... */
+
+ nPosSel = nrrdNew();
+ if (bag->nstrn) {
+ nStrnSel = nrrdNew();
+ } else {
+ nStrnSel = NULL;
+ }
+ outputGet(bag);
+ outputShow(bag); /* will exploit its masking of ten[0] */
+ count = 0;
+ nn = bag->nPosOut->axis[1].size;
+ ten = AIR_CAST(float *, bag->nten->data);
+ for (ii = 0; ii < nn; ii++) {
+ count += !!ten[0];
+ ten += 7;
+ }
+ nrrdMaybeAlloc_va(nPosSel, nrrdTypeDouble, 2, AIR_CAST(size_t, 4),
+ AIR_CAST(size_t, count));
+ posAll = AIR_CAST(double *, bag->nPosOut->data);
+ posSel = AIR_CAST(double *, nPosSel->data);
+ if (bag->nstrn) {
+ nrrdMaybeAlloc_va(nStrnSel, nrrdTypeDouble, 1, AIR_CAST(size_t, count));
+ strnAll = AIR_CAST(double *, bag->nstrn->data);
+ strnSel = AIR_CAST(double *, nStrnSel->data);
+ } else {
+ strnSel = NULL;
+ strnAll = NULL;
+ }
+ ten = AIR_CAST(float *, bag->nten->data);
+ count = 0;
+ for (ii = 0; ii < nn; ii++) {
+ if (ten[0]) {
+ ELL_4V_COPY(posSel, posAll);
+ if (strnSel && strnAll) {
+ strnSel[count] = strnAll[ii];
+ }
+ posSel += 4;
+ count++;
+ }
+ posAll += 4;
+ ten += 7;
+ }
+
+ /* ... DEFT ... */
+
+ nrrdSave("pos-all.nrrd", bag->nPosOut, NULL);
+ if (0) {
+ nrrdSave("pos-sel.nrrd", nPosSel, NULL);
+ } else {
+ char fname[512];
+ FILE *ff;
+ unsigned int ii = 0;
+
+ for (ii = 0, ff = NULL; AIR_TRUE; ii++) {
+ ff = airFclose(ff);
+ sprintf(fname, "pos-sel-%03u.nrrd", ii);
+ if (!(ff = fopen(fname, "rb"))) {
+ break;
+ }
+ }
+ ff = airFclose(ff);
+ nrrdSave(fname, nPosSel, NULL);
+ }
+ nrrdSave("covar-all.nrrd", bag->ncovar, NULL);
+# if PULL_TANCOVAR
+ nrrdSave("tcovar-all.nrrd", bag->ntcovar, NULL);
+# endif
+ nrrdSave("stab-all.nrrd", bag->nstab, NULL);
+ nrrdSave("intern-all.nrrd", bag->nintern, NULL);
+ if (bag->nstrn) {
+ nrrdSave("strn-all.nrrd", bag->nstrn, NULL);
+ nrrdSave("strn-sel.nrrd", nStrnSel, NULL);
+ }
+ nrrdNuke(nPosSel);
+ if (bag->nstrn) {
+ nrrdNuke(nStrnSel);
+ }
+ return;
+}
+
+#endif /* DEFT */
+
+int
+main(int argc, const char **argv) {
+ hestOpt *hopt = NULL;
+ hestParm *hparm;
+ airArray *mop;
+ const char *me;
+
+#ifdef DEFT
+ float fr[3], at[3], up[3], fovy, neer, faar, dist, bg[3];
+ int imgSize[2], ortho, rght, atrel, camkeep;
+
+ float anisoThresh, anisoThreshMin, glyphScale, haloTraceBound, glyphHaloWidth,
+ glyphNormPow, glyphEvalPow, sqdSharp;
+ int glyphType, glyphFacetRes, aniso;
+ double ssrange[2];
+ pullBag bag;
+#endif
+
+ char *err, *outS, *extraOutBaseS, *addLogS, *cachePathSS;
+ FILE *addLog;
+ meetPullVol **vspec;
+ meetPullInfo **idef;
+ Nrrd *nPosIn = NULL, *nPosOut;
+ pullEnergySpec *enspR, *enspS, *enspWin;
+ NrrdKernelSpec *k00, *k11, *k22, *kSSrecon, *kSSblur;
+ NrrdBoundarySpec *bspec;
+ pullContext *pctx;
+ int E = 0, ret = 0;
+ unsigned int vspecNum, idefNum;
+ double scaleVec[3], glyphScaleRad;
+ /* things that used to be set directly inside pullContext */
+ int energyFromStrength, nixAtVolumeEdgeSpace, constraintBeforeSeedThresh, binSingle,
+ liveThresholdOnInit, permuteOnRebin, noPopCntlWithZeroAlpha, useBetaForGammaLearn,
+ restrictiveAddToBins, noAdd, unequalShapesAllow, popCntlEnoughTest,
+ convergenceIgnoresPopCntl, zeroZ;
+ int verbose;
+ int interType, allowCodimension3Constraints, scaleIsTau, useHalton, pointPerVoxel;
+ unsigned int samplesAlongScaleNum, pointNumInitial, ppvZRange[2], snap, iterMax,
+ stuckIterMax, constraintIterMax, popCntlPeriod, addDescent, iterCallback, rngSeed,
+ progressBinMod, threadNum, eipHalfLife, kssOpi, kssFinished, bspOpi, bspFinished;
+ double jitter, stepInitial, constraintStepMin, radiusSpace, binWidthSpace, radiusScale,
+ alpha, beta, _gamma, wall, energyIncreasePermit, backStepScale, opporStepScale,
+ energyDecreaseMin, energyDecreasePopCntlMin, neighborTrueProb, probeProb,
+ fracNeighNixedMax;
+
+ mop = airMopNew();
+ hparm = hestParmNew();
+ airMopAdd(mop, hparm, (airMopper)hestParmFree, airMopAlways);
+
+ nPosOut = nrrdNew();
+ airMopAdd(mop, nPosOut, (airMopper)nrrdNuke, airMopAlways);
+
+ hparm->respFileEnable = AIR_TRUE;
+ hparm->respectDashDashHelp = AIR_TRUE;
+ me = argv[0];
+
+#ifdef DEFT
+ unsigned int baryRes;
+ int saveAndQuit, fog;
+
+ hestOptAdd(&hopt, "csqvmm", "min max", airTypeDouble, 2, 2,
+ Deft::colorSclQuantityValueMinMax, "nan nan",
+ "min/max values for cutting planes of scalar values");
+ hestOptAdd(&hopt, "saq", "save & quit", airTypeInt, 0, 0, &saveAndQuit, NULL,
+ "save image and quit, for batch processing");
+ hestOptAdd(&hopt, "cmap", "nin", airTypeOther, 1, 1, &(bag.ncmap), "",
+ "colormap for particles", NULL, NULL, nrrdHestNrrd);
+ hestOptAdd(&hopt, "fr", "from point", airTypeFloat, 3, 3, fr, "3 4 5",
+ "position of camera, used to determine view vector");
+ hestOptAdd(&hopt, "at", "at point", airTypeFloat, 3, 3, at, "0 0 0",
+ "camera look-at point, used to determine view vector");
+ hestOptAdd(&hopt, "up", "up vector", airTypeFloat, 3, 3, up, "0 0 1",
+ "camera pseudo-up vector, used to determine view coordinates");
+ hestOptAdd(&hopt, "rh", NULL, airTypeInt, 0, 0, &rght, NULL,
+ "normally, use a right-handed UVN frame (V points down), "
+ "but in Deft this is always true");
+ hestOptAdd(&hopt, "fv", "fov", airTypeFloat, 1, 1, &fovy, "20",
+ "vertical field-of-view, in degrees");
+ hestOptAdd(&hopt, "or", NULL, airTypeInt, 0, 0, &ortho, NULL,
+ "use orthogonal projection instead of perspective");
+ hestOptAdd(&hopt, "dn", "near clip", airTypeFloat, 1, 1, &neer, "-2",
+ "position of near clipping plane, relative to look-at point");
+ hestOptAdd(&hopt, "di", "image", airTypeFloat, 1, 1, &dist, "0.0",
+ "normally, distance to image plane, "
+ "but in Deft this is always 0.0");
+ hestOptAdd(&hopt, "df", "far clip", airTypeFloat, 1, 1, &faar, "2",
+ "position of far clipping plane, relative to look-at point");
+ hestOptAdd(&hopt, "ar", NULL, airTypeInt, 0, 0, &atrel, NULL,
+ "normally: near, image, and far plane distances are relative to "
+ "the *at* point, instead of the eye point, "
+ "but for Deft, this is always true");
+ hestOptAdd(&hopt, "usecam", NULL, airTypeInt, 0, 0, &camkeep, NULL,
+ "hack: by default, a camera reset is done to put the volume "
+ "in view. Use this to say that the camera specified by the "
+ "flags above should be preserved and used");
+ hestOptAdd(&hopt, "bg", "R G B", airTypeFloat, 3, 3, bg, "0.2 0.3 0.4",
+ "background color");
+ hestOptAdd(&hopt, "fog", NULL, airTypeInt, 0, 0, &fog, NULL, "hack: turn on fog");
+ hestOptAdd(&hopt, "is", "su sv", airTypeInt, 2, 2, imgSize, "640 480",
+ "initial window size");
+ /* ... DEFT ... */
+ /* this tensor stuff is here because we're hijacking the tensor glyph
+ object for doing the particle display ... */
+ hestOptAdd(&hopt, "a", "aniso", airTypeEnum, 1, 1, &aniso, NULL,
+ "anisotropy metric to make volume of", NULL, tenAniso);
+ hestOptAdd(&hopt, "atr", "aniso thresh", airTypeFloat, 1, 1, &anisoThresh, "0.85",
+ "Glyphs will be drawn only for tensors with anisotropy "
+ "greater than this threshold");
+ hestOptAdd(&hopt, "atrm", "aniso thresh min", airTypeFloat, 1, 1, &anisoThreshMin,
+ "0.4", "lower bound on aniso thresh");
+ hestOptAdd(&hopt, "g", "glyph shape", airTypeEnum, 1, 1, &glyphType, "sqd",
+ "shape of glyph to use for display. Possibilities "
+ "include \"box\", \"sphere\"=\"sph\", \"cylinder\"=\"cyl\", and "
+ "\"superquad\"=\"sqd\"",
+ NULL, tenGlyphType);
+ hestOptAdd(&hopt, "gsc", "scale", airTypeFloat, 1, 1, &glyphScale, "0.25",
+ "over-all glyph size");
+ hestOptAdd(&hopt, "htb", "trace", airTypeFloat, 1, 1, &haloTraceBound, "1.0",
+ "halo trace bound");
+ hestOptAdd(&hopt, "ghw", "hwidth", airTypeFloat, 1, 1, &glyphHaloWidth, "0.0",
+ "glyph halo width");
+ hestOptAdd(&hopt, "gnp", "npow", airTypeFloat, 1, 1, &glyphNormPow, "1.0",
+ "pow() exponent for compressing range of norms");
+ hestOptAdd(&hopt, "gep", "epow", airTypeFloat, 1, 1, &glyphEvalPow, "1.0",
+ "pow() exponent for compressing single eigenvalues");
+ hestOptAdd(&hopt, "br", "barycentric res", airTypeInt, 1, 1, &baryRes, "50",
+ "resolution of sampling of tensor shape palette");
+ hestOptAdd(&hopt, "gr", "glyph res", airTypeInt, 1, 1, &glyphFacetRes, "7",
+ "resolution of polygonalization of glyphs (other than box)");
+ hestOptAdd(&hopt, "sh", "sharpness", airTypeFloat, 1, 1, &sqdSharp, "2.5",
+ "for superquadric glyphs, how much to sharp edges form as a "
+ "function of differences between eigenvalues. Higher values "
+ "mean that edges form more easily");
+#endif /* DEFT */
+
+ hestOptAdd(&hopt, "int", "int", airTypeEnum, 1, 1, &interType, "justr",
+ "inter-particle energy type", NULL, pullInterType);
+ hestOptAdd(&hopt, "enr", "spec", airTypeOther, 1, 1, &enspR, "cotan",
+ "inter-particle energy, radial component", NULL, NULL, pullHestEnergySpec);
+ hestOptAdd(&hopt, "ens", "spec", airTypeOther, 1, 1, &enspS, "zero",
+ "inter-particle energy, scale component", NULL, NULL, pullHestEnergySpec);
+ hestOptAdd(&hopt, "enw", "spec", airTypeOther, 1, 1, &enspWin, "butter:16,0.8",
+ "windowing to create locality with additive "
+ "scale-space interaction (\"-int add\")",
+ NULL, NULL, pullHestEnergySpec);
+ hestOptAdd(&hopt, "zz", "bool", airTypeBool, 1, 1, &zeroZ, "false",
+ "always constrain Z=0, to process 2D images");
+ hestOptAdd(&hopt, "efs", "bool", airTypeBool, 1, 1, &energyFromStrength, "false",
+ "whether or not strength contributes to particle-image energy");
+ 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",
+ "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",
+ "allow volumes to have different shapes (false is safe as "
+ "different volume sizes are often accidental)");
+ hestOptAdd(&hopt, "pcet", "bool", airTypeBool, 1, 1, &popCntlEnoughTest, "true",
+ "use neighbor-counting \"enough\" heuristic to "
+ "bail out of pop cntl");
+ hestOptAdd(&hopt, "cipc", "bool", airTypeBool, 1, 1, &convergenceIgnoresPopCntl,
+ "false",
+ "convergence test doesn't care if there has been "
+ "recent changes due to population control");
+ 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",
+ "impose liveThresh on initialization");
+ hestOptAdd(&hopt, "por", "bool", airTypeBool, 1, 1, &permuteOnRebin, "true",
+ "permute points during rebinning");
+ hestOptAdd(&hopt, "npcwza", "bool", airTypeBool, 1, 1, &noPopCntlWithZeroAlpha,
+ "false", "no pop cntl with zero alpha");
+ hestOptAdd(&hopt, "ubfgl", "bool", airTypeBool, 1, 1, &useBetaForGammaLearn, "false",
+ "use beta for gamma learning");
+ hestOptAdd(&hopt, "ratb", "bool", airTypeBool, 1, 1, &restrictiveAddToBins, "true",
+ "be choosy when adding points to bins to avoid overlap");
+ hestOptAdd(&hopt, "svec", "vec", airTypeDouble, 3, 3, scaleVec, "0 0 0",
+ "if non-zero (length), vector to use for displaying scale "
+ "in 3-space");
+ hestOptAdd(&hopt, "gssr", "rad", airTypeDouble, 1, 1, &glyphScaleRad, "0.0",
+ "if non-zero (length), scaling of scale to cylindrical tensors");
+ 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);
+ 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, "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,
+ "dgauss: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",
+ "number of points to start in system");
+ hestOptAdd(&hopt, "halton", NULL, airTypeInt, 0, 0, &useHalton, NULL,
+ "use Halton sequence initialization instead of "
+ "uniform random");
+ hestOptAdd(&hopt, "ppv", "# pnts/vox", airTypeInt, 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",
+ "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",
+ "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",
+ "initial step size for gradient descent");
+ hestOptAdd(&hopt, "csm", "step", airTypeDouble, 1, 1, &constraintStepMin, "0.0001",
+ "convergence criterion for constraint satisfaction");
+ hestOptAdd(&hopt, "snap", "# iters", airTypeUInt, 1, 1, &snap, "0",
+ "if non-zero, # iters between saved snapshots");
+ hestOptAdd(&hopt, "maxi", "# iters", airTypeUInt, 1, 1, &iterMax, "0",
+ "if non-zero, max # iterations to run whole system");
+ 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",
+ "if non-zero, max # iterations for contraint enforcement");
+ hestOptAdd(&hopt, "irad", "scale", airTypeDouble, 1, 1, &radiusSpace, "1",
+ "particle radius in spatial domain");
+ 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",
+ "spatial bin width as multiple of spatial radius");
+ hestOptAdd(&hopt, "alpha", "alpha", airTypeDouble, 1, 1, &alpha, "0.5",
+ "blend between particle-image (alpha=0) and "
+ "inter-particle (alpha=1) energies");
+ hestOptAdd(&hopt, "beta", "beta", airTypeDouble, 1, 1, &beta, "1.0",
+ "when using Phi2 energy, blend between pure "
+ "space repulsion (beta=0) and "
+ "scale attraction (beta=1)");
+ hestOptAdd(&hopt, "gamma", "gamma", airTypeDouble, 1, 1, &_gamma, "1.0",
+ "scaling factor on energy from strength");
+ hestOptAdd(&hopt, "wall", "k", airTypeDouble, 1, 1, &wall, "0.0",
+ "spring constant on walls");
+ hestOptAdd(&hopt, "eip", "k", airTypeDouble, 1, 1, &energyIncreasePermit, "0.0",
+ "amount by which its okay for *per-particle* energy to increase "
+ "during gradient descent process");
+ 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",
+ "opportunistic scaling (hopefully up, >1) of step size "
+ "on every iteration");
+ hestOptAdd(&hopt, "edmin", "frac", airTypeDouble, 1, 1, &energyDecreaseMin, "0.0001",
+ "convergence threshold: stop when fractional improvement "
+ "(decrease) in energy dips below this");
+ hestOptAdd(&hopt, "edpcmin", "frac", airTypeDouble, 1, 1, &energyDecreasePopCntlMin,
+ "0.01",
+ "population control is triggered when energy improvement "
+ "goes below this threshold");
+ hestOptAdd(&hopt, "fnnm", "frac", airTypeDouble, 1, 1, &fracNeighNixedMax, "0.25",
+ "don't nix if this fraction (or more) of neighbors "
+ "have been nixed");
+ hestOptAdd(&hopt, "pcp", "period", airTypeUInt, 1, 1, &popCntlPeriod, "20",
+ "# iters to wait between attempts at population control");
+ hestOptAdd(&hopt, "iad", "# iters", airTypeUInt, 1, 1, &addDescent, "10",
+ "# iters to run descent on tentative new points during PC");
+ hestOptAdd(&hopt, "icb", "# iters", airTypeUInt, 1, 1, &iterCallback, "1",
+ "periodicity of calling rendering callback");
+
+ 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",
+ "base seed value for RNGs");
+ hestOptAdd(&hopt, "pbm", "mod", airTypeUInt, 1, 1, &progressBinMod, "50",
+ "progress bin mod");
+ hestOptAdd(&hopt, "eiphl", "hl", airTypeUInt, 1, 1, &eipHalfLife, "0",
+ "half-life of energyIncreasePermute (\"-eip\")");
+ hestOptAdd(&hopt, "nt", "# threads", airTypeInt, 1, 1, &threadNum, "1",
+ (airThreadCapable
+ ? "number of threads hoover should use"
+ : "if threads where enabled in this Teem build, this is how "
+ "you would control the number of threads to use"));
+ hestOptAdd(&hopt, "nprob", "prob", airTypeDouble, 1, 1, &neighborTrueProb, "1.0",
+ "do full neighbor discovery with this probability");
+ hestOptAdd(&hopt, "pprob", "prob", airTypeDouble, 1, 1, &probeProb, "1.0",
+ "probe local image values with this probability");
+
+ hestOptAdd(&hopt, "addlog", "fname", airTypeString, 1, 1, &addLogS, "",
+ "name of file in which to log all particle additions");
+ hestOptAdd(&hopt, "o", "nout", airTypeString, 1, 1, &outS, "-",
+ "filename for saving computed positions");
+ hestOptAdd(&hopt, "eob", "base", airTypeString, 1, 1, &extraOutBaseS, "",
+ "save extra info (besides position), and use this string as "
+ "the base of the filenames. Not using this means the extra "
+ "info is not saved.");
+
+ 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);
+
+#ifdef DEFT
+ if (const char *envS = getenv("DEFT_HOME")) {
+ strcpy(Deft::homeDir, envS);
+ strcat(Deft::homeDir, "/");
+ } else {
+ fprintf(stderr,
+ "%s: WARNING: \"DEFT_HOME\" environment variable "
+ "not set; assuming \".\"\n",
+ me);
+ strcpy(Deft::homeDir, "./");
+ }
+#endif
+ /*
+ airEnumPrint(stderr, gageScl);
+ exit(0);
+ */
+ if (airStrlen(addLogS)) {
+ if (!(addLog = airFopen(addLogS, stdout, "w"))) {
+ fprintf(stderr, "%s: couldn't open %s for writing", me, addLogS);
+ airMopError(mop);
+ return 1;
+ }
+ airMopAdd(mop, addLog, (airMopper)airFclose, airMopAlways);
+ } else {
+ addLog = NULL;
+ }
+
+ pctx = pullContextNew();
+ airMopAdd(mop, pctx, (airMopper)pullContextNix, airMopAlways);
+ if (pullVerboseSet(pctx, verbose) || pullFlagSet(pctx, pullFlagZeroZ, zeroZ)
+ || pullFlagSet(pctx, pullFlagEnergyFromStrength, energyFromStrength)
+ || pullFlagSet(pctx, pullFlagNixAtVolumeEdgeSpace, nixAtVolumeEdgeSpace)
+ || pullFlagSet(pctx, pullFlagConstraintBeforeSeedThresh,
+ constraintBeforeSeedThresh)
+ || pullFlagSet(pctx, pullFlagPopCntlEnoughTest, popCntlEnoughTest)
+ || pullFlagSet(pctx, pullFlagConvergenceIgnoresPopCntl, convergenceIgnoresPopCntl)
+ || pullFlagSet(pctx, pullFlagBinSingle, binSingle)
+ || pullFlagSet(pctx, pullFlagNoAdd, noAdd)
+ || pullFlagSet(pctx, pullFlagPermuteOnRebin, permuteOnRebin)
+ || pullFlagSet(pctx, pullFlagNoPopCntlWithZeroAlpha, noPopCntlWithZeroAlpha)
+ || pullFlagSet(pctx, pullFlagUseBetaForGammaLearn, useBetaForGammaLearn)
+ || pullFlagSet(pctx, pullFlagRestrictiveAddToBins, restrictiveAddToBins)
+ || pullFlagSet(pctx, pullFlagAllowCodimension3Constraints,
+ allowCodimension3Constraints)
+ || pullFlagSet(pctx, pullFlagScaleIsTau, scaleIsTau)
+ || pullInitUnequalShapesAllowSet(pctx, unequalShapesAllow)
+ || pullIterParmSet(pctx, pullIterParmSnap, snap)
+ || pullIterParmSet(pctx, pullIterParmMax, iterMax)
+ || pullIterParmSet(pctx, pullIterParmStuckMax, stuckIterMax)
+ || pullIterParmSet(pctx, pullIterParmConstraintMax, constraintIterMax)
+ || pullIterParmSet(pctx, pullIterParmPopCntlPeriod, popCntlPeriod)
+ || pullIterParmSet(pctx, pullIterParmAddDescent, addDescent)
+ || pullIterParmSet(pctx, pullIterParmCallback, iterCallback)
+ || pullIterParmSet(pctx, pullIterParmEnergyIncreasePermitHalfLife, eipHalfLife)
+ || pullSysParmSet(pctx, pullSysParmStepInitial, stepInitial)
+ || pullSysParmSet(pctx, pullSysParmConstraintStepMin, constraintStepMin)
+ || pullSysParmSet(pctx, pullSysParmRadiusSpace, radiusSpace)
+ || pullSysParmSet(pctx, pullSysParmRadiusScale, radiusScale)
+ || pullSysParmSet(pctx, pullSysParmBinWidthSpace, binWidthSpace)
+ || pullSysParmSet(pctx, pullSysParmAlpha, alpha)
+ || pullSysParmSet(pctx, pullSysParmBeta, beta)
+ || pullSysParmSet(pctx, pullSysParmGamma, _gamma)
+ || pullSysParmSet(pctx, pullSysParmWall, wall)
+ || pullSysParmSet(pctx, pullSysParmEnergyIncreasePermit, energyIncreasePermit)
+ || pullSysParmSet(pctx, pullSysParmEnergyDecreaseMin, energyDecreaseMin)
+ || pullSysParmSet(pctx, pullSysParmFracNeighNixedMax, fracNeighNixedMax)
+ || pullSysParmSet(pctx, pullSysParmEnergyDecreasePopCntlMin,
+ energyDecreasePopCntlMin)
+ || pullSysParmSet(pctx, pullSysParmBackStepScale, backStepScale)
+ || pullSysParmSet(pctx, pullSysParmOpporStepScale, opporStepScale)
+ || pullSysParmSet(pctx, pullSysParmNeighborTrueProb, neighborTrueProb)
+ || pullSysParmSet(pctx, pullSysParmProbeProb, probeProb)
+ || pullRngSeedSet(pctx, rngSeed) || pullProgressBinModSet(pctx, progressBinMod)
+ || pullThreadNumSet(pctx, threadNum)
+ || pullInterEnergySet(pctx, interType, enspR, enspS, enspWin)
+ || pullInitLiveThreshUseSet(pctx, liveThresholdOnInit)
+ || pullLogAddSet(pctx, addLog)) {
+ airMopAdd(mop, err = biffGetDone(PULL), airFree, airMopAlways);
+ fprintf(stderr, "%s: trouble with flags:\n%s", me, err);
+ airMopError(mop);
+ return 1;
+ }
+
+ if (nPosIn) {
+ E = pullInitGivenPosSet(pctx, nPosIn);
+ } else if (pointPerVoxel) {
+ E = pullInitPointPerVoxelSet(pctx, pointPerVoxel, ppvZRange[0], ppvZRange[1],
+ samplesAlongScaleNum, jitter);
+ } else if (useHalton) {
+ E = pullInitHaltonSet(pctx, pointNumInitial, 0);
+ } else {
+ E = pullInitRandomSet(pctx, pointNumInitial);
+ }
+ if (E) {
+ airMopAdd(mop, err = biffGetDone(PULL), airFree, airMopAlways);
+ fprintf(stderr, "%s: trouble with flags:\n%s", me, err);
+ airMopError(mop);
+ return 1;
+ }
+ if (meetPullVolStackBlurParmFinishMulti(vspec, vspecNum, &kssFinished, &bspFinished,
+ kSSblur, bspec)
+ || meetPullVolLoadMulti(vspec, vspecNum, cachePathSS, verbose)
+ || 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;
+ }
+ 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);
+ }
+ 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);
+ }
+ if (pullStart(pctx)) {
+ airMopAdd(mop, err = biffGetDone(PULL), airFree, airMopAlways);
+ fprintf(stderr, "%s: trouble starting system:\n%s", me, err);
+ airMopError(mop);
+ return 1;
+ }
+
+ /* -------------------------------------------------- */
+
+ /* not sure when this table was created, don't have heart to nix it
+ *
+ * hght scl tang1 tang2 mode scl strength
+ * ridge surface: -1 evec2 - - -eval2
+ * ridge line: -1 evec2 evec1 - -eval1
+ * all ridges: -1 evec2 evec1 +1 ??
+ * valley surface: +1 evec0 - - eval0
+ * valley line: +1 evec0 evec1 - eval1
+ * all lines: +1 evec0 evec1 -1
+ */
+
+#ifdef DEFT
+ ssrange[0] = FLT_MAX;
+ ssrange[1] = -FLT_MAX;
+ for (vsi = 0; vsi < vspecNum; vsi++) {
+ meetPullVol *vol;
+ vol = vspec[vsi];
+ if (vol->numSS) {
+ ssrange[0] = AIR_MIN(ssrange[0], vol->rangeSS[0]);
+ ssrange[1] = AIR_MAX(ssrange[1], vol->rangeSS[1]);
+ }
+ }
+ if (pctx->flag.scaleIsTau) {
+ ssrange[0] = gageTauOfSig(ssrange[0]);
+ ssrange[1] = gageTauOfSig(ssrange[1]);
+ }
+ /* -------------------------------------------------- */
+ /* initialize bag and its UI */
+ bag.pctx = pctx;
+ bag.nPosOut = nrrdNew();
+ bag.nTenOut = nrrdNew();
+ bag.nFrcOut = nrrdNew();
+ bag.nposOld = nrrdNew();
+ bag.nposNew = nrrdNew();
+ bag.nten = nrrdNew();
+ bag.ntmp = nrrdNew();
+ bag.nenr = nrrdNew();
+ bag.nscl = nrrdNew();
+ bag.nidcc = nrrdNew();
+ bag.ncovar = nrrdNew();
+# if PULL_TANCOVAR
+ bag.ntcovar = nrrdNew();
+# endif
+ bag.nstab = nrrdNew();
+ bag.nintern = nrrdNew();
+ if (pctx->ispec[pullInfoStrength]) {
+ printf("!%s: trouble creating strength nrrd\n", me);
+ bag.nstrn = nrrdNew();
+ } else {
+ bag.nstrn = NULL;
+ }
+ if (pctx->ispec[pullInfoQuality]) {
+ printf("!%s: trouble creating quality nrrd\n", me);
+ bag.nqual = nrrdNew();
+ } else {
+ bag.nqual = NULL;
+ }
+ bag.nstuck = nrrdNew();
+ bag.nfrcOld = nrrdNew();
+ bag.nfrcNew = nrrdNew();
+ bag.nrgb = nrrdNew();
+ bag.nccrgb = nrrdNew();
+ bag.ncmapOut = nrrdNew();
+ bag.nblur = nrrdNew();
+ bag.norig = vspec[0]->nin;
+ nrrdCopy(bag.nblur, bag.norig);
+ bag.rsmc = nrrdResampleContextNew();
+ E = 0;
+ if (!E) E |= nrrdResampleDefaultCenterSet(bag.rsmc, nrrdDefaultCenter);
+ if (!E) E |= nrrdResampleInputSet(bag.rsmc, bag.norig);
+ for (unsigned int axi = 0; axi < 3; axi++) {
+ if (!E) E |= nrrdResampleSamplesSet(bag.rsmc, axi, bag.norig->axis[axi].size);
+ if (!E) E |= nrrdResampleRangeFullSet(bag.rsmc, axi);
+ }
+ if (!E) E |= nrrdResampleBoundarySet(bag.rsmc, nrrdBoundaryBleed);
+ if (!E) E |= nrrdResampleTypeOutSet(bag.rsmc, nrrdTypeDefault);
+ if (!E) E |= nrrdResampleRenormalizeSet(bag.rsmc, AIR_TRUE);
+ if (E) {
+ airMopAdd(mop, err = biffGetDone(NRRD), airFree, airMopAlways);
+ fprintf(stderr, "%s: trouble setting up resampler:\n%s", me, err);
+ airMopError(mop);
+ return 1;
+ }
+ /* bag.ncval is just a pointer to other nrrds */
+ bag.cvalRange = nrrdRangeNew(AIR_NAN, AIR_NAN);
+ ELL_3V_COPY(bag.scaleVec, scaleVec);
+ bag.glyphScaleRad = glyphScaleRad;
+
+ bag.scene = new Deft::Scene();
+ bag.scene->bgColor(bg[0], bg[1], bg[2]);
+
+ int winy = 10;
+ int incy;
+ fltk::Window *win = new fltk::Window(400, 600, "pull UI");
+ win->begin();
+ fltk::Button *stepButton = new fltk::Button(10, winy, 50, incy = 20, "step");
+ stepButton->callback((fltk::Callback *)step_cb, &bag);
+
+ bag.verbose = new fltk::ValueInput(100, winy, 30, 20, "verb");
+ bag.verbose->value(pctx->verbose);
+ bag.verbose->callback((fltk::Callback *)verbose_cb, &bag);
+
+ bag.iters = new fltk::IntInput(200, winy, 50, 20, "# iters");
+ bag.iters->value(1);
+
+ if (ssrange[1] > ssrange[0]) {
+ fltk::Button *gamButton = new fltk::Button(260, winy, 50, 20, "gamma");
+ gamButton->callback((fltk::Callback *)gammaSet_cb, &bag);
+ }
+ fltk::Button *ccButton = new fltk::Button(360, winy, 30, 20, "CC");
+ ccButton->callback((fltk::Callback *)cc_cb, &bag);
+
+ winy += incy + 5;
+ fltk::Button *saveButton = new fltk::Button(10, winy, 50, 20, "save");
+ saveButton->callback((fltk::Callback *)save_cb, &bag);
+
+ bag.scaleVecInput[0] = new fltk::FloatInput(120, winy, 35, 20, "scaleVec");
+ bag.scaleVecInput[1] = new fltk::FloatInput(160, winy, 35, 20, "");
+ bag.scaleVecInput[2] = new fltk::FloatInput(200, winy, 35, 20, "");
+ bag.scaleVecInput[0]->value(scaleVec[0]);
+ bag.scaleVecInput[1]->value(scaleVec[1]);
+ bag.scaleVecInput[2]->value(scaleVec[2]);
+ bag.scaleVecInput[0]->callback((fltk::Callback *)scaleGlyph_cb, &bag);
+ bag.scaleVecInput[1]->callback((fltk::Callback *)scaleGlyph_cb, &bag);
+ bag.scaleVecInput[2]->callback((fltk::Callback *)scaleGlyph_cb, &bag);
+
+ bag.glyphScaleRadInput = new fltk::ValueInput(300, winy, 45, 20, "gssr");
+ bag.glyphScaleRadInput->range(0.0, 100.0);
+ bag.glyphScaleRadInput->step(0.1);
+ bag.glyphScaleRadInput->linesize(0.1);
+ bag.glyphScaleRadInput->value(glyphScaleRad);
+ bag.glyphScaleRadInput->callback((fltk::Callback *)scaleGlyph_cb, &bag);
+
+ winy += incy;
+ bag.alpha = new Deft::Slider(0, winy, win->w(), incy = 55, "alpha");
+ bag.alpha->align(fltk::ALIGN_LEFT);
+ bag.alpha->range(0, 1);
+ bag.alpha->value(pctx->sysParm.alpha);
+ bag.alpha->fastUpdate(1);
+ bag.alpha->callback((fltk::Callback *)alpha_cb, &bag);
+
+ if (pullInterTypeAdditive == pctx->interType) {
+ winy += incy;
+ bag.beta = new Deft::Slider(0, winy, win->w(), incy = 55, "beta");
+ bag.beta->align(fltk::ALIGN_LEFT);
+ bag.beta->range(0, 1);
+ bag.beta->value(pctx->sysParm.beta);
+ bag.beta->fastUpdate(1);
+ bag.beta->callback((fltk::Callback *)beta_cb, &bag);
+ }
+
+ if (pullEnergyCubicWell == pctx->energySpecR->energy
+ || pullEnergyBetterCubicWell == pctx->energySpecR->energy) {
+ winy += incy;
+ bag.cwell = new Deft::Slider(0, winy, win->w(), incy = 55, "well depth");
+ bag.cwell->align(fltk::ALIGN_LEFT);
+ bag.cwell->range(-0.04, 0);
+ bag.cwell->value(bag.pctx->energySpecR->parm[1]);
+ bag.cwell->fastUpdate(1);
+ bag.cwell->callback((fltk::Callback *)cwell_cb, &bag);
+ /* remember eip as fraction of well depth */
+ bag.energyIncreasePermitFrac = energyIncreasePermit / bag.pctx->energySpecR->parm[1];
+ } else {
+ bag.energyIncreasePermitFrac = AIR_NAN;
+ }
+
+ winy += incy;
+ bag.gamma = new Deft::Slider(0, winy, win->w(), incy = 55, "gamma");
+ bag.gamma->align(fltk::ALIGN_LEFT);
+ bag.gamma->range(0, 2 * pctx->sysParm.gamma);
+ bag.gamma->value(pctx->sysParm.gamma);
+ bag.gamma->fastUpdate(1);
+ bag.gamma->callback((fltk::Callback *)gamma_cb, &bag);
+
+ winy += incy;
+ bag.ccSelect = new Deft::Slider(0, winy, win->w(), incy = 55, "CC Select");
+ bag.ccSelect->align(fltk::ALIGN_LEFT);
+ bag.ccSelect->range(0, 0);
+ bag.ccSelect->step(1);
+ bag.ccSelect->value(0);
+ bag.ccSelect->fastUpdate(1);
+ bag.ccSelect->callback((fltk::Callback *)ccSelect_cb, &bag);
+
+ bag.ccSingle = new fltk::CheckButton(130, winy + 4, 50, 20, "Single");
+ bag.ccSingle->value(0);
+ bag.ccSingle->callback((fltk::Callback *)ccSelect_cb, &bag);
+
+ winy += incy;
+ bag.rho = new Deft::Slider(0, winy, win->w(), incy = 55, "rho");
+ bag.rho->align(fltk::ALIGN_LEFT);
+ bag.rho->range(0, 1.0);
+ bag.rho->value(0.5);
+ bag.rho->fastUpdate(1);
+ bag.rho->callback((fltk::Callback *)cc_cb, &bag);
+
+ if (ssrange[1] > ssrange[0]) {
+ winy += incy;
+ bag.sclMean = new Deft::Slider(0, winy, win->w(), incy = 55, "scale mean");
+ bag.sclMean->align(fltk::ALIGN_LEFT);
+ bag.sclMean->range(ssrange[0], ssrange[1]);
+ bag.sclMean->value((ssrange[0] + ssrange[1]) / 2);
+ bag.sclMean->fastUpdate(1);
+ bag.sclMean->callback((fltk::Callback *)scale_cb, &bag);
+
+ fltk::Button *reblurButton = new fltk::Button(130, winy + 4, 50, 20, "reblur");
+ reblurButton->callback((fltk::Callback *)reblur_cb, &bag);
+
+ winy += incy;
+ bag.sclWind = new Deft::Slider(0, winy, win->w(), incy = 55, "scale window");
+ bag.sclWind->align(fltk::ALIGN_LEFT);
+ bag.sclWind->range(0, ssrange[1] - ssrange[0]);
+ bag.sclWind->value(ssrange[1] - ssrange[0]);
+ bag.sclWind->fastUpdate(1);
+ bag.sclWind->callback((fltk::Callback *)scale_cb, &bag);
+ scale_cb(NULL, &bag);
+ } else {
+ bag.sclMin = bag.sclMax = 0;
+ }
+
+ if (pctx->ispec[pullInfoStrength]) {
+ winy += incy;
+ bag.strength = new Deft::Slider(0, winy, win->w(), incy = 55, "strength");
+ bag.strength->align(fltk::ALIGN_LEFT);
+ bag.strength->range(0, 1);
+ bag.strength->callback((fltk::Callback *)strength_cb, &bag);
+ bag.strength->fastUpdate(1);
+ bag.strength->value(0);
+ } else {
+ bag.strnMin = 0;
+ }
+ if (pctx->ispec[pullInfoQuality]) {
+ winy += incy;
+ bag.quality = new Deft::Slider(0, winy, win->w(), incy = 55, "quality");
+ bag.quality->align(fltk::ALIGN_LEFT);
+ bag.quality->range(-0.1, 1);
+ bag.quality->callback((fltk::Callback *)quality_cb, &bag);
+ bag.quality->fastUpdate(1);
+ bag.quality->value(-0.1);
+ } else {
+ bag.qualMin = 0;
+ }
+
+ /*
+ winy += incy;
+ bag.height = new Deft::Slider(0, winy, win->w(), incy=55, "height");
+ bag.height->align(fltk::ALIGN_LEFT);
+ bag.height->range(0, 10);
+ bag.height->value(10);
+ bag.height->fastUpdate(1);
+ bag.height->callback((fltk::Callback*)strength_cb, &bag);
+ */
+
+ win->end();
+ win->show();
+
+ /* -------------------------------------------------- */
+ bag.viewer = new Deft::Viewer(bag.scene, imgSize[0], imgSize[1]);
+ if (camkeep) {
+ bag.viewer->camera(fr[0], fr[1], fr[2], at[0], at[1], at[2], up[0], up[1], up[2],
+ fovy, neer, faar);
+ }
+ bag.viewer->resizable(bag.viewer);
+ bag.viewer->end();
+ const char *fakeArgv[2] = {"Deft_pull", NULL};
+ bag.viewer->show(1, (char **)fakeArgv);
+ if (ortho) {
+ /* total hack */
+ bag.viewer->keyboard('p', 0, 0);
+ }
+ /* bag.viewer->helpPrint(); */
+ Deft::ViewerUI *viewerUI = new Deft::ViewerUI(bag.viewer);
+ viewerUI->show();
+ fltk::flush();
+
+ /* -------------------------------------------------- */
+ if (gageKindScl == vspec[0]->kind) {
+ bag.contour = new Deft::Contour();
+ bag.contour->volumeSet(bag.nblur);
+ bag.contour->twoSided(true);
+ bag.scene->objectAdd(bag.contour);
+ } else {
+ bag.contour = NULL;
+ }
+
+ /* -------------------------------------------------- */
+ Deft::TensorGlyph *glyph = new Deft::TensorGlyph();
+ glyph->dynamic(true);
+ glyph->twoSided(true);
+ glyph->anisoType(aniso);
+ glyph->anisoThreshMin(anisoThreshMin);
+ glyph->anisoThresh(anisoThresh);
+ glyph->glyphType(glyphType);
+ glyph->superquadSharpness(sqdSharp);
+ glyph->glyphResolution(glyphFacetRes);
+ if (tenGlyphTypeBetterquad) {
+ glyph->barycentricResolution(baryRes);
+ } else {
+ glyph->barycentricResolution(20);
+ }
+ glyph->glyphScale(glyphScale);
+ glyph->glyphHaloWidth(glyphHaloWidth);
+ glyph->haloTraceBound(haloTraceBound);
+ glyph->glyphNormPow(glyphNormPow);
+ glyph->glyphEvalPow(glyphEvalPow);
+ glyph->rgbEvecParmSet(tenAniso_Cl2, 0, 0.7, 1.0, 2.3, 1.0);
+ glyph->rgbEvecParmSet(tenAniso_Cl2, 0, 0, 1.0, 1, 0.0);
+ glyph->maskThresh(0.5);
+ /*
+ void rgbParmSet(int aniso, unsigned int evec,
+ double maxSat, double isoGray,
+ double gamma, double modulate);
+ */
+
+ bag.scene->objectAdd(glyph);
+ bag.glyph = glyph;
+
+ Deft::TensorGlyphUI *glyphUI = new Deft::TensorGlyphUI(bag.glyph, bag.viewer);
+ glyphUI->show();
+
+ /* -------------------------------------------------- */
+ /*
+ Deft::TensorGlyph *hedge = new Deft::TensorGlyph();
+ hedge->dynamic(true);
+ hedge->anisoType(aniso);
+ hedge->anisoThreshMin(anisoThreshMin);
+ hedge->anisoThresh(anisoThresh);
+ hedge->glyphType(glyphType);
+ hedge->superquadSharpness(sqdSharp);
+ hedge->glyphResolution(glyphFacetRes);
+ hedge->glyphScale(glyphScale/4);
+ hedge->rgbParmSet(tenAniso_Cl2, 0, 0.7, 1.0, 2.3, 1.0);
+ hedge->rgbParmSet(tenAniso_Cl2, 0, 0, 1.0, 1, 0.0);
+ hedge->maskThresh(0.0);
+ bag.hedge = hedge;
+ bag.scene->objectAdd(hedge);
+ Deft::TensorGlyphUI *hedgeUI = new Deft::TensorGlyphUI(bag.hedge,
+ bag.viewer);
+ hedgeUI->show();
+ */
+
+ /* -------------------------------------------------- */
+ Deft::Volume *vol = new Deft::Volume(vspec[0]->kind, bag.nblur);
+ fprintf(stderr, "!%s: vol = %p *********************\n", me, vol);
+ Deft::TriPlane *triplane = new Deft::TriPlane(vol);
+ /*
+ ** HEY: you can eventually segfault if this isn't set here
+ ** shouldn't doing so be optional?
+ */
+ if (gageKindScl == vspec[0]->kind) {
+ triplane->alphaMaskQuantity(Deft::alphaMaskSclQuantityValue);
+ triplane->alphaMaskThreshold(0);
+ triplane->colorQuantity(Deft::colorSclQuantityValue);
+ } else if (tenGageKind == vspec[0]->kind) {
+ triplane->alphaMaskQuantity(Deft::alphaMaskTenQuantityConfidence);
+ triplane->alphaMaskThreshold(0);
+ triplane->colorQuantity(Deft::colorTenQuantityRgbLinear);
+ }
+
+ NrrdKernelSpec *ksp = nrrdKernelSpecNew();
+ double kparm[10];
+
+ kparm[0] = 1.0;
+ nrrdKernelSpecSet(ksp, nrrdKernelTent, kparm);
+ triplane->kernel(gageKernel00, ksp);
+ ELL_3V_SET(kparm, 1, 1, 0);
+ nrrdKernelSpecSet(ksp, nrrdKernelBCCubicD, kparm);
+ triplane->kernel(gageKernel11, ksp);
+ nrrdKernelSpecSet(ksp, nrrdKernelBCCubicDD, kparm);
+ triplane->kernel(gageKernel22, ksp);
+ triplane->visible(false);
+
+ bag.scene->groupAdd(triplane);
+
+ Deft::TriPlaneUI *planeUI = new Deft::TriPlaneUI(triplane, bag.viewer);
+ planeUI->show();
+
+ /* -------------------------------------------------- */
+
+ if (gageKindScl == vspec[0]->kind) {
+ fltk::Window *window = new fltk::Window(400, 80, "isovalu...
[truncated message content] |
|
From: <kin...@us...> - 2023-07-13 11:26:42
|
Revision: 7083
http://sourceforge.net/p/teem/code/7083
Author: kindlmann
Date: 2023-07-13 11:26:41 +0000 (Thu, 13 Jul 2023)
Log Message:
-----------
some things missed the signed -> unsigned int switch
Modified Paths:
--------------
teem/trunk/src/hoover/hoover.h
teem/trunk/src/hoover/methodsHoover.c
Modified: teem/trunk/src/hoover/hoover.h
===================================================================
--- teem/trunk/src/hoover/hoover.h 2023-07-13 11:16:11 UTC (rev 7082)
+++ teem/trunk/src/hoover/hoover.h 2023-07-13 11:26:41 UTC (rev 7083)
@@ -101,16 +101,16 @@
/******** 2) volume information: size and spacing, centering, or
a gageShape that sets everything */
- int volSize[3]; /* X,Y,Z resolution of volume */
- double volSpacing[3]; /* distance between samples in X,Y,Z direction */
- int volCentering; /* either nrrdCenterNode or nrrdCenterCell */
- const gageShape *shape; /* if non-NULL, use this gageShape (which we do
- NOT own), which over-rides
- volSize, volSpacing, volCentering */
+ unsigned int volSize[3]; /* X,Y,Z resolution of volume */
+ double volSpacing[3]; /* distance between samples in X,Y,Z direction */
+ int volCentering; /* either nrrdCenterNode or nrrdCenterCell */
+ const gageShape *shape; /* if non-NULL, use this gageShape (which we do
+ NOT own), which over-rides
+ volSize, volSpacing, volCentering */
/******** 3) image information: dimensions + centering */
- int imgSize[2], /* # samples of image along U and V axes */
- imgCentering; /* either nrrdCenterNode or nrrdCenterCell */
+ unsigned int imgSize[2]; /* # samples of image along U and V axes */
+ int imgCentering; /* either nrrdCenterNode or nrrdCenterCell */
/******** 4) opaque "user information" pointer */
void *user; /* passed to all callbacks */
Modified: teem/trunk/src/hoover/methodsHoover.c
===================================================================
--- teem/trunk/src/hoover/methodsHoover.c 2023-07-13 11:16:11 UTC (rev 7082)
+++ teem/trunk/src/hoover/methodsHoover.c 2023-07-13 11:26:41 UTC (rev 7083)
@@ -52,7 +52,8 @@
int /* Biff: 1 */
hooverContextCheck(hooverContext *ctx) {
static const char me[] = "hooverContextCheck";
- int sxe, sye, sze, minSize, centr;
+ int sxe, sye, sze, centr;
+ unsigned int minSize;
if (!ctx) {
biffAddf(HOOVER, "%s: got NULL pointer", me);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <kin...@us...> - 2023-07-13 11:16:13
|
Revision: 7082
http://sourceforge.net/p/teem/code/7082
Author: kindlmann
Date: 2023-07-13 11:16:11 +0000 (Thu, 13 Jul 2023)
Log Message:
-----------
using new typed non-var-args functions in hest
Modified Paths:
--------------
teem/trunk/src/limn/hestLimn.c
Modified: teem/trunk/src/limn/hestLimn.c
===================================================================
--- teem/trunk/src/limn/hestLimn.c 2023-07-13 10:50:36 UTC (rev 7081)
+++ teem/trunk/src/limn/hestLimn.c 2023-07-13 11:16:11 UTC (rev 7082)
@@ -47,31 +47,28 @@
hestOpt *hopt;
hopt = *hoptP;
- hestOptAdd(&hopt, "fr", "eye pos", airTypeDouble, 3, 3, cam->from, frDef,
- "camera eye point");
- hestOptAdd(&hopt, "at", "at pos", airTypeDouble, 3, 3, cam->at, atDef,
- "camera look-at point");
- hestOptAdd(&hopt, "up", "up dir", airTypeDouble, 3, 3, cam->up, upDef,
- "camera pseudo-up vector");
- hestOptAdd(&hopt, "rh", NULL, airTypeInt, 0, 0, &(cam->rightHanded), NULL,
- "use a right-handed UVN frame (V points down)");
- hestOptAdd(&hopt, "or", NULL, airTypeInt, 0, 0, &(cam->orthographic), NULL,
- "orthogonal (not perspective) projection");
- hestOptAdd(&hopt, "dn", "near", airTypeDouble, 1, 1, &(cam->neer), dnDef,
- "distance to near clipping plane");
- hestOptAdd(&hopt, "di", "image", airTypeDouble, 1, 1, &(cam->dist), diDef,
- "distance to image plane");
- hestOptAdd(&hopt, "df", "far", airTypeDouble, 1, 1, &(cam->faar), dfDef,
- "distance to far clipping plane");
- hestOptAdd(&hopt, "ar", NULL, airTypeInt, 0, 0, &(cam->atRelative), NULL,
- "near, image, and far plane distances are relative to "
- "the *at* point, instead of the eye point");
- hestOptAdd(&hopt, "ur", "uMin uMax", airTypeDouble, 2, 2, cam->uRange, urDef,
- "range in U direction of image plane");
- hestOptAdd(&hopt, "vr", "vMin vMax", airTypeDouble, 2, 2, cam->vRange, vrDef,
- "range in V direction of image plane");
- hestOptAdd(&hopt, "fv", "field of view", airTypeDouble, 1, 1, &(cam->fov), fvDef,
- "angle (in degrees) vertically subtended by view window");
+ hestOptAdd_3_Double(&hopt, "fr", "eye pos", cam->from, frDef, "camera eye point");
+ hestOptAdd_3_Double(&hopt, "at", "at pos", cam->at, atDef, "camera look-at point");
+ hestOptAdd_3_Double(&hopt, "up", "up dir", cam->up, upDef, "camera pseudo-up vector");
+ hestOptAdd_Flag(&hopt, "rh", &(cam->rightHanded),
+ "use a right-handed UVN frame (V points down)");
+ hestOptAdd_Flag(&hopt, "or", &(cam->orthographic),
+ "orthogonal (not perspective) projection");
+ hestOptAdd_1_Double(&hopt, "dn", "near", &(cam->neer), dnDef,
+ "distance to near clipping plane");
+ hestOptAdd_1_Double(&hopt, "di", "image", &(cam->dist), diDef,
+ "distance to image plane");
+ hestOptAdd_1_Double(&hopt, "df", "far", &(cam->faar), dfDef,
+ "distance to far clipping plane");
+ hestOptAdd_Flag(&hopt, "ar", &(cam->atRelative),
+ "near, image, and far plane distances are relative to "
+ "the *at* point, instead of the eye point");
+ hestOptAdd_2_Double(&hopt, "ur", "uMin uMax", cam->uRange, urDef,
+ "range in U direction of image plane");
+ hestOptAdd_2_Double(&hopt, "vr", "vMin vMax", cam->vRange, vrDef,
+ "range in V direction of image plane");
+ hestOptAdd_1_Double(&hopt, "fv", "field of view", &(cam->fov), fvDef,
+ "angle (in degrees) vertically subtended by view window");
*hoptP = hopt;
return;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <kin...@us...> - 2023-07-13 10:50:38
|
Revision: 7081
http://sourceforge.net/p/teem/code/7081
Author: kindlmann
Date: 2023-07-13 10:50:36 +0000 (Thu, 13 Jul 2023)
Log Message:
-----------
trimming down how many EXPERIMENTAL_APPS there are
Modified Paths:
--------------
teem/trunk/src/bin/CMakeLists.txt
Modified: teem/trunk/src/bin/CMakeLists.txt
===================================================================
--- teem/trunk/src/bin/CMakeLists.txt 2023-07-12 19:14:11 UTC (rev 7080)
+++ teem/trunk/src/bin/CMakeLists.txt 2023-07-13 10:50:36 UTC (rev 7081)
@@ -38,26 +38,29 @@
CREATE_EXEC(miter miter.c)
CREATE_EXEC(vprobe vprobe.c)
CREATE_EXEC(gprobe gprobe.c)
-# CREATE_EXEC(ninspect ninspect.c) moved to "unu ninspect"
+# CREATE_EXEC(ninspect ninspect.c) # moved to "unu ninspect"
CREATE_EXEC(unu unu.c)
CREATE_EXEC(puller puller.c)
CREATE_EXEC(tend tend.c)
+# For Teem v2 many of these were removed from compilation: they have no compelling
+# general purpose, for reasons indicated with further comments. No reason
+# to delete the sources though.
# NOTE: The BUILD_EXPERIMENTAL_LIBS-dependent inclusion of binaries has to be
# done with knowledge of how BUILD_EXPERIMENTAL_LIBS behaves in the top-level
# CMakeLists.txt file
if(BUILD_EXPERIMENTAL_APPS)
- CREATE_EXEC(airSanity airSanity.c)
- CREATE_EXEC(cubic cubic.c)
- CREATE_EXEC(qbert qbert.c)
- CREATE_EXEC(ilk ilk.c)
- CREATE_EXEC(emap emap.c)
- CREATE_EXEC(talkweb talkweb.c)
- CREATE_EXEC(pprobe pprobe.c)
- CREATE_EXEC(ungantry ungantry.c)
- CREATE_EXEC(deconv deconv.c)
- if(BUILD_EXPERIMENTAL_LIBS)
- CREATE_EXEC(gkms gkms.c)
- CREATE_EXEC(spots spots.c)
- endif()
+# CREATE_EXEC(airSanity airSanity.c) # tests included in nrrdSanity
+# CREATE_EXEC(cubic cubic.c) # just calls ell_cubic; more easily done via Python wrappers
+# CREATE_EXEC(qbert qbert.c) # created for volume rendering on GPUs from 20 years ago
+# CREATE_EXEC(ilk ilk.c) # now part of unu: "unu ilk"
+ CREATE_EXEC(emap emap.c) # (functionality not currently handled elsewhere)
+# CREATE_EXEC(talkweb talkweb.c) # the web has changed in 20 years
+# CREATE_EXEC(pprobe pprobe.c) # gprobe can do this
+# CREATE_EXEC(ungantry ungantry.c) # gprobe can do this
+ CREATE_EXEC(deconv deconv.c) # (functionality not currently handled elsewhere)
+# if(BUILD_EXPERIMENTAL_LIBS)
+# CREATE_EXEC(gkms gkms.c) # hasn't been tested in a long time
+# CREATE_EXEC(spots spots.c) # hasn't been tested in a long time
+# endif()
endif()
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <kin...@us...> - 2023-07-12 19:14:12
|
Revision: 7080
http://sourceforge.net/p/teem/code/7080
Author: kindlmann
Date: 2023-07-12 19:14:11 +0000 (Wed, 12 Jul 2023)
Log Message:
-----------
the functions never did the signed->unsigned switch, even if the struct did
Modified Paths:
--------------
teem/trunk/src/alan/alan.h
teem/trunk/src/alan/methodsAlan.c
Modified: teem/trunk/src/alan/alan.h
===================================================================
--- teem/trunk/src/alan/alan.h 2023-07-12 12:12:58 UTC (rev 7079)
+++ teem/trunk/src/alan/alan.h 2023-07-12 19:14:11 UTC (rev 7080)
@@ -158,9 +158,10 @@
ALAN_EXPORT void alanContextInit(alanContext *actx);
ALAN_EXPORT alanContext *alanContextNew(void);
ALAN_EXPORT alanContext *alanContextNix(alanContext *actx);
-ALAN_EXPORT int alanDimensionSet(alanContext *actx, int dim);
-ALAN_EXPORT int alan2DSizeSet(alanContext *actx, int sizeX, int sizeY);
-ALAN_EXPORT int alan3DSizeSet(alanContext *actx, int sizeX, int sizeY, int sizeZ);
+ALAN_EXPORT int alanDimensionSet(alanContext *actx, unsigned int dim);
+ALAN_EXPORT int alan2DSizeSet(alanContext *actx, unsigned int sizeX, unsigned int sizeY);
+ALAN_EXPORT int alan3DSizeSet(alanContext *actx, unsigned int sizeX, unsigned int sizeY,
+ unsigned int sizeZ);
ALAN_EXPORT int alanTensorSet(alanContext *actx, Nrrd *nten, int oversample);
ALAN_EXPORT int alanParmSet(alanContext *actx, int whichParm, double parm);
Modified: teem/trunk/src/alan/methodsAlan.c
===================================================================
--- teem/trunk/src/alan/methodsAlan.c 2023-07-12 12:12:58 UTC (rev 7079)
+++ teem/trunk/src/alan/methodsAlan.c 2023-07-12 19:14:11 UTC (rev 7080)
@@ -101,7 +101,7 @@
}
int /* Biff: 1 */
-alanDimensionSet(alanContext *actx, int dim) {
+alanDimensionSet(alanContext *actx, unsigned int dim) {
static const char me[] = "alanDimensionSet";
GOT_NULL;
@@ -116,7 +116,7 @@
}
int /* Biff: 1 */
-alan2DSizeSet(alanContext *actx, int sizeX, int sizeY) {
+alan2DSizeSet(alanContext *actx, unsigned int sizeX, unsigned int sizeY) {
static const char me[] = "alan2DSizeSet";
GOT_NULL;
@@ -136,7 +136,8 @@
}
int /* Biff: 1 */
-alan3DSizeSet(alanContext *actx, int sizeX, int sizeY, int sizeZ) {
+alan3DSizeSet(alanContext *actx, unsigned int sizeX, unsigned int sizeY,
+ unsigned int sizeZ) {
static const char me[] = "alan3DSizeSet";
GOT_NULL;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <kin...@us...> - 2023-07-12 12:13:00
|
Revision: 7079
http://sourceforge.net/p/teem/code/7079
Author: kindlmann
Date: 2023-07-12 12:12:58 +0000 (Wed, 12 Jul 2023)
Log Message:
-----------
tweaks to comments
Modified Paths:
--------------
teem/trunk/src/hest/adders.c
Modified: teem/trunk/src/hest/adders.c
===================================================================
--- teem/trunk/src/hest/adders.c 2023-07-11 23:58:18 UTC (rev 7078)
+++ teem/trunk/src/hest/adders.c 2023-07-12 12:12:58 UTC (rev 7079)
@@ -32,7 +32,7 @@
concatenation, and ended up passing total garbage to hestOptAdd for
the airEnum pointer, causing him to think that the tenGlyphType airEnum
was malformed, when it was in fact fine ...
-This motivated the r7026 2023-07-06 addition of hestOptAdd_nva, which
+This motivated the r7026 2023-07-06 addition of non-var-args hestOptAdd_nva, which
would have caught the above error.
The underlying issue there, though, is the total lack of type-checking associated with
@@ -45,17 +45,17 @@
generated here for completeness (an option for 4 floats or 4 doubles is great for
R,G,B,A values).
-However with airTypeOther, when the caller passes a hestCB struct of callbacks to parse
-arbitrary things from the command-line, there is still unfortunately a type-checking
-black hole void* involved. And, there is no away around that: either valueP is an array
-of structs (when hestCB->destroy is NULL) or an array of pointers to structs
-(hestCB->destroy is non-NULL), for which the most specific type for valueP would be
-either void* or void**, respectively. But void** is not a generic pointer to pointer type
-(like void* is the generic pointer type), and, we're not doing compile-time checks on the
-non-NULL-ity of hestCB->destroy. So it all devolves back to plain void*. Still, the
-hestOptAdd_*_Other function are generated here to slightly simplify the hestOptAdd call,
-since there is no more NULL and NULL for sawP and enum. Actually, there is a way around
-a type-checking black hole: extreme attentiveness!
+However for airTypeOther (i.e. when the caller passes a hestCB struct of callbacks to
+parse arbitrary things from the command-line) there is still unfortunately a
+type-checking black hole void* involved. And, there is no away around that: either
+valueP is an array of structs (when hestCB->destroy is NULL) or an array of pointers to
+structs (hestCB->destroy is non-NULL), for which the most specific type for valueP would
+be either void* or void**, respectively. But void** is not a generic pointer to pointer
+type (like void* is the generic pointer type), and, we're not doing compile-time checks
+on the non-NULL-ity of hestCB->destroy. So it all devolves back to plain void*. Still,
+the hestOptAdd_*_Other function are generated here to slightly simplify the hestOptAdd
+call, since there is no more NULL and NULL for sawP and enum. Actually, there is a way
+around a type-checking black hole: extreme attentiveness!
*/
/* --------------------------------------------------------------- 1 == kind */
@@ -283,7 +283,7 @@
MAC(M, String, char *)
/* MAP(BSN, X, M) takes a macro basename BSN (like DEF) and
-expands it to the _T, _E, and _O cases for _X. E.g. "MAP(DEF, 1, 0)" expands to:
+expands it to the _T_, _E_, and _O_ cases for _X. E.g. "MAP(DEF, 1, 0)" expands to:
MAP_T(DEF_T_1, 0)
DEF_E_1(0)
DEF_O_1(0)
@@ -290,8 +290,8 @@
*/
#define MAP(BSN, X, M) MAP_T(CONC3(BSN, T, X), M) CONC3(BSN, E, X)(M) CONC3(BSN, O, X)(M)
-/* DOIT does expansion over all possibilities of BSN */
-#define DOIT(BSN) \
+/* This does expansion over all possibilities of BSN */
+#define LETS_GET_THIS_PARTY_STARTED(BSN) \
MAP(BSN, 1, 0) \
MAP(BSN, 1, 1) \
MAP(BSN, M, 2) \
@@ -301,7 +301,7 @@
MAP(BSN, V, _)
/* !!! HERE IS THE ACTUAL CODE FOR ALL THE hestOptAdd_*_* CASES !!! */
-DOIT(DEF)
+LETS_GET_THIS_PARTY_STARTED(DEF)
/* Macro for making a string out of whatever something has been #define'd to
https://gcc.gnu.org/onlinedocs/cpp/Stringizing.html */
@@ -327,7 +327,7 @@
#define PRINT_E_V(_) fprintf(ff, "HEST_EXPORT " _STR(DCL_E_V(_)) ";\n");
#define PRINT_O_V(_) fprintf(ff, "HEST_EXPORT " _STR(DCL_O_V(_)) ";\n");
-/* prints declarations for everything defined by macro magic above */
+/* prints declarations (for hest.h) for everything defined by macros above */
void
hestOptAddDeclsPrint(FILE *ff) {
/* the flag is the one case not handled by macro expansion */
@@ -334,5 +334,5 @@
fprintf(ff, "HEST_EXPORT unsigned int hestOptAdd_Flag(hestOpt **optP, "
"const char *flag, int *valueP, const char *info);\n");
/* declarations for all other cases */
- DOIT(PRINT)
+ LETS_GET_THIS_PARTY_STARTED(PRINT)
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <kin...@us...> - 2023-07-11 23:58:21
|
Revision: 7078
http://sourceforge.net/p/teem/code/7078
Author: kindlmann
Date: 2023-07-11 23:58:18 +0000 (Tue, 11 Jul 2023)
Log Message:
-----------
Start of shifting hest usage to non-var-args typed functions
Modified Paths:
--------------
teem/trunk/src/unrrdu/1op.c
teem/trunk/src/unrrdu/2op.c
teem/trunk/src/unrrdu/3op.c
teem/trunk/src/unrrdu/crop.c
teem/trunk/src/unrrdu/make.c
teem/trunk/src/unrrdu/minmax.c
teem/trunk/src/unrrdu/mlut.c
teem/trunk/src/unrrdu/mrmap.c
teem/trunk/src/unrrdu/ninspect.c
teem/trunk/src/unrrdu/pad.c
teem/trunk/src/unrrdu/permute.c
teem/trunk/src/unrrdu/privateUnrrdu.h
teem/trunk/src/unrrdu/project.c
teem/trunk/src/unrrdu/quantize.c
teem/trunk/src/unrrdu/resample.c
teem/trunk/src/unrrdu/reshape.c
teem/trunk/src/unrrdu/rmap.c
teem/trunk/src/unrrdu/save.c
teem/trunk/src/unrrdu/shuffle.c
teem/trunk/src/unrrdu/slice.c
teem/trunk/src/unrrdu/splice.c
teem/trunk/src/unrrdu/sselect.c
teem/trunk/src/unrrdu/subst.c
teem/trunk/src/unrrdu/swap.c
teem/trunk/src/unrrdu/tile.c
teem/trunk/src/unrrdu/unblock.c
teem/trunk/src/unrrdu/uncmt.c
teem/trunk/src/unrrdu/undos.c
teem/trunk/src/unrrdu/unorient.c
teem/trunk/src/unrrdu/unquantize.c
teem/trunk/src/unrrdu/untile.c
teem/trunk/src/unrrdu/vidicon.c
teem/trunk/src/unrrdu/w2i.c
Modified: teem/trunk/src/unrrdu/1op.c
===================================================================
--- teem/trunk/src/unrrdu/1op.c 2023-07-11 22:15:46 UTC (rev 7077)
+++ teem/trunk/src/unrrdu/1op.c 2023-07-11 23:58:18 UTC (rev 7078)
@@ -29,47 +29,47 @@
static int
unrrdu_1opMain(int argc, const char **argv, const char *me, hestParm *hparm) {
hestOpt *opt = NULL;
- char *out, *err, *seedS;
+ char *out, *err;
Nrrd *nin, *nout, *ntmp = NULL;
int op, pret, type;
airArray *mop;
- unsigned int seed;
+ unsigned int seed, seedOI;
- hestOptAdd(&opt, NULL, "operator", airTypeEnum, 1, 1, &op, NULL,
- "Unary operator. Possibilities include:\n "
- "\b\bo \"-\": negative (multiply by -1.0)\n "
- "\b\bo \"r\": reciprocal (1.0/value)\n "
- "\b\bo \"sin\", \"cos\", \"tan\", \"asin\", \"acos\", \"atan\": "
- "same as in C\n "
- "\b\bo \"exp\", \"log\", \"log10\": same as in C\n "
- "\b\bo \"log1p\", \"expm1\": accurate log(x+1) and exp(x)-1\n "
- "\b\bo \"log2\": log base 2\n "
- "\b\bo \"sqrt\", \"cbrt\", \"ceil\", \"floor\": same as in C\n "
- "\b\bo \"erf\": error function (integral of Gaussian)\n "
- "\b\bo \"rup\", \"rdn\": round up or down to integral value\n "
- "\b\bo \"abs\": absolute value\n "
- "\b\bo \"sgn\": -1, 0, 1 if value is <0, ==0, or >0\n "
- "\b\bo \"exists\": 1 iff not NaN or +/-Inf, 0 otherwise\n "
- "\b\bo \"rand\": random value in [0.0,1.0), "
- "no relation to input\n "
- "\b\bo \"nrand\": random sample from normal distribution with "
- "mean 0.0 and stdv 1.0, no relation to input\n "
- "\b\bo \"if\": if input is non-zero, 1, else 0\n "
- "\b\bo \"0\": output always 0\n "
- "\b\bo \"1\": output always 1",
- NULL, nrrdUnaryOp);
- hestOptAdd(&opt, "s,seed", "seed", airTypeString, 1, 1, &seedS, "",
- "seed value for RNG for rand and nrand, so that you "
- "can get repeatable results between runs, or, "
- "by not using this option, the RNG seeding will be "
- "based on the current time");
- hestOptAdd(&opt, "t,type", "type", airTypeOther, 1, 1, &type, "default",
- "convert input nrrd to this type prior to "
- "doing operation. Useful when desired output is float "
- "(e.g., with log1p), but input is integral. By default "
- "(not using this option), the types of "
- "the input nrrds are left unchanged.",
- NULL, NULL, &unrrduHestMaybeTypeCB);
+ hestOptAdd_1_Enum(&opt, NULL, "operator", &op, NULL,
+ "Unary operator. Possibilities include:\n "
+ "\b\bo \"-\": negative (multiply by -1.0)\n "
+ "\b\bo \"r\": reciprocal (1.0/value)\n "
+ "\b\bo \"sin\", \"cos\", \"tan\", \"asin\", \"acos\", \"atan\": "
+ "same as in C\n "
+ "\b\bo \"exp\", \"log\", \"log10\": same as in C\n "
+ "\b\bo \"log1p\", \"expm1\": accurate log(x+1) and exp(x)-1\n "
+ "\b\bo \"log2\": log base 2\n "
+ "\b\bo \"sqrt\", \"cbrt\", \"ceil\", \"floor\": same as in C\n "
+ "\b\bo \"erf\": error function (integral of Gaussian)\n "
+ "\b\bo \"rup\", \"rdn\": round up or down to integral value\n "
+ "\b\bo \"abs\": absolute value\n "
+ "\b\bo \"sgn\": -1, 0, 1 if value is <0, ==0, or >0\n "
+ "\b\bo \"exists\": 1 iff not NaN or +/-Inf, 0 otherwise\n "
+ "\b\bo \"rand\": random value in [0.0,1.0), "
+ "no relation to input\n "
+ "\b\bo \"nrand\": random sample from normal distribution with "
+ "mean 0.0 and stdv 1.0, no relation to input\n "
+ "\b\bo \"if\": if input is non-zero, 1, else 0\n "
+ "\b\bo \"0\": output always 0\n "
+ "\b\bo \"1\": output always 1",
+ nrrdUnaryOp);
+ seedOI = hestOptAdd_1_UInt(&opt, "s,seed", "seed", &seed, "0",
+ "seed value for random number generator (RNG), to "
+ "enable repeatable results between runs, or, "
+ "by not using this option, the RNG seeding will be "
+ "based on the current time");
+ hestOptAdd_1_Other(&opt, "t,type", "type", &type, "default",
+ "convert input nrrd to this type prior to "
+ "doing operation. Useful when desired output is float "
+ "(e.g., with log1p), but input is integral. By default "
+ "(not using this option), the types of "
+ "the input nrrds are left unchanged.",
+ &unrrduHestMaybeTypeCB);
OPT_ADD_NIN(nin, "input nrrd");
OPT_ADD_NOUT(out, "output nrrd");
@@ -99,14 +99,8 @@
** if (nrrdUnaryOpRand == op
** || nrrdUnaryOpNormalRand == op) {
*/
- if (airStrlen(seedS)) {
- if (1 != sscanf(seedS, "%u", &seed)) {
- fprintf(stderr, "%s: couldn't parse seed \"%s\" as uint\n", me, seedS);
- airMopError(mop);
- return 1;
- } else {
- airSrandMT(seed);
- }
+ if (hestSourceDefault != opt[seedOI].source) {
+ airSrandMT(seed);
} else {
/* got no request for specific seed */
airSrandMT(AIR_UINT(airTime()));
Modified: teem/trunk/src/unrrdu/2op.c
===================================================================
--- teem/trunk/src/unrrdu/2op.c 2023-07-11 22:15:46 UTC (rev 7077)
+++ teem/trunk/src/unrrdu/2op.c 2023-07-11 23:58:18 UTC (rev 7078)
@@ -33,60 +33,59 @@
static int
unrrdu_2opMain(int argc, const char **argv, const char *me, hestParm *hparm) {
hestOpt *opt = NULL;
- char *out, *err, *seedS;
+ char *out, *err;
NrrdIter *in1, *in2;
Nrrd *nout, *ntmp = NULL;
int op, type, E, pret, which;
airArray *mop;
- unsigned int seed;
+ unsigned int seed, seedOI;
- hestOptAdd(&opt, NULL, "operator", airTypeEnum, 1, 1, &op, NULL,
- "Binary operator. Possibilities include:\n "
- "\b\bo \"+\", \"-\", \"x\", \"/\": "
- "add, subtract, multiply, divide\n "
- "\b\bo \"+c\", \"-c\", \"xc\": add, subtract, multiply, with "
- "clamping to range of output, in case its integral\n "
- "\b\bo \"^\": exponentiation (pow)\n "
- "\b\bo \"spow\": signed exponentiation: sgn(x)pow(abs(x),p)\n "
- "\b\bo \"fpow\": like spow but with curves flipped\n "
- "\b\bo \"%\": integer modulo\n "
- "\b\bo \"fmod\": same as fmod() in C\n "
- "\b\bo \"atan2\": same as atan2() in C\n "
- "\b\bo \"min\", \"max\": minimum, maximum\n "
- "\b\bo \"lt\", \"lte\", \"gt\", \"gte\": same as C's <, <=, >, <=\n "
- "\b\bo \"eq\", \"neq\": same as C's == and !=\n "
- "\b\bo \"comp\": -1, 0, or 1 if 1st value is less than, "
- "equal to, or greater than 2nd value\n "
- "\b\bo \"if\": if 1st value is non-zero, use it, "
- "else use 2nd value\n "
- "\b\bo \"exists\": if 1st value exists, use it, "
- "else use 2nd value\n "
- "\b\bo \"nrand\": scale unit-stdv Gaussian noise by 2nd value "
- "and add to first value\n "
- "\b\bo \"rrand\": sample Rician distribution with 1st value "
- "for \"true\" mean, and 2nd value for sigma",
- NULL, nrrdBinaryOp);
- hestOptAdd(&opt, NULL, "in1", airTypeOther, 1, 1, &in1, NULL,
- "First input. Can be a single value or a nrrd.", NULL, NULL, nrrdHestIter);
- hestOptAdd(&opt, NULL, "in2", airTypeOther, 1, 1, &in2, NULL,
- "Second input. Can be a single value or a nrrd.", NULL, NULL,
- nrrdHestIter);
- hestOptAdd(&opt, "s,seed", "seed", airTypeString, 1, 1, &seedS, "",
- "seed value for RNG for nrand, so that you "
- "can get repeatable results between runs, or, "
- "by not using this option, the RNG seeding will be "
- "based on the current time");
- hestOptAdd(&opt, "t,type", "type", airTypeOther, 1, 1, &type, "default",
- "type to convert all INPUT nrrds to, prior to "
- "doing operation, useful for doing, for instance, the difference "
- "between two unsigned char nrrds. This will also determine "
- "output type. By default (not using this option), the types of "
- "the input nrrds are left unchanged.",
- NULL, NULL, &unrrduHestMaybeTypeCB);
- hestOptAdd(&opt, "w,which", "arg", airTypeInt, 1, 1, &which, "-1",
- "Which argument (0 or 1) should be used to determine the "
- "shape of the output nrrd. By default (not using this option), "
- "the first non-constant argument is used. ");
+ hestOptAdd_1_Enum(&opt, NULL, "operator", &op, NULL,
+ "Binary operator. Possibilities include:\n "
+ "\b\bo \"+\", \"-\", \"x\", \"/\": "
+ "add, subtract, multiply, divide\n "
+ "\b\bo \"+c\", \"-c\", \"xc\": add, subtract, multiply, with "
+ "clamping to range of output, in case its integral\n "
+ "\b\bo \"^\": exponentiation (pow)\n "
+ "\b\bo \"spow\": signed exponentiation: sgn(x)pow(abs(x),p)\n "
+ "\b\bo \"fpow\": like spow but with curves flipped\n "
+ "\b\bo \"%\": integer modulo\n "
+ "\b\bo \"fmod\": same as fmod() in C\n "
+ "\b\bo \"atan2\": same as atan2() in C\n "
+ "\b\bo \"min\", \"max\": minimum, maximum\n "
+ "\b\bo \"lt\", \"lte\", \"gt\", \"gte\": same as C's <, <=, >, <=\n "
+ "\b\bo \"eq\", \"neq\": same as C's == and !=\n "
+ "\b\bo \"comp\": -1, 0, or 1 if 1st value is less than, "
+ "equal to, or greater than 2nd value\n "
+ "\b\bo \"if\": if 1st value is non-zero, use it, "
+ "else use 2nd value\n "
+ "\b\bo \"exists\": if 1st value exists, use it, "
+ "else use 2nd value\n "
+ "\b\bo \"nrand\": scale unit-stdv Gaussian noise by 2nd value "
+ "and add to first value\n "
+ "\b\bo \"rrand\": sample Rician distribution with 1st value "
+ "for \"true\" mean, and 2nd value for sigma",
+ nrrdBinaryOp);
+ hestOptAdd_1_Other(&opt, NULL, "in1", &in1, NULL,
+ "First input. Can be a single value or a nrrd.", nrrdHestIter);
+ hestOptAdd_1_Other(&opt, NULL, "in2", &in2, NULL,
+ "Second input. Can be a single value or a nrrd.", nrrdHestIter);
+ seedOI = hestOptAdd_1_UInt(&opt, "s,seed", "seed", &seed, "0",
+ "seed value for random number generator (RNG), to "
+ "enable repeatable results between runs, or, "
+ "by not using this option, the RNG seeding will be "
+ "based on the current time");
+ hestOptAdd_1_Other(&opt, "t,type", "type", &type, "default",
+ "type to convert all INPUT nrrds to, prior to "
+ "doing operation, useful for doing, for instance, the difference "
+ "between two unsigned char nrrds. This will also determine "
+ "output type. By default (not using this option), the types of "
+ "the input nrrds are left unchanged.",
+ &unrrduHestMaybeTypeCB);
+ hestOptAdd_1_Int(&opt, "w,which", "arg", &which, "-1",
+ "Which argument (0 or 1) should be used to determine the "
+ "shape of the output nrrd. By default (not using this option), "
+ "the first non-constant argument is used. ");
OPT_ADD_NOUT(out, "output nrrd");
mop = airMopNew();
@@ -128,19 +127,13 @@
** if (nrrdBinaryOpNormalRandScaleAdd == op) {
** but then when nrrdBinaryOpRicianRand was added, then the seed wasn't being
** used ==> BUG. To be more future proof, we try to parse and use seed
- ** whenever a non-empty string is given, and end up *ALWAYS* calling
+ ** whenever the user exercies this option, and end up *ALWAYS* calling
** airSrandMT, even for operations that have nothing to do with random
** numbers. Could also have a new array that indicates if an op involves
** the RNG, but this would add rarely-needed complexity
*/
- if (airStrlen(seedS)) {
- if (1 != sscanf(seedS, "%u", &seed)) {
- fprintf(stderr, "%s: couldn't parse seed \"%s\" as uint\n", me, seedS);
- airMopError(mop);
- return 1;
- } else {
- airSrandMT(seed);
- }
+ if (hestSourceDefault != opt[seedOI].source) {
+ airSrandMT(seed);
} else {
/* got no request for specific seed */
airSrandMT(AIR_UINT(airTime()));
Modified: teem/trunk/src/unrrdu/3op.c
===================================================================
--- teem/trunk/src/unrrdu/3op.c 2023-07-11 22:15:46 UTC (rev 7077)
+++ teem/trunk/src/unrrdu/3op.c 2023-07-11 23:58:18 UTC (rev 7078)
@@ -39,53 +39,52 @@
int op, type, E, pret, which;
airArray *mop;
- hestOptAdd(&opt, NULL, "operator", airTypeEnum, 1, 1, &op, NULL,
- "Ternary operator. Possibilities include:\n "
- "\b\bo \"+\", \"x\": sum or product of three values\n "
- "\b\bo \"min\", \"max\": minimum, maximum\n "
- "\b\bo \"min_sm\": smoothed minimum function; "
- "min_sm(x, w, M) is like min(x,M) but for x > M-w (with w > 0) "
- "there is a smooth transition from x to asymptotic to M\n "
- "\b\bo \"max_sm\": smoothed maximum function; "
- "max_sm(M, w, x) is like max(M,x) but for x < m+w (with w > m) "
- "there is a smooth transition from x to asymptotic to m\n "
- "\b\bo \"lt_sm\": 1st less than 3rd, smoothed by 2nd\n "
- "\b\bo \"gt_sm\": 1st greater than 3rd, smoothed by 2nd\n "
- "\b\bo \"clamp\": 2nd value is clamped to range between "
- "the 1st and the 3rd\n "
- "\b\bo \"ifelse\": if 1st value non-zero, then 2nd value, else "
- "3rd value\n "
- "\b\bo \"lerp\": linear interpolation between the 2nd and "
- "3rd values, as the 1st value varies between 0.0 and 1.0, "
- "respectively\n "
- "\b\bo \"exists\": if the 1st value exists, use the 2nd "
- "value, otherwise use the 3rd\n "
- "\b\bo \"in_op\": 1 iff 2nd value is > 1st and < 3rd, "
- "0 otherwise\n "
- "\b\bo \"in_cl\": 1 iff 2nd value is >= 1st and <= 3rd, "
- "0 otherwise\n "
- "\b\bo \"gauss\": evaluate (at 1st value) Gaussian with mean=2nd "
- "and stdv=3rd value\n "
- "\b\bo \"rician\": evaluate (at 1st value) Rician with mean=2nd "
- "and stdv=3rd value",
- NULL, nrrdTernaryOp);
- hestOptAdd(&opt, NULL, "in1", airTypeOther, 1, 1, &in1, NULL,
- "First input. Can be a single value or a nrrd.", NULL, NULL, nrrdHestIter);
- hestOptAdd(&opt, NULL, "in2", airTypeOther, 1, 1, &in2, NULL,
- "Second input. Can be a single value or a nrrd.", NULL, NULL,
- nrrdHestIter);
- hestOptAdd(&opt, NULL, "in3", airTypeOther, 1, 1, &in3, NULL,
- "Third input. Can be a single value or a nrrd.", NULL, NULL, nrrdHestIter);
- hestOptAdd(&opt, "t,type", "type", airTypeOther, 1, 1, &type, "default",
- "type to convert all nrrd inputs to, prior to "
- "doing operation. This also determines output type. "
- "By default (not using this option), the types of the input "
- "nrrds are left unchanged.",
- NULL, NULL, &unrrduHestMaybeTypeCB);
- hestOptAdd(&opt, "w,which", "arg", airTypeInt, 1, 1, &which, "-1",
- "Which argument (0, 1, or 2) should be used to determine the "
- "shape of the output nrrd. By default (not using this option), "
- "the first non-constant argument is used. ");
+ hestOptAdd_1_Enum(&opt, NULL, "operator", &op, NULL,
+ "Ternary operator. Possibilities include:\n "
+ "\b\bo \"+\", \"x\": sum or product of three values\n "
+ "\b\bo \"min\", \"max\": minimum, maximum\n "
+ "\b\bo \"min_sm\": smoothed minimum function; "
+ "min_sm(x, w, M) is like min(x,M) but for x > M-w (with w > 0) "
+ "there is a smooth transition from x to asymptotic to M\n "
+ "\b\bo \"max_sm\": smoothed maximum function; "
+ "max_sm(M, w, x) is like max(M,x) but for x < m+w (with w > m) "
+ "there is a smooth transition from x to asymptotic to m\n "
+ "\b\bo \"lt_sm\": 1st less than 3rd, smoothed by 2nd\n "
+ "\b\bo \"gt_sm\": 1st greater than 3rd, smoothed by 2nd\n "
+ "\b\bo \"clamp\": 2nd value is clamped to range between "
+ "the 1st and the 3rd\n "
+ "\b\bo \"ifelse\": if 1st value non-zero, then 2nd value, else "
+ "3rd value\n "
+ "\b\bo \"lerp\": linear interpolation between the 2nd and "
+ "3rd values, as the 1st value varies between 0.0 and 1.0, "
+ "respectively\n "
+ "\b\bo \"exists\": if the 1st value exists, use the 2nd "
+ "value, otherwise use the 3rd\n "
+ "\b\bo \"in_op\": 1 iff 2nd value is > 1st and < 3rd, "
+ "0 otherwise\n "
+ "\b\bo \"in_cl\": 1 iff 2nd value is >= 1st and <= 3rd, "
+ "0 otherwise\n "
+ "\b\bo \"gauss\": evaluate (at 1st value) Gaussian with mean=2nd "
+ "and stdv=3rd value\n "
+ "\b\bo \"rician\": evaluate (at 1st value) Rician with mean=2nd "
+ "and stdv=3rd value",
+ nrrdTernaryOp);
+ hestOptAdd_1_Other(&opt, NULL, "in1", &in1, NULL,
+ "First input. Can be a single value or a nrrd.", nrrdHestIter);
+ hestOptAdd_1_Other(&opt, NULL, "in2", &in2, NULL,
+ "Second input. Can be a single value or a nrrd.", nrrdHestIter);
+ hestOptAdd_1_Other(&opt, NULL, "in3", &in3, NULL,
+ "Third input. Can be a single value or a nrrd.", nrrdHestIter);
+ hestOptAdd_1_Other(&opt, "t,type", "type", &type, "default",
+ "type to convert all nrrd inputs to, prior to "
+ "doing operation. This also determines output type. "
+ "By default (not using this option), the types of the input "
+ "nrrds are left unchanged.",
+ &unrrduHestMaybeTypeCB);
+ hestOptAdd_1_Int(&opt, "w,which", "arg", &which, "-1",
+ "Which argument (0, 1, or 2) should be used to determine the "
+ "shape of the output nrrd. By default (not using this option), "
+ "the first non-constant argument is used. ");
OPT_ADD_NOUT(out, "output nrrd");
mop = airMopNew();
Modified: teem/trunk/src/unrrdu/crop.c
===================================================================
--- teem/trunk/src/unrrdu/crop.c 2023-07-11 22:15:46 UTC (rev 7077)
+++ teem/trunk/src/unrrdu/crop.c 2023-07-11 23:58:18 UTC (rev 7078)
@@ -31,8 +31,8 @@
hestOpt *opt = NULL;
char *out, *err;
Nrrd *nin, *nout;
- unsigned int ai;
- int minLen, maxLen, pret;
+ unsigned int ai, minLen, maxLen;
+ int pret;
long int *minOff, *maxOff;
size_t min[NRRD_DIM_MAX], max[NRRD_DIM_MAX];
airArray *mop;
@@ -50,14 +50,14 @@
"there's also:\n "
"\b\bo m+<int> give index relative to minimum.",
maxLen);
- hestOptAdd(&opt, "b,bounds", "filename", airTypeOther, 1, 1, &_nbounds, "",
- "a filename given here overrides the -min and -max "
- "options (they don't need to be used) and provides the "
- "cropping bounds as a 2-D array; first scanline is for "
- "-min, second is for -max. Unfortunately the "
- "\"m\" and \"M\" semantics (above) are currently not "
- "supported in the bounds file.",
- NULL, NULL, nrrdHestNrrd);
+ hestOptAdd_1_Other(&opt, "b,bounds", "filename", &_nbounds, "",
+ "a filename given here overrides the -min and -max "
+ "options (they don't need to be used) and provides the "
+ "cropping bounds as a 2-D array; first scanline is for "
+ "-min, second is for -max. Unfortunately the "
+ "\"m\" and \"M\" semantics (above) are currently not "
+ "supported in the bounds file.",
+ nrrdHestNrrd);
OPT_ADD_NIN(nin, "input nrrd");
OPT_ADD_NOUT(out, "output nrrd");
@@ -68,8 +68,8 @@
airMopAdd(mop, opt, (airMopper)hestParseFree, airMopAlways);
if (!_nbounds) {
- if (!(minLen == (int)nin->dim && maxLen == (int)nin->dim)) {
- fprintf(stderr, "%s: # min coords (%d) or max coords (%d) != nrrd dim (%d)\n", me,
+ if (!(minLen == nin->dim && maxLen == nin->dim)) {
+ fprintf(stderr, "%s: # min coords (%u) or max coords (%u) != nrrd dim (%u)\n", me,
minLen, maxLen, nin->dim);
airMopError(mop);
return 1;
@@ -76,7 +76,7 @@
}
for (ai = 0; ai < nin->dim; ai++) {
if (-1 == minOff[0 + 2 * ai]) {
- fprintf(stderr, "%s: can't use m+<int> specification for axis %d min\n", me, ai);
+ fprintf(stderr, "%s: can't use m+<int> specification for axis %u min\n", me, ai);
airMopError(mop);
return 1;
}
Modified: teem/trunk/src/unrrdu/make.c
===================================================================
--- teem/trunk/src/unrrdu/make.c 2023-07-11 22:15:46 UTC (rev 7077)
+++ teem/trunk/src/unrrdu/make.c 2023-07-11 23:58:18 UTC (rev 7078)
@@ -69,12 +69,12 @@
encInfo[AIR_STRLEN_LARGE + 1];
Nrrd *nrrd;
size_t *size, bufLen;
- int headerOnly, pret, lineSkip, endian, type, encodingType, gotSpacing, gotThickness,
- gotMin, gotMax, space, spaceSet;
- long int byteSkip;
+ int headerOnly, pret, endian, type, encodingType, gotSpacing, gotThickness, gotMin,
+ gotMax, space, spaceSet;
+ long int byteSkip; /* NOT unsigned: -1 means "from the end" */
unsigned int ii, kindsLen, thicknessLen, spacingLen, sizeLen, nameLen, centeringsLen,
unitsLen, labelLen, kvpLen, spunitsLen, dataFileDim, spaceDim, minLen, maxLen,
- thicknessIdx, spacingIdx, minIdx, maxIdx;
+ thicknessIdx, spacingIdx, minIdx, maxIdx, lineSkip;
double *spacing, *axmin, *axmax, *thickness;
airArray *mop;
NrrdIoState *nio;
@@ -89,81 +89,80 @@
mop = airMopNew();
- hestOptAdd(&opt, "h", NULL, airTypeBool, 0, 0, &headerOnly, NULL,
- "Generate header ONLY: don't write out the whole nrrd, "
- "don't even bother reading the input data, just output the "
- "detached nrrd header file (usually with a \".nhdr\" "
- "extension) determined by the options below. The single "
- "constraint is that detached headers are incompatible with "
- "using stdin as the data source.");
- hestOptAdd(&opt, "i,input", "file", airTypeString, 1, -1, &dataFileNames, "-",
- "Filename(s) of data file(s); use \"-\" for stdin. *OR*, can "
- "use sprintf-style format for identifying a range of numbered "
- "files, see above for details.",
- &nameLen);
- hestOptAdd(&opt, "t,type", "type", airTypeEnum, 1, 1, &type, NULL,
- "type of data (e.g. \"uchar\", \"int\", \"float\", "
- "\"double\", etc.)",
- NULL, nrrdType);
- hestOptAdd(&opt, "s,size", "sz0 sz1", airTypeSize_t, 1, -1, &size, NULL,
- "number of samples along each axis (and implicit indicator "
- "of dimension of nrrd)",
- &sizeLen);
- hestOptAdd(&opt, "fd,filedim", "dim", airTypeUInt, 1, 1, &dataFileDim, "0",
- "When using *multiple* input data files (to \"-i\"), what is "
- "the dimension of the array data in each individual file. By "
- "default (not using this option), this dimension is assumed "
- "to be one less than the whole data dimension. ");
- spacingIdx
- = hestOptAdd(&opt, "sp,spacing", "sp0 sp1", airTypeDouble, 1, -1, &spacing, "nan",
- "spacing between samples on each axis. Use \"nan\" for "
- "any non-spatial axes (e.g. spacing between red, green, and blue "
- "along axis 0 of interleaved RGB image data)",
- &spacingLen);
+ hestOptAdd_Flag(&opt, "h", &headerOnly,
+ "Generate header ONLY: don't write out the whole nrrd, "
+ "don't even bother reading the input data, just output the "
+ "detached nrrd header file (usually with a \".nhdr\" "
+ "extension) determined by the options below. The single "
+ "constraint is that detached headers are incompatible with "
+ "using stdin as the data source.");
+ hestOptAdd_Nv_String(&opt, "i,input", "file", 1, -1, &dataFileNames, "-",
+ "Filename(s) of data file(s); use \"-\" for stdin. *OR*, can "
+ "use sprintf-style format for identifying a range of numbered "
+ "files, see above for details.",
+ &nameLen);
+ hestOptAdd_1_Enum(&opt, "t,type", "type", &type, NULL,
+ "type of data (e.g. \"uchar\", \"int\", \"float\", "
+ "\"double\", etc.)",
+ nrrdType);
+ hestOptAdd_Nv_Size_t(&opt, "s,size", "sz0 sz1", 1, -1, &size, NULL,
+ "number of samples along each axis (and implicit indicator "
+ "of dimension of nrrd)",
+ &sizeLen);
+ hestOptAdd_1_UInt(&opt, "fd,filedim", "dim", &dataFileDim, "0",
+ "When using *multiple* input data files (to \"-i\"), what is "
+ "the dimension of the array data in each individual file. By "
+ "default (not using this option), this dimension is assumed "
+ "to be one less than the whole data dimension. ");
+ spacingIdx = hestOptAdd_Nv_Double(
+ &opt, "sp,spacing", "sp0 sp1", 1, -1, &spacing, "nan",
+ "spacing between samples on each axis. Use \"nan\" for "
+ "any non-spatial axes (e.g. spacing between red, green, and blue "
+ "along axis 0 of interleaved RGB image data)",
+ &spacingLen);
/* NB: these are like unu jhisto's -min -max, not like unu crop's */
- minIdx = hestOptAdd(&opt, "min,axismin", "min0 min1", airTypeDouble, 1, -1, &axmin,
- "nan",
- "When each axis has a distinct meaning (as in a joint "
- "histogram), the per-axis min is the smallest \"position\" "
- "associated with the first sample on the axis. Use \"nan\" for "
- "\"no value to set\" when other axes do have axis min",
- &minLen);
- maxIdx = hestOptAdd(&opt, "max,axismax", "max0 max1", airTypeDouble, 1, -1, &axmax,
- "nan",
- "Goes with -min: the per-axis maximum \"position\". "
- "-max and -min should probably be used together, and having "
- "this information logically supersedes the -sp spacing on those "
- "axes.",
- &maxLen);
- thicknessIdx
- = hestOptAdd(&opt, "th,thickness", "th0 th1", airTypeDouble, 1, -1, &thickness,
- "nan",
- "thickness of region represented by one sample along each axis. "
- " As with -sp spacing, use \"nan\" for "
- "any non-spatial axes.",
- &thicknessLen);
- hestOptAdd(&opt, "k,kind", "k0 k1", airTypeString, 1, -1, &kinds, "",
- "what \"kind\" is each axis, from the nrrdKind airEnum "
- "(e.g. space, time, 3-vector, 3D-masked-symmetric-matrix, "
- "or \"none\" to signify no kind)",
- &kindsLen);
- hestOptAdd(&opt, "cn,centering", "c0 c1", airTypeString, 1, -1, ¢erings, "",
- "kind of centering (node or cell) for each axis, or "
- "\"none\" to signify no centering",
- ¢eringsLen);
- hestOptAdd(&opt, "l,label", "lb0 lb1", airTypeString, 1, -1, &label, "",
- "short string labels for each of the axes", &labelLen);
- hestOptAdd(&opt, "u,unit", "un0 un1", airTypeString, 1, -1, &units, "",
- "short strings giving units for each of the axes", &unitsLen);
- hestOptAdd(&opt, "c,content", "content", airTypeString, 1, 1, &content, "",
- "Specifies the content string of the nrrd, which is built upon "
- "by many nrrd function to record a history of operations");
- hestOptAdd(&opt, "ls,lineskip", "num", airTypeInt, 1, 1, &lineSkip, "0",
- "number of ascii lines to skip before reading data");
- hestOptAdd(&opt, "bs,byteskip", "num", airTypeLongInt, 1, 1, &byteSkip, "0",
- "number of bytes to skip (after skipping ascii lines, if any) "
- "before reading data. Can use \"-bs -1\" to skip a binary "
- "header of unknown length in raw-encoded data");
+ minIdx = hestOptAdd_Nv_Double(
+ &opt, "min,axismin", "min0 min1", 1, -1, &axmin, "nan",
+ "When each axis has a distinct meaning (as in a joint "
+ "histogram), the per-axis min is the smallest \"position\" "
+ "associated with the first sample on the axis. Use \"nan\" for "
+ "\"no value to set\" when other axes do have axis min",
+ &minLen);
+ maxIdx = hestOptAdd_Nv_Double(
+ &opt, "max,axismax", "max0 max1", 1, -1, &axmax, "nan",
+ "Goes with -min: the per-axis maximum \"position\". "
+ "-max and -min should probably be used together, and having "
+ "this information logically supersedes the -sp spacing on those "
+ "axes.",
+ &maxLen);
+ thicknessIdx = hestOptAdd_Nv_Double(
+ &opt, "th,thickness", "th0 th1", 1, -1, &thickness, "nan",
+ "thickness of region represented by one sample along each axis. "
+ " As with -sp spacing, use \"nan\" for "
+ "any non-spatial axes.",
+ &thicknessLen);
+ hestOptAdd_Nv_String(&opt, "k,kind", "k0 k1", 1, -1, &kinds, "",
+ "what \"kind\" is each axis, from the nrrdKind airEnum "
+ "(e.g. space, time, 3-vector, 3D-masked-symmetric-matrix, "
+ "or \"none\" to signify no kind)",
+ &kindsLen);
+ hestOptAdd_Nv_String(&opt, "cn,centering", "c0 c1", 1, -1, ¢erings, "",
+ "kind of centering (node or cell) for each axis, or "
+ "\"none\" to signify no centering",
+ ¢eringsLen);
+ hestOptAdd_Nv_String(&opt, "l,label", "lb0 lb1", 1, -1, &label, "",
+ "short string labels for each of the axes", &labelLen);
+ hestOptAdd_Nv_String(&opt, "u,unit", "un0 un1", 1, -1, &units, "",
+ "short strings giving units for each of the axes", &unitsLen);
+ hestOptAdd_1_String(&opt, "c,content", "content", &content, "",
+ "Specifies the content string of the nrrd, which is built upon "
+ "by many nrrd function to record a history of operations");
+ hestOptAdd_1_UInt(&opt, "ls,lineskip", "num", &lineSkip, "0",
+ "number of ascii lines to skip before reading data");
+ hestOptAdd_1_LongInt(&opt, "bs,byteskip", "num", &byteSkip, "0",
+ "number of bytes to skip (after skipping ascii lines, if any) "
+ "before reading data. Can use \"-bs -1\" to skip a binary "
+ "header of unknown length in raw-encoded data");
strcpy(encInfo,
"encoding of input data. Possibilities include:"
"\n \b\bo \"raw\": raw encoding"
@@ -176,71 +175,70 @@
if (nrrdEncodingBzip2->available()) {
strcat(encInfo, "\n \b\bo \"bzip2\", \"bz2\": bzip2 compressed raw data");
}
- hestOptAdd(&opt, "e,encoding", "enc", airTypeEnum, 1, 1, &encodingType, "raw", encInfo,
- NULL, nrrdEncodingType);
- hestOptAdd(&opt, "en,endian", "end", airTypeEnum, 1, 1, &endian,
- airEnumStr(airEndian, airMyEndian()),
- "Endianness of data; relevent for any data with value "
- "representation bigger than 8 bits, with a non-ascii encoding: "
- "\"little\" for Intel and friends "
- "(least significant byte first, at lower address); "
- "\"big\" for everyone else (most significant byte first). "
- "Defaults to endianness of this machine",
- NULL, airEndian);
- hestOptAdd(&opt, "kv,keyvalue", "key/val", airTypeString, 1, -1, &kvp, "",
- "key/value string pairs to be stored in nrrd. Each key/value "
- "pair must be a single string (put it in \"\"s "
- "if the key or the value contain spaces). The format of each "
- "pair is \"<key>:=<value>\", with no spaces before or after "
- "\":=\".",
- &kvpLen);
- hestOptAdd(&opt, "spc,space", "space", airTypeString, 1, 1, &spcStr, "",
- "identify the space (e.g. \"RAS\", \"LPS\") in which the array "
- "conceptually lives, from the nrrdSpace airEnum, which in turn "
- "determines the dimension of the space. Or, use an integer>0 to"
- "give the dimension of a space that nrrdSpace doesn't know "
- "about. "
- "By default (not using this option), the enclosing space is "
- "set as unknown.");
- hestOptAdd(&opt, "orig,origin", "origin", airTypeString, 1, 1, &_origStr, "",
- "(NOTE: must quote vector) the origin in space of the array: "
- "the location of the center "
- "of the first sample, of the form \"(x,y,z)\" (or however "
- "many coefficients are needed for the chosen space). Quoting the "
- "vector is needed to stop interpretation from the shell");
- hestOptAdd(&opt, "dirs,directions", "v0 v1 ...", airTypeString, 1, 1, &_dirStr, "",
- "(NOTE: must quote whole vector list) The \"space directions\": "
- "the vectors in space spanned by incrementing (by one) each "
- "axis index (the column vectors of the index-to-world "
- "matrix transform), OR, \"none\" for non-spatial axes. Give "
- "one vector per axis. Using a space direction logically "
- "supersedes both per-axis -sp spacing and -min,-max. "
- "(Quoting around whole vector list, not "
- "individually, is needed because of limitations in the parser)");
- hestOptAdd(&opt, "mf,measurementframe", "v0 v1 ...", airTypeString, 1, 1, &_mframeStr,
- "",
- "(NOTE: must quote whole vector list). Each vector is a *column* "
- "vector of the matrix which transforms from coordinates in "
- "measurement frame (in which the coefficients of vectors and "
- "tensors are given) to coordinates of world space (given with "
- "\"-spc\"). This is not a per-axis field: the column vectors "
- "comprise a D-by-D square matrix, where D is the dimension of "
- "world space.");
- hestOptAdd(&opt, "spu,spaceunit", "su0 su1", airTypeString, 1, -1, &spunits, "",
- "short strings giving units with which the coefficients of the "
- "space origin and direction vectors are measured.",
- &spunitsLen);
- hestOptAdd(&opt, "o,output", "nout", airTypeString, 1, 1, &out, "-",
- "output filename. If \"-h\" has been used, the output file is "
- "always a detached header. Otherwise, use extension "
- "\".nrrd\" to signal creation of self-contained nrrd, and "
- "\".nhdr\" to signal creating of a detached header with "
- "(single) data file.");
- hestOptAdd(&opt, "od,outputdata", "name", airTypeString, 1, 1, &outData, "",
- "when *not* using \"-h\" and saving to a \".nhdr\" file, using "
- "this option allows you to explicitly name the data file, "
- "instead of (by default, not using this option) having it be "
- "the same filename base as the header file.");
+ hestOptAdd_1_Enum(&opt, "e,encoding", "enc", &encodingType, "raw", encInfo,
+ nrrdEncodingType);
+ hestOptAdd_1_Enum(&opt, "en,endian", "end", &endian,
+ airEnumStr(airEndian, airMyEndian()),
+ "Endianness of data; relevent for any data with value "
+ "representation bigger than 8 bits, with a non-ascii encoding: "
+ "\"little\" for Intel and friends "
+ "(least significant byte first, at lower address); "
+ "\"big\" for everyone else (most significant byte first). "
+ "Defaults to endianness of this machine",
+ airEndian);
+ hestOptAdd_Nv_String(&opt, "kv,keyvalue", "key/val", 1, -1, &kvp, "",
+ "key/value string pairs to be stored in nrrd. Each key/value "
+ "pair must be a single string (put it in \"\"s "
+ "if the key or the value contain spaces). The format of each "
+ "pair is \"<key>:=<value>\", with no spaces before or after "
+ "\":=\".",
+ &kvpLen);
+ hestOptAdd_1_String(&opt, "spc,space", "space", &spcStr, "",
+ "identify the space (e.g. \"RAS\", \"LPS\") in which the array "
+ "conceptually lives, from the nrrdSpace airEnum, which in turn "
+ "determines the dimension of the space. Or, use an integer>0 to"
+ "give the dimension of a space that nrrdSpace doesn't know "
+ "about. "
+ "By default (not using this option), the enclosing space is "
+ "set as unknown.");
+ hestOptAdd_1_String(&opt, "orig,origin", "origin", &_origStr, "",
+ "(NOTE: must quote vector) the origin in space of the array: "
+ "the location of the center "
+ "of the first sample, of the form \"(x,y,z)\" (or however "
+ "many coefficients are needed for the chosen space). Quoting the "
+ "vector is needed to stop interpretation from the shell");
+ hestOptAdd_1_String(&opt, "dirs,directions", "v0 v1 ...", &_dirStr, "",
+ "(NOTE: must quote whole vector list) The \"space directions\": "
+ "the vectors in space spanned by incrementing (by one) each "
+ "axis index (the column vectors of the index-to-world "
+ "matrix transform), OR, \"none\" for non-spatial axes. Give "
+ "one vector per axis. Using a space direction logically "
+ "supersedes both per-axis -sp spacing and -min,-max. "
+ "(Quoting around whole vector list, not "
+ "individually, prevents the shell from interpreting parentheses)");
+ hestOptAdd_1_String(&opt, "mf,measurementframe", "v0 v1 ...", &_mframeStr, "",
+ "(NOTE: must quote whole vector list). Each vector is a *column* "
+ "vector of the matrix which transforms from coordinates in "
+ "measurement frame (in which the coefficients of vectors and "
+ "tensors are given) to coordinates of world space (given with "
+ "\"-spc\"). This is not a per-axis field: the column vectors "
+ "comprise a D-by-D square matrix, where D is the dimension of "
+ "world space.");
+ hestOptAdd_Nv_String(&opt, "spu,spaceunit", "su0 su1", 1, -1, &spunits, "",
+ "short strings giving units with which the coefficients of the "
+ "space origin and direction vectors are measured.",
+ &spunitsLen);
+ hestOptAdd_1_String(&opt, "o,output", "nout", &out, "-",
+ "output filename. If \"-h\" has been used, the output file is "
+ "always a detached header. Otherwise, use extension "
+ "\".nrrd\" to signal creation of self-contained nrrd, and "
+ "\".nhdr\" to signal creating of a detached header with "
+ "(single) data file.");
+ hestOptAdd_1_String(&opt, "od,outputdata", "name", &outData, "",
+ "when *not* using \"-h\" and saving to a \".nhdr\" file, using "
+ "this option allows you to explicitly name the data file, "
+ "instead of (by default, not using this option) having it be "
+ "the same filename base as the header file.");
airMopAdd(mop, opt, hestOptFree_vp, airMopAlways);
airStrtokQuoting = AIR_TRUE;
Modified: teem/trunk/src/unrrdu/minmax.c
===================================================================
--- teem/trunk/src/unrrdu/minmax.c 2023-07-11 22:15:46 UTC (rev 7077)
+++ teem/trunk/src/unrrdu/minmax.c 2023-07-11 23:58:18 UTC (rev 7078)
@@ -85,25 +85,25 @@
#define B8DEF "false"
mop = airMopNew();
- hestOptAdd(&opt, "blind8", "bool", airTypeBool, 1, 1, &blind8BitRange,
- B8DEF, /* NOTE: not using nrrdStateBlind8BitRange here
- for consistency with previous behavior */
- "whether to blindly assert the range of 8-bit data, "
- "without actually going through the data values, i.e. "
- "uchar is always [0,255], signed char is [-128,127]. "
- "Note that even if you do not use this option, the default "
- "(" B8DEF ") is potentialy over-riding the effect of "
- "environment variable NRRD_STATE_BLIND_8_BIT_RANGE; "
- "see \"unu env\"");
- hestOptAdd(&opt, "sl", NULL, airTypeInt, 0, 0, &singleLine, NULL,
- "Without this option, output is on multiple lines (for min, for max, "
- "and then maybe more lines about non-existent values or min, max "
- "conditions). With \"-sl\", output is a single line containing just min "
- "and max, possibly followed by the single word \"non-existent\" if and "
- "only if there were non-existent values. If there are multiple inputs, "
- "the input filename is printed first on the per-input single line.");
- hestOptAdd(&opt, NULL, "nin1", airTypeString, 1, -1, &inS, NULL, "input nrrd(s)",
- &ninLen);
+ hestOptAdd_1_Bool(&opt, "blind8", "bool", &blind8BitRange,
+ B8DEF, /* NOTE: not using nrrdStateBlind8BitRange here
+ for consistency with previous behavior */
+ "whether to blindly assert the range of 8-bit data, "
+ "without actually going through the data values, i.e. "
+ "uchar is always [0,255], signed char is [-128,127]. "
+ "Note that even if you do not use this option, the default "
+ "(" B8DEF ") is potentialy over-riding the effect of "
+ "environment variable NRRD_STATE_BLIND_8_BIT_RANGE; "
+ "see \"unu env\"");
+ hestOptAdd_Flag(
+ &opt, "sl", &singleLine,
+ "Without this option, output is on multiple lines (for min, for max, "
+ "and then maybe more lines about non-existent values or min, max "
+ "conditions). With \"-sl\", output is a single line containing just min "
+ "and max, possibly followed by the single word \"non-existent\" if and "
+ "only if there were non-existent values. If there are multiple inputs, "
+ "the input filename is printed first on the per-input single line.");
+ hestOptAdd_Nv_String(&opt, NULL, "nin1", 1, -1, &inS, NULL, "input nrrd(s)", &ninLen);
airMopAdd(mop, opt, hestOptFree_vp, airMopAlways);
USAGE_OR_PARSE(_unrrdu_minmaxInfoL);
Modified: teem/trunk/src/unrrdu/mlut.c
===================================================================
--- teem/trunk/src/unrrdu/mlut.c 2023-07-11 22:15:46 UTC (rev 7077)
+++ teem/trunk/src/unrrdu/mlut.c 2023-07-11 23:58:18 UTC (rev 7078)
@@ -42,36 +42,36 @@
double min, max;
NrrdRange *range = NULL;
- hestOptAdd(&opt, "m,map", "mlut", airTypeOther, 1, -1, &_nmlut, NULL,
- "one nrrd of lookup tables to map input nrrd through, or, "
- "list of nrrds which contain the individual entries of "
- "the lookup table at each voxel, which will be joined together.",
- &_nmlutLen, NULL, nrrdHestNrrd);
- hestOptAdd(&opt, "r,rescale", NULL, airTypeInt, 0, 0, &rescale, NULL,
- "rescale the input values from the input range to the "
- "lut domain. The lut domain is either explicitly "
- "defined by the axis min,max along axis 0 or 1, or, it "
- "is implicitly defined as zero to the length of that axis "
- "minus one.");
- hestOptAdd(&opt, "min,minimum", "value", airTypeDouble, 1, 1, &min, "nan",
- "Low end of input range. Defaults to lowest value "
- "found in input nrrd. Explicitly setting this is useful "
- "only with rescaling (\"-r\")");
- hestOptAdd(&opt, "max,maximum", "value", airTypeDouble, 1, 1, &max, "nan",
- "High end of input range. Defaults to highest value "
- "found in input nrrd. Explicitly setting this is useful "
- "only with rescaling (\"-r\")");
- hestOptAdd(&opt, "blind8", "bool", airTypeBool, 1, 1, &blind8BitRange,
- nrrdStateBlind8BitRange ? "true" : "false",
- "Whether to know the range of 8-bit data blindly "
- "(uchar is always [0,255], signed char is [-128,127]). "
- "Explicitly setting this is useful only with rescaling (\"-r\")");
- hestOptAdd(&opt, "t,type", "type", airTypeOther, 1, 1, &typeOut, "default",
- "specify the type (\"int\", \"float\", etc.) of the "
- "output nrrd. "
- "By default (not using this option), the output type "
- "is the lut's type.",
- NULL, NULL, &unrrduHestMaybeTypeCB);
+ hestOptAdd_Nv_Other(&opt, "m,map", "mlut", 1, -1, &_nmlut, NULL,
+ "one nrrd of lookup tables to map input nrrd through, or, "
+ "list of nrrds which contain the individual entries of "
+ "the lookup table at each voxel, which will be joined together.",
+ &_nmlutLen, nrrdHestNrrd);
+ hestOptAdd_Flag(&opt, "r,rescale", &rescale,
+ "rescale the input values from the input range to the "
+ "lut domain. The lut domain is either explicitly "
+ "defined by the axis min,max along axis 0 or 1, or, it "
+ "is implicitly defined as zero to the length of that axis "
+ "minus one.");
+ hestOptAdd_1_Double(&opt, "min,minimum", "value", &min, "nan",
+ "Low end of input range. Defaults to lowest value "
+ "found in input nrrd. Explicitly setting this is useful "
+ "only with rescaling (\"-r\")");
+ hestOptAdd_1_Double(&opt, "max,maximum", "value", &max, "nan",
+ "High end of input range. Defaults to highest value "
+ "found in input nrrd. Explicitly setting this is useful "
+ "only with rescaling (\"-r\")");
+ hestOptAdd_1_Bool(&opt, "blind8", "bool", &blind8BitRange,
+ nrrdStateBlind8BitRange ? "true" : "false",
+ "Whether to know the range of 8-bit data blindly "
+ "(uchar is always [0,255], signed char is [-128,127]). "
+ "Explicitly setting this is useful only with rescaling (\"-r\")");
+ hestOptAdd_1_Other(&opt, "t,type", "type", &typeOut, "default",
+ "specify the type (\"int\", \"float\", etc.) of the "
+ "output nrrd. "
+ "By default (not using this option), the output type "
+ "is the lut's type.",
+ &unrrduHestMaybeTypeCB);
OPT_ADD_NIN(nin, "input nrrd");
OPT_ADD_NOUT(out, "output nrrd");
Modified: teem/trunk/src/unrrdu/mrmap.c
===================================================================
--- teem/trunk/src/unrrdu/mrmap.c 2023-07-11 22:15:46 UTC (rev 7077)
+++ teem/trunk/src/unrrdu/mrmap.c 2023-07-11 23:58:18 UTC (rev 7078)
@@ -42,40 +42,40 @@
unsigned int _nmmapLen;
double min, max;
- hestOptAdd(&opt, "m,map", "mmap", airTypeOther, 1, -1, &_nmmap, NULL,
- "one nrrd of regular maps to map input nrrd through, or, "
- "list of nrrds which contain the individual entries of the map "
- "at each voxel, which will be joined together.",
- &_nmmapLen, NULL, nrrdHestNrrd);
- hestOptAdd(&opt, "r,rescale", NULL, airTypeInt, 0, 0, &rescale, NULL,
- "rescale the input values from the input range to the "
- "map domain. The map domain is either explicitly "
- "defined by the axis min,max along axis 0 or 1, or, it "
- "is implicitly defined as zero to one minus the length of "
- "that axis.");
- hestOptAdd(&opt, "min,minimum", "value", airTypeDouble, 1, 1, &min, "nan",
- "Low end of input range. Defaults to lowest value "
- "found in input nrrd. Explicitly setting this is useful "
- "only with rescaling (\"-r\") or if the map domain is only "
- "implicitly defined");
- hestOptAdd(&opt, "max,maximum", "value", airTypeDouble, 1, 1, &max, "nan",
- "High end of input range. Defaults to highest value "
- "found in input nrrd. Explicitly setting this is useful "
- "only with rescaling (\"-r\") or if the map domain is only "
- "implicitly defined");
- hestOptAdd(&opt, "blind8", "bool", airTypeBool, 1, 1, &blind8BitRange,
- nrrdStateBlind8BitRange ? "true" : "false",
- "Whether to know the range of 8-bit data blindly "
- "(uchar is always [0,255], signed char is [-128,127]). "
- "Explicitly setting this is useful "
- "only with rescaling (\"-r\") or if the map domain is only "
- "implicitly defined");
- hestOptAdd(&opt, "t,type", "type", airTypeOther, 1, 1, &typeOut, "default",
- "specify the type (\"int\", \"float\", etc.) of the "
- "output nrrd. "
- "By default (not using this option), the output type "
- "is the map's type.",
- NULL, NULL, &unrrduHestMaybeTypeCB);
+ hestOptAdd_Nv_Other(&opt, "m,map", "mmap", 1, -1, &_nmmap, NULL,
+ "one nrrd of regular maps to map input nrrd through, or, "
+ "list of nrrds which contain the individual entries of the map "
+ "at each voxel, which will be joined together.",
+ &_nmmapLen, nrrdHestNrrd);
+ hestOptAdd_Flag(&opt, "r,rescale", &rescale,
+ "rescale the input values from the input range to the "
+ "map domain. The map domain is either explicitly "
+ "defined by the axis min,max along axis 0 or 1, or, it "
+ "is implicitly defined as zero to one minus the length of "
+ "that axis.");
+ hestOptAdd_1_Double(&opt, "min,minimum", "value", &min, "nan",
+ "Low end of input range. Defaults to lowest value "
+ "found in input nrrd. Explicitly setting this is useful "
+ "only with rescaling (\"-r\") or if the map domain is only "
+ "implicitly defined");
+ hestOptAdd_1_Double(&opt, "max,maximum", "value", &max, "nan",
+ "High end of input range. Defaults to highest value "
+ "found in input nrrd. Explicitly setting this is useful "
+ "only with rescaling (\"-r\") or if the map domain is only "
+ "implicitly defined");
+ hestOptAdd_1_Bool(&opt, "blind8", "bool", &blind8BitRange,
+ nrrdStateBlind8BitRange ? "true" : "false",
+ "Whether to know the range of 8-bit data blindly "
+ "(uchar is always [0,255], signed char is [-128,127]). "
+ "Explicitly setting this is useful "
+ "only with rescaling (\"-r\") or if the map domain is only "
+ "implicitly defined");
+ hestOptAdd_1_Other(&opt, "t,type", "type", &typeOut, "default",
+ "specify the type (\"int\", \"float\", etc.) of the "
+ "output nrrd. "
+ "By default (not using this option), the output type "
+ "is the map's type.",
+ &unrrduHestMaybeTypeCB);
OPT_ADD_NIN(nin, "input nrrd");
OPT_ADD_NOUT(out, "output nrrd");
Modified: teem/trunk/src/unrrdu/ninspect.c
===================================================================
--- teem/trunk/src/unrrdu/ninspect.c 2023-07-11 22:15:46 UTC (rev 7077)
+++ teem/trunk/src/unrrdu/ninspect.c 2023-07-11 23:58:18 UTC (rev 7078)
@@ -341,18 +341,18 @@
mop = airMopNew();
- hestOptAdd(&opt, "i", "nin", airTypeOther, 1, 1, &nin, NULL,
- "input nrrd to project. Must be three dimensional.", NULL, NULL,
- nrrdHestNrrd);
- hestOptAdd(&opt, "amt", "heq", airTypeFloat, 1, 1, &heqamount, "0.5",
- "how much to apply histogram equalization to projection images");
- hestOptAdd(&opt, "m", "margin", airTypeUInt, 1, 1, &margin, "6",
- "pixel size of margin on boundary, and space between the projections");
- hestOptAdd(&opt, "b", "background", airTypeUInt, 3, 3, back, "0 0 0",
- "background color (8-bit RGB)");
- hestOptAdd(&opt, "o", "img out", airTypeString, 1, 1, &outS, NULL,
- "output image to save to. Will try to use whatever "
- "format is implied by extension, but will fall back to PPM.");
+ hestOptAdd_1_Other(&opt, "i", "nin", &nin, NULL,
+ "input nrrd to project. Must be three dimensional.", nrrdHestNrrd);
+ hestOptAdd_1_Float(&opt, "amt", "heq", &heqamount, "0.5",
+ "how much to apply histogram equalization to projection images");
+ hestOptAdd_1_UInt(
+ &opt, "m", "margin", &margin, "6",
+ "pixel size of margin on boundary, and space between the projections");
+ hestOptAdd_3_UInt(&opt, "b", "background", back, "0 0 0",
+ "background color (8-bit RGB)");
+ hestOptAdd_1_String(&opt, "o", "img out", &outS, NULL,
+ "output image to save to. Will try to use whatever "
+ "format is implied by extension, but will fall back to PPM.");
USAGE_OR_PARSE(_unrrdu_infoL);
airMopAdd(mop, opt, (airMopper)hestParseFree, airMopAlways);
Modified: teem/trunk/src/unrrdu/pad.c
===================================================================
--- teem/trunk/src/unrrdu/pad.c 2023-07-11 22:15:46 UTC (rev 7077)
+++ teem/trunk/src/unrrdu/pad.c 2023-07-11 23:58:18 UTC (rev 7078)
@@ -31,8 +31,8 @@
hestOpt *opt = NULL;
char *out, *err;
Nrrd *nin, *nout;
- unsigned int ai;
- int minLen, maxLen, bb, pret;
+ unsigned int minLen, maxLen, ai;
+ int bb, pret;
long int *minOff, *maxOff;
ptrdiff_t min[NRRD_DIM_MAX], max[NRRD_DIM_MAX];
double padVal;
@@ -50,15 +50,15 @@
"there's also:\n "
"\b\bo m+<int> give index relative to minimum.",
maxLen);
- hestOptAdd(&opt, "b,boundary", "behavior", airTypeEnum, 1, 1, &bb, "bleed",
- "How to handle samples beyond the input bounds:\n "
- "\b\bo \"pad\": use some specified value\n "
- "\b\bo \"bleed\": extend border values outward\n "
- "\b\bo \"mirror\": repeated reflections\n "
- "\b\bo \"wrap\": wrap-around to other side",
- NULL, nrrdBoundary);
- hestOptAdd(&opt, "v,value", "val", airTypeDouble, 1, 1, &padVal, "0.0",
- "for \"pad\" boundary behavior, pad with this value");
+ hestOptAdd_1_Enum(&opt, "b,boundary", "behavior", &bb, "bleed",
+ "How to handle samples beyond the input bounds:\n "
+ "\b\bo \"pad\": use some specified value\n "
+ "\b\bo \"bleed\": extend border values outward\n "
+ "\b\bo \"mirror\": repeated reflections\n "
+ "\b\bo \"wrap\": wrap-around to other side",
+ nrrdBoundary);
+ hestOptAdd_1_Double(&opt, "v,value", "val", &padVal, "0.0",
+ "for \"pad\" boundary behavior, pad with this value");
OPT_ADD_NIN(nin, "input nrrd");
OPT_ADD_NOUT(out, "output nrrd");
@@ -68,8 +68,8 @@
USAGE_OR_PARSE(_unrrdu_padInfoL);
airMopAdd(mop, opt, (airMopper)hestParseFree, airMopAlways);
- if (!(minLen == (int)nin->dim && maxLen == (int)nin->dim)) {
- fprintf(stderr, "%s: # min coords (%d) or max coords (%d) != nrrd dim (%d)\n", me,
+ if (!(minLen == nin->dim && maxLen == nin->dim)) {
+ fprintf(stderr, "%s: # min coords (%u) or max coords (%u) != nrrd dim (%u)\n", me,
minLen, maxLen, nin->dim);
airMopError(mop);
return 1;
@@ -76,7 +76,7 @@
}
for (ai = 0; ai < nin->dim; ai++) {
if (-1 == minOff[0 + 2 * ai]) {
- fprintf(stderr, "%s: can't use m+<int> specification for axis %d min\n", me, ai);
+ fprintf(stderr, "%s: can't use m+<int> specification for axis %u min\n", me, ai);
airMopError(mop);
return 1;
}
Modified: teem/trunk/src/unrrdu/permute.c
===================================================================
-...
[truncated message content] |
|
From: <kin...@us...> - 2023-07-11 22:15:48
|
Revision: 7077
http://sourceforge.net/p/teem/code/7077
Author: kindlmann
Date: 2023-07-11 22:15:46 +0000 (Tue, 11 Jul 2023)
Log Message:
-----------
weird biffMsg-related functions have already been removed from biff.h (as of 2022-08-04 22:09:25 +0000 (Thu, 04 Aug 2022) Revision: 6691)
Modified Paths:
--------------
teem/trunk/src/TODO.txt
Modified: teem/trunk/src/TODO.txt
===================================================================
--- teem/trunk/src/TODO.txt 2023-07-11 22:12:47 UTC (rev 7076)
+++ teem/trunk/src/TODO.txt 2023-07-11 22:15:46 UTC (rev 7077)
@@ -109,7 +109,6 @@
so that it matches biffMovef
* rename biffCheck --> biffErrNum
* consider biffGetStrlen --> biffStrlenGet, biffSetStr --> biffStrSet
-******* a few biff functions are never used in Teem, is that ok?
nrrd:
* allow the API for median filtering to be more flexible about boundaries
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <kin...@us...> - 2023-07-11 22:12:51
|
Revision: 7076
http://sourceforge.net/p/teem/code/7076
Author: kindlmann
Date: 2023-07-11 22:12:47 +0000 (Tue, 11 Jul 2023)
Log Message:
-----------
correcting me[] in _biffMoveVL
Modified Paths:
--------------
teem/trunk/src/biff/biffbiff.c
Modified: teem/trunk/src/biff/biffbiff.c
===================================================================
--- teem/trunk/src/biff/biffbiff.c 2023-07-11 22:06:33 UTC (rev 7075)
+++ teem/trunk/src/biff/biffbiff.c 2023-07-11 22:12:47 UTC (rev 7076)
@@ -411,7 +411,7 @@
static void
_biffMoveVL(const char *destKey, const char *srcKey, const char *errfmt, va_list args) {
- static const char me[] = "biffMovev";
+ static const char me[] = "_biffMoveVL";
biffMsg *dest, *src;
_bmsgStart();
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <kin...@us...> - 2023-07-11 22:06:35
|
Revision: 7075
http://sourceforge.net/p/teem/code/7075
Author: kindlmann
Date: 2023-07-11 22:06:33 +0000 (Tue, 11 Jul 2023)
Log Message:
-----------
alternative hest API done!
Modified Paths:
--------------
teem/trunk/src/TODO.txt
Modified: teem/trunk/src/TODO.txt
===================================================================
--- teem/trunk/src/TODO.txt 2023-07-11 21:58:01 UTC (rev 7074)
+++ teem/trunk/src/TODO.txt 2023-07-11 22:06:33 UTC (rev 7075)
@@ -103,14 +103,6 @@
optional parameters is why things like "unu make" learn centerings via
strings: the string can be given or not, and if its given, then the
information is used.
-******* (from tendGlyph.c): there needs to be an alternative API for hest
-that is not var-args based (as is hestOptAdd). You can't tell when
-you've passed multiple strings for the detailed usage information by
-accident. GLK had accidentally inserted a comma into my multi-line
-string for the "info" arg, relying on the automatic string
-concatenation, and ended up passing total garbage to hestOptAdd for
-the airEnum pointer, causing him to think that the tenGlyphType airEnum
-was malformed, when it was in fact fine ...
biff:
* biffMove(destKey, err, srcKey) --> biffMove(destKey, srcKey, err)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <kin...@us...> - 2023-07-11 21:58:04
|
Revision: 7074
http://sourceforge.net/p/teem/code/7074
Author: kindlmann
Date: 2023-07-11 21:58:01 +0000 (Tue, 11 Jul 2023)
Log Message:
-----------
(a previous commit should have had this message; this commit is just for this information
added to hest.h)
API NEW:
Many many non-var-args alternatives to hestOptAdd, also usefully type-specific for the
type of value to be parsed in a way that hestOptAdd_nva cannot match. These capture all
the common uses (and them some) of hest within Teem. They can be categorized, like
hestOpt->kind, in terms of the min, max number of (type T) parameters to the option:
min == max == 0 hestOptAdd_Flag (stand-alone flag; no parameters)
min == max == 1 hestOptAdd_1_T single fixed parameter
min == max >= 2 hestOptAdd_{2,3,4,N}_T multiple fixed parameters
min == 0; max == 1 hestOptAdd_1v_T single variable parameter
min < max; max >= 2 hestOptAdd_Nv_T multiple variable parameters
An airEnum* is passed for _Enum options; or a hestCB* for _Other options. The number of
parameters *sawP that hestParm saw on the command-line is passed for the _Nv_ options.
All declarations below were automatically generated via hestOptAddDeclsPrint (followed by
clang-format), which (like the implementation of all the functions) is done via lots of
#define macro tricks.
Modified Paths:
--------------
teem/trunk/src/hest/hest.h
Modified: teem/trunk/src/hest/hest.h
===================================================================
--- teem/trunk/src/hest/hest.h 2023-07-11 21:36:23 UTC (rev 7073)
+++ teem/trunk/src/hest/hest.h 2023-07-11 21:58:01 UTC (rev 7074)
@@ -288,7 +288,23 @@
/* adders.c */
HEST_EXPORT void hestOptAddDeclsPrint(FILE *f);
-/* these declarations are from clang-format of hestOptAddDeclsPrint output */
+/* Many many non-var-args alternatives to hestOptAdd, also usefully type-specific for the
+type of value to be parsed in a way that hestOptAdd_nva cannot match. These capture all
+the common uses (and them some) of hest within Teem. They can be categorized, like
+hestOpt->kind, in terms of the min, max number of (type T) parameters to the option:
+
+ min == max == 0 hestOptAdd_Flag (stand-alone flag; no parameters)
+ min == max == 1 hestOptAdd_1_T single fixed parameter
+ min == max >= 2 hestOptAdd_{2,3,4,N}_T multiple fixed parameters
+ min == 0; max == 1 hestOptAdd_1v_T single variable parameter
+ min < max; max >= 2 hestOptAdd_Nv_T multiple variable parameters
+
+An airEnum* is passed for _Enum options; or a hestCB* for _Other options. The number of
+parameters *sawP that hestParm saw on the command-line is passed for the _Nv_ options.
+
+All declarations below were automatically generated via hestOptAddDeclsPrint (followed by
+clang-format), which (like the implementation of all the functions) is done via lots of
+#define macro tricks. */
HEST_EXPORT unsigned int hestOptAdd_Flag(hestOpt **optP, const char *flag, int *valueP,
const char *info);
HEST_EXPORT unsigned int hestOptAdd_1v_Bool(hestOpt **hoptP, const char *flag,
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <kin...@us...> - 2023-07-11 21:36:26
|
Revision: 7073
http://sourceforge.net/p/teem/code/7073
Author: kindlmann
Date: 2023-07-11 21:36:23 +0000 (Tue, 11 Jul 2023)
Log Message:
-----------
correct name strings
Modified Paths:
--------------
teem/trunk/src/hest/test/ex6.c
Modified: teem/trunk/src/hest/test/ex6.c
===================================================================
--- teem/trunk/src/hest/test/ex6.c 2023-07-11 21:33:08 UTC (rev 7072)
+++ teem/trunk/src/hest/test/ex6.c 2023-07-11 21:36:23 UTC (rev 7073)
@@ -328,59 +328,59 @@
/* HEY also try 0, -1 */
int *bv;
unsigned int bvSaw;
- hestOptAdd_Nv_Bool(&opt, "bv", "bool1 bool2", 1, -1, &bv, "true false",
+ hestOptAdd_Nv_Bool(&opt, "bv", "bool1", 1, -1, &bv, "true false",
"test of hestOptAdd_Nv_Bool", &bvSaw);
int *iv;
unsigned int ivSaw;
- hestOptAdd_Nv_Int(&opt, "iv", "int1 ...", 1, -1, &iv, "42 24",
- "test of hestOptAdd_Nv_Int", &ivSaw);
+ hestOptAdd_Nv_Int(&opt, "iv", "int1", 1, -1, &iv, "42 24", "test of hestOptAdd_Nv_Int",
+ &ivSaw);
unsigned int *uiv;
unsigned int uivSaw;
- hestOptAdd_Nv_UInt(&opt, "uiv", "uint1 uint2", 1, -1, &uiv, "42 24",
+ hestOptAdd_Nv_UInt(&opt, "uiv", "uint1", 1, -1, &uiv, "42 24",
"test of hestOptAdd_Nv_UInt", &uivSaw);
long int *liv;
unsigned int livSaw;
- hestOptAdd_Nv_LongInt(&opt, "liv", "lint1 ...", 1, -1, &liv, "42 24",
+ hestOptAdd_Nv_LongInt(&opt, "liv", "lint1", 1, -1, &liv, "42 24",
"test of hestOptAdd_Nv_LongInt", &livSaw);
unsigned long int *uliv;
unsigned int ulivSaw;
- hestOptAdd_Nv_ULongInt(&opt, "uliv", "ulint1 ...", 1, -1, &uliv, "42 24",
+ hestOptAdd_Nv_ULongInt(&opt, "uliv", "ulint1", 1, -1, &uliv, "42 24",
"test of hestOptAdd_Nv_ULongInt", &ulivSaw);
size_t *szv;
unsigned int szvSaw;
- hestOptAdd_Nv_Size_t(&opt, "szv", "size1 ...", 1, -1, &szv, "42 24",
+ hestOptAdd_Nv_Size_t(&opt, "szv", "size1", 1, -1, &szv, "42 24",
"test of hestOptAdd_Nv_Size_t", &szvSaw);
float *flv;
unsigned int flvSaw;
- hestOptAdd_Nv_Float(&opt, "flv", "float1 ...", 1, -1, &flv, "4.2 2.4",
+ hestOptAdd_Nv_Float(&opt, "flv", "float1", 1, -1, &flv, "4.2 2.4",
"test of hestOptAdd_Nv_Float", &flvSaw);
double *dbv;
unsigned int dbvSaw;
- hestOptAdd_Nv_Double(&opt, "dbv", "double1 ...", 1, -1, &dbv, "4.2 2.4",
+ hestOptAdd_Nv_Double(&opt, "dbv", "double1", 1, -1, &dbv, "4.2 2.4",
"test of hestOptAdd_Nv_Double", &dbvSaw);
char *cv;
unsigned int cvSaw;
- hestOptAdd_Nv_Char(&opt, "cv", "char1 ...", 1, -1, &cv, "x y",
+ hestOptAdd_Nv_Char(&opt, "cv", "char1", 1, -1, &cv, "x y",
"test of hestOptAdd_Nv_Char", &cvSaw);
char **sv;
unsigned int svSaw;
- hestOptAdd_Nv_String(&opt, "sv", "str1 ...", 1, -1, &sv, "bingo bob",
+ hestOptAdd_Nv_String(&opt, "sv", "str1", 1, -1, &sv, "bingo bob",
"test of hestOptAdd_Nv_String", &svSaw);
int *ev;
unsigned int evSaw;
- hestOptAdd_Nv_Enum(&opt, "ev", "enum1 ...", 1, -1, &ev, "little big",
+ hestOptAdd_Nv_Enum(&opt, "ev", "enum1", 1, -1, &ev, "little big",
"test of hestOptAdd_Nv_Enum", &evSaw, airEndian);
double *pv;
unsigned int pvSaw;
- hestOptAdd_Nv_Other(&opt, "pv", "pos1 ...", 1, -1, &pv, "1.5,5.25 2.9,9.2",
+ hestOptAdd_Nv_Other(&opt, "pv", "pos1", 1, -1, &pv, "1.5,5.25 2.9,9.2",
"test of hestOptAdd_Nv_Other A", &pvSaw, &posCB);
Quat **qv;
unsigned int qvSaw;
- hestOptAdd_Nv_Other(&opt, "qv", "quat1 ...", 1, -1, &qv, "12.34 43.21",
+ hestOptAdd_Nv_Other(&opt, "qv", "quat1", 1, -1, &qv, "12.34 43.21",
"test of hestOptAdd_Nv_Other B", &qvSaw, &quatCB);
if (2 == argc && !strcmp("decls", argv[1])) {
- printf("Writing decls.h and then bailing ...\n");
+ printf("Writing decls.h and then bailing\n");
FILE *ff = fopen("decls.h", "w");
hestOptAddDeclsPrint(ff);
fclose(ff);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <kin...@us...> - 2023-07-11 21:33:11
|
Revision: 7072
http://sourceforge.net/p/teem/code/7072
Author: kindlmann
Date: 2023-07-11 21:33:08 +0000 (Tue, 11 Jul 2023)
Log Message:
-----------
crude fix to buffer overflow problem
Modified Paths:
--------------
teem/trunk/src/hest/usage.c
Modified: teem/trunk/src/hest/usage.c
===================================================================
--- teem/trunk/src/hest/usage.c 2023-07-11 21:18:05 UTC (rev 7071)
+++ teem/trunk/src/hest/usage.c 2023-07-11 21:33:08 UTC (rev 7072)
@@ -230,7 +230,10 @@
void
hestUsage(FILE *f, hestOpt *opt, const char *argv0, const hestParm *_parm) {
int i, numOpts;
- char buff[2 * AIR_STRLEN_HUGE + 1], tmpS[AIR_STRLEN_HUGE + 1];
+ /* with a very large number of options, it is possible to overflow buff[].
+ Previous to the 2023 revisit, it was for max lenth 2*AIR_STRLEN_HUGE, but
+ test/ex6.c blew past that. May have to increment again in the future :) */
+ char buff[64 * AIR_STRLEN_HUGE + 1], tmpS[AIR_STRLEN_SMALL + 1];
hestParm *parm;
parm = _parm ? NULL : hestParmNew();
@@ -271,7 +274,8 @@
hestGlossary(FILE *f, hestOpt *opt, const hestParm *_parm) {
int i, j, maxlen, numOpts;
unsigned int len;
- char buff[2 * AIR_STRLEN_HUGE + 1], tmpS[AIR_STRLEN_HUGE + 1];
+ /* See note above about overflowing buff[] */
+ char buff[64 * AIR_STRLEN_HUGE + 1], tmpS[AIR_STRLEN_HUGE + 1];
hestParm *parm;
parm = _parm ? NULL : hestParmNew();
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <kin...@us...> - 2023-07-11 21:18:08
|
Revision: 7071
http://sourceforge.net/p/teem/code/7071
Author: kindlmann
Date: 2023-07-11 21:18:05 +0000 (Tue, 11 Jul 2023)
Log Message:
-----------
the min argument to hestOptAdd and friends is now an unsigned int, as it should have been as soon as hestOpt->min was unsigned. ALSO: API NEW: 85 new type-specific hestOptAdd_N_T functions, created by some macro magic
Modified Paths:
--------------
teem/trunk/src/hest/adders.c
teem/trunk/src/hest/hest.h
teem/trunk/src/hest/methodsHest.c
teem/trunk/src/hest/parseHest.c
teem/trunk/src/hest/test/ex6.c
Modified: teem/trunk/src/hest/adders.c
===================================================================
--- teem/trunk/src/hest/adders.c 2023-07-11 12:45:20 UTC (rev 7070)
+++ teem/trunk/src/hest/adders.c 2023-07-11 21:18:05 UTC (rev 7071)
@@ -36,27 +36,30 @@
would have caught the above error.
The underlying issue there, though, is the total lack of type-checking associated with
-the var-args functions. The functions in this file help do as much type-checking as
-possible with hest. These functions cover nearly all uses of hest within Teem (and in
-GLK's SciVIs class), in a way that is specific to the type of the value storage pointer
-valueP, which is still a void* even in hestOptAdd_nva. Many of the possibilities here
-are unlikely to be needed (an option for 4 booleans?), but are generated here for
-completeness (an option for 4 floats or 4 doubles is great for R,G,B,A).
+the var-args functions. Even without var-args, the "void*" type of the value storage
+pointer is still a problem. Therefore, the functions in this file help do as much
+type-checking as possible with hest. These functions cover nearly all uses of hest
+within Teem (and in GLK's SciVis class), in a way that is specific to the type of the
+value storage pointer valueP, which is still a void* even in hestOptAdd_nva. Many of the
+possibilities here are unlikely to be needed (an option for 4 booleans?), but are
+generated here for completeness (an option for 4 floats or 4 doubles is great for
+R,G,B,A values).
-However with airTypeOther, in which case the caller passes a hestCB struct of callbacks
-to parse arbitrary things from the command-line, there is still unfortunately a
-type-checking black hole void* involved. And, there is no away around that:
-the non-NULL-ity of hestCB->destroy determines wether the thing being parsed is
-merely space to be initialized (valueP is an array of structs), versus a
-struct to be allocated (valueP is an array of pointers to structs), we want that to
-determine the type of valueP. But the struct itself as to be void type, and void** is
-not a generic pointer to pointer type (like void* is the generic pointer type). Still
-the _Other versions of the function are generated here to slightly simplify the
-hestOptAdd call (no more NULL, NULL for sawP and enum). Actually, there is around
+However with airTypeOther, when the caller passes a hestCB struct of callbacks to parse
+arbitrary things from the command-line, there is still unfortunately a type-checking
+black hole void* involved. And, there is no away around that: either valueP is an array
+of structs (when hestCB->destroy is NULL) or an array of pointers to structs
+(hestCB->destroy is non-NULL), for which the most specific type for valueP would be
+either void* or void**, respectively. But void** is not a generic pointer to pointer type
+(like void* is the generic pointer type), and, we're not doing compile-time checks on the
+non-NULL-ity of hestCB->destroy. So it all devolves back to plain void*. Still, the
+hestOptAdd_*_Other function are generated here to slightly simplify the hestOptAdd call,
+since there is no more NULL and NULL for sawP and enum. Actually, there is a way around
a type-checking black hole: extreme attentiveness!
*/
/* --------------------------------------------------------------- 1 == kind */
+/* (there is only one kind of kind==1 option) */
unsigned int
hestOptAdd_Flag(hestOpt **hoptP, const char *flag, int *valueP, const char *info) {
@@ -65,274 +68,271 @@
NULL, NULL, NULL);
}
-/* --------------------------------------------------------------- 2 == kind */
-unsigned int
-hestOptAdd_1_Bool(hestOpt **hoptP, const char *flag, const char *name, /* */
- int *valueP, const char *dflt, const char *info) {
- return hestOptAdd_nva(hoptP, flag, name, airTypeBool, 1, 1, /* */
- valueP, dflt, info, /* */
- NULL, NULL, NULL);
-}
+/* The number of very similar functions to define here justifies macro tricks,
+which follow these naming conventions:
-unsigned int
-hestOptAdd_1_Int(hestOpt **hoptP, const char *flag, const char *name, /* */
- int *valueP, const char *dflt, const char *info) {
- return hestOptAdd_nva(hoptP, flag, name, airTypeInt, 1, 1, /* */
- valueP, dflt, info, /* */
- NULL, NULL, NULL);
-}
+DCL_ = declaration (for the header file)
+IMP- = implementation (for this file)
+DEF_ = definition = declaration + implementation
+_T_ = simple scalar types
+_E_ = airEnum
+_O_ = Other (needs hestCB)
+_1 = single parameter, either fixed (kind 2) or variable (kind 4)
+_M = 2, 3, or 4 = COMPILE-TIME fixed # of parameters (kind 3)
+ (these exist as a convenience, covering many common hest uses)
+_N = RUN_TIME user-given fixed # of parameters (still kind 3)
+_V = RUN_TIME variable # of parameters (kind 5)
-unsigned int
-hestOptAdd_1_UInt(hestOpt **hoptP, const char *flag, const char *name, /* */
- unsigned int *valueP, const char *dflt, const char *info) {
- return hestOptAdd_nva(hoptP, flag, name, airTypeUInt, 1, 1, /* */
- valueP, dflt, info, /* */
- NULL, NULL, NULL);
-}
+*/
-unsigned int
-hestOptAdd_1_LongInt(hestOpt **hoptP, const char *flag, const char *name, /* */
- long int *valueP, const char *dflt, const char *info) {
- return hestOptAdd_nva(hoptP, flag, name, airTypeLongInt, 1, 1, /* */
- valueP, dflt, info, /* */
- NULL, NULL, NULL);
-}
+/* utility concatenators, used to form the name of macros to expand further */
+#define CONC(A, B) A##_##B
+#define CONC3(A, B, C) A##_##B##_##C
-unsigned int
-hestOptAdd_1_ULongInt(hestOpt **hoptP, const char *flag, const char *name, /* */
- unsigned long int *valueP, const char *dflt, const char *info) {
- return hestOptAdd_nva(hoptP, flag, name, airTypeULongInt, 1, 1, /* */
- valueP, dflt, info, /* */
- NULL, NULL, NULL);
-}
+/*
+_1 _1 _1 _1 _1 _1 _1 _1 _1 _1 _1 _1 _1 _1 _1 _1 _1 _1 _1 _1 _1 _1 _1 _1 _1 _1
+_1 _1 _1 _1 _1 _1 _1 _1 _1 _1 _1 _1 _1 _1 _1 _1 _1 _1 _1 _1 _1 _1 _1 _1 _1 _1
+_1 _1 _1 _1 _1 _1 _1 _1 _1 _1 _1 _1 _1 _1 _1 _1 _1 _1 _1 _1 _1 _1 _1 _1 _1 _1
+*/
-unsigned int
-hestOptAdd_1_Size_t(hestOpt **hoptP, const char *flag, const char *name, /* */
- size_t *valueP, const char *dflt, const char *info) {
- return hestOptAdd_nva(hoptP, flag, name, airTypeSize_t, 1, 1, /* */
- valueP, dflt, info, /* */
- NULL, NULL, NULL);
-}
+/* "_1v_" functions (declared via _DCL_T_0) are for a single variable parm opt (kind 4),
+ "_1_" functions (declared via _DCL_T_1) are for a single fixed parm opt (kind 2)
+*/
+#define _DCL_T_0(ATYP, CTYP) \
+ unsigned int hestOptAdd_1v_##ATYP(hestOpt **hoptP, const char *flag, \
+ const char *name, CTYP *valueP, const char *dflt, \
+ const char *info)
+#define _DCL_T_1(ATYP, CTYP) \
+ unsigned int hestOptAdd_1_##ATYP(hestOpt **hoptP, const char *flag, /* */ \
+ const char *name, CTYP *valueP, const char *dflt, \
+ const char *info)
+/* DCL_T_1(M) chooses between _DCL_T_0 and _DCL_T_1 */
+#define DCL_T_1(M, ATYP, CTYP) CONC(_DCL_T, M)(ATYP, CTYP)
+/* IMP_T_1(M) passes M as minimum # parms;
+ M=0 --> kind 4
+ M=1 --> kind 2; max # parms is 1 for both */
+#define IMP_T_1(M, ATYP, CTYP) \
+ { \
+ return hestOptAdd_nva(hoptP, flag, name, airType##ATYP, M, 1, /* */ \
+ valueP, dflt, info, /* */ \
+ NULL, NULL, NULL); \
+ }
+#define DEF_T_1(M, ATYP, CTYP) DCL_T_1(M, ATYP, CTYP) IMP_T_1(M, ATYP, CTYP)
+/* copy-pasta for Enum -------------- */
+#define _DCL_E_0 \
+ unsigned int hestOptAdd_1v_Enum(hestOpt **hoptP, const char *flag, /* */ \
+ const char *name, int *valueP, const char *dflt, \
+ const char *info, const airEnum *enm)
+#define _DCL_E_1 \
+ unsigned int hestOptAdd_1_Enum(hestOpt **hoptP, const char *flag, /* */ \
+ const char *name, int *valueP, const char *dflt, \
+ const char *info, const airEnum *enm)
+#define DCL_E_1(M) CONC(_DCL_E, M)
+#define IMP_E_1(M) \
+ { \
+ return hestOptAdd_nva(hoptP, flag, name, airTypeEnum, M, 1, /* */ \
+ valueP, dflt, info, /* */ \
+ NULL, enm, NULL); \
+ }
+#define DEF_E_1(M) DCL_E_1(M) IMP_E_1(M)
+/* copy-pasta for Other -------------- */
+#define _DCL_O_0 \
+ unsigned int hestOptAdd_1v_Other(hestOpt **hoptP, const char *flag, /* */ \
+ const char *name, void *valueP, const char *dflt, \
+ const char *info, const hestCB *CB)
+#define _DCL_O_1 \
+ unsigned int hestOptAdd_1_Other(hestOpt **hoptP, const char *flag, /* */ \
+ const char *name, void *valueP, const char *dflt, \
+ const char *info, const hestCB *CB)
+#define DCL_O_1(M) CONC(_DCL_O, M)
+#define IMP_O_1(M) \
+ { \
+ return hestOptAdd_nva(hoptP, flag, name, airTypeOther, M, 1, /* */ \
+ valueP, dflt, info, /* */ \
+ NULL, NULL, CB); \
+ }
+#define DEF_O_1(M) DCL_O_1(M) IMP_O_1(M)
-unsigned int
-hestOptAdd_1_Float(hestOpt **hoptP, const char *flag, const char *name, /* */
- float *valueP, const char *dflt, const char *info) {
- return hestOptAdd_nva(hoptP, flag, name, airTypeFloat, 1, 1, /* */
- valueP, dflt, info, /* */
- NULL, NULL, NULL);
-}
+/*
+_M and _N _M and _N _M and _N _M and _N _M and _N _M and _N _M and _N
+_M and _N _M and _N _M and _N _M and _N _M and _N _M and _N _M and _N
+_M and _N _M and _N _M and _N _M and _N _M and _N _M and _N _M and _N
+*/
-unsigned int
-hestOptAdd_1_Double(hestOpt **hoptP, const char *flag, const char *name, /* */
- double *valueP, const char *dflt, const char *info) {
- return hestOptAdd_nva(hoptP, flag, name, airTypeDouble, 1, 1, /* */
- valueP, dflt, info, /* */
- NULL, NULL, NULL);
-}
-
-unsigned int
-hestOptAdd_1_Char(hestOpt **hoptP, const char *flag, const char *name, /* */
- char *valueP, const char *dflt, const char *info) {
- return hestOptAdd_nva(hoptP, flag, name, airTypeChar, 1, 1, /* */
- valueP, dflt, info, /* */
- NULL, NULL, NULL);
-}
-
-unsigned int
-hestOptAdd_1_String(hestOpt **hoptP, const char *flag, const char *name, /* */
- char **valueP, const char *dflt, const char *info) {
- return hestOptAdd_nva(hoptP, flag, name, airTypeString, 1, 1, /* */
- valueP, dflt, info, /* */
- NULL, NULL, NULL);
-}
-
-unsigned int
-hestOptAdd_1_Enum(hestOpt **hoptP, const char *flag, const char *name, /* */
- int *valueP, const char *dflt, const char *info, /* */
- const airEnum *enm) {
-
- return hestOptAdd_nva(hoptP, flag, name, airTypeEnum, 1, 1, /* */
- valueP, dflt, info, /* */
- NULL, enm, NULL);
-}
-
-unsigned int
-hestOptAdd_1_Other(hestOpt **hoptP, const char *flag, const char *name, /* */
- void *valueP, const char *dflt, const char *info, /* */
- const hestCB *CB) {
- return hestOptAdd_nva(hoptP, flag, name, airTypeOther, 1, 1, /* */
- valueP, dflt, info, /* */
- NULL, NULL, CB);
-}
-
-/* --------------------------------------------------------------- 2 == kind */
-
-/* for some reason writing out code above (and their declarations in hest.h) by hand was
-tolerated, but from here on out the coding is going to use a lot of macro tricks, with
-these name conventions:
-
-M = 2, 3, or 4 = fixed # of parameters
-N = user-given fixed # of parameters
-_S = simple scalar types
-_E = airEnum
-_O = Other
-
-Some way of gracefully handling the 10 different simple types, plus the airEnum and
-Other, with the context of the functional-ish MAP macros, is surely possible, but it
-eludes GLK at this time */
-
-/* _S: simple scalar types */
-#define DCL_M_S(M, ATYP, CTYP) \
+/* copy-pasta for _T scalar types for (compile-time) M or (run-time) N fixed parms */
+#define DCL_T_M(M, ATYP, CTYP) \
unsigned int hestOptAdd_##M##_##ATYP(hestOpt **hoptP, const char *flag, \
const char *name, CTYP valueP[M], \
const char *dflt, const char *info)
-#define BODY_M_S(M, ATYP, CTYP) \
+#define IMP_T_M(M, ATYP, CTYP) \
{ \
return hestOptAdd_nva(hoptP, flag, name, airType##ATYP, M, M, valueP, dflt, info, \
NULL, NULL, NULL); \
}
-#define DEF_M_S(M, ATYP, CTYP) DCL_M_S(M, ATYP, CTYP) BODY_M_S(M, ATYP, CTYP)
-#define DCL_N_S(ATYP, CTYP) \
+#define DEF_T_M(M, ATYP, CTYP) DCL_T_M(M, ATYP, CTYP) IMP_T_M(M, ATYP, CTYP)
+#define DCL_T_N(_, ATYP, CTYP) \
unsigned int hestOptAdd_N_##ATYP(hestOpt **hoptP, const char *flag, const char *name, \
unsigned int N, CTYP *valueP, const char *dflt, \
const char *info)
-#define BODY_N_S(ATYP, CTYP) \
+#define IMP_T_N(_, ATYP, CTYP) \
{ \
return hestOptAdd_nva(hoptP, flag, name, airType##ATYP, N, N, valueP, dflt, info, \
NULL, NULL, NULL); \
}
-#define DEF_N_S(ATYP, CTYP) DCL_N_S(ATYP, CTYP) BODY_N_S(ATYP, CTYP)
-
-/* _E: Enum */
-#define DCL_M_E(M) \
+#define DEF_T_N(_, ATYP, CTYP) DCL_T_N(_, ATYP, CTYP) IMP_T_N(_, ATYP, CTYP)
+/* copy-pasta for _E Enums */
+#define DCL_E_M(M) \
unsigned int hestOptAdd_##M##_Enum(hestOpt **hoptP, const char *flag, \
const char *name, int valueP[M], const char *dflt, \
const char *info, const airEnum *enm)
-#define BODY_M_E(M) \
+#define IMP_E_M(M) \
{ \
return hestOptAdd_nva(hoptP, flag, name, airTypeEnum, M, M, valueP, dflt, info, \
NULL, enm, NULL); \
}
-#define DEF_M_E(M) DCL_M_E(M) BODY_M_E(M)
-#define DCL_N_E \
+#define DEF_E_M(M) DCL_E_M(M) IMP_E_M(M)
+#define DCL_E_N(_) \
unsigned int hestOptAdd_N_Enum(hestOpt **hoptP, const char *flag, const char *name, \
unsigned int N, int *valueP, const char *dflt, \
const char *info, const airEnum *enm)
-#define BODY_N_E \
+#define IMP_E_N(_) \
{ \
return hestOptAdd_nva(hoptP, flag, name, airTypeEnum, N, N, valueP, dflt, info, \
NULL, enm, NULL); \
}
-#define DEF_N_E DCL_N_E BODY_N_E
-
-/* _O: Other */
-#define DCL_M_O(M) \
+#define DEF_E_N(_) DCL_E_N(_) IMP_E_N(_)
+/* copy-pasta for _O Other */
+#define DCL_O_M(M) \
unsigned int hestOptAdd_##M##_Other(hestOpt **hoptP, const char *flag, \
const char *name, void *valueP, const char *dflt, \
const char *info, const hestCB *CB)
-#define BODY_M_O(M) \
+#define IMP_O_M(M) \
{ \
return hestOptAdd_nva(hoptP, flag, name, airTypeOther, M, M, valueP, dflt, info, \
NULL, NULL, CB); \
}
-#define DEF_M_O(M) DCL_M_O(M) BODY_M_O(M)
-#define DCL_N_O \
+#define DEF_O_M(M) DCL_O_M(M) IMP_O_M(M)
+#define DCL_O_N(_) \
unsigned int hestOptAdd_N_Other(hestOpt **hoptP, const char *flag, const char *name, \
unsigned int N, void *valueP, const char *dflt, \
const char *info, const hestCB *CB)
-#define BODY_N_O \
+#define IMP_O_N(_) \
{ \
return hestOptAdd_nva(hoptP, flag, name, airTypeOther, N, N, valueP, dflt, info, \
NULL, NULL, CB); \
}
-#define DEF_N_O DCL_N_O BODY_N_O
+#define DEF_O_N(_) DCL_O_N(_) IMP_O_N(_)
-/* MAP_M_S takes a macro MMAC that (like DCL_M_S or DEF_M_S) takes three args
--- M, ATYP, CTYP -- and applies it to all the simple scalar types.
-MAP_N_S takes a macro NMAC (like DCL_N_S or DEF_N_S) that takes just two args
--- ATYP, CTYPE -- and applies to the scalar types */
-#define MAP_M_S(MMAC, M) \
- MMAC(M, Bool, int) \
- MMAC(M, Int, int) \
- MMAC(M, UInt, unsigned int) \
- MMAC(M, LongInt, long int) \
- MMAC(M, ULongInt, unsigned long int) \
- MMAC(M, Size_t, size_t) \
- MMAC(M, Float, float) \
- MMAC(M, Double, double) \
- MMAC(M, Char, char) \
- MMAC(M, String, char *)
-/* (yes would be nicer to avoid copy-pasta, but how?) */
-#define MAP_N_S(NMAC) \
- NMAC(Bool, int) \
- NMAC(Int, int) \
- NMAC(UInt, unsigned int) \
- NMAC(LongInt, long int) \
- NMAC(ULongInt, unsigned long int) \
- NMAC(Size_t, size_t) \
- NMAC(Float, float) \
- NMAC(Double, double) \
- NMAC(Char, char) \
- NMAC(String, char *)
+/*
+_V _V _V _V _V _V _V _V _V _V _V _V _V _V _V _V _V _V _V _V _V _V _V _V _V _V
+_V _V _V _V _V _V _V _V _V _V _V _V _V _V _V _V _V _V _V _V _V _V _V _V _V _V
+_V _V _V _V _V _V _V _V _V _V _V _V _V _V _V _V _V _V _V _V _V _V _V _V _V _V
+*/
-/* v.v.v.v.v.v.v.v.v Actual code! v.v.v.v.v.v.v.v.v */
-MAP_M_S(DEF_M_S, 2)
-DEF_M_E(2)
-DEF_M_O(2)
-MAP_M_S(DEF_M_S, 3)
-DEF_M_E(3)
-DEF_M_O(3)
-MAP_M_S(DEF_M_S, 4)
-DEF_M_E(4)
-DEF_M_O(4)
-MAP_N_S(DEF_N_S)
-DEF_N_E
-DEF_N_O
-/* ^'^'^'^'^'^'^'^'^'^'^'^'^'^'^'^'^'^'^'^'^'^'^'^'^'^'^ */
+#define DCL_T_V(_, ATYP, CTYP) \
+ unsigned int hestOptAdd_Nv_##ATYP(hestOpt **hoptP, const char *flag, \
+ const char *name, unsigned int min, int max, \
+ CTYP **valueP, const char *dflt, const char *info, \
+ unsigned int *sawP)
+#define IMP_T_V(_, ATYP, CTYP) \
+ { \
+ return hestOptAdd_nva(hoptP, flag, name, airType##ATYP, min, max, /* */ \
+ valueP, dflt, info, /* */ \
+ sawP, NULL, NULL); \
+ }
+#define DEF_T_V(M, ATYP, CTYP) DCL_T_V(M, ATYP, CTYP) IMP_T_V(M, ATYP, CTYP)
+/* copy-pasta for Enum -------------- */
+#define DCL_E_V(_) \
+ unsigned int hestOptAdd_Nv_Enum(hestOpt **hoptP, const char *flag, /* */ \
+ const char *name, unsigned int min, int max, \
+ int **valueP, const char *dflt, const char *info, \
+ unsigned int *sawP, const airEnum *enm)
+#define IMP_E_V(_) \
+ { \
+ return hestOptAdd_nva(hoptP, flag, name, airTypeEnum, min, max, /* */ \
+ valueP, dflt, info, /* */ \
+ sawP, enm, NULL); \
+ }
+#define DEF_E_V(_) DCL_E_V(_) IMP_E_V(_)
+/* copy-pasta for Other -------------- */
+#define DCL_O_V(_) \
+ unsigned int hestOptAdd_Nv_Other(hestOpt **hoptP, const char *flag, /* */ \
+ const char *name, unsigned int min, int max, \
+ void *valueP, const char *dflt, const char *info, \
+ unsigned int *sawP, const hestCB *CB)
+#define IMP_O_V(_) \
+ { \
+ return hestOptAdd_nva(hoptP, flag, name, airTypeOther, min, max, /* */ \
+ valueP, dflt, info, /* */ \
+ sawP, NULL, CB); \
+ }
+#define DEF_O_V(_) DCL_O_V(_) IMP_O_V(_)
-/* Macro for making a string out of whatever something has been #define'd to, exactly,
- without chasing down a sequence of #includes.
+/* MAP_T takes a macro MAC that (like DCL_T_M or DEF_T_M) takes three args
+(M, ATYP, CTYP) and applies it to all the simple scalar types */
+#define MAP_T(MAC, M) \
+ MAC(M, Bool, int) \
+ MAC(M, Int, int) \
+ MAC(M, UInt, unsigned int) \
+ MAC(M, LongInt, long int) \
+ MAC(M, ULongInt, unsigned long int) \
+ MAC(M, Size_t, size_t) \
+ MAC(M, Float, float) \
+ MAC(M, Double, double) \
+ MAC(M, Char, char) \
+ MAC(M, String, char *)
+
+/* MAP(BSN, X, M) takes a macro basename BSN (like DEF) and
+expands it to the _T, _E, and _O cases for _X. E.g. "MAP(DEF, 1, 0)" expands to:
+MAP_T(DEF_T_1, 0)
+DEF_E_1(0)
+DEF_O_1(0)
+*/
+#define MAP(BSN, X, M) MAP_T(CONC3(BSN, T, X), M) CONC3(BSN, E, X)(M) CONC3(BSN, O, X)(M)
+
+/* DOIT does expansion over all possibilities of BSN */
+#define DOIT(BSN) \
+ MAP(BSN, 1, 0) \
+ MAP(BSN, 1, 1) \
+ MAP(BSN, M, 2) \
+ MAP(BSN, M, 3) \
+ MAP(BSN, M, 4) \
+ MAP(BSN, N, _) \
+ MAP(BSN, V, _)
+
+/* !!! HERE IS THE ACTUAL CODE FOR ALL THE hestOptAdd_*_* CASES !!! */
+DOIT(DEF)
+
+/* Macro for making a string out of whatever something has been #define'd to
https://gcc.gnu.org/onlinedocs/cpp/Stringizing.html */
#define __STR(name) #name
#define _STR(name) __STR(name)
/* for generating body of hestOptAddDeclsPrint;
-NOTE assuming the local FILE *ff */
-#define PRINT_M_S(M, ATYP, CTYP) \
- fprintf(ff, "HEST_EXPORT " _STR(DCL_M_S(M, ATYP, CTYP)) ";\n");
-#define PRINT_M_E(M) fprintf(ff, "HEST_EXPORT " _STR(DCL_M_E(M)) ";\n");
-#define PRINT_M_O(M) fprintf(ff, "HEST_EXPORT " _STR(DCL_M_O(M)) ";\n");
-#define PRINT_N_S(ATYP, CTYP) \
- fprintf(ff, "HEST_EXPORT " _STR(DCL_N_S(ATYP, CTYP)) ";\n");
-#define PRINT_N_E fprintf(ff, "HEST_EXPORT " _STR(DCL_N_E) ";\n");
-#define PRINT_N_O fprintf(ff, "HEST_EXPORT " _STR(DCL_N_O) ";\n");
+NOTE assuming the local variable FILE *ff */
+#define PRINT_T_1(M, ATYP, CTYP) \
+ fprintf(ff, "HEST_EXPORT " _STR(DCL_T_1(M, ATYP, CTYP)) ";\n");
+#define PRINT_E_1(M) fprintf(ff, "HEST_EXPORT " _STR(DCL_E_1(M)) ";\n");
+#define PRINT_O_1(M) fprintf(ff, "HEST_EXPORT " _STR(DCL_O_1(M)) ";\n");
+#define PRINT_T_M(M, ATYP, CTYP) \
+ fprintf(ff, "HEST_EXPORT " _STR(DCL_T_M(M, ATYP, CTYP)) ";\n");
+#define PRINT_E_M(M) fprintf(ff, "HEST_EXPORT " _STR(DCL_E_M(M)) ";\n");
+#define PRINT_O_M(M) fprintf(ff, "HEST_EXPORT " _STR(DCL_O_M(M)) ";\n");
+#define PRINT_T_N(_, ATYP, CTYP) \
+ fprintf(ff, "HEST_EXPORT " _STR(DCL_T_N(_, ATYP, CTYP)) ";\n");
+#define PRINT_E_N(_) fprintf(ff, "HEST_EXPORT " _STR(DCL_E_N(_)) ";\n");
+#define PRINT_O_N(_) fprintf(ff, "HEST_EXPORT " _STR(DCL_O_N(_)) ";\n");
+#define PRINT_T_V(_, ATYP, CTYP) \
+ fprintf(ff, "HEST_EXPORT " _STR(DCL_T_V(_, ATYP, CTYP)) ";\n");
+#define PRINT_E_V(_) fprintf(ff, "HEST_EXPORT " _STR(DCL_E_V(_)) ";\n");
+#define PRINT_O_V(_) fprintf(ff, "HEST_EXPORT " _STR(DCL_O_V(_)) ";\n");
-/* prints declarations for everything defined by macro above, which
-HEY does not include the hestOptAdd_Flag and hestOptAdd_1_* functions */
+/* prints declarations for everything defined by macro magic above */
void
hestOptAddDeclsPrint(FILE *ff) {
- /* HEY copy-pasta from "Actual code" above */
- MAP_M_S(PRINT_M_S, 2)
- PRINT_M_E(2)
- PRINT_M_O(2)
- MAP_M_S(PRINT_M_S, 3)
- PRINT_M_E(3)
- PRINT_M_O(3)
- MAP_M_S(PRINT_M_S, 4)
- PRINT_M_E(4)
- PRINT_M_O(4)
- MAP_N_S(PRINT_N_S)
- PRINT_N_E
- PRINT_N_O
+ /* the flag is the one case not handled by macro expansion */
+ fprintf(ff, "HEST_EXPORT unsigned int hestOptAdd_Flag(hestOpt **optP, "
+ "const char *flag, int *valueP, const char *info);\n");
+ /* declarations for all other cases */
+ DOIT(PRINT)
}
-
-/*
-hestOptSetXX(hestOpt *opt, )
-1v<T>, Nv<T> need sawP
-
-<T>=
-Bool, Int, UInt, LongInt, ULongInt, Size_t,
-Float, Double, Char, String,
-Enum, need Enum
-Other, need CB
-*/
Modified: teem/trunk/src/hest/hest.h
===================================================================
--- teem/trunk/src/hest/hest.h 2023-07-11 12:45:20 UTC (rev 7070)
+++ teem/trunk/src/hest/hest.h 2023-07-11 21:18:05 UTC (rev 7071)
@@ -97,7 +97,7 @@
int type; /* type of option (from airType enum) */
unsigned int min; /* min # of parameters for option */
int max; /* max # of parameters for option,
- or -1 for "there is no max" */
+ or -1 for "there is no max; # parms is unbounded" */
void *valueP; /* storage of parsed values */
char *dflt, /* default value written out as string */
*info; /* description to be printed with "glossary" info */
@@ -246,17 +246,17 @@
HEST_EXPORT hestParm *hestParmFree(hestParm *parm);
HEST_EXPORT void *hestParmFree_vp(void *parm);
HEST_EXPORT void hestOptSingleSet(hestOpt *opt, const char *flag, const char *name,
- int type, int min, int max, void *valueP,
+ int type, unsigned int min, int max, void *valueP,
const char *dflt, const char *info, unsigned int *sawP,
const airEnum *enm, const hestCB *CB);
HEST_EXPORT unsigned int hestOptAdd_nva(hestOpt **optP, const char *flag,
- const char *name, int type, int min, int max,
- void *valueP, const char *dflt, const char *info,
- unsigned int *sawP, const airEnum *enm,
- const hestCB *CB);
+ const char *name, int type, unsigned int min,
+ int max, void *valueP, const char *dflt,
+ const char *info, unsigned int *sawP,
+ const airEnum *enm, const hestCB *CB);
HEST_EXPORT unsigned int hestOptAdd(hestOpt **optP,
const char *flag, const char *name,
- int type, int min, int max,
+ int type, unsigned int min, int max,
void *valueP, const char *dflt,
const char *info,
... /* unsigned int *sawP,
@@ -288,49 +288,87 @@
/* adders.c */
HEST_EXPORT void hestOptAddDeclsPrint(FILE *f);
+/* these declarations are from clang-format of hestOptAddDeclsPrint output */
HEST_EXPORT unsigned int hestOptAdd_Flag(hestOpt **optP, const char *flag, int *valueP,
const char *info);
-HEST_EXPORT unsigned int hestOptAdd_1_Bool(hestOpt **optP, const char *flag,
+HEST_EXPORT unsigned int hestOptAdd_1v_Bool(hestOpt **hoptP, const char *flag,
+ const char *name, int *valueP,
+ const char *dflt, const char *info);
+HEST_EXPORT unsigned int hestOptAdd_1v_Int(hestOpt **hoptP, const char *flag,
const char *name, int *valueP,
const char *dflt, const char *info);
-HEST_EXPORT unsigned int hestOptAdd_1_Int(hestOpt **optP, const char *flag,
+HEST_EXPORT unsigned int hestOptAdd_1v_UInt(hestOpt **hoptP, const char *flag,
+ const char *name, unsigned int *valueP,
+ const char *dflt, const char *info);
+HEST_EXPORT unsigned int hestOptAdd_1v_LongInt(hestOpt **hoptP, const char *flag,
+ const char *name, long int *valueP,
+ const char *dflt, const char *info);
+HEST_EXPORT unsigned int hestOptAdd_1v_ULongInt(hestOpt **hoptP, const char *flag,
+ const char *name,
+ unsigned long int *valueP,
+ const char *dflt, const char *info);
+HEST_EXPORT unsigned int hestOptAdd_1v_Size_t(hestOpt **hoptP, const char *flag,
+ const char *name, size_t *valueP,
+ const char *dflt, const char *info);
+HEST_EXPORT unsigned int hestOptAdd_1v_Float(hestOpt **hoptP, const char *flag,
+ const char *name, float *valueP,
+ const char *dflt, const char *info);
+HEST_EXPORT unsigned int hestOptAdd_1v_Double(hestOpt **hoptP, const char *flag,
+ const char *name, double *valueP,
+ const char *dflt, const char *info);
+HEST_EXPORT unsigned int hestOptAdd_1v_Char(hestOpt **hoptP, const char *flag,
+ const char *name, char *valueP,
+ const char *dflt, const char *info);
+HEST_EXPORT unsigned int hestOptAdd_1v_String(hestOpt **hoptP, const char *flag,
+ const char *name, char **valueP,
+ const char *dflt, const char *info);
+HEST_EXPORT unsigned int hestOptAdd_1v_Enum(hestOpt **hoptP, const char *flag,
+ const char *name, int *valueP,
+ const char *dflt, const char *info,
+ const airEnum *enm);
+HEST_EXPORT unsigned int hestOptAdd_1v_Other(hestOpt **hoptP, const char *flag,
+ const char *name, void *valueP,
+ const char *dflt, const char *info,
+ const hestCB *CB);
+HEST_EXPORT unsigned int hestOptAdd_1_Bool(hestOpt **hoptP, const char *flag,
+ const char *name, int *valueP,
+ const char *dflt, const char *info);
+HEST_EXPORT unsigned int hestOptAdd_1_Int(hestOpt **hoptP, const char *flag,
const char *name, int *valueP,
const char *dflt, const char *info);
-HEST_EXPORT unsigned int hestOptAdd_1_UInt(hestOpt **optP, const char *flag,
+HEST_EXPORT unsigned int hestOptAdd_1_UInt(hestOpt **hoptP, const char *flag,
const char *name, unsigned int *valueP,
const char *dflt, const char *info);
-HEST_EXPORT unsigned int hestOptAdd_1_LongInt(hestOpt **optP, const char *flag,
+HEST_EXPORT unsigned int hestOptAdd_1_LongInt(hestOpt **hoptP, const char *flag,
const char *name, long int *valueP,
const char *dflt, const char *info);
-HEST_EXPORT unsigned int hestOptAdd_1_ULongInt(hestOpt **optP, const char *flag,
+HEST_EXPORT unsigned int hestOptAdd_1_ULongInt(hestOpt **hoptP, const char *flag,
const char *name,
unsigned long int *valueP,
const char *dflt, const char *info);
-HEST_EXPORT unsigned int hestOptAdd_1_Size_t(hestOpt **optP, const char *flag,
+HEST_EXPORT unsigned int hestOptAdd_1_Size_t(hestOpt **hoptP, const char *flag,
const char *name, size_t *valueP,
const char *dflt, const char *info);
-HEST_EXPORT unsigned int hestOptAdd_1_Float(hestOpt **optP, const char *flag,
+HEST_EXPORT unsigned int hestOptAdd_1_Float(hestOpt **hoptP, const char *flag,
const char *name, float *valueP,
const char *dflt, const char *info);
-HEST_EXPORT unsigned int hestOptAdd_1_Double(hestOpt **optP, const char *flag,
+HEST_EXPORT unsigned int hestOptAdd_1_Double(hestOpt **hoptP, const char *flag,
const char *name, double *valueP,
const char *dflt, const char *info);
-HEST_EXPORT unsigned int hestOptAdd_1_Char(hestOpt **optP, const char *flag,
+HEST_EXPORT unsigned int hestOptAdd_1_Char(hestOpt **hoptP, const char *flag,
const char *name, char *valueP,
const char *dflt, const char *info);
-HEST_EXPORT unsigned int hestOptAdd_1_String(hestOpt **optP, const char *flag,
+HEST_EXPORT unsigned int hestOptAdd_1_String(hestOpt **hoptP, const char *flag,
const char *name, char **valueP,
const char *dflt, const char *info);
-HEST_EXPORT unsigned int hestOptAdd_1_Enum(hestOpt **optP, const char *flag,
+HEST_EXPORT unsigned int hestOptAdd_1_Enum(hestOpt **hoptP, const char *flag,
const char *name, int *valueP,
const char *dflt, const char *info,
const airEnum *enm);
-HEST_EXPORT unsigned int hestOptAdd_1_Other(hestOpt **optP, const char *flag,
+HEST_EXPORT unsigned int hestOptAdd_1_Other(hestOpt **hoptP, const char *flag,
const char *name, void *valueP,
const char *dflt, const char *info,
const hestCB *CB);
-/* from here on, declarations are from calling hestOptAddDeclsPrint and then
-clang-formatting */
HEST_EXPORT unsigned int hestOptAdd_2_Bool(hestOpt **hoptP, const char *flag,
const char *name, int valueP[2],
const char *dflt, const char *info);
@@ -494,6 +532,58 @@
const char *name, unsigned int N,
void *valueP, const char *dflt,
const char *info, const hestCB *CB);
+HEST_EXPORT unsigned int hestOptAdd_Nv_Bool(hestOpt **hoptP, const char *flag,
+ const char *name, unsigned int min, int max,
+ int **valueP, const char *dflt,
+ const char *info, unsigned int *sawP);
+HEST_EXPORT unsigned int hestOptAdd_Nv_Int(hestOpt **hoptP, const char *flag,
+ const char *name, unsigned int min, int max,
+ int **valueP, const char *dflt,
+ const char *info, unsigned int *sawP);
+HEST_EXPORT unsigned int hestOptAdd_Nv_UInt(hestOpt **hoptP, const char *flag,
+ const char *name, unsigned int min, int max,
+ unsigned int **valueP, const char *dflt,
+ const char *info, unsigned int *sawP);
+HEST_EXPORT unsigned int hestOptAdd_Nv_LongInt(hestOpt **hoptP, const char *flag,
+ const char *name, unsigned int min,
+ int max, long int **valueP,
+ const char *dflt, const char *info,
+ unsigned int *sawP);
+HEST_EXPORT unsigned int hestOptAdd_Nv_ULongInt(hestOpt **hoptP, const char *flag,
+ const char *name, unsigned int min,
+ int max, unsigned long int **valueP,
+ const char *dflt, const char *info,
+ unsigned int *sawP);
+HEST_EXPORT unsigned int hestOptAdd_Nv_Size_t(hestOpt **hoptP, const char *flag,
+ const char *name, unsigned int min,
+ int max, size_t **valueP, const char *dflt,
+ const char *info, unsigned int *sawP);
+HEST_EXPORT unsigned int hestOptAdd_Nv_Float(hestOpt **hoptP, const char *flag,
+ const char *name, unsigned int min, int max,
+ float **valueP, const char *dflt,
+ const char *info, unsigned int *sawP);
+HEST_EXPORT unsigned int hestOptAdd_Nv_Double(hestOpt **hoptP, const char *flag,
+ const char *name, unsigned int min,
+ int max, double **valueP, const char *dflt,
+ const char *info, unsigned int *sawP);
+HEST_EXPORT unsigned int hestOptAdd_Nv_Char(hestOpt **hoptP, const char *flag,
+ const char *name, unsigned int min, int max,
+ char **valueP, const char *dflt,
+ const char *info, unsigned int *sawP);
+HEST_EXPORT unsigned int hestOptAdd_Nv_String(hestOpt **hoptP, const char *flag,
+ const char *name, unsigned int min,
+ int max, char ***valueP, const char *dflt,
+ const char *info, unsigned int *sawP);
+HEST_EXPORT unsigned int hestOptAdd_Nv_Enum(hestOpt **hoptP, const char *flag,
+ const char *name, unsigned int min, int max,
+ int **valueP, const char *dflt,
+ const char *info, unsigned int *sawP,
+ const airEnum *enm);
+HEST_EXPORT unsigned int hestOptAdd_Nv_Other(hestOpt **hoptP, const char *flag,
+ const char *name, unsigned int min, int max,
+ void *valueP, const char *dflt,
+ const char *info, unsigned int *sawP,
+ const hestCB *CB);
#ifdef __cplusplus
}
Modified: teem/trunk/src/hest/methodsHest.c
===================================================================
--- teem/trunk/src/hest/methodsHest.c 2023-07-11 12:45:20 UTC (rev 7070)
+++ teem/trunk/src/hest/methodsHest.c 2023-07-11 21:18:05 UTC (rev 7071)
@@ -96,17 +96,11 @@
/* opt_kind determines the kind (1,2,3,4, or 5) of an opt,
from being passed its min and max fields */
static int
-opt_kind(unsigned int _min, int _max) {
- int min, max;
+opt_kind(unsigned int min, int _max) {
+ int max;
- min = AIR_CAST(int, _min);
- if (min < 0) {
- /* invalid */
- return -1;
- }
-
max = _hestMax(_max);
- if (!(min <= max)) {
+ if (!(AIR_CAST(int, min) <= max)) {
/* invalid */
return -1;
}
@@ -121,7 +115,7 @@
return 2;
}
- if (2 <= min && 2 <= max && min == max) {
+ if (2 <= min && 2 <= max && AIR_CAST(int, min) == max) {
/* multiple fixed parameters */
return 3;
}
@@ -221,9 +215,10 @@
Note that this makes no attempt at error-checking; that is all in hestOptCheck
*/
void
-hestOptSingleSet(hestOpt *opt, const char *flag, const char *name, int type, int min,
- int max, void *valueP, const char *dflt, const char *info,
- unsigned int *sawP, const airEnum *enm, const hestCB *CB) {
+hestOptSingleSet(hestOpt *opt, const char *flag, const char *name, int type,
+ unsigned int min, int max, void *valueP, const char *dflt,
+ const char *info, unsigned int *sawP, const airEnum *enm,
+ const hestCB *CB) {
if (!opt) return;
opt->flag = airStrdup(flag);
@@ -262,9 +257,10 @@
Like hestOptAdd has done since 2013: returns UINT_MAX in case of error.
*/
unsigned int
-hestOptAdd_nva(hestOpt **optP, const char *flag, const char *name, int type, int min,
- int max, void *valueP, const char *dflt, const char *info,
- unsigned int *sawP, const airEnum *enm, const hestCB *CB) {
+hestOptAdd_nva(hestOpt **optP, const char *flag, const char *name, int type,
+ unsigned int min, int max, void *valueP, const char *dflt,
+ const char *info, unsigned int *sawP, const airEnum *enm,
+ const hestCB *CB) {
unsigned int retIdx;
/* NULL address of opt array: can't proceed */
@@ -287,8 +283,9 @@
** option just added. Returns UINT_MAX in case of error.
*/
unsigned int
-hestOptAdd(hestOpt **optP, const char *flag, const char *name, int type, int min,
- int max, void *valueP, const char *dflt, const char *info, ...) {
+hestOptAdd(hestOpt **optP, const char *flag, const char *name, int type,
+ unsigned int min, int max, void *valueP, const char *dflt, const char *info,
+ ...) {
unsigned int *sawP = NULL;
const airEnum *enm = NULL;
const hestCB *CB = NULL;
Modified: teem/trunk/src/hest/parseHest.c
===================================================================
--- teem/trunk/src/hest/parseHest.c 2023-07-11 12:45:20 UTC (rev 7070)
+++ teem/trunk/src/hest/parseHest.c 2023-07-11 21:18:05 UTC (rev 7071)
@@ -193,8 +193,11 @@
** _hestPanic()
**
** all error checking on the given hest array itself (not the
-** command line to be parsed). Also, sets the "kind" field of
-** the opt struct
+** command line to be parsed).
+**
+** Prior to 2023 code revisit; this used to set the "kind" in all the opts
+** but now that is more appropriately done at the time the option is added
+** (by hestOptAdd, hestOptAdd_nva, hestOptSingleSet, or hestOptAdd_*_*)
*/
int
_hestPanic(hestOpt *opt, char *err, const hestParm *parm) {
@@ -836,7 +839,7 @@
break;
case 4:
/* -------- optional single variables -------- */
- /* if the flag appeared (if there is a flag) but the paramter didn't,
+ /* if the flag appeared (if there is a flag) but the parameter didn't,
we'll "invert" the default; if the flag didn't appear (or if there
isn't a flag) and the parameter also didn't appear, we'll use the
default. In either case, nprm[op] will be zero, and in both cases,
@@ -1156,6 +1159,39 @@
/* -------- optional single variables -------- */
if (prms[op] && vP) {
switch (type) {
+ case airTypeChar:
+ /* no "inversion" for chars: using the flag with no parameter is the same as
+ not using the flag i.e. we just parse from the default string */
+ if (1 != airParseStr[type](vP, prms[op], " ", 1)) {
+ sprintf(err, "%scouldn't parse %s\"%s\" as %s for %s", ME,
+ udflt[op] ? "(default) " : "", prms[op], airTypeStr[type], ident);
+ return 1;
+ }
+ opt[op].alloc = 0;
+ break;
+ case airTypeString:
+ /* this is a bizarre case: optional single string, with some kind of value
+ "inversion". 2023 GLK would prefer to make this like Char, Enum, and Other: for
+ which there is no attempt at "inversion". But for some reason the inversion of
+ a non-empty default string to a NULL string value, when the flag is used
+ without a parameter, was implemented from the early days of hest. Assuming
+ that a younger GLK long ago had a reason for that, that functionality now
+ persists.*/
+ if (1 != airParseStr[type](vP, prms[op], " ", 1, parm->greedySingleString)) {
+ sprintf(err, "%scouldn't parse %s\"%s\" as %s for %s", ME,
+ udflt[op] ? "(default) " : "", prms[op], airTypeStr[type], ident);
+ return 1;
+ }
+ opt[op].alloc = 1;
+ if (opt[op].flag && 1 == whichCase(opt, udflt, nprm, appr, op)) {
+ /* we just parsed the default, but now we want to "invert" it */
+ *((char **)vP) = (char *)airFree(*((char **)vP));
+ opt[op].alloc = 0;
+ }
+ /* vP is the address of a char* (a char**), and what we
+ manage with airMop is the char * */
+ airMopMem(pmop, vP, airMopOnError);
+ break;
case airTypeEnum:
if (1 != airParseStrE((int *)vP, prms[op], " ", 1, opt[op].enm)) {
sprintf(err, "%scouldn't parse %s\"%s\" as %s for %s", ME,
@@ -1164,7 +1200,7 @@
}
break;
case airTypeOther:
- /* we're parsing an "other". We will not perform the special
+ /* we're parsing an single single "other". We will not perform the special
flagged single variable parameter games as done above, so
whether this option is flagged or unflagged, we're going
to treat it like an unflagged single variable parameter option:
@@ -1189,22 +1225,6 @@
airMopAdd(pmop, *((void **)vP), opt[op].CB->destroy, airMopOnError);
}
break;
- case airTypeString:
- if (1 != airParseStr[type](vP, prms[op], " ", 1, parm->greedySingleString)) {
- sprintf(err, "%scouldn't parse %s\"%s\" as %s for %s", ME,
- udflt[op] ? "(default) " : "", prms[op], airTypeStr[type], ident);
- return 1;
- }
- opt[op].alloc = 1;
- if (opt[op].flag && 1 == whichCase(opt, udflt, nprm, appr, op)) {
- /* we just parsed the default, but now we want to "invert" it */
- *((char **)vP) = (char *)airFree(*((char **)vP));
- opt[op].alloc = 0;
- }
- /* vP is the address of a char* (a char**), and what we
- manage with airMop is the char * */
- airMopMem(pmop, vP, airMopOnError);
- break;
default:
if (1 != airParseStr[type](vP, prms[op], " ", 1)) {
sprintf(err, "%scouldn't parse %s\"%s\" as %s for %s", ME,
Modified: teem/trunk/src/hest/test/ex6.c
===================================================================
--- teem/trunk/src/hest/test/ex6.c 2023-07-11 12:45:20 UTC (rev 7070)
+++ teem/trunk/src/hest/test/ex6.c 2023-07-11 21:18:05 UTC (rev 7071)
@@ -92,6 +92,7 @@
/* going past C89 to have declarations here */
int flag;
hestOptAdd_Flag(&opt, "f,flag", &flag, "a flag created via hestOptAdd_Flag");
+
int b1;
hestOptAdd_1_Bool(&opt, "b1", "bool1", &b1, "false", "test of hestOptAdd_1_Bool");
int i1;
@@ -124,8 +125,43 @@
Quat *q1;
hestOptAdd_1_Other(&opt, "q1", "quat", &q1, "12.34", "test of hestOptAdd_1_Other B",
&quatCB);
- printf("----- &q1 = %p\n", &q1);
+ int b1v;
+ hestOptAdd_1v_Bool(&opt, "b1v", "bool1", &b1v, "false", "test of hestOptAdd_1v_Bool");
+ int i1v;
+ hestOptAdd_1v_Int(&opt, "i1v", "int1", &i1v, "42", "test of hestOptAdd_1v_Int");
+ unsigned int ui1v;
+ hestOptAdd_1v_UInt(&opt, "ui1v", "uint1", &ui1v, "42", "test of hestOptAdd_1v_UInt");
+ long int li1v;
+ hestOptAdd_1v_LongInt(&opt, "li1v", "lint1", &li1v, "42",
+ "test of hestOptAdd_1v_LongInt");
+ unsigned long int uli1v;
+ hestOptAdd_1v_ULongInt(&opt, "uli1v", "ulint1", &uli1v, "42",
+ "test of hestOptAdd_1v_ULongInt");
+ size_t sz1v;
+ hestOptAdd_1v_Size_t(&opt, "sz1v", "size1", &sz1v, "42",
+ "test of hestOptAdd_1v_Size_t");
+ float fl1v;
+ hestOptAdd_1v_Float(&opt, "fl1v", "float1", &fl1v, "0.0",
+ "test of hestOptAdd_1v_Float");
+ double db1v;
+ hestOptAdd_1v_Double(&opt, "db1v", "double1", &db1v, "4.2",
+ "test of hestOptAdd_1v_Double");
+ char c1v;
+ hestOptAdd_1v_Char(&opt, "c1v", "char1", &c1v, "x", "test of hestOptAdd_1v_Char");
+ char *s1v;
+ hestOptAdd_1v_String(&opt, "s1v", "string1", &s1v, "bingo",
+ "test of hestOptAdd_1v_String");
+ int e1v;
+ hestOptAdd_1v_Enum(&opt, "e1v", "enum1", &e1v, "little", "test of hestOptAdd_1v_Enum",
+ airEndian);
+ double p1v[2];
+ hestOptAdd_1v_Other(&opt, "p1v", "pos", &p1v, "1.5,5.25",
+ "test of hestOptAdd_1v_Other A", &posCB);
+ Quat *q1v;
+ hestOptAdd_1v_Other(&opt, "q1v", "quat", &q1v, "12.34",
+ "test of hestOptAdd_1v_Other B", &quatCB);
+
int b2[2];
hestOptAdd_2_Bool(&opt, "b2", "bool1 bool2", b2, "true false",
"test of hestOptAdd_2_Bool");
@@ -289,10 +325,74 @@
"15.55 55.51 66.77 88.99 100.2", "test of hestOptAdd_N_Other B",
&quatCB);
+ /* HEY also try 0, -1 */
+ int *bv;
+ unsigned int bvSaw;
+ hestOptAdd_Nv_Bool(&opt, "bv", "bool1 bool2", 1, -1, &bv, "true false",
+ "test of hestOptAdd_Nv_Bool", &bvSaw);
+ int *iv;
+ unsigned int ivSaw;
+ hestOptAdd_Nv_Int(&opt, "iv", "int1 ...", 1, -1, &iv, "42 24",
+ "test of hestOptAdd_Nv_Int", &ivSaw);
+ unsigned int *uiv;
+ unsigned int uivSaw;
+ hestOptAdd_Nv_UInt(&opt, "uiv", "uint1 uint2", 1, -1, &uiv, "42 24",
+ "test of hestOptAdd_Nv_UInt", &uivSaw);
+ long int *liv;
+ unsigned int livSaw;
+ hestOptAdd_Nv_LongInt(&opt, "liv", "lint1 ...", 1, -1, &liv, "42 24",
+ "test of hestOptAdd_Nv_LongInt", &livSaw);
+ unsigned long int *uliv;
+ unsigned int ulivSaw;
+ hestOptAdd_Nv_ULongInt(&opt, "uliv", "ulint1 ...", 1, -1, &uliv, "42 24",
+ "test of hestOptAdd_Nv_ULongInt", &ulivSaw);
+ size_t *szv;
+ unsigned int szvSaw;
+ hestOptAdd_Nv_Size_t(&opt, "szv", "size1 ...", 1, -1, &szv, "42 24",
+ "test of hestOptAdd_Nv_Size_t", &szvSaw);
+ float *flv;
+ unsigned int flvSaw;
+ hestOptAdd_Nv_Float(&opt, "flv", "float1 ...", 1, -1, &flv, "4.2 2.4",
+ "test of hestOptAdd_Nv_Float", &flvSaw);
+ double *dbv;
+ unsigned int dbvSaw;
+ hestOptAdd_Nv_Double(&opt, "dbv", "double1 ...", 1, -1, &dbv, "4.2 2.4",
+ "test of hestOptAdd_Nv_Double", &dbvSaw);
+ char *cv;
+ unsigned int cvSaw;
+ hestOptAdd_Nv_Char(&opt, "cv", "char1 ...", 1, -1, &cv, "x y",
+ "test of hestOptAdd_Nv_Char", &cvSaw);
+ char **sv;
+ unsigned int svSaw;
+ hestOptAdd_Nv_String(&opt, "sv", "str1 ...", 1, -1, &sv, "bingo bob",
+ "test of hestOptAdd_Nv_String", &svSaw);
+ int *ev;
+ unsigned int evSaw;
+ hestOptAdd_Nv_Enum(&opt, "ev", "enum1 ...", 1, -1, &ev, "little big",
+ "test of hestOptAdd_Nv_Enum", &evSaw, airEndian);
+ double *pv;
+ unsigned int pvSaw;
+ hestOptAdd_Nv_Other(&opt, "pv", "pos1 ...", 1, -1, &pv, "1.5,5.25 2.9,9.2",
+ "test of hestOptAdd_Nv_Other A", &pvSaw, &posCB);
+ Quat **qv;
+ unsigned int qvSaw;
+ hestOptAdd_Nv_Other(&opt, "qv", "quat1 ...", 1, -1, &qv, "12.34 43.21",
+ "test of hestOptAdd_Nv_Other B", &qvSaw, &quatCB);
+
+ if (2 == argc && !strcmp("decls", argv[1])) {
+ printf("Writing decls.h and then bailing ...\n");
+ FILE *ff = fopen("decls.h", "w");
+ hestOptAddDeclsPrint(ff);
+ fclose(ff);
+ exit(0);
+ }
+ /* else not writing decls.h; remove it to ensure freshness */
+ remove("decls.h");
+
hestParseOrDie(opt, argc - 1, argv + 1, parm, argv[0], info, AIR_TRUE, AIR_TRUE,
AIR_TRUE);
- if (1) {
+ if (0) {
unsigned int opi, numO;
numO = hestOptNum(opt);
for (opi = 0; opi < numO; opi++) {
@@ -305,40 +405,51 @@
printf(" parmStr=|%s|\n", opt[opi].parmStr ? opt[opi].parmStr : "(null)");
}
}
- if (1) {
- printf("(err = %s)\n", err ? err : "(null)");
- printf("flag = %d\n", flag);
- printf("b1 = %d\n", b1);
- printf("i1 = %d\n", i1);
- printf("ui1 = %u\n", ui1);
- printf("li1 = %ld\n", li1);
- printf("uli1 = %lu\n", uli1);
- printf("sz1 = %zu\n", sz1);
- printf("fl1 = %g\n", fl1);
- printf("db1 = %g\n", db1);
- printf("c1 = %c\n", c1);
- printf("s1 = |%s|\n", s1);
- ...
[truncated message content] |
|
From: <kin...@us...> - 2023-07-11 12:45:23
|
Revision: 7070
http://sourceforge.net/p/teem/code/7070
Author: kindlmann
Date: 2023-07-11 12:45:20 +0000 (Tue, 11 Jul 2023)
Log Message:
-----------
notes on type safety
Modified Paths:
--------------
teem/trunk/src/hest/adders.c
Modified: teem/trunk/src/hest/adders.c
===================================================================
--- teem/trunk/src/hest/adders.c 2023-07-11 06:14:44 UTC (rev 7069)
+++ teem/trunk/src/hest/adders.c 2023-07-11 12:45:20 UTC (rev 7070)
@@ -22,6 +22,40 @@
#include "hest.h"
#include "privateHest.h"
+/*
+Since r6184 2014-03-17, GLK has noted (in ../TODO.txt):
+ (from tendGlyph.c): there needs to be an alternative API for hest
+ that is not var-args based (as is hestOptAdd). You can't tell when
+ you've passed multiple strings for the detailed usage information by
+ accident. GLK had accidentally inserted a comma into my multi-line
+ string for the "info" arg, relying on the automatic string
+ concatenation, and ended up passing total garbage to hestOptAdd for
+ the airEnum pointer, causing him to think that the tenGlyphType airEnum
+ was malformed, when it was in fact fine ...
+This motivated the r7026 2023-07-06 addition of hestOptAdd_nva, which
+would have caught the above error.
+
+The underlying issue there, though, is the total lack of type-checking associated with
+the var-args functions. The functions in this file help do as much type-checking as
+possible with hest. These functions cover nearly all uses of hest within Teem (and in
+GLK's SciVIs class), in a way that is specific to the type of the value storage pointer
+valueP, which is still a void* even in hestOptAdd_nva. Many of the possibilities here
+are unlikely to be needed (an option for 4 booleans?), but are generated here for
+completeness (an option for 4 floats or 4 doubles is great for R,G,B,A).
+
+However with airTypeOther, in which case the caller passes a hestCB struct of callbacks
+to parse arbitrary things from the command-line, there is still unfortunately a
+type-checking black hole void* involved. And, there is no away around that:
+the non-NULL-ity of hestCB->destroy determines wether the thing being parsed is
+merely space to be initialized (valueP is an array of structs), versus a
+struct to be allocated (valueP is an array of pointers to structs), we want that to
+determine the type of valueP. But the struct itself as to be void type, and void** is
+not a generic pointer to pointer type (like void* is the generic pointer type). Still
+the _Other versions of the function are generated here to slightly simplify the
+hestOptAdd call (no more NULL, NULL for sawP and enum). Actually, there is around
+a type-checking black hole: extreme attentiveness!
+*/
+
/* --------------------------------------------------------------- 1 == kind */
unsigned int
hestOptAdd_Flag(hestOpt **hoptP, const char *flag, int *valueP, const char *info) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <kin...@us...> - 2023-07-11 06:14:46
|
Revision: 7069
http://sourceforge.net/p/teem/code/7069
Author: kindlmann
Date: 2023-07-11 06:14:44 +0000 (Tue, 11 Jul 2023)
Log Message:
-----------
progress made
Modified Paths:
--------------
teem/trunk/src/hest/adders.c
Modified: teem/trunk/src/hest/adders.c
===================================================================
--- teem/trunk/src/hest/adders.c 2023-07-11 05:55:51 UTC (rev 7068)
+++ teem/trunk/src/hest/adders.c 2023-07-11 06:14:44 UTC (rev 7069)
@@ -134,8 +134,8 @@
/* --------------------------------------------------------------- 2 == kind */
/* for some reason writing out code above (and their declarations in hest.h) by hand was
-ok, but from here on out its going to use a lot of macro tricks, with these name
-conventions:
+tolerated, but from here on out the coding is going to use a lot of macro tricks, with
+these name conventions:
M = 2, 3, or 4 = fixed # of parameters
N = user-given fixed # of parameters
@@ -274,7 +274,7 @@
#define PRINT_N_O fprintf(ff, "HEST_EXPORT " _STR(DCL_N_O) ";\n");
/* prints declarations for everything defined by macro above, which
-HEY does not includethe hestOptAdd_Flag and hestOptAdd_1_* functions */
+HEY does not include the hestOptAdd_Flag and hestOptAdd_1_* functions */
void
hestOptAddDeclsPrint(FILE *ff) {
/* HEY copy-pasta from "Actual code" above */
@@ -294,7 +294,6 @@
/*
hestOptSetXX(hestOpt *opt, )
-1<T>, 2<T>, 3<T>, 4<T>, N<T>
1v<T>, Nv<T> need sawP
<T>=
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <kin...@us...> - 2023-07-11 05:55:54
|
Revision: 7068
http://sourceforge.net/p/teem/code/7068
Author: kindlmann
Date: 2023-07-11 05:55:51 +0000 (Tue, 11 Jul 2023)
Log Message:
-----------
type-specific kinds 1, 2, and 3 now all finished
Modified Paths:
--------------
teem/trunk/src/hest/adders.c
teem/trunk/src/hest/hest.h
teem/trunk/src/hest/parseHest.c
teem/trunk/src/hest/test/ex6.c
Modified: teem/trunk/src/hest/adders.c
===================================================================
--- teem/trunk/src/hest/adders.c 2023-07-10 18:48:53 UTC (rev 7067)
+++ teem/trunk/src/hest/adders.c 2023-07-11 05:55:51 UTC (rev 7068)
@@ -24,9 +24,9 @@
/* --------------------------------------------------------------- 1 == kind */
unsigned int
-hestOptAdd_Flag(hestOpt **optP, const char *flag, int *valueP, const char *info) {
+hestOptAdd_Flag(hestOpt **hoptP, const char *flag, int *valueP, const char *info) {
- return hestOptAdd_nva(optP, flag, NULL /* name */, airTypeInt /* actually moot */,
+ return hestOptAdd_nva(hoptP, flag, NULL /* name */, airTypeInt /* actually moot */,
0 /* min */, 0 /* max */, valueP, NULL /* default */, info, /* */
NULL, NULL, NULL);
}
@@ -33,223 +33,265 @@
/* --------------------------------------------------------------- 2 == kind */
unsigned int
-hestOptAdd_1_Bool(hestOpt **optP, const char *flag, const char *name, /* */
- int *valueP, int dflt, const char *info) {
- char dfltStr[AIR_STRLEN_SMALL + 1];
- sprintf(dfltStr, "%s", airEnumStr(airBool, !!dflt));
- return hestOptAdd_nva(optP, flag, name, airTypeBool, 1, 1, /* */
- valueP, dfltStr, info, /* */
+hestOptAdd_1_Bool(hestOpt **hoptP, const char *flag, const char *name, /* */
+ int *valueP, const char *dflt, const char *info) {
+ return hestOptAdd_nva(hoptP, flag, name, airTypeBool, 1, 1, /* */
+ valueP, dflt, info, /* */
NULL, NULL, NULL);
}
unsigned int
-hestOptAdd_1_Int(hestOpt **optP, const char *flag, const char *name, /* */
- int *valueP, int dflt, const char *info) {
- char dfltStr[AIR_STRLEN_SMALL + 1];
- sprintf(dfltStr, "%d", dflt);
- return hestOptAdd_nva(optP, flag, name, airTypeInt, 1, 1, /* */
- valueP, dfltStr, info, /* */
+hestOptAdd_1_Int(hestOpt **hoptP, const char *flag, const char *name, /* */
+ int *valueP, const char *dflt, const char *info) {
+ return hestOptAdd_nva(hoptP, flag, name, airTypeInt, 1, 1, /* */
+ valueP, dflt, info, /* */
NULL, NULL, NULL);
}
unsigned int
-hestOptAdd_1_UInt(hestOpt **optP, const char *flag, const char *name, /* */
- unsigned int *valueP, unsigned int dflt, const char *info) {
- char dfltStr[AIR_STRLEN_SMALL + 1];
- sprintf(dfltStr, "%u", dflt);
- return hestOptAdd_nva(optP, flag, name, airTypeUInt, 1, 1, /* */
- valueP, dfltStr, info, /* */
+hestOptAdd_1_UInt(hestOpt **hoptP, const char *flag, const char *name, /* */
+ unsigned int *valueP, const char *dflt, const char *info) {
+ return hestOptAdd_nva(hoptP, flag, name, airTypeUInt, 1, 1, /* */
+ valueP, dflt, info, /* */
NULL, NULL, NULL);
}
unsigned int
-hestOptAdd_1_LongInt(hestOpt **optP, const char *flag, const char *name, /* */
- long int *valueP, long int dflt, const char *info) {
- char dfltStr[AIR_STRLEN_SMALL + 1];
- sprintf(dfltStr, "%ld", dflt);
- return hestOptAdd_nva(optP, flag, name, airTypeLongInt, 1, 1, /* */
- valueP, dfltStr, info, /* */
+hestOptAdd_1_LongInt(hestOpt **hoptP, const char *flag, const char *name, /* */
+ long int *valueP, const char *dflt, const char *info) {
+ return hestOptAdd_nva(hoptP, flag, name, airTypeLongInt, 1, 1, /* */
+ valueP, dflt, info, /* */
NULL, NULL, NULL);
}
unsigned int
-hestOptAdd_1_ULongInt(hestOpt **optP, const char *flag, const char *name, /* */
- unsigned long int *valueP, unsigned long int dflt,
- const char *info) {
- char dfltStr[AIR_STRLEN_SMALL + 1];
- sprintf(dfltStr, "%lu", dflt);
- return hestOptAdd_nva(optP, flag, name, airTypeULongInt, 1, 1, /* */
- valueP, dfltStr, info, /* */
+hestOptAdd_1_ULongInt(hestOpt **hoptP, const char *flag, const char *name, /* */
+ unsigned long int *valueP, const char *dflt, const char *info) {
+ return hestOptAdd_nva(hoptP, flag, name, airTypeULongInt, 1, 1, /* */
+ valueP, dflt, info, /* */
NULL, NULL, NULL);
}
unsigned int
-hestOptAdd_1_Size_t(hestOpt **optP, const char *flag, const char *name, /* */
- size_t *valueP, size_t dflt, const char *info) {
- char dfltStr[AIR_STRLEN_SMALL + 1];
- airSprintSize_t(dfltStr, dflt);
- return hestOptAdd_nva(optP, flag, name, airTypeSize_t, 1, 1, /* */
- valueP, dfltStr, info, /* */
+hestOptAdd_1_Size_t(hestOpt **hoptP, const char *flag, const char *name, /* */
+ size_t *valueP, const char *dflt, const char *info) {
+ return hestOptAdd_nva(hoptP, flag, name, airTypeSize_t, 1, 1, /* */
+ valueP, dflt, info, /* */
NULL, NULL, NULL);
}
unsigned int
-hestOptAdd_1_Float(hestOpt **optP, const char *flag, const char *name, /* */
- float *valueP, float dflt, const char *info) {
- char dfltStr[AIR_STRLEN_SMALL + 1];
- airSinglePrintf(NULL, dfltStr, "%g", dflt);
- return hestOptAdd_nva(optP, flag, name, airTypeFloat, 1, 1, /* */
- valueP, dfltStr, info, /* */
+hestOptAdd_1_Float(hestOpt **hoptP, const char *flag, const char *name, /* */
+ float *valueP, const char *dflt, const char *info) {
+ return hestOptAdd_nva(hoptP, flag, name, airTypeFloat, 1, 1, /* */
+ valueP, dflt, info, /* */
NULL, NULL, NULL);
}
unsigned int
-hestOptAdd_1_Double(hestOpt **optP, const char *flag, const char *name, /* */
- double *valueP, double dflt, const char *info) {
- char dfltStr[AIR_STRLEN_SMALL + 1];
- airSinglePrintf(NULL, dfltStr, "%lg", dflt);
- return hestOptAdd_nva(optP, flag, name, airTypeDouble, 1, 1, /* */
- valueP, dfltStr, info, /* */
+hestOptAdd_1_Double(hestOpt **hoptP, const char *flag, const char *name, /* */
+ double *valueP, const char *dflt, const char *info) {
+ return hestOptAdd_nva(hoptP, flag, name, airTypeDouble, 1, 1, /* */
+ valueP, dflt, info, /* */
NULL, NULL, NULL);
}
unsigned int
-hestOptAdd_1_Char(hestOpt **optP, const char *flag, const char *name, /* */
- char *valueP, char dflt, const char *info) {
- char dfltStr[AIR_STRLEN_SMALL + 1];
- sprintf(dfltStr, "%c", dflt);
- return hestOptAdd_nva(optP, flag, name, airTypeChar, 1, 1, /* */
- valueP, dfltStr, info, /* */
+hestOptAdd_1_Char(hestOpt **hoptP, const char *flag, const char *name, /* */
+ char *valueP, const char *dflt, const char *info) {
+ return hestOptAdd_nva(hoptP, flag, name, airTypeChar, 1, 1, /* */
+ valueP, dflt, info, /* */
NULL, NULL, NULL);
}
unsigned int
-hestOptAdd_1_String(hestOpt **optP, const char *flag, const char *name, /* */
+hestOptAdd_1_String(hestOpt **hoptP, const char *flag, const char *name, /* */
char **valueP, const char *dflt, const char *info) {
- return hestOptAdd_nva(optP, flag, name, airTypeString, 1, 1, /* */
- valueP, dflt, info, /* */
+ return hestOptAdd_nva(hoptP, flag, name, airTypeString, 1, 1, /* */
+ valueP, dflt, info, /* */
NULL, NULL, NULL);
}
unsigned int
-hestOptAdd_1_Enum(hestOpt **optP, const char *flag, const char *name, /* */
- int *valueP, int dflt, const char *info, /* */
+hestOptAdd_1_Enum(hestOpt **hoptP, const char *flag, const char *name, /* */
+ int *valueP, const char *dflt, const char *info, /* */
const airEnum *enm) {
- return hestOptAdd_nva(optP, flag, name, airTypeEnum, 1, 1, /* */
- valueP, airEnumStr(enm, dflt), info, /* */
+ return hestOptAdd_nva(hoptP, flag, name, airTypeEnum, 1, 1, /* */
+ valueP, dflt, info, /* */
NULL, enm, NULL);
}
unsigned int
-hestOptAdd_1_Other(hestOpt **optP, const char *flag, const char *name, /* */
- void *valueP, const char *dflt, const char *info, /* */
+hestOptAdd_1_Other(hestOpt **hoptP, const char *flag, const char *name, /* */
+ void *valueP, const char *dflt, const char *info, /* */
const hestCB *CB) {
- return hestOptAdd_nva(optP, flag, name, airTypeOther, 1, 1, /* */
- valueP, dflt, info, /* */
+ return hestOptAdd_nva(hoptP, flag, name, airTypeOther, 1, 1, /* */
+ valueP, dflt, info, /* */
NULL, NULL, CB);
}
-#if 0
+
/* --------------------------------------------------------------- 2 == kind */
-unsigned int
-hestOptAdd_2_Bool(hestOpt **optP, const char *flag, const char *name, /* */
- int valueP[2], const char *dflt, const char *info) {
- return hestOptAdd_nva(optP, flag, name, airTypeBool, 2, 2, /* */
- valueP, dflt, info, /* */
- NULL, NULL, NULL);
-}
-unsigned int
-hestOptAdd_2_Int(hestOpt **optP, const char *flag, const char *name, /* */
- int valueP[2], const char *dflt, const char *info) {
- return hestOptAdd_nva(optP, flag, name, airTypeInt, 2, 2, /* */
- valueP, dflt, info, /* */
- NULL, NULL, NULL);
-}
+/* for some reason writing out code above (and their declarations in hest.h) by hand was
+ok, but from here on out its going to use a lot of macro tricks, with these name
+conventions:
-unsigned int
-hestOptAdd_2_UInt(hestOpt **optP, const char *flag, const char *name, /* */
- unsigned int valueP[3], const char *dflt, const char *info) {
- return hestOptAdd_nva(optP, flag, name, airTypeUInt, 2, 2, /* */
- valueP, dflt, info, /* */
- NULL, NULL, NULL);
-}
+M = 2, 3, or 4 = fixed # of parameters
+N = user-given fixed # of parameters
+_S = simple scalar types
+_E = airEnum
+_O = Other
-unsigned int
-hestOptAdd_2_LongInt(hestOpt **optP, const char *flag, const char *name, /* */
- long int valueP[2], const char *dflt, const char *info) {
- return hestOptAdd_nva(optP, flag, name, airTypeLongInt, 2, 2, /* */
- valueP, dflt, info, /* */
- NULL, NULL, NULL);
-}
+Some way of gracefully handling the 10 different simple types, plus the airEnum and
+Other, with the context of the functional-ish MAP macros, is surely possible, but it
+eludes GLK at this time */
-unsigned int
-hestOptAdd_2_ULongInt(hestOpt **optP, const char *flag, const char *name, /* */
- unsigned long int valueP[2], const char *dflt, const char *info) {
- return hestOptAdd_nva(optP, flag, name, airTypeULongInt, 2, 2, /* */
- valueP, dflt, info, /* */
- NULL, NULL, NULL);
-}
+/* _S: simple scalar types */
+#define DCL_M_S(M, ATYP, CTYP) \
+ unsigned int hestOptAdd_##M##_##ATYP(hestOpt **hoptP, const char *flag, \
+ const char *name, CTYP valueP[M], \
+ const char *dflt, const char *info)
+#define BODY_M_S(M, ATYP, CTYP) \
+ { \
+ return hestOptAdd_nva(hoptP, flag, name, airType##ATYP, M, M, valueP, dflt, info, \
+ NULL, NULL, NULL); \
+ }
+#define DEF_M_S(M, ATYP, CTYP) DCL_M_S(M, ATYP, CTYP) BODY_M_S(M, ATYP, CTYP)
+#define DCL_N_S(ATYP, CTYP) \
+ unsigned int hestOptAdd_N_##ATYP(hestOpt **hoptP, const char *flag, const char *name, \
+ unsigned int N, CTYP *valueP, const char *dflt, \
+ const char *info)
+#define BODY_N_S(ATYP, CTYP) \
+ { \
+ return hestOptAdd_nva(hoptP, flag, name, airType##ATYP, N, N, valueP, dflt, info, \
+ NULL, NULL, NULL); \
+ }
+#define DEF_N_S(ATYP, CTYP) DCL_N_S(ATYP, CTYP) BODY_N_S(ATYP, CTYP)
-unsigned int
-hestOptAdd_2_Size_t(hestOpt **optP, const char *flag, const char *name, /* */
- size_t valueP[2], const char *dflt, const char *info) {
- return hestOptAdd_nva(optP, flag, name, airTypeSize_t, 2, 2, /* */
- valueP, dflt, info, /* */
- NULL, NULL, NULL);
-}
+/* _E: Enum */
+#define DCL_M_E(M) \
+ unsigned int hestOptAdd_##M##_Enum(hestOpt **hoptP, const char *flag, \
+ const char *name, int valueP[M], const char *dflt, \
+ const char *info, const airEnum *enm)
+#define BODY_M_E(M) \
+ { \
+ return hestOptAdd_nva(hoptP, flag, name, airTypeEnum, M, M, valueP, dflt, info, \
+ NULL, enm, NULL); \
+ }
+#define DEF_M_E(M) DCL_M_E(M) BODY_M_E(M)
+#define DCL_N_E \
+ unsigned int hestOptAdd_N_Enum(hestOpt **hoptP, const char *flag, const char *name, \
+ unsigned int N, int *valueP, const char *dflt, \
+ const char *info, const airEnum *enm)
+#define BODY_N_E \
+ { \
+ return hestOptAdd_nva(hoptP, flag, name, airTypeEnum, N, N, valueP, dflt, info, \
+ NULL, enm, NULL); \
+ }
+#define DEF_N_E DCL_N_E BODY_N_E
-unsigned int
-hestOptAdd_2_Float(hestOpt **optP, const char *flag, const char *name, /* */
- float valueP[2], const char *dflt, const char *info) {
- return hestOptAdd_nva(optP, flag, name, airTypeFloat, 2, 2, /* */
- valueP, dflt, info, /* */
- NULL, NULL, NULL);
-}
+/* _O: Other */
+#define DCL_M_O(M) \
+ unsigned int hestOptAdd_##M##_Other(hestOpt **hoptP, const char *flag, \
+ const char *name, void *valueP, const char *dflt, \
+ const char *info, const hestCB *CB)
+#define BODY_M_O(M) \
+ { \
+ return hestOptAdd_nva(hoptP, flag, name, airTypeOther, M, M, valueP, dflt, info, \
+ NULL, NULL, CB); \
+ }
+#define DEF_M_O(M) DCL_M_O(M) BODY_M_O(M)
+#define DCL_N_O \
+ unsigned int hestOptAdd_N_Other(hestOpt **hoptP, const char *flag, const char *name, \
+ unsigned int N, void *valueP, const char *dflt, \
+ const char *info, const hestCB *CB)
+#define BODY_N_O \
+ { \
+ return hestOptAdd_nva(hoptP, flag, name, airTypeOther, N, N, valueP, dflt, info, \
+ NULL, NULL, CB); \
+ }
+#define DEF_N_O DCL_N_O BODY_N_O
-unsigned int
-hestOptAdd_2_Double(hestOpt **optP, const char *flag, const char *name, /* */
- double valueP[2], const char *dflt, const char *info) {
- return hestOptAdd_nva(optP, flag, name, airTypeDouble, 2, 2, /* */
- valueP, dflt, info, /* */
- NULL, NULL, NULL);
-}
+/* MAP_M_S takes a macro MMAC that (like DCL_M_S or DEF_M_S) takes three args
+-- M, ATYP, CTYP -- and applies it to all the simple scalar types.
+MAP_N_S takes a macro NMAC (like DCL_N_S or DEF_N_S) that takes just two args
+-- ATYP, CTYPE -- and applies to the scalar types */
+#define MAP_M_S(MMAC, M) \
+ MMAC(M, Bool, int) \
+ MMAC(M, Int, int) \
+ MMAC(M, UInt, unsigned int) \
+ MMAC(M, LongInt, long int) \
+ MMAC(M, ULongInt, unsigned long int) \
+ MMAC(M, Size_t, size_t) \
+ MMAC(M, Float, float) \
+ MMAC(M, Double, double) \
+ MMAC(M, Char, char) \
+ MMAC(M, String, char *)
+/* (yes would be nicer to avoid copy-pasta, but how?) */
+#define MAP_N_S(NMAC) \
+ NMAC(Bool, int) \
+ NMAC(Int, int) \
+ NMAC(UInt, unsigned int) \
+ NMAC(LongInt, long int) \
+ NMAC(ULongInt, unsigned long int) \
+ NMAC(Size_t, size_t) \
+ NMAC(Float, float) \
+ NMAC(Double, double) \
+ NMAC(Char, char) \
+ NMAC(String, char *)
-unsigned int
-hestOptAdd_2_Char(hestOpt **optP, const char *flag, const char *name, /* */
- char valueP[2], const char *dflt, const char *info) {
- return hestOptAdd_nva(optP, flag, name, airTypeChar, 2, 2, /* */
- valueP, dflt, info, /* */
- NULL, NULL, NULL);
-}
+/* v.v.v.v.v.v.v.v.v Actual code! v.v.v.v.v.v.v.v.v */
+MAP_M_S(DEF_M_S, 2)
+DEF_M_E(2)
+DEF_M_O(2)
+MAP_M_S(DEF_M_S, 3)
+DEF_M_E(3)
+DEF_M_O(3)
+MAP_M_S(DEF_M_S, 4)
+DEF_M_E(4)
+DEF_M_O(4)
+MAP_N_S(DEF_N_S)
+DEF_N_E
+DEF_N_O
+/* ^'^'^'^'^'^'^'^'^'^'^'^'^'^'^'^'^'^'^'^'^'^'^'^'^'^'^ */
-unsigned int
-hestOptAdd_2_String(hestOpt **optP, const char *flag, const char *name, /* */
- char *valueP[2], const char *dflt, const char *info) {
- return hestOptAdd_nva(optP, flag, name, airTypeString, 2, 2, /* */
- valueP, dflt, info, /* */
- NULL, NULL, NULL);
-}
+/* Macro for making a string out of whatever something has been #define'd to, exactly,
+ without chasing down a sequence of #includes.
+ https://gcc.gnu.org/onlinedocs/cpp/Stringizing.html */
+#define __STR(name) #name
+#define _STR(name) __STR(name)
-unsigned int
-hestOptAdd_2_Enum(hestOpt **optP, const char *flag, const char *name, /* */
- int valueP[2], const char *dflt, const char *info, /* */
- const airEnum *enm) {
- return hestOptAdd_nva(optP, flag, name, airTypeEnum, 2, 2, /* */
- valueP, dflt, info, /* */
- NULL, enm, NULL);
-}
+/* for generating body of hestOptAddDeclsPrint;
+NOTE assuming the local FILE *ff */
+#define PRINT_M_S(M, ATYP, CTYP) \
+ fprintf(ff, "HEST_EXPORT " _STR(DCL_M_S(M, ATYP, CTYP)) ";\n");
+#define PRINT_M_E(M) fprintf(ff, "HEST_EXPORT " _STR(DCL_M_E(M)) ";\n");
+#define PRINT_M_O(M) fprintf(ff, "HEST_EXPORT " _STR(DCL_M_O(M)) ";\n");
+#define PRINT_N_S(ATYP, CTYP) \
+ fprintf(ff, "HEST_EXPORT " _STR(DCL_N_S(ATYP, CTYP)) ";\n");
+#define PRINT_N_E fprintf(ff, "HEST_EXPORT " _STR(DCL_N_E) ";\n");
+#define PRINT_N_O fprintf(ff, "HEST_EXPORT " _STR(DCL_N_O) ";\n");
-unsigned int
-hestOptAdd_2_Other(hestOpt **optP, const char *flag, const char *name, /* */
- void *valueP[2], const char *dflt, const char *info, /* */
- const hestCB *CB) {
- return hestOptAdd_nva(optP, flag, name, airTypeOther, 2, 2, /* */
- valueP, dflt, info, /* */
- NULL, NULL, CB);
+/* prints declarations for everything defined by macro above, which
+HEY does not includethe hestOptAdd_Flag and hestOptAdd_1_* functions */
+void
+hestOptAddDeclsPrint(FILE *ff) {
+ /* HEY copy-pasta from "Actual code" above */
+ MAP_M_S(PRINT_M_S, 2)
+ PRINT_M_E(2)
+ PRINT_M_O(2)
+ MAP_M_S(PRINT_M_S, 3)
+ PRINT_M_E(3)
+ PRINT_M_O(3)
+ MAP_M_S(PRINT_M_S, 4)
+ PRINT_M_E(4)
+ PRINT_M_O(4)
+ MAP_N_S(PRINT_N_S)
+ PRINT_N_E
+ PRINT_N_O
}
-#endif
/*
hestOptSetXX(hestOpt *opt, )
1<T>, 2<T>, 3<T>, 4<T>, N<T>
Modified: teem/trunk/src/hest/hest.h
===================================================================
--- teem/trunk/src/hest/hest.h 2023-07-10 18:48:53 UTC (rev 7067)
+++ teem/trunk/src/hest/hest.h 2023-07-11 05:55:51 UTC (rev 7068)
@@ -60,9 +60,9 @@
/*
******** hestCB struct
**
-** for when the thing you want to parse from the command-line is not a simple boolean,
-** number, airEnum, or string. hestParse() will not allocate anything to store
-** individual things, though it may allocate an array in the case of a multiple
+** for when the thing you want to parse from the command-line is airTypeOther: not a
+** simple boolean, number, string, or airEnum. hestParse() will not allocate anything to
+** store individual things, though it may allocate an array in the case of a multiple
** variable parameter option. If your things are actually pointers to things, then you
** do the allocation in the parse() callback. In this case, you set destroy() to be
** your "destructor", and it will be called on the result of derefencing the argument
@@ -287,46 +287,213 @@
const hestParm *parm);
/* adders.c */
+HEST_EXPORT void hestOptAddDeclsPrint(FILE *f);
HEST_EXPORT unsigned int hestOptAdd_Flag(hestOpt **optP, const char *flag, int *valueP,
const char *info);
HEST_EXPORT unsigned int hestOptAdd_1_Bool(hestOpt **optP, const char *flag,
- const char *name, int *valueP, int dflt,
- const char *info);
+ const char *name, int *valueP,
+ const char *dflt, const char *info);
HEST_EXPORT unsigned int hestOptAdd_1_Int(hestOpt **optP, const char *flag,
- const char *name, int *valueP, int dflt,
- const char *info);
+ const char *name, int *valueP,
+ const char *dflt, const char *info);
HEST_EXPORT unsigned int hestOptAdd_1_UInt(hestOpt **optP, const char *flag,
const char *name, unsigned int *valueP,
- unsigned int dflt, const char *info);
+ const char *dflt, const char *info);
HEST_EXPORT unsigned int hestOptAdd_1_LongInt(hestOpt **optP, const char *flag,
const char *name, long int *valueP,
- long int dflt, const char *info);
+ const char *dflt, const char *info);
HEST_EXPORT unsigned int hestOptAdd_1_ULongInt(hestOpt **optP, const char *flag,
const char *name,
unsigned long int *valueP,
- unsigned long int dflt, const char *info);
+ const char *dflt, const char *info);
HEST_EXPORT unsigned int hestOptAdd_1_Size_t(hestOpt **optP, const char *flag,
const char *name, size_t *valueP,
- size_t dflt, const char *info);
+ const char *dflt, const char *info);
HEST_EXPORT unsigned int hestOptAdd_1_Float(hestOpt **optP, const char *flag,
- const char *name, float *valueP, float dflt,
- const char *info);
+ const char *name, float *valueP,
+ const char *dflt, const char *info);
HEST_EXPORT unsigned int hestOptAdd_1_Double(hestOpt **optP, const char *flag,
const char *name, double *valueP,
- double dflt, const char *info);
+ const char *dflt, const char *info);
HEST_EXPORT unsigned int hestOptAdd_1_Char(hestOpt **optP, const char *flag,
- const char *name, char *valueP, char dflt,
- const char *info);
+ const char *name, char *valueP,
+ const char *dflt, const char *info);
HEST_EXPORT unsigned int hestOptAdd_1_String(hestOpt **optP, const char *flag,
const char *name, char **valueP,
const char *dflt, const char *info);
HEST_EXPORT unsigned int hestOptAdd_1_Enum(hestOpt **optP, const char *flag,
- const char *name, int *valueP, int dflt,
- const char *info, const airEnum *enm);
+ const char *name, int *valueP,
+ const char *dflt, const char *info,
+ const airEnum *enm);
HEST_EXPORT unsigned int hestOptAdd_1_Other(hestOpt **optP, const char *flag,
const char *name, void *valueP,
const char *dflt, const char *info,
const hestCB *CB);
+/* from here on, declarations are from calling hestOptAddDeclsPrint and then
+clang-formatting */
+HEST_EXPORT unsigned int hestOptAdd_2_Bool(hestOpt **hoptP, const char *flag,
+ const char *name, int valueP[2],
+ const char *dflt, const char *info);
+HEST_EXPORT unsigned int hestOptAdd_2_Int(hestOpt **hoptP, const char *flag,
+ const char *name, int valueP[2],
+ const char *dflt, const char *info);
+HEST_EXPORT unsigned int hestOptAdd_2_UInt(hestOpt **hoptP, const char *flag,
+ const char *name, unsigned int valueP[2],
+ const char *dflt, const char *info);
+HEST_EXPORT unsigned int hestOptAdd_2_LongInt(hestOpt **hoptP, const char *flag,
+ const char *name, long int valueP[2],
+ const char *dflt, const char *info);
+HEST_EXPORT unsigned int hestOptAdd_2_ULongInt(hestOpt **hoptP, const char *flag,
+ const char *name,
+ unsigned long int valueP[2],
+ const char *dflt, const char *info);
+HEST_EXPORT unsigned int hestOptAdd_2_Size_t(hestOpt **hoptP, const char *flag,
+ const char *name, size_t valueP[2],
+ const char *dflt, const char *info);
+HEST_EXPORT unsigned int hestOptAdd_2_Float(hestOpt **hoptP, const char *flag,
+ const char *name, float valueP[2],
+ const char *dflt, const char *info);
+HEST_EXPORT unsigned int hestOptAdd_2_Double(hestOpt **hoptP, const char *flag,
+ const char *name, double valueP[2],
+ const char *dflt, const char *info);
+HEST_EXPORT unsigned int hestOptAdd_2_Char(hestOpt **hoptP, const char *flag,
+ const char *name, char valueP[2],
+ const char *dflt, const char *info);
+HEST_EXPORT unsigned int hestOptAdd_2_String(hestOpt **hoptP, const char *flag,
+ const char *name, char *valueP[2],
+ const char *dflt, const char *info);
+HEST_EXPORT unsigned int hestOptAdd_2_Enum(hestOpt **hoptP, const char *flag,
+ const char *name, int valueP[2],
+ const char *dflt, const char *info,
+ const airEnum *enm);
+HEST_EXPORT unsigned int hestOptAdd_2_Other(hestOpt **hoptP, const char *flag,
+ const char *name, void *valueP,
+ const char *dflt, const char *info,
+ const hestCB *CB);
+HEST_EXPORT unsigned int hestOptAdd_3_Bool(hestOpt **hoptP, const char *flag,
+ const char *name, int valueP[3],
+ const char *dflt, const char *info);
+HEST_EXPORT unsigned int hestOptAdd_3_Int(hestOpt **hoptP, const char *flag,
+ const char *name, int valueP[3],
+ const char *dflt, const char *info);
+HEST_EXPORT unsigned int hestOptAdd_3_UInt(hestOpt **hoptP, const char *flag,
+ const char *name, unsigned int valueP[3],
+ const char *dflt, const char *info);
+HEST_EXPORT unsigned int hestOptAdd_3_LongInt(hestOpt **hoptP, const char *flag,
+ const char *name, long int valueP[3],
+ const char *dflt, const char *info);
+HEST_EXPORT unsigned int hestOptAdd_3_ULongInt(hestOpt **hoptP, const char *flag,
+ const char *name,
+ unsigned long int valueP[3],
+ const char *dflt, const char *info);
+HEST_EXPORT unsigned int hestOptAdd_3_Size_t(hestOpt **hoptP, const char *flag,
+ const char *name, size_t valueP[3],
+ const char *dflt, const char *info);
+HEST_EXPORT unsigned int hestOptAdd_3_Float(hestOpt **hoptP, const char *flag,
+ const char *name, float valueP[3],
+ const char *dflt, const char *info);
+HEST_EXPORT unsigned int hestOptAdd_3_Double(hestOpt **hoptP, const char *flag,
+ const char *name, double valueP[3],
+ const char *dflt, const char *info);
+HEST_EXPORT unsigned int hestOptAdd_3_Char(hestOpt **hoptP, const char *flag,
+ const char *name, char valueP[3],
+ const char *dflt, const char *info);
+HEST_EXPORT unsigned int hestOptAdd_3_String(hestOpt **hoptP, const char *flag,
+ const char *name, char *valueP[3],
+ const char *dflt, const char *info);
+HEST_EXPORT unsigned int hestOptAdd_3_Enum(hestOpt **hoptP, const char *flag,
+ const char *name, int valueP[3],
+ const char *dflt, const char *info,
+ const airEnum *enm);
+HEST_EXPORT unsigned int hestOptAdd_3_Other(hestOpt **hoptP, const char *flag,
+ const char *name, void *valueP,
+ const char *dflt, const char *info,
+ const hestCB *CB);
+HEST_EXPORT unsigned int hestOptAdd_4_Bool(hestOpt **hoptP, const char *flag,
+ const char *name, int valueP[4],
+ const char *dflt, const char *info);
+HEST_EXPORT unsigned int hestOptAdd_4_Int(hestOpt **hoptP, const char *flag,
+ const char *name, int valueP[4],
+ const char *dflt, const char *info);
+HEST_EXPORT unsigned int hestOptAdd_4_UInt(hestOpt **hoptP, const char *flag,
+ const char *name, unsigned int valueP[4],
+ const char *dflt, const char *info);
+HEST_EXPORT unsigned int hestOptAdd_4_LongInt(hestOpt **hoptP, const char *flag,
+ const char *name, long int valueP[4],
+ const char *dflt, const char *info);
+HEST_EXPORT unsigned int hestOptAdd_4_ULongInt(hestOpt **hoptP, const char *flag,
+ const char *name,
+ unsigned long int valueP[4],
+ const char *dflt, const char *info);
+HEST_EXPORT unsigned int hestOptAdd_4_Size_t(hestOpt **hoptP, const char *flag,
+ const char *name, size_t valueP[4],
+ const char *dflt, const char *info);
+HEST_EXPORT unsigned int hestOptAdd_4_Float(hestOpt **hoptP, const char *flag,
+ const char *name, float valueP[4],
+ const char *dflt, const char *info);
+HEST_EXPORT unsigned int hestOptAdd_4_Double(hestOpt **hoptP, const char *flag,
+ const char *name, double valueP[4],
+ const char *dflt, const char *info);
+HEST_EXPORT unsigned int hestOptAdd_4_Char(hestOpt **hoptP, const char *flag,
+ const char *name, char valueP[4],
+ const char *dflt, const char *info);
+HEST_EXPORT unsigned int hestOptAdd_4_String(hestOpt **hoptP, const char *flag,
+ const char *name, char *valueP[4],
+ const char *dflt, const char *info);
+HEST_EXPORT unsigned int hestOptAdd_4_Enum(hestOpt **hoptP, const char *flag,
+ const char *name, int valueP[4],
+ const char *dflt, const char *info,
+ const airEnum *enm);
+HEST_EXPORT unsigned int hestOptAdd_4_Other(hestOpt **hoptP, const char *flag,
+ const char *name, void *valueP,
+ const char *dflt, const char *info,
+ const hestCB *CB);
+HEST_EXPORT unsigned int hestOptAdd_N_Bool(hestOpt **hoptP, const char *flag,
+ const char *name, unsigned int N, int *valueP,
+ const char *dflt, const char *info);
+HEST_EXPORT unsigned int hestOptAdd_N_Int(hestOpt **hoptP, const char *flag,
+ const char *name, unsigned int N, int *valueP,
+ const char *dflt, const char *info);
+HEST_EXPORT unsigned int hestOptAdd_N_UInt(hestOpt **hoptP, const char *flag,
+ const char *name, unsigned int N,
+ unsigned int *valueP, const char *dflt,
+ const char *info);
+HEST_EXPORT unsigned int hestOptAdd_N_LongInt(hestOpt **hoptP, const char *flag,
+ const char *name, unsigned int N,
+ long int *valueP, const char *dflt,
+ const char *info);
+HEST_EXPORT unsigned int hestOptAdd_N_ULongInt(hestOpt **hoptP, const char *flag,
+ const char *name, unsigned int N,
+ unsigned long int *valueP,
+ const char *dflt, const char *info);
+HEST_EXPORT unsigned int hestOptAdd_N_Size_t(hestOpt **hoptP, const char *flag,
+ const char *name, unsigned int N,
+ size_t *valueP, const char *dflt,
+ const char *info);
+HEST_EXPORT unsigned int hestOptAdd_N_Float(hestOpt **hoptP, const char *flag,
+ const char *name, unsigned int N,
+ float *valueP, const char *dflt,
+ const char *info);
+HEST_EXPORT unsigned int hestOptAdd_N_Double(hestOpt **hoptP, const char *flag,
+ const char *name, unsigned int N,
+ double *valueP, const char *dflt,
+ const char *info);
+HEST_EXPORT unsigned int hestOptAdd_N_Char(hestOpt **hoptP, const char *flag,
+ const char *name, unsigned int N,
+ char *valueP, const char *dflt,
+ const char *info);
+HEST_EXPORT unsigned int hestOptAdd_N_String(hestOpt **hoptP, const char *flag,
+ const char *name, unsigned int N,
+ char **valueP, const char *dflt,
+ const char *info);
+HEST_EXPORT unsigned int hestOptAdd_N_Enum(hestOpt **hoptP, const char *flag,
+ const char *name, unsigned int N, int *valueP,
+ const char *dflt, const char *info,
+ const airEnum *enm);
+HEST_EXPORT unsigned int hestOptAdd_N_Other(hestOpt **hoptP, const char *flag,
+ const char *name, unsigned int N,
+ void *valueP, const char *dflt,
+ const char *info, const hestCB *CB);
#ifdef __cplusplus
}
Modified: teem/trunk/src/hest/parseHest.c
===================================================================
--- teem/trunk/src/hest/parseHest.c 2023-07-10 18:48:53 UTC (rev 7067)
+++ teem/trunk/src/hest/parseHest.c 2023-07-11 05:55:51 UTC (rev 7068)
@@ -288,9 +288,9 @@
if (opt[op].CB->destroy && (sizeof(void *) != opt[op].CB->size)) {
if (err)
sprintf(err,
- "%s!!!!!! opt[%d] has a \"destroy\", but size isn't "
+ "%s!!!!!! opt[%d] has a \"destroy\", but size %lu isn't "
"sizeof(void*)",
- ME, op);
+ ME, op, (unsigned long)(opt[op].CB->size));
else
fprintf(stderr, "%s: panic 8\n", me);
return 1;
@@ -1000,7 +1000,7 @@
easy way to see (or print, for an error message) the parameter (or
concatenation of parameters) that was passed for a given option?
and it turns out that adding this was as simple as adding this one following
- line. The inscrutability of the hest code (or more acutely the self-reinforcing
+ line. The inscrutability of the hest code (or really the self-reinforcing
learned fear of working with the hest code) seems to have been the barrier. */
opt[op].parmStr = airStrdup(prms[op]);
type = opt[op].type;
Modified: teem/trunk/src/hest/test/ex6.c
===================================================================
--- teem/trunk/src/hest/test/ex6.c 2023-07-10 18:48:53 UTC (rev 7067)
+++ teem/trunk/src/hest/test/ex6.c 2023-07-11 05:55:51 UTC (rev 7068)
@@ -21,8 +21,8 @@
#include "../hest.h"
-int
-parse(void *_ptr, const char *str, char *err) {
+static int
+pos_parse(void *_ptr, const char *str, char *err) {
double *ptr;
int ret;
@@ -35,8 +35,42 @@
return 0;
}
-hestCB posCB = {2 * sizeof(double), "location", parse, NULL};
+hestCB posCB = {2 * sizeof(double), "position", pos_parse, NULL};
+typedef struct {
+ char *str;
+ double val;
+} Quat;
+
+static int
+quat_parse(void *_ptr, const char *str, char *err) {
+ Quat **ptrP;
+ Quat *ptr;
+
+ ptrP = _ptr;
+ ptr = (*ptrP) = AIR_MALLOC(1, Quat);
+ /* printf("%s: ptrP = %p ---malloc--> ptr = *ptrP = %p\n", __func__, ptrP, *ptrP); */
+ ptr->str = NULL;
+ if (1 != sscanf(str, "%lf", &(ptr->val))) {
+ sprintf(err, "didn't parse a double from %s", str);
+ return 1;
+ }
+ ptr->str = airStrdup(str);
+ return 0;
+}
+
+Quat *
+quat_free(void *_ptr) {
+ Quat *ptr = _ptr;
+ if (ptr) {
+ free(ptr->str);
+ free(ptr);
+ }
+ return NULL;
+}
+
+hestCB quatCB = {sizeof(Quat *), "quatty", quat_parse, (airMopper)quat_free};
+
int
main(int argc, const char **argv) {
hestOpt *opt = NULL;
@@ -50,6 +84,8 @@
parm = hestParmNew();
parm->respFileEnable = AIR_TRUE;
parm->respectDashDashHelp = AIR_TRUE;
+ parm->noArgsIsNoProblem = AIR_TRUE;
+ parm->dieLessVerbose = AIR_TRUE;
parm->verbosity = 0;
opt = NULL;
@@ -57,67 +93,206 @@
int flag;
hestOptAdd_Flag(&opt, "f,flag", &flag, "a flag created via hestOptAdd_Flag");
int b1;
- hestOptAdd_1_Bool(&opt, "b1", "bool1", &b1, AIR_FALSE, "test of hestOptAdd_1_Bool");
+ hestOptAdd_1_Bool(&opt, "b1", "bool1", &b1, "false", "test of hestOptAdd_1_Bool");
int i1;
- hestOptAdd_1_Int(&opt, "i1", "int1", &i1, 42, "test of hestOptAdd_1_Int");
+ hestOptAdd_1_Int(&opt, "i1", "int1", &i1, "42", "test of hestOptAdd_1_Int");
unsigned int ui1;
- hestOptAdd_1_UInt(&opt, "ui1", "uint1", &ui1, 42, "test of hestOptAdd_1_UInt");
+ hestOptAdd_1_UInt(&opt, "ui1", "uint1", &ui1, "42", "test of hestOptAdd_1_UInt");
long int li1;
- hestOptAdd_1_LongInt(&opt, "li1", "lint1", &li1, 42, "test of hestOptAdd_1_LongInt");
+ hestOptAdd_1_LongInt(&opt, "li1", "lint1", &li1, "42", "test of hestOptAdd_1_LongInt");
unsigned long int uli1;
- hestOptAdd_1_ULongInt(&opt, "uli1", "ulint1", &uli1, 42,
+ hestOptAdd_1_ULongInt(&opt, "uli1", "ulint1", &uli1, "42",
"test of hestOptAdd_1_ULongInt");
size_t sz1;
- hestOptAdd_1_Size_t(&opt, "sz1", "size1", &sz1, 42, "test of hestOptAdd_1_Size_t");
+ hestOptAdd_1_Size_t(&opt, "sz1", "size1", &sz1, "42", "test of hestOptAdd_1_Size_t");
float fl1;
- hestOptAdd_1_Float(&opt, "fl1", "float1", &fl1, 4.2f, "test of hestOptAdd_1_Float");
+ hestOptAdd_1_Float(&opt, "fl1", "float1", &fl1, "4.2", "test of hestOptAdd_1_Float");
double db1;
- hestOptAdd_1_Double(&opt, "db1", "double1", &db1, 4.2, "test of hestOptAdd_1_Double");
+ hestOptAdd_1_Double(&opt, "db1", "double1", &db1, "4.2",
+ "test of hestOptAdd_1_Double");
char c1;
- hestOptAdd_1_Char(&opt, "c1", "char1", &c1, 'x', "test of hestOptAdd_1_Char");
+ hestOptAdd_1_Char(&opt, "c1", "char1", &c1, "x", "test of hestOptAdd_1_Char");
char *s1;
hestOptAdd_1_String(&opt, "s1", "string1", &s1, "bingo bob",
"test of hestOptAdd_1_String");
int e1;
- hestOptAdd_1_Enum(&opt, "e1", "enum1", &e1, airEndianLittle,
- "test of hestOptAdd_1_Enum", airEndian);
+ hestOptAdd_1_Enum(&opt, "e1", "enum1", &e1, "little", "test of hestOptAdd_1_Enum",
+ airEndian);
double p1[2];
- hestOptAdd_1_Other(&opt, "p1", "pos", &p1, "1.5,5.25", "test of hestOptAdd_1_Other",
+ hestOptAdd_1_Other(&opt, "p1", "pos", &p1, "1.5,5.25", "test of hestOptAdd_1_Other A",
&posCB);
+ Quat *q1;
+ hestOptAdd_1_Other(&opt, "q1", "quat", &q1, "12.34", "test of hestOptAdd_1_Other B",
+ &quatCB);
+ printf("----- &q1 = %p\n", &q1);
- if (1 == argc) {
- /* didn't get anything at all on command line */
- /* print program information ... */
- hestInfo(stderr, argv[0], info, parm);
- /* ... and usage information ... */
- hestUsage(stderr, opt, argv[0], parm);
- hestGlossary(stderr, opt, parm);
- /* ... and avoid memory leaks */
- opt = hestOptFree(opt);
- parm = hestParmFree(parm);
- exit(1);
- }
+ int b2[2];
+ hestOptAdd_2_Bool(&opt, "b2", "bool1 bool2", b2, "true false",
+ "test of hestOptAdd_2_Bool");
+ int i2[2];
+ hestOptAdd_2_Int(&opt, "i2", "int1 int2", i2, "42 24", "test of hestOptAdd_2_Int");
+ unsigned int ui2[2];
+ hestOptAdd_2_UInt(&opt, "ui2", "uint1 uint2", ui2, "42 24",
+ "test of hestOptAdd_2_UInt");
+ long int li2[2];
+ hestOptAdd_2_LongInt(&opt, "li2", "lint1 lint2", li2, "42 24",
+ "test of hestOptAdd_2_LongInt");
+ unsigned long int uli2[2];
+ hestOptAdd_2_ULongInt(&opt, "uli2", "ulint1 ulint2", uli2, "42 24",
+ "test of hestOptAdd_2_ULongInt");
+ size_t sz2[2];
+ hestOptAdd_2_Size_t(&opt, "sz2", "size1 size2", sz2, "42 24",
+ "test of hestOptAdd_2_Size_t");
+ float fl2[2];
+ hestOptAdd_2_Float(&opt, "fl2", "float1 float2", fl2, "4.2 2.4",
+ "test of hestOptAdd_2_Float");
+ double db2[2];
+ hestOptAdd_2_Double(&opt, "db2", "double1 double2", db2, "4.2 2.4",
+ "test of hestOptAdd_2_Double");
+ char c2[2];
+ hestOptAdd_2_Char(&opt, "c2", "char1 char2", c2, "x y", "test of hestOptAdd_2_Char");
+ char *s2[2];
+ hestOptAdd_2_String(&opt, "s2", "str1 str2", s2, "bingo bob",
+ "test of hestOptAdd_2_String");
+ int e2[2];
+ hestOptAdd_2_Enum(&opt, "e2", "enum1 enum2", e2, "little big",
+ "test of hestOptAdd_2_Enum", airEndian);
+ double p2[2][2];
+ hestOptAdd_2_Other(&opt, "p2", "pos1 pos2", p2, "1.5,5.25 2.9,9.2",
+ "test of hestOptAdd_2_Other A", &posCB);
+ Quat *q2[2];
+ hestOptAdd_2_Other(&opt, "q2", "quat1 quat2", q2, "12.34 43.21",
+ "test of hestOptAdd_2_Other B", &quatCB);
- /* else we got something, see if we can parse it */
- if (hestParse(opt, argc - 1, argv + 1, &err, parm)) {
- fprintf(stderr, "ERROR: %s\n", err);
- free(err);
- /* print usage information ... */
- hestUsage(stderr, opt, argv[0], parm);
- hestGlossary(stderr, opt, parm);
- /* ... and then avoid memory leaks */
- opt = hestOptFree(opt);
- parm = hestParmFree(parm);
- exit(1);
- } else if (opt->helpWanted) {
- hestUsage(stdout, opt, argv[0], parm);
- hestGlossary(stdout, opt, parm);
- opt = hestOptFree(opt);
- parm = hestParmFree(parm);
- exit(1);
- }
+ int b3[3];
+ hestOptAdd_3_Bool(&opt, "b3", "bool1 bool2 bool3", b3, "true false true",
+ "test of hestOptAdd_3_Bool");
+ int i3[3];
+ hestOptAdd_3_Int(&opt, "i3", "int1 int2 int3", i3, "43 3 34",
+ "test of hestOptAdd_3_Int");
+ unsigned int ui3[3];
+ hestOptAdd_3_UInt(&opt, "ui3", "uint1 uint2 uint3", ui3, "43 3 34",
+ "test of hestOptAdd_3_UInt");
+ long int li3[3];
+ hestOptAdd_3_LongInt(&opt, "li3", "lint1 lint2 lint3", li3, "43 4 34",
+ "test of hestOptAdd_3_LongInt");
+ unsigned long int uli3[3];
+ hestOptAdd_3_ULongInt(&opt, "uli3", "ulint1 ulint2 ulint3", uli3, "43 5 34",
+ "test of hestOptAdd_3_ULongInt");
+ size_t sz3[3];
+ hestOptAdd_3_Size_t(&opt, "sz3", "size1 size2 size3", sz3, "43 6 34",
+ "test of hestOptAdd_3_Size_t");
+ float fl3[3];
+ hestOptAdd_3_Float(&opt, "fl3", "float1 float2 float3", fl3, "4.3 1.1 3.4",
+ "test of hestOptAdd_3_Float");
+ double db3[3];
+ hestOptAdd_3_Double(&opt, "db3", "double1 double2 double3", db3, "4.3 2.2 3.4",
+ "test of hestOptAdd_3_Double");
+ char c3[3];
+ hestOptAdd_3_Char(&opt, "c3", "char1 char2 char3", c3, "x y z",
+ "test of hestOptAdd_3_Char");
+ char *s3[3];
+ hestOptAdd_3_String(&opt, "s3", "str1 str2 str3", s3, "bingo bob susan",
+ "test of hestOptAdd_3_String");
+ int e3[3];
+ hestOptAdd_3_Enum(&opt, "e3", "enum1 enum2 enum3", e3, "little big little",
+ "test of hestOptAdd_3_Enum", airEndian);
+ double p3[3][2];
+ hestOptAdd_3_Other(&opt, "p3", "pos1 pos2 pos3", p3, "1.5,5.35 3.9,9.3 6.7,7.6",
+ "test of hestOptAdd_3_Other A", &posCB);
+ Quat *q3[3];
+ hestOptAdd_3_Other(&opt, "q3", "quat1 quat2 quat3", q3, "13.34 43.31 66.77",
+ "test of hestOptAdd_3_Other B", &quatCB);
- {
+ int b4[4];
+ hestOptAdd_4_Bool(&opt, "b4", "bool1 bool2 bool3 bool4", b4, "true false no true",
+ "test of hestOptAdd_4_Bool");
+ int i4[4];
+ hestOptAdd_4_Int(&opt, "i4", "int1 int2 int3 int4", i4, "44 4 33 44",
+ "test of hestOptAdd_4_Int");
+ unsigned int ui4[4];
+ hestOptAdd_4_UInt(&opt, "ui4", "uint1 uint2 uint3 uint4", ui4, "44 4 33 44",
+ "test of hestOptAdd_4_UInt");
+ long int li4[4];
+ hestOptAdd_4_LongInt(&opt, "li4", "lint1 lint2 lint3 lint4", li4, "44 4 33 44",
+ "test of hestOptAdd_4_LongInt");
+ unsigned long int uli4[4];
+ hestOptAdd_4_ULongInt(&opt, "uli4", "ulint1 ulint2 ulint3 ulint4", uli4, "44 5 33 44",
+ "test of hestOptAdd_4_ULongInt");
+ size_t sz4[4];
+ hestOptAdd_4_Size_t(&opt, "sz4", "size1 size2 size3 size4", sz4, "44 6 33 44",
+ "test of hestOptAdd_4_Size_t");
+ float fl4[4];
+ hestOptAdd_4_Float(&opt, "fl4", "float1 float2 float3 float4", fl4, "4.4 1.1 3.3 4.4",
+ "test of hestOptAdd_4_Float");
+ double db4[4];
+ hestOptAdd_4_Double(&opt, "db4", "double1 double2 double3 double4", db4,
+ "4.4 2.2 3.3 4.4", "test of hestOptAdd_4_Double");
+ char c4[4];
+ hestOptAdd_4_Char(&opt, "c4", "char1 char2 char3 char4", c4, "x y z w",
+ "test of hestOptAdd_4_Char");
+ char *s4[4];
+ hestOptAdd_4_String(&opt, "s4", "str1 str2 str3 str4", s4, "bingo bob frank susan",
+ "test of hestOptAdd_4_String");
+ int e4[4];
+ hestOptAdd_4_Enum(&opt, "e4", "enum1 enum2 enum3 enum4", e4, "little big big little",
+ "test of hestOptAdd_4_Enum", airEndian);
+ double p4[4][2];
+ hestOptAdd_4_Other(&opt, "p4", "pos1 pos2 pos3 pos4", p4,
+ "1.5,5.45 4.9,9.4 6.7,7.6 63.4,97,3",
+ "test of hestOptAdd_4_Other A", &posCB);
+ Quat *q4[4];
+ hestOptAdd_4_Other(&opt, "q4", "quat1 quat2 quat3 quat4", q4,
+ "14.44 44.41 66.77 88.99", "test of hestOptAdd_4_Other B",
+ &quatCB);
+
+ int b5[5];
+ hestOptAdd_N_Bool(&opt, "b5", "bool1 bool2 bool3 bool4 bool5", 5, b5,
+ "true false no yes true", "test of hestOptAdd_N_Bool");
+ int i5[5];
+ hestOptAdd_N_Int(&opt, "i5", "int1 int2 int3 int4 int5", 5, i5, "55 5 33 500 55",
+ "test of hestOptAdd_N_Int");
+ unsigned int ui5[5];
+ hestOptAdd_N_UInt(&opt, "ui5", "uint1 uint2 uint3 uint4 uint5", 5, ui5,
+ "55 5 33 500 55", "test of hestOptAdd_N_UInt");
+ long int li5[5];
+ hestOptAdd_N_LongInt(&opt, "li5", "lint1 lint2 lint3 lint4 lint5", 5, li5,
+ "55 5 33 500 55", "test of hestOptAdd_N_LongInt");
+ unsigned long int uli5[5];
+ hestOptAdd_N_ULongInt(&opt, "uli5", "ulint1 ulint2 ulint3 ulint4 ulint5", 5, uli5,
+ "55 5 33 500 55", "test of hestOptAdd_N_ULongInt");
+ size_t sz5[5];
+ hestOptAdd_N_Size_t(&opt, "sz5", "size1 size2 size3 size5", 5, sz5, "55 6 33 500 55",
+ "test of hestOptAdd_N_Size_t");
+ float fl5[5];
+ hestOptAdd_N_Float(&opt, "fl5", "float1 float2 float3 float4 float5", 5, fl5,
+ "5.5 1.1 3.3 500 5.5", "test of hestOptAdd_N_Float");
+ double db5[5];
+ hestOptAdd_N_Double(&opt, "db5", "double1 double2 double3 double4 double5", 5, db5,
+ "5.5 2.2 3.3 4.4 5.5", "test of hestOptAdd_N_Double");
+ char c5[5];
+ hestOptAdd_N_Char(&opt, "c5", "char1 char2 char3 char4 char5", 5, c5, "x y z w v",
+ "test of hestOptAdd_N_Char");
+ char *s5[5];
+ hestOptAdd_N_String(&opt, "s5", "str1 str2 str3 str4, str5", 5, s5,
+ "bingo bob frank harry susan", "test of hestOptAdd_N_String");
+ int e5[5];
+ hestOptAdd_N_Enum(&opt, "e5", "enum1 enum2 enum3 enum4 enum5", 5, e5,
+ "little big little big little", "test of hestOptAdd_N_Enum",
+ airEndian);
+ double p5[5][2];
+ hestOptAdd_N_Other(&opt, "p5", "pos1 pos2 pos3 pos4 pos5", 5, p5,
+ "1.5,5.55 5.9,9.5 6.7,7.6 63.5,97,3 300,400",
+ "test of hestOptAdd_N_Other A", &posCB);
+ Quat *q5[5];
+ hestOptAdd_N_Other(&opt, "q5", "quat1 quat2 quat3 quat4 quat5", 5, q5,
+ "15.55 55.51 66.77 88.99 100.2", "test of hestOptAdd_N_Other B",
+ &quatCB);
+
+ hestParseOrDie(opt, argc - 1, argv + 1, parm, argv[0], info, AIR_TRUE, AIR_TRUE,
+ AIR_TRUE);
+
+ if (1) {
unsigned int opi, numO;
numO = hestOptNum(opt);
for (opi = 0; opi < numO; opi++) {
@@ -130,21 +305,100 @@
printf(" parmStr=|%s|\n", opt[opi].parmStr ? opt[opi].parmStr : "(null)");
}
}
- printf("(err = %s)\n", err ? err : "(null)");
- printf("flag = %d\n", flag);
- printf("b1 = %d\n", b1);
- printf("i1 = %d\n", i1);
- printf("ui1 = %u\n", ui1);
- printf("li1 = %ld\n", li1);
- printf("uli1 = %lu\n", uli1);
- printf("sz1 = %zu\n", sz1);
- printf("fl1 = %g\n", fl1);
- printf("db1 = %g\n", db1);
- printf("c1 = %c\n", c1);
- printf("s1 = %s\n", s1);
- printf("e1 = %d\n", e1);
- printf("p1 = %g,%g\n", p1[0], p1[1]);
+ if (1) {
+ printf("(err = %s)\n", err ? err : "(null)");
+ printf("flag = %d\n", flag);
+ printf("b1 = %d\n", b1);
+ printf("i1 = %d\n", i1);
+ printf("ui1 = %u\n", ui1);
+ printf("li1 = %ld\n", li1);
+ printf("uli1 = %lu\n", uli1);
+ printf("sz1 = %zu\n", sz1);
+ printf("fl1 = %g\n", fl1);
+ printf("db1 = %g\n", db1);
+ printf("c1 = %c\n", c1);
+ printf("s1 = |%s|\n", s1);
+ printf("e1 = %d\n", e1);
+ printf("p1 = %g,%g\n", p1[0], p1[1]);
+ }
+ printf("q1 (@ %p) = %g(%s)\n", q1, q1->val, q1->str);
+ printf("\n");
+
+ if (1) {
+ printf("b2 = %d %d\n", b2[0], b2[1]);
+ printf("i2 = %d %d\n", i2[0], i2[1]);
+ printf("ui2 = %u %u\n", ui2[0], ui2[1]);
+ printf("li2 = %ld %ld\n", li2[0], li2[1]);
+ printf("uli2 = %lu %lu\n", uli2[0], uli2[1]);
+ printf("sz2 = %zu %zu\n", sz2[0], sz2[1]);
+ printf("fl2 = %g %g\n", fl2[0], fl2[1]);
+ printf("db2 = %g %g\n", db2[0], db2[1]);
+ printf("c2 = %c %c\n", c2[0], c2[1]);
+ printf("s2 = |%s| |%s|\n", s2[0], s2[1]);
+ printf("e2 = %d %d\n", e2[0], e2[1]);
+ printf("p2 = %g,%g %g,%g\n", p2[0][0], p2[0][1], p2[1][0], p2[1][1]);
+ }
+ printf(" (q2 = %p : [%p %p])\n", q2, q2[0], q2[1]);
+ printf("q2 = %g(%s) %g(%s)\n", q2[0]->val, q2[0]->str, q2[1]->val, q2[1]->str);
+
+ printf("b3 = %d %d %d\n", b3[0], b3[1], b3[2]);
+ printf("i3 = %d %d %d\n", i3[0], i3[1], i3[2]);
+ printf("ui3 = %u %u %u\n", ui3[0], ui3[1], ui3[2]);
+ printf("li3 = %ld %ld %ld\n", li3[0], li3[1], li3[2]);
+ printf("uli3 = %lu %lu %lu\n", uli3[0], uli3[1], uli3[2]);
+ printf("sz3 = %zu %zu %zu\n", sz3[0], sz3[1], sz3[2]);
+ printf("fl3 = %g %g %g\n", fl3[0], fl3[1], fl3[2]);
+ printf("db3 = %g %g %g\n", db3[0], db3[1], db3[2]);
+ printf("c3 = %c %c %c\n", c3[0], c3[1], c3[2]);
+ printf("s3 = |%s| |%s| |%s|\n", s3[0], s3[1], s3[2]);
+ printf("e3 = %d %d %d\n", e3[0], e3[1], e3[2]);
+ printf("p3 = %g,%g %g,%g %g,%g\n", p3[0][0], p3[0][1], p3[1][0], p3[1][1], p3[2][0],
+ p3[2][1]);
+ printf("q3 = %g(%s) %g(%s) %g(%s)\n", q3[0]->val, q3[0]->str, q3[1]->val, q3[1]->str,
+ q3[2]->val, q3[2]->str);
+
+ printf("b4 = %d %d %d %d\n", b4[0], b4[1], b4[2], b4[3]);
+ printf("i4 = %d %d %d %d\n", i4[0], i4[1], i4[2], i4[3]);
+ printf("ui4 = %u %u %u %u\n", ui4[0], ui4[1], ui4[2], ui4[3]);
+ printf("li4 = %ld %ld %ld %ld\n", li4[0], li4[1], li4[2], li4[3]);
+ printf("uli4 = %lu %lu %lu %lu\n", uli4[0], uli4[1], uli4[2], uli4[3]);
+ printf("sz4 = %zu %zu %zu %zu\n", sz4[0], sz4[1], sz4[2], sz4[3]);
+ printf("fl4 = %g %g %g %g\n", fl4[0], fl4[1], fl4[2], fl4[3]);
+ printf("db4 = %g %g %g %g\n", db4[0], db4[1], db4[2], db4[3]);
+ printf("c4 = %c %c %c %c\n", c4[0], c4[1], c4[2], c4[3]);
+ printf("s4 = |%s| |%s| |%s| |%s|\n", s4[0], s4[1], s4[2], s4[3]);
+ printf("e4 = %d %d %d %d\n", e4[0], e4[1], e4[2], e4[3]);
+ printf("p4 = %g,%g %g,%g %g,%g %g,%g\n", p4[0][0], p4[0][1], p4[1][0], p4[1][1],
+ p4[2][0], p4[2][1], p4[3][0], p4[3][1]);
+ printf("q4 = %g(%s) %g(%s) %g(%s) %g(%s)\n", q4[0]->val, q4[0]->str, q4[1]->val,
+ q4[1]->str, q4[2]->val, q4[2]->str, q...
[truncated message content] |
|
From: <kin...@us...> - 2023-07-10 18:48:55
|
Revision: 7067
http://sourceforge.net/p/teem/code/7067
Author: kindlmann
Date: 2023-07-10 18:48:53 +0000 (Mon, 10 Jul 2023)
Log Message:
-----------
fixing long-standing bug in what was being checked for non-NULL-ity with a hestCB
Modified Paths:
--------------
teem/trunk/src/hest/parseHest.c
Modified: teem/trunk/src/hest/parseHest.c
===================================================================
--- teem/trunk/src/hest/parseHest.c 2023-07-08 15:48:39 UTC (rev 7066)
+++ teem/trunk/src/hest/parseHest.c 2023-07-10 18:48:53 UTC (rev 7067)
@@ -271,7 +271,7 @@
fprintf(stderr, "%s: panic 5\n", me);
return 1;
}
- if (!(opt[op].type)) {
+ if (!(opt[op].CB->type)) {
if (err)
sprintf(err, "%s!!!!!! opt[%d]'s \"type\" is NULL", ME, op);
else
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <kin...@us...> - 2023-07-08 15:48:43
|
Revision: 7066
http://sourceforge.net/p/teem/code/7066
Author: kindlmann
Date: 2023-07-08 15:48:39 +0000 (Sat, 08 Jul 2023)
Log Message:
-----------
better descriptive comment
Modified Paths:
--------------
teem/trunk/src/echo/intx.c
Modified: teem/trunk/src/echo/intx.c
===================================================================
--- teem/trunk/src/echo/intx.c 2023-07-08 15:01:52 UTC (rev 7065)
+++ teem/trunk/src/echo/intx.c 2023-07-08 15:48:39 UTC (rev 7066)
@@ -27,7 +27,7 @@
** needed for shadow rays
*/
-/* forward declaration with incomplete array type */
+/* forward declaration */
static const _echoRayIntx_t _echoRayIntx[ECHO_TYPE_NUM];
/*
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <kin...@us...> - 2023-07-08 15:01:54
|
Revision: 7065
http://sourceforge.net/p/teem/code/7065
Author: kindlmann
Date: 2023-07-08 15:01:52 +0000 (Sat, 08 Jul 2023)
Log Message:
-----------
fixing warning
Modified Paths:
--------------
teem/trunk/src/echo/intx.c
Modified: teem/trunk/src/echo/intx.c
===================================================================
--- teem/trunk/src/echo/intx.c 2023-07-08 14:52:40 UTC (rev 7064)
+++ teem/trunk/src/echo/intx.c 2023-07-08 15:01:52 UTC (rev 7065)
@@ -28,7 +28,7 @@
*/
/* forward declaration with incomplete array type */
-static const _echoRayIntx_t _echoRayIntx[];
+static const _echoRayIntx_t _echoRayIntx[ECHO_TYPE_NUM];
/*
** ALL of the intersection functions are responsible for setting
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <kin...@us...> - 2023-07-08 14:52:42
|
Revision: 7064
http://sourceforge.net/p/teem/code/7064
Author: kindlmann
Date: 2023-07-08 14:52:40 +0000 (Sat, 08 Jul 2023)
Log Message:
-----------
trailing commas arent c89
Modified Paths:
--------------
teem/trunk/src/unrrdu/uncmt.c
Modified: teem/trunk/src/unrrdu/uncmt.c
===================================================================
--- teem/trunk/src/unrrdu/uncmt.c 2023-07-08 14:50:03 UTC (rev 7063)
+++ teem/trunk/src/unrrdu/uncmt.c 2023-07-08 14:52:40 UTC (rev 7064)
@@ -49,7 +49,7 @@
this deficiency was discovered by running this command on this source file.
*/
stateCCEsc, /* 7: in '' character constant and saw \ */
- stateElse, /* 8: everything else */
+ stateElse /* 8: everything else */
};
/* nfdsChar: next char for "No Float or Double in String" mode
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <kin...@us...> - 2023-07-08 14:50:05
|
Revision: 7063
http://sourceforge.net/p/teem/code/7063
Author: kindlmann
Date: 2023-07-08 14:50:03 +0000 (Sat, 08 Jul 2023)
Log Message:
-----------
fixing warnings: isnan isn't C89, and using correct conversion format for unsigned
Modified Paths:
--------------
teem/trunk/src/nrrd/arith.c
teem/trunk/src/nrrd/formatVTK.c
Modified: teem/trunk/src/nrrd/arith.c
===================================================================
--- teem/trunk/src/nrrd/arith.c 2023-07-08 14:43:47 UTC (rev 7062)
+++ teem/trunk/src/nrrd/arith.c 2023-07-08 14:50:03 UTC (rev 7063)
@@ -488,9 +488,9 @@
break;
case 2:
/* two non-finite values */
- if (isnan(A) && isnan(B)) {
+ if (airIsNaN(A) && airIsNaN(B)) {
ret = 0; /* really, no meaningful difference between 2 NaNs */
- } else if (isnan(A) || isnan(B)) {
+ } else if (airIsNaN(A) || airIsNaN(B)) {
/* one NaN and one inf, which seems like a big difference */
ret = maxd;
} else {
Modified: teem/trunk/src/nrrd/formatVTK.c
===================================================================
--- teem/trunk/src/nrrd/formatVTK.c 2023-07-08 14:43:47 UTC (rev 7062)
+++ teem/trunk/src/nrrd/formatVTK.c 2023-07-08 14:50:03 UTC (rev 7063)
@@ -155,7 +155,7 @@
GETLINE(next);
airToUpper(nio->line);
}
- if (1 != sscanf(nio->line, "POINT_DATA %d", &N)) {
+ if (1 != sscanf(nio->line, "POINT_DATA %u", &N)) {
biffAddf(NRRD, "%s: couldn't parse POINT_DATA line (\"%s\")", me, nio->line);
return 1;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <kin...@us...> - 2023-07-08 14:43:49
|
Revision: 7062
http://sourceforge.net/p/teem/code/7062
Author: kindlmann
Date: 2023-07-08 14:43:47 +0000 (Sat, 08 Jul 2023)
Log Message:
-----------
fixing warning
Modified Paths:
--------------
teem/trunk/src/hest/parseHest.c
Modified: teem/trunk/src/hest/parseHest.c
===================================================================
--- teem/trunk/src/hest/parseHest.c 2023-07-08 14:29:44 UTC (rev 7061)
+++ teem/trunk/src/hest/parseHest.c 2023-07-08 14:43:47 UTC (rev 7062)
@@ -1481,7 +1481,10 @@
/* currently, any left-over arguments indicate error */
if (argc_used) {
- char stops[3] = {'-', PARM->varParamStopFlag, '\0'};
+ /* char stops[3] = {'-', PARM->varParamStopFlag, '\0'}; triggers warning:
+ initializer element is not computable at load time */
+ char stops[3] = "-X";
+ stops[1] = PARM->varParamStopFlag;
if (strcmp(stops, argv[0])) {
sprintf(err, "%sunexpected arg%s: \"%s\"", ME,
('-' == argv[0][0] ? " (or unrecognized flag)" : ""), argv[0]);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|