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 char * |
28 |
|
|
_gage2VecStr[] = { |
29 |
|
|
"(unknown gage2Vec)", |
30 |
|
|
"vector", |
31 |
|
|
"vector0", |
32 |
|
|
"vector1", |
33 |
|
|
"length", |
34 |
|
|
}; |
35 |
|
|
|
36 |
|
|
const char * |
37 |
|
|
_gage2VecDesc[] = { |
38 |
|
|
"unknown gage2Vec query", |
39 |
|
|
"component-wise-interpolated vector", |
40 |
|
|
"vector[0]", |
41 |
|
|
"vector[1]", |
42 |
|
|
"length of vector", |
43 |
|
|
}; |
44 |
|
|
|
45 |
|
|
const int |
46 |
|
|
_gage2VecVal[] = { |
47 |
|
|
gage2VecUnknown, |
48 |
|
|
gage2VecVector, |
49 |
|
|
gage2VecVector0, |
50 |
|
|
gage2VecVector1, |
51 |
|
|
gage2VecLength, |
52 |
|
|
}; |
53 |
|
|
|
54 |
|
|
#define GV_V gage2VecVector |
55 |
|
|
#define GV_V0 gage2VecVector0 |
56 |
|
|
#define GV_V1 gage2VecVector1 |
57 |
|
|
#define GV_L gage2VecLength |
58 |
|
|
|
59 |
|
|
const char * |
60 |
|
|
_gage2VecStrEqv[] = { |
61 |
|
|
"v", "vector", "vec", |
62 |
|
|
"v0", "vector0", "vec0", |
63 |
|
|
"v1", "vector1", "vec1", |
64 |
|
|
"l", "length", "len", |
65 |
|
|
"" |
66 |
|
|
}; |
67 |
|
|
|
68 |
|
|
const int |
69 |
|
|
_gage2VecValEqv[] = { |
70 |
|
|
GV_V, GV_V, GV_V, |
71 |
|
|
GV_V0, GV_V0, GV_V0, |
72 |
|
|
GV_V1, GV_V1, GV_V1, |
73 |
|
|
GV_L, GV_L, GV_L, |
74 |
|
|
}; |
75 |
|
|
|
76 |
|
|
const airEnum |
77 |
|
|
_gage2Vec = { |
78 |
|
|
"gage2Vec", |
79 |
|
|
GAGE_2VEC_ITEM_MAX, |
80 |
|
|
_gage2VecStr, _gage2VecVal, |
81 |
|
|
_gage2VecDesc, |
82 |
|
|
_gage2VecStrEqv, _gage2VecValEqv, |
83 |
|
|
AIR_FALSE |
84 |
|
|
}; |
85 |
|
|
const airEnum *const |
86 |
|
|
gage2Vec = &_gage2Vec; |
87 |
|
|
|
88 |
|
|
|
89 |
|
|
|
90 |
|
|
gageItemEntry |
91 |
|
|
_gage2VecTable[GAGE_2VEC_ITEM_MAX+1] = { |
92 |
|
|
/* enum value len, deriv, prereqs, parent item, parent index, needData */ |
93 |
|
|
{gage2VecUnknown, 0, 0, {0}, 0, 0, AIR_FALSE}, |
94 |
|
|
{gage2VecVector, 2, 0, {0}, 0, 0, AIR_FALSE}, |
95 |
|
|
{gage2VecVector0, 1, 0, {gage2VecVector}, gage2VecVector, 0, AIR_FALSE}, |
96 |
|
|
{gage2VecVector1, 1, 0, {gage2VecVector}, gage2VecVector, 1, AIR_FALSE}, |
97 |
|
|
{gage2VecLength, 1, 0, {gage2VecVector}, 0, 0, AIR_FALSE}, |
98 |
|
|
}; |
99 |
|
|
|
100 |
|
|
void |
101 |
|
|
_gage2VecFilter(gageContext *ctx, gagePerVolume *pvl) { |
102 |
|
|
static const char me[]="_gage2VecFilter"; |
103 |
|
|
double *fw00, *fw11, *fw22, *vec; |
104 |
|
|
int fd; |
105 |
|
|
gageScl3PFilter_t *filter[5] = {NULL, gageScl3PFilter2, gageScl3PFilter4, |
106 |
|
|
gageScl3PFilter6, gageScl3PFilter8}; |
107 |
|
|
unsigned int valIdx; |
108 |
|
|
|
109 |
|
|
fd = 2*ctx->radius; |
110 |
|
|
vec = pvl->directAnswer[gage2VecVector]; |
111 |
|
|
if (!ctx->parm.k3pack) { |
112 |
|
|
fprintf(stderr, "!%s: sorry, 6pack filtering not implemented\n", me); |
113 |
|
|
return; |
114 |
|
|
} |
115 |
|
|
fw00 = ctx->fw + fd*3*gageKernel00; |
116 |
|
|
fw11 = ctx->fw + fd*3*gageKernel11; |
117 |
|
|
fw22 = ctx->fw + fd*3*gageKernel22; |
118 |
|
|
/* perform the filtering */ |
119 |
|
|
if (fd <= 8) { |
120 |
|
|
for (valIdx=0; valIdx<2; valIdx++) { |
121 |
|
|
filter[ctx->radius](ctx->shape, |
122 |
|
|
pvl->iv3 + valIdx*fd*fd*fd, |
123 |
|
|
pvl->iv2 + valIdx*fd*fd, |
124 |
|
|
pvl->iv1 + valIdx*fd, |
125 |
|
|
fw00, fw11, fw22, |
126 |
|
|
vec + valIdx, NULL, NULL, /* jac + valIdx*2, hes + valIdx*4, */ |
127 |
|
|
pvl->needD); |
128 |
|
|
} |
129 |
|
|
} else { |
130 |
|
|
for (valIdx=0; valIdx<2; valIdx++) { |
131 |
|
|
gageScl3PFilterN(ctx->shape, fd, |
132 |
|
|
pvl->iv3 + valIdx*fd*fd*fd, |
133 |
|
|
pvl->iv2 + valIdx*fd*fd, |
134 |
|
|
pvl->iv1 + valIdx*fd, |
135 |
|
|
fw00, fw11, fw22, |
136 |
|
|
vec + valIdx, NULL, NULL, /* jac + valIdx*2, hes + valIdx*4, */ |
137 |
|
|
pvl->needD); |
138 |
|
|
} |
139 |
|
|
} |
140 |
|
|
|
141 |
|
|
return; |
142 |
|
|
} |
143 |
|
|
|
144 |
|
|
void |
145 |
|
|
_gage2VecAnswer(gageContext *ctx, gagePerVolume *pvl) { |
146 |
|
|
/* static const char me[]="_gage2VecAnswer"; */ |
147 |
|
|
double *vecAns; |
148 |
|
|
/* int asw; */ |
149 |
|
|
|
150 |
|
|
AIR_UNUSED(ctx); |
151 |
|
|
vecAns = pvl->directAnswer[gage2VecVector]; |
152 |
|
|
|
153 |
|
|
if (GAGE_QUERY_ITEM_TEST(pvl->query, gage2VecVector)) { |
154 |
|
|
/* done if doV */ |
155 |
|
|
/* |
156 |
|
|
if (ctx->verbose) { |
157 |
|
|
fprintf(stderr, "vec = %f %f", vecAns[0], vecAns[1]); |
158 |
|
|
} |
159 |
|
|
*/ |
160 |
|
|
} |
161 |
|
|
/* done if doV |
162 |
|
|
if (GAGE_QUERY_ITEM_TEST(pvl->query, gage2VecVector{0,1})) { |
163 |
|
|
} |
164 |
|
|
*/ |
165 |
|
|
if (GAGE_QUERY_ITEM_TEST(pvl->query, gage2VecLength)) { |
166 |
|
|
pvl->directAnswer[gage2VecLength][0] = ELL_2V_LEN(vecAns); |
167 |
|
|
} |
168 |
|
|
return; |
169 |
|
|
} |
170 |
|
|
|
171 |
|
|
void |
172 |
|
|
_gage2VecIv3Print (FILE *file, gageContext *ctx, gagePerVolume *pvl) { |
173 |
|
|
|
174 |
|
|
AIR_UNUSED(ctx); |
175 |
|
|
AIR_UNUSED(pvl); |
176 |
|
|
fprintf(file, "_gage2VecIv3Print() not implemented\n"); |
177 |
|
|
} |
178 |
|
|
|
179 |
|
|
gageKind |
180 |
|
|
_gageKind2Vec = { |
181 |
|
|
AIR_FALSE, /* statically allocated */ |
182 |
|
|
"2vector", |
183 |
|
|
&_gage2Vec, |
184 |
|
|
1, /* baseDim */ |
185 |
|
|
2, /* valLen */ |
186 |
|
|
GAGE_2VEC_ITEM_MAX, |
187 |
|
|
_gage2VecTable, |
188 |
|
|
_gage2VecIv3Print, |
189 |
|
|
_gage2VecFilter, |
190 |
|
|
_gage2VecAnswer, |
191 |
|
|
NULL, NULL, NULL, NULL, |
192 |
|
|
NULL |
193 |
|
|
}; |
194 |
|
|
gageKind *const |
195 |
|
|
gageKind2Vec = &_gageKind2Vec; |