GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: src/gage/miscGage.c Lines: 23 33 69.7 %
Date: 2017-05-26 Branches: 2 8 25.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 "gage.h"
25
#include "privateGage.h"
26
27
const int
28
gagePresent = 42;
29
30
/*
31
******** gageZeroNormal[]
32
**
33
** this is the vector to supply when someone wants the normalized
34
** version of a vector with zero length.  We could be nasty and
35
** set this to {AIR_NAN, AIR_NAN, AIR_NAN}, but simply passing
36
** NANs around can make things fantastically slow . . .
37
*/
38
double
39
gageZeroNormal[3] = {0,0,0};
40
41
const char *
42
_gageKernelStr[] = {
43
  "(unknown_kernel)",
44
  "00",
45
  "10",
46
  "11",
47
  "20",
48
  "21",
49
  "22",
50
  /* "33", */
51
  /* "44", */
52
  "stack"
53
};
54
55
const char *
56
_gageKernelDesc[] = {
57
  "unknown kernel",
58
  "kernel for reconstructing values",
59
  "kernel for reconstruction values when doing 1st derivatives",
60
  "kernel for measuring 1st derivatives when doing 1st derivatives",
61
  "kernel for reconstruction values when doing 2nd derivatives",
62
  "kernel for measuring 1st derivatives when doing 2nd derivatives",
63
  "kernel for measuring 2nd derivatives when doing 2nd derivatives",
64
  /* "kernel for measuring 3rd derivatives when doing 3rd derivatives", */
65
  /* "kernel for measuring 4th derivatives when doing 4th derivatives", */
66
  "kernel for reconstruction across a stack"
67
};
68
69
const char *
70
_gageKernelStrEqv[] = {
71
  "00", "k00",
72
  "10", "k10",
73
  "11", "k11",
74
  "20", "k20",
75
  "21", "k21",
76
  "22", "k22",
77
  /* "33", "k33", */
78
  /* "44", "k44", */
79
  "stack", "ss", "kss",
80
  ""
81
};
82
83
const int
84
_gageKernelValEqv[] = {
85
  gageKernel00, gageKernel00,
86
  gageKernel10, gageKernel10,
87
  gageKernel11, gageKernel11,
88
  gageKernel20, gageKernel20,
89
  gageKernel21, gageKernel21,
90
  gageKernel22, gageKernel22,
91
  /* gageKernel33, gageKernel33, */
92
  /* gageKernel44, gageKernel44, */
93
  gageKernelStack, gageKernelStack, gageKernelStack
94
};
95
96
const airEnum
97
_gageKernel_enum = {
98
  "kernel",
99
  GAGE_KERNEL_MAX,
100
  _gageKernelStr, NULL,
101
  _gageKernelDesc,
102
  _gageKernelStrEqv, _gageKernelValEqv,
103
  AIR_FALSE
104
};
105
const airEnum *const
106
gageKernel = &_gageKernel_enum;
107
108
void
109
gageParmReset(gageParm *parm) {
110
111
226
  if (parm) {
112
113
    parm->renormalize = gageDefRenormalize;
113
113
    parm->checkIntegrals = gageDefCheckIntegrals;
114
113
    parm->k3pack = gageDefK3Pack;
115
113
    parm->gradMagCurvMin = gageDefGradMagCurvMin;
116
113
    parm->curvNormalSide = gageDefCurvNormalSide;
117
113
    parm->kernelIntegralNearZero = gageDefKernelIntegralNearZero;
118
113
    parm->defaultCenter = gageDefDefaultCenter;
119
113
    parm->stackUse = gageDefStackUse;
120
113
    parm->stackNormalizeRecon = gageDefStackNormalizeRecon;
121
113
    parm->stackNormalizeDeriv = gageDefStackNormalizeDeriv;
122
113
    parm->stackNormalizeDerivBias = gageDefStackNormalizeDerivBias;
123
113
    parm->orientationFromSpacing = gageDefOrientationFromSpacing;
124
113
    parm->generateErrStr = gageDefGenerateErrStr;
125
113
    parm->twoDimZeroZ = gageDefTwoDimZeroZ;
126
113
  }
127
113
  return;
128
}
129
130
void
131
gagePointReset(gagePoint *point) {
132
133
906
  if (point) {
134
    unsigned int big;
135
    /* learned: can't initialize the floating point to AIR_NAN,
136
       non-dot-net windows compilers proclaim that QNAN == x
137
       for any existent x!!!  For some reason though, infinity
138
       is handled correctly */
139
453
    ELL_4V_SET(point->frac,
140
               AIR_POS_INF, AIR_POS_INF, AIR_POS_INF, AIR_POS_INF);
141
    big = AIR_CAST(unsigned int, -1);
142
453
    ELL_4V_SET(point->idx, big, big, big, big);
143
453
    point->stackFwNonZeroNum = 0;
144
453
  }
145
453
  return;
146
}
147
148
void
149
gageItemSpecInit(gageItemSpec *isp) {
150
151
  if (isp) {
152
    isp->item = -1;
153
    isp->kind = NULL;
154
  }
155
  return;
156
}
157
158
gageItemSpec *
159
gageItemSpecNew(void) {
160
  gageItemSpec *isp;
161
162
  isp = (gageItemSpec *)calloc(1, sizeof(gageItemSpec));
163
  gageItemSpecInit(isp);
164
  return isp;
165
}
166
167
gageItemSpec *
168
gageItemSpecNix(gageItemSpec *isp) {
169
170
  if (isp) {
171
    airFree(isp);
172
  }
173
  return NULL;
174
}
175
176
const char *
177
_gageErrStr[GAGE_ERR_MAX+1] = {
178
  "(unknown gageErr)",
179
  "none",
180
  "space bounds",
181
  "stack bounds",
182
  "stack integral",
183
  "stack search",
184
  "stack unused"
185
};
186
187
const airEnum
188
_gageErr = {
189
  "gageErr",
190
  GAGE_ERR_MAX,
191
  _gageErrStr, NULL,
192
  NULL,
193
  NULL, NULL,
194
  AIR_FALSE
195
};
196
const airEnum *const
197
gageErr = &_gageErr;
198
199
const char *
200
_gageItemPackPartStr[] = {
201
  "(unknown_pack_part)",
202
  "scalar",
203
  "gradvec",
204
  "gradmag",
205
  "normal",
206
  "hessian",
207
  "hesseval0",
208
  "hesseval1",
209
  "hesseval2",
210
  "hessevec0",
211
  "hessevec1",
212
  "hessevec2"
213
};
214
215
const char *
216
_gageItemPackPartDesc[] = {
217
  "unknown pack part",
218
  "the base scalar F",
219
  "gradient (vector) of F",
220
  "magnitude of the gradient of F",
221
  "normalized gradient (vector) of F",
222
  "Hessian of F",
223
  "1st eigenvalue of Hessian of F",
224
  "2nd eigenvalue of Hessian of F",
225
  "3rd eigenvalue of Hessian of F",
226
  "1st eigenvector of Hessian of F",
227
  "2nd eigenvector of Hessian of F",
228
  "3rd eigenvector of Hessian of F"
229
};
230
231
const char *
232
_gageItemPackPartStrEqv[] = {
233
  "scalar", "scl",
234
  "gradvec", "gvec",
235
  "gradmag", "gmag",
236
  "normal", "norm",
237
  "hessian", "hess",
238
  "hesseval0", "heval0",
239
  "hesseval1", "heval1",
240
  "hesseval2", "heval2",
241
  "hessevec0", "hevec0",
242
  "hessevec1", "hevec1",
243
  "hessevec2", "hevec2",
244
  ""
245
};
246
247
const int
248
_gageItemPackPartValEqv[] = {
249
  gageItemPackPartScalar,      gageItemPackPartScalar,
250
  gageItemPackPartGradVec,     gageItemPackPartGradVec,
251
  gageItemPackPartGradMag,     gageItemPackPartGradMag,
252
  gageItemPackPartNormal,      gageItemPackPartNormal,
253
  gageItemPackPartHessian,     gageItemPackPartHessian,
254
  gageItemPackPartHessEval0,   gageItemPackPartHessEval0,
255
  gageItemPackPartHessEval1,   gageItemPackPartHessEval1,
256
  gageItemPackPartHessEval2,   gageItemPackPartHessEval2,
257
  gageItemPackPartHessEvec0,   gageItemPackPartHessEvec0,
258
  gageItemPackPartHessEvec1,   gageItemPackPartHessEvec1,
259
  gageItemPackPartHessEvec2,   gageItemPackPartHessEvec2,
260
};
261
262
const airEnum
263
_gageItemPackPart_enum = {
264
  "pack part",
265
  GAGE_ITEM_PACK_PART_MAX,
266
  _gageItemPackPartStr, NULL,
267
  _gageItemPackPartDesc,
268
  _gageItemPackPartStrEqv, _gageItemPackPartValEqv,
269
  AIR_FALSE
270
};
271
const airEnum *const
272
gageItemPackPart = &_gageItemPackPart_enum;
273