GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: src/unrrdu/block.c Lines: 0 21 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 "Condense axis-0 scanlines into \"blocks\""
28
static const char *_unrrdu_blockInfoL =
29
(INFO
30
 ". Output nrrd will be of type \"block\": the type "
31
 "for an opaque chunk of "
32
 "memory.  Block samples can be sliced, cropped, shuffled, "
33
 "permuted, etc., but there is no scalar value associated "
34
 "with them, so they can not be histogrammed, quantized, "
35
 "resampled, converted, etc.  The output nrrd will have "
36
 "one less dimension than input; axis N information will "
37
 "be shifted down to axis N-1.  Underlying data "
38
 "is unchanged.");
39
40
int
41
unrrdu_blockMain(int argc, const char **argv, const char *me,
42
                 hestParm *hparm) {
43
  hestOpt *opt = NULL;
44
  char *out, *err;
45
  Nrrd *nin, *nout;
46
  airArray *mop;
47
  int pret;
48
49
  /* if we gave a default for this, then there it would fine to have
50
     no command-line arguments whatsoever, and then the user would not
51
     know how to get the basic usage information */
52
  hestOptAdd(&opt, "i", "nin", airTypeOther, 1, 1, &nin, NULL, "input nrrd",
53
             NULL, NULL, nrrdHestNrrd);
54
  OPT_ADD_NOUT(out, "output nrrd");
55
56
  mop = airMopNew();
57
  airMopAdd(mop, opt, (airMopper)hestOptFree, airMopAlways);
58
59
  USAGE(_unrrdu_blockInfoL);
60
  PARSE();
61
  airMopAdd(mop, opt, (airMopper)hestParseFree, airMopAlways);
62
63
  nout = nrrdNew();
64
  airMopAdd(mop, nout, (airMopper)nrrdNuke, airMopAlways);
65
66
  if (nrrdBlock(nout, nin)) {
67
    airMopAdd(mop, err = biffGetDone(NRRD), airFree, airMopAlways);
68
    fprintf(stderr, "%s: error blocking 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
}
78
79
UNRRDU_CMD(block, INFO);