MCPcopy Create free account
hub / github.com/Kitware/VTK / EvaluateGradient

Method EvaluateGradient

Common/DataModel/vtkBox.cxx:178–295  ·  view source on GitHub ↗

------------------------------------------------------------------------------ Evaluate box gradient.

Source from the content-addressed store, hash-verified

176//------------------------------------------------------------------------------
177// Evaluate box gradient.
178void vtkBox::EvaluateGradient(double x[3], double n[3])
179{
180 int i, loc[3], minAxis = 0;
181 double dist, minDist = VTK_DOUBLE_MAX, center[3];
182 double inDir[3], outDir[3];
183 const double* minP = this->BBox->GetMinPoint();
184 const double* maxP = this->BBox->GetMaxPoint();
185
186 // Compute the location of the point with respect to the box.
187 // Ultimately the point will lie in one of 27 separate regions around
188 // or within the box. The gradient vector is computed differently in
189 // each of the regions.
190 inDir[0] = inDir[1] = inDir[2] = 0.0;
191 outDir[0] = outDir[1] = outDir[2] = 0.0;
192 this->BBox->GetCenter(center);
193 for (i = 0; i < 3; i++)
194 {
195 if (x[i] < minP[i])
196 {
197 loc[i] = 0;
198 outDir[i] = -1.0;
199 }
200 else if (x[i] > maxP[i])
201 {
202 loc[i] = 2;
203 outDir[i] = 1.0;
204 }
205 else
206 {
207 loc[i] = 1;
208 if (x[i] <= center[i])
209 {
210 dist = x[i] - minP[i];
211 inDir[i] = -1.0;
212 }
213 else
214 {
215 dist = maxP[i] - x[i];
216 inDir[i] = 1.0;
217 }
218 if (dist < minDist) // remember, it's negative
219 {
220 minDist = dist;
221 minAxis = i;
222 }
223 } // if inside
224 } // for all coordinate directions
225
226 int indx = loc[0] + 3 * loc[1] + 9 * loc[2];
227
228 switch (indx)
229 {
230 // verts - gradient points away from center point
231 case 0:
232 case 2:
233 case 6:
234 case 8:
235 case 18:

Callers 4

FunctionGradientMethod · 0.45
UnitTestImplicitVolumeFunction · 0.45
TestCoordinateFrameFunction · 0.45
UnitTestImplicitDataSetFunction · 0.45

Calls 5

GetMinPointMethod · 0.80
GetMaxPointMethod · 0.80
NormalizeFunction · 0.70
assertFunction · 0.50
GetCenterMethod · 0.45

Tested by 3

UnitTestImplicitVolumeFunction · 0.36
TestCoordinateFrameFunction · 0.36
UnitTestImplicitDataSetFunction · 0.36