GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: src/unrrdu/unblock.c Lines: 0 25 0.0 %
Date: 2017-05-26 Branches: 0 14 0.0 %

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 "Expand \"blocks\" into scanlines on axis 0"
28
static const char *
29
_unrrdu_unblockInfoL =
30
  (INFO
31
   ". Based on the requested output type, the number of "
32
   "samples along axis 0 will be determined automatically. "
33
   "Axis N information will be bumped up to axis N+1. "
34
   "Underlying data is unchanged.");
35
36
int
37
unrrdu_unblockMain(int argc, const char **argv, const char *me,
38
                   hestParm *hparm) {
39
  hestOpt *opt = NULL;
40
  char *out, *err;
41
  Nrrd *nin, *nout;
42
  int type, pret;
43
  size_t blockSize;
44
  airArray *mop;
45
46
  OPT_ADD_TYPE(type, "type to unblock to", NULL);
47
  hestOptAdd(&opt, "bs", "blocksize", airTypeSize_t, 1, 1, &blockSize, "0",
48
             "Useful only if *output* type is also block: the size of "
49
             "blocks in output nrrd");
50
  OPT_ADD_NIN(nin, "input nrrd");
51
  OPT_ADD_NOUT(out, "output nrrd");
52
53
  mop = airMopNew();
54
  airMopAdd(mop, opt, (airMopper)hestOptFree, airMopAlways);
55
56
  USAGE(_unrrdu_unblockInfoL);
57
  PARSE();
58
  airMopAdd(mop, opt, (airMopper)hestParseFree, airMopAlways);
59
60
  nout = nrrdNew();
61
  nout->blockSize = blockSize;
62
  airMopAdd(mop, nout, (airMopper)nrrdNuke, airMopAlways);
63
64
  if (nrrdUnblock(nout, nin, type)) {
65
    airMopAdd(mop, err = biffGetDone(NRRD), airFree, airMopAlways);
66
    fprintf(stderr, "%s: error unblocking nrrd:\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
}
76
77
UNRRDU_CMD(unblock, INFO);