1 |
|
|
/* |
2 |
|
|
Teem: Tools to process and visualize scientific data and images . |
3 |
|
|
Copyright (C) 2013, 2012, 2011, 2010, 2009 University of Chicago |
4 |
|
|
Copyright (C) 2008, 2007, 2006, 2005 Gordon Kindlmann |
5 |
|
|
Copyright (C) 2004, 2003, 2002, 2001, 2000, 1999, 1998 University of Utah |
6 |
|
|
|
7 |
|
|
This library is free software; you can redistribute it and/or |
8 |
|
|
modify it under the terms of the GNU Lesser General Public License |
9 |
|
|
(LGPL) as published by the Free Software Foundation; either |
10 |
|
|
version 2.1 of the License, or (at your option) any later version. |
11 |
|
|
The terms of redistributing and/or modifying this software also |
12 |
|
|
include exceptions to the LGPL that facilitate static linking. |
13 |
|
|
|
14 |
|
|
This library is distributed in the hope that it will be useful, |
15 |
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
16 |
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
17 |
|
|
Lesser General Public License for more details. |
18 |
|
|
|
19 |
|
|
You should have received a copy of the GNU Lesser General Public License |
20 |
|
|
along with this library; if not, write to Free Software Foundation, Inc., |
21 |
|
|
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
22 |
|
|
*/ |
23 |
|
|
|
24 |
|
|
#include "unrrdu.h" |
25 |
|
|
#include "privateUnrrdu.h" |
26 |
|
|
|
27 |
|
|
#define INFO "a hack of some kind" |
28 |
|
|
static const char *_unrrdu_hackInfoL = |
29 |
|
|
(INFO ". This is used as a place to put whatever one-off code " |
30 |
|
|
"you want to try, with the whatever benefits come with being a " |
31 |
|
|
"unu command.\n " |
32 |
|
|
"* (not based on any particular nrrd function)"); |
33 |
|
|
|
34 |
|
|
int |
35 |
|
|
unrrdu_hackMain(int argc, const char **argv, const char *me, |
36 |
|
|
hestParm *hparm) { |
37 |
|
2 |
hestOpt *opt = NULL; |
38 |
|
1 |
char *out, *err; |
39 |
|
1 |
Nrrd *nin, *nout; |
40 |
|
|
int pret; |
41 |
|
|
airArray *mop; |
42 |
|
|
|
43 |
|
1 |
char *what; |
44 |
|
|
|
45 |
|
1 |
hestOptAdd(&opt, NULL, "what", airTypeString, 1, 1, &what, NULL, |
46 |
|
|
"what hack to do"); |
47 |
|
1 |
OPT_ADD_NIN(nin, "input nrrd"); |
48 |
|
1 |
OPT_ADD_NOUT(out, "output nrrd"); |
49 |
|
|
|
50 |
|
1 |
mop = airMopNew(); |
51 |
|
1 |
airMopAdd(mop, opt, (airMopper)hestOptFree, airMopAlways); |
52 |
|
|
|
53 |
✓✗ |
2 |
USAGE(_unrrdu_hackInfoL); |
54 |
|
|
PARSE(); |
55 |
|
|
airMopAdd(mop, opt, (airMopper)hestParseFree, airMopAlways); |
56 |
|
|
|
57 |
|
|
nout = nrrdNew(); |
58 |
|
|
airMopAdd(mop, nout, (airMopper)nrrdNuke, airMopAlways); |
59 |
|
|
|
60 |
|
|
if (!strcmp(what, "sdincr")) { |
61 |
|
|
unsigned int sdim, axi; |
62 |
|
|
sdim = nin->spaceDim; |
63 |
|
|
if (!sdim) { |
64 |
|
|
fprintf(stderr, "%s: need non-zero space dimension", me); |
65 |
|
|
airMopError(mop); |
66 |
|
|
return 1; |
67 |
|
|
} |
68 |
|
|
if (nrrdCopy(nout, nin)) { |
69 |
|
|
airMopAdd(mop, err = biffGetDone(NRRD), airFree, airMopAlways); |
70 |
|
|
fprintf(stderr, "%s: error converting nrrd:\n%s", me, err); |
71 |
|
|
airMopError(mop); |
72 |
|
|
return 1; |
73 |
|
|
} |
74 |
|
|
nout->spaceDim = sdim + 1; |
75 |
|
|
nout->space = nrrdSpaceUnknown; |
76 |
|
|
nout->spaceOrigin[sdim] = 0.0; |
77 |
|
|
for (axi=0; axi<nout->dim; axi++) { |
78 |
|
|
if (nrrdSpaceVecExists(sdim, nout->axis[axi].spaceDirection)) { |
79 |
|
|
nout->axis[axi].spaceDirection[sdim] = 0.0; |
80 |
|
|
} |
81 |
|
|
} |
82 |
|
|
} else { |
83 |
|
|
fprintf(stderr, "%s: no \"%s\" hack implemented", me, what); |
84 |
|
|
airMopError(mop); |
85 |
|
|
return 1; |
86 |
|
|
} |
87 |
|
|
|
88 |
|
|
SAVE(out, nout, NULL); |
89 |
|
|
|
90 |
|
|
airMopOkay(mop); |
91 |
|
|
return 0; |
92 |
|
1 |
} |
93 |
|
|
|
94 |
|
|
UNRRDU_CMD_HIDE(hack, INFO); |