GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: src/unrrdu/unorient.c Lines: 12 24 50.0 %
Date: 2017-05-26 Branches: 1 14 7.1 %

Line Branch Exec Source
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 "Make image orientation be axis-aligned"
28
static const char *_unrrdu_unorientInfoL =
29
  (INFO
30
   ". Does various tricks.\n "
31
   "* Uses nrrdOrientationReduce");
32
33
int
34
unrrdu_unorientMain(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
  int setMinsFromOrigin;
41
  airArray *mop;
42
43
  /* if we gave a default for this, then there it would fine to have
44
     no command-line arguments whatsoever, and then the user would not
45
     know how to get the basic usage information */
46
1
  hestOptAdd(&opt, "i,input", "nin", airTypeOther, 1, 1, &nin, NULL,
47
             "input nrrd "
48
             "(sorry, can't use usual default of \"-\" for stdin "
49
             "because of hest quirk)",
50
1
             NULL, NULL, nrrdHestNrrd);
51
1
  hestOptAdd(&opt, "smfo", NULL, airTypeInt, 0, 0,
52
             &setMinsFromOrigin, NULL,
53
             "set some axis mins based on space origin (hack)");
54
1
  OPT_ADD_NOUT(out, "output nrrd");
55
56
1
  mop = airMopNew();
57
1
  airMopAdd(mop, opt, (airMopper)hestOptFree, airMopAlways);
58
59
2
  USAGE(_unrrdu_unorientInfoL);
60
  PARSE();
61
  airMopAdd(mop, opt, (airMopper)hestParseFree, airMopAlways);
62
63
  nout = nrrdNew();
64
  airMopAdd(mop, nout, (airMopper)nrrdNuke, airMopAlways);
65
66
  if (nrrdOrientationReduce(nout, nin, setMinsFromOrigin)) {
67
    airMopAdd(mop, err = biffGetDone(NRRD), airFree, airMopAlways);
68
    fprintf(stderr, "%s: error unorienting nrrd:\n%s", me, err);
69
    airMopError(mop);
70
    return 1;
71
  }
72
73
  SAVE(out, nout, NULL);
74
75
  airMopOkay(mop);
76
  return 0;
77
1
}
78
79
UNRRDU_CMD(unorient, INFO);