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

Method ComputeBounds

Common/DataModel/vtkImageData.cxx:444–521  ·  view source on GitHub ↗

------------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

442
443//------------------------------------------------------------------------------
444void vtkImageData::ComputeBounds()
445{
446 if (this->GetMTime() <= this->ComputeTime)
447 {
448 return;
449 }
450 const int* extent = this->GetExtent();
451
452 if (extent[0] > extent[1] || extent[2] > extent[3] || extent[4] > extent[5])
453 {
454 vtkMath::UninitializeBounds(this->Bounds);
455 }
456 else
457 {
458 if (this->DirectionMatrixIsIdentity)
459 {
460 // Direction is identity: bounds are easy to compute
461 // with only origin and spacing
462 const double* origin = this->Origin;
463 const double* spacing = this->Spacing;
464 int swapXBounds = (spacing[0] < 0); // 1 if true, 0 if false
465 int swapYBounds = (spacing[1] < 0); // 1 if true, 0 if false
466 int swapZBounds = (spacing[2] < 0); // 1 if true, 0 if false
467
468 this->Bounds[0] = origin[0] + (extent[0 + swapXBounds] * spacing[0]);
469 this->Bounds[2] = origin[1] + (extent[2 + swapYBounds] * spacing[1]);
470 this->Bounds[4] = origin[2] + (extent[4 + swapZBounds] * spacing[2]);
471
472 this->Bounds[1] = origin[0] + (extent[1 - swapXBounds] * spacing[0]);
473 this->Bounds[3] = origin[1] + (extent[3 - swapYBounds] * spacing[1]);
474 this->Bounds[5] = origin[2] + (extent[5 - swapZBounds] * spacing[2]);
475 }
476 else
477 {
478 // Direction isn't identity: use IndexToPhysical matrix
479 // to determine the position of the dataset corners
480 int iMin, iMax, jMin, jMax, kMin, kMax;
481 iMin = extent[0];
482 iMax = extent[1];
483 jMin = extent[2];
484 jMax = extent[3];
485 kMin = extent[4];
486 kMax = extent[5];
487 int ijkCorners[8][3] = {
488 { iMin, jMin, kMin },
489 { iMax, jMin, kMin },
490 { iMin, jMax, kMin },
491 { iMax, jMax, kMin },
492 { iMin, jMin, kMax },
493 { iMax, jMin, kMax },
494 { iMin, jMax, kMax },
495 { iMax, jMax, kMax },
496 };
497
498 double xyz[3];
499 double xMin, xMax, yMin, yMax, zMin, zMax;
500 xMin = yMin = zMin = VTK_DOUBLE_MAX;
501 xMax = yMax = zMax = VTK_DOUBLE_MIN;

Callers

nothing calls this directly

Calls 7

UninitializeBoundsFunction · 0.85
minFunction · 0.50
maxFunction · 0.50
GetMTimeMethod · 0.45
GetExtentMethod · 0.45
ModifiedMethod · 0.45

Tested by

no test coverage detected