/usr/include/teem/nrrdMacros.h is in libteem-dev 1.11.0~svn5226-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 | /*
Teem: Tools to process and visualize scientific data and images
Copyright (C) 2011, 2010, 2009 University of Chicago
Copyright (C) 2008, 2007, 2006, 2005 Gordon Kindlmann
Copyright (C) 2004, 2003, 2002, 2001, 2000, 1999, 1998 University of Utah
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public License
(LGPL) as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
The terms of redistributing and/or modifying this software also
include exceptions to the LGPL that facilitate static linking.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this library; if not, write to Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef NRRD_MACROS_HAS_BEEN_INCLUDED
#define NRRD_MACROS_HAS_BEEN_INCLUDED
#ifdef __cplusplus
extern "C" {
#endif
/*
******** NRRD_CELL_POS, NRRD_NODE_POS, NRRD_POS
******** NRRD_CELL_IDX, NRRD_NODE_IDX, NRRD_IDX
**
** the guts of nrrdAxisPos() and nrrdAxisIdx(), for converting
** between "index space" location and "position" or "world space" location,
** given the centering, min and max "position", and number of samples.
**
** Unlike nrrdAxisPos() and nrrdAxisIdx(), this assumes that center
** is either nrrdCenterCell or nrrdCenterNode, but not nrrdCenterUnknown.
*/
/* index to position, cell centering */
#define NRRD_CELL_POS(min, max, size, idx) \
AIR_AFFINE(0, (idx) + 0.5, (size), (min), (max))
/* index to position, node centering */
#define NRRD_NODE_POS(min, max, size, idx) \
AIR_AFFINE(0, (idx), (size)-1, (min), (max))
/* index to position, either centering */
#define NRRD_POS(center, min, max, size, idx) \
(nrrdCenterCell == (center) \
? NRRD_CELL_POS((min), (max), (size), (idx)) \
: NRRD_NODE_POS((min), (max), (size), (idx)))
/* position to index, cell centering */
#define NRRD_CELL_IDX(min, max, size, pos) \
(AIR_AFFINE((min), (pos), (max), 0, (size)) - 0.5)
/* position to index, node centering */
#define NRRD_NODE_IDX(min, max, size, pos) \
AIR_AFFINE((min), (pos), (max), 0, (size)-1)
/* position to index, either centering */
#define NRRD_IDX(center, min, max, size, pos) \
(nrrdCenterCell == (center) \
? NRRD_CELL_IDX((min), (max), (size), (pos)) \
: NRRD_NODE_IDX((min), (max), (size), (pos)))
/*
******** NRRD_SPACING
**
** the guts of nrrdAxisSpacing(), determines the inter-sample
** spacing, given centering, min and max "position", and number of samples
**
** Unlike nrrdAxisSpacing, this assumes that center is either
** nrrdCenterCell or nrrdCenterNode, but not nrrdCenterUnknown.
*/
#define NRRD_SPACING(center, min, max, size) \
(nrrdCenterCell == center \
? ((max) - (min))/(size) \
: ((max) - (min))/((size) - 1)) \
/*
******** NRRD_COORD_UPDATE
**
** This is for doing the "carrying" associated with gradually
** incrementing an array of coordinates. Assuming that the given
** coordinate array "coord" has been incrementing by adding 1 to THE
** FIRST, THE ZERO-ETH, ELEMENT (this is a strong assumption), then,
** this macro is good for propagating the change up to higher axes
** (which really only happens when the position has stepped over the
** limit on a lower axis.) Relies on the array of axes sizes "size",
** as as the length "dim" of "coord" and "size".
**
** This may be turned into something more general purpose soon.
*/
#define NRRD_COORD_UPDATE(coord, size, dim) \
do { \
unsigned int d; \
for (d=0; \
d < (dim)-1 && (coord)[d] == (size)[d]; \
d++) { \
(coord)[d] = 0; \
(coord)[d+1]++; \
} \
} while (0)
/*
******** NRRD_COORD_INCR
**
** same as NRRD_COORD_UPDATE, but starts by incrementing coord[idx]
*/
#define NRRD_COORD_INCR(coord, size, dim, idx) \
do { \
unsigned int d; \
for (d=idx, (coord)[d]++; \
d < (dim)-1 && (coord)[d] == (size)[d]; \
d++) { \
(coord)[d] = 0; \
(coord)[d+1]++; \
} \
} while (0)
/*
******** NRRD_INDEX_GEN
**
** Given a coordinate array "coord", as well as the array sizes "size"
** and dimension "dim", calculates the linear index, and stores it in
** "I".
*/
#define NRRD_INDEX_GEN(I, coord, size, dim) \
{ \
int d; \
d = (dim) - 1; \
if ((d) >= 0) { \
(I) = (coord)[d]; \
d--; \
while (d >= 0) { \
(I) = (coord)[d] + (size)[d] * (I); \
d--; \
} \
} else { \
(I) = 0; \
} \
}
/*
******** NRRD_COORD_GEN
**
** opposite of NRRD_INDEX_GEN: going from linear index "I" to
** coordinate array "coord".
**
** HUGE NOTE: the I argument will end up as ZERO when this is done!
** If passing a loop control variable, pass a copy instead!
** Hello, side-effects! This is awful!
*/
#define NRRD_COORD_GEN(coord, size, dim, I) \
do { \
unsigned int d; \
for (d=0; d<=(dim)-1; d++) { \
(coord)[d] = I % (size)[d]; \
I /= (size)[d]; \
} \
} while (0)
#ifdef __cplusplus
}
#endif
#endif /* NRRD_MACROS_HAS_BEEN_INCLUDED */
|