GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: src/unrrdu/untile.c Lines: 13 25 52.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 "Undo \"unu tile\": merge slow parts of two axis splits"
28
static const char *_unrrdu_untileInfoL =
29
(INFO
30
 ". Untiling an array means spliting two axes, permuting the slow parts "
31
 "of those axes to be adjecent in the axis ordering, and then merging "
32
 "them.  This increases the dimension by one.  Undoing a \"unu tile\" "
33
 "uses the same \"-s\" argument, and sometimes a different \"-a\" argument, "
34
 "as demonstrated here for a 3-D array:\n "
35
 "\"unu untile -a 2 0 1\" undoes \"unu tile -a 2 0 1\"\n "
36
 "\"unu untile -a 1 0 1\" undoes \"unu tile -a 1 0 2\"\n "
37
 "\"unu untile -a 0 0 1\" undoes \"unu tile -a 0 1 2\".\n "
38
 "* Uses nrrdUntile2D");
39
40
int
41
unrrdu_untileMain(int argc, const char **argv, const char *me,
42
                  hestParm *hparm) {
43
2
  hestOpt *opt = NULL;
44
1
  char *out, *err;
45
1
  Nrrd *nin, *nout;
46
1
  unsigned int axes[3];
47
  int pret;
48
1
  size_t size[2];
49
  airArray *mop;
50
51
1
  hestOptAdd(&opt, "a,axis", "axMerge ax0 ax1", airTypeUInt, 3, 3, axes, NULL,
52
             "the slow parts of axes ax0 and ax1 are merged into a (new) "
53
             "axis axMerge, with the axis ax0 part being faster than ax1.");
54
1
  hestOptAdd(&opt, "s,size", "size0 size1", airTypeSize_t, 2, 2, size, NULL,
55
             "the slow parts of axes ax0 and ax1 are taken to have size "
56
             "size0 and size1, respectively, and axis axMerge will have "
57
             "size size0*size1.");
58
1
  OPT_ADD_NIN(nin, "input nrrd");
59
1
  OPT_ADD_NOUT(out, "output nrrd");
60
61
1
  mop = airMopNew();
62
1
  airMopAdd(mop, opt, (airMopper)hestOptFree, airMopAlways);
63
64
2
  USAGE(_unrrdu_untileInfoL);
65
  PARSE();
66
  airMopAdd(mop, opt, (airMopper)hestParseFree, airMopAlways);
67
68
  nout = nrrdNew();
69
  airMopAdd(mop, nout, (airMopper)nrrdNuke, airMopAlways);
70
71
  if (nrrdUntile2D(nout, nin, axes[1], axes[2], axes[0], size[0], size[1])) {
72
    airMopAdd(mop, err = biffGetDone(NRRD), airFree, airMopAlways);
73
    fprintf(stderr, "%s: error tiling nrrd:\n%s", me, err);
74
    airMopError(mop);
75
    return 1;
76
  }
77
78
  SAVE(out, nout, NULL);
79
80
  airMopOkay(mop);
81
  return 0;
82
1
}
83
84
UNRRDU_CMD(untile, INFO);