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

Method ComputeStructuredCoordinates

Common/DataModel/vtkAMRBox.cxx:426–504  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

424}
425
426int vtkAMRBox::ComputeStructuredCoordinates(const vtkAMRBox& box, const double dataOrigin[3],
427 const double h[3], const double x[3], int ijk[3], double pcoords[3])
428{
429 double origin[3];
430 vtkAMRBox::GetBoxOrigin(box, dataOrigin, h, origin);
431
432 int num[3];
433 box.GetNumberOfNodes(num);
434 int extent[6] = { 0, num[0] - 1, 0, num[1] - 1, 0, num[2] - 1 };
435
436 double bounds[6];
437 vtkAMRBox::GetBounds(box, dataOrigin, h, bounds);
438
439 // tolerance is needed for 2D data (this is squared tolerance)
440 constexpr double tol2 = 1e-12;
441
442 //
443 // Compute the ijk location
444 //
445 int isInBounds = 1;
446 for (int i = 0; i < 3; i++)
447 {
448 double d = x[i] - origin[i];
449 double doubleLoc = d / h[i];
450 // Floor for negative indexes.
451 ijk[i] = vtkMath::Floor(doubleLoc);
452 pcoords[i] = doubleLoc - static_cast<double>(ijk[i]);
453
454 int tmpInBounds = 0;
455 int minExt = extent[i * 2];
456 int maxExt = extent[i * 2 + 1];
457
458 // check if data is one pixel thick
459 if (minExt == maxExt)
460 {
461 double dist = x[i] - bounds[2 * i];
462 if (dist * dist <= h[i] * h[i] * tol2)
463 {
464 pcoords[i] = 0.0;
465 ijk[i] = minExt;
466 tmpInBounds = 1;
467 }
468 }
469
470 // low boundary check
471 else if (ijk[i] < minExt)
472 {
473 if ((h[i] >= 0 && x[i] >= bounds[i * 2]) || (h[i] < 0 && x[i] <= bounds[i * 2 + 1]))
474 {
475 pcoords[i] = 0.0;
476 ijk[i] = minExt;
477 tmpInBounds = 1;
478 }
479 }
480
481 // high boundary check
482 else if (ijk[i] >= maxExt)
483 {

Callers 8

EvaluateFunctionMethod · 0.45
EvaluateGradientMethod · 0.45
DoTestFunction · 0.45
FoundDonorMethod · 0.45

Calls 2

GetBoundsFunction · 0.70
GetNumberOfNodesMethod · 0.45

Tested by 1

DoTestFunction · 0.36