GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: src/unrrdu/axsplit.c Lines: 14 26 53.8 %
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 "Split one axis into two axes"
28
static const char *_unrrdu_axsplitInfoL =
29
(INFO
30
 ". More general version of \"unu axinsert\", since a given axis can "
31
 "be split into fast and slow axes of arbitrary size, as long as the "
32
 "product of the fast and slow sizes is the same as the original size.\n "
33
 "* Uses nrrdAxesSplit");
34
35
int
36
unrrdu_axsplitMain(int argc, const char **argv, const char *me,
37
                   hestParm *hparm) {
38
2
  hestOpt *opt = NULL;
39
1
  char *out, *err;
40
1
  Nrrd *nin, *nout;
41
  int pret;
42
1
  size_t size[2];
43
1
  unsigned int axis;
44
  airArray *mop;
45
46
1
  OPT_ADD_AXIS(axis, "dimension (axis index) to split at");
47
1
  hestOptAdd(&opt, "s,size", "fast, slow sizes", airTypeSize_t, 2, 2,
48
1
             size, NULL,
49
             "fast and slow axis sizes to produce as result of splitting "
50
             "given axis.");
51
1
  OPT_ADD_NIN(nin, "input nrrd");
52
1
  OPT_ADD_NOUT(out, "output nrrd");
53
54
1
  mop = airMopNew();
55
1
  airMopAdd(mop, opt, (airMopper)hestOptFree, airMopAlways);
56
57
2
  USAGE(_unrrdu_axsplitInfoL);
58
  PARSE();
59
  airMopAdd(mop, opt, (airMopper)hestParseFree, airMopAlways);
60
61
  nout = nrrdNew();
62
  airMopAdd(mop, nout, (airMopper)nrrdNuke, airMopAlways);
63
64
  if (nrrdAxesSplit(nout, nin, axis, size[0], size[1])) {
65
    airMopAdd(mop, err = biffGetDone(NRRD), airFree, airMopAlways);
66
    fprintf(stderr, "%s: error splitting axis:\n%s", me, err);
67
    airMopError(mop);
68
    return 1;
69
  }
70
71
  SAVE(out, nout, NULL);
72
73
  airMopOkay(mop);
74
  return 0;
75
1
}
76
77
UNRRDU_CMD(axsplit, INFO);