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 "Interchange ordering of two axes" |
28 |
|
|
static const char *_unrrdu_swapInfoL = |
29 |
|
|
(INFO |
30 |
|
|
". Special case of \"unu\tpermute\".\n " |
31 |
|
|
"* Uses nrrdAxesSwap"); |
32 |
|
|
|
33 |
|
|
int |
34 |
|
|
unrrdu_swapMain(int argc, const char **argv, const char *me, |
35 |
|
|
hestParm *hparm) { |
36 |
|
2 |
hestOpt *opt = NULL; |
37 |
|
1 |
char *out, *err; |
38 |
|
1 |
Nrrd *nin, *nout; |
39 |
|
|
int pret; |
40 |
|
1 |
unsigned int ax[2]; |
41 |
|
|
airArray *mop; |
42 |
|
|
|
43 |
|
1 |
hestOptAdd(&opt, "a,axis", "axisA axisB", airTypeUInt, 2, 2, ax, NULL, |
44 |
|
|
"the two axes to switch (0-based numbering)"); |
45 |
|
1 |
OPT_ADD_NIN(nin, "input nrrd"); |
46 |
|
1 |
OPT_ADD_NOUT(out, "output nrrd"); |
47 |
|
|
|
48 |
|
1 |
mop = airMopNew(); |
49 |
|
1 |
airMopAdd(mop, opt, (airMopper)hestOptFree, airMopAlways); |
50 |
|
|
|
51 |
✓✗ |
2 |
USAGE(_unrrdu_swapInfoL); |
52 |
|
|
PARSE(); |
53 |
|
|
airMopAdd(mop, opt, (airMopper)hestParseFree, airMopAlways); |
54 |
|
|
|
55 |
|
|
nout = nrrdNew(); |
56 |
|
|
airMopAdd(mop, nout, (airMopper)nrrdNuke, airMopAlways); |
57 |
|
|
|
58 |
|
|
if (nrrdAxesSwap(nout, nin, ax[0], ax[1])) { |
59 |
|
|
airMopAdd(mop, err = biffGetDone(NRRD), airFree, airMopAlways); |
60 |
|
|
fprintf(stderr, "%s: error swapping nrrd:\n%s", me, err); |
61 |
|
|
airMopError(mop); |
62 |
|
|
return 1; |
63 |
|
|
} |
64 |
|
|
|
65 |
|
|
SAVE(out, nout, NULL); |
66 |
|
|
|
67 |
|
|
airMopOkay(mop); |
68 |
|
|
return 0; |
69 |
|
1 |
} |
70 |
|
|
|
71 |
|
|
UNRRDU_CMD(swap, INFO); |