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

Function ComputeGlobalOrigin

Filters/Parallel/vtkAlignImageDataSetFilter.cxx:38–83  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

36}
37
38bool ComputeGlobalOrigin(vtkVector3d& origin, const std::vector<vtkImageData*>& images,
39 vtkMultiProcessController* controller, const int minimumExtent[3])
40{
41 // First, confirm that spacing is compatible. All images must have the same
42 // spacing otherwise we cannot pick a valid global origin/extent.
43 vtkVector3d spacing =
44 images.empty() ? vtkVector3d(0.0) : vtkVector3d(images.front()->GetSpacing());
45 for (auto* image : images)
46 {
47 if (image->GetNumberOfPoints() > 0)
48 {
49 const vtkVector3d imgSpacing(image->GetSpacing());
50 if (spacing != imgSpacing)
51 {
52 spacing = vtkVector3d(VTK_DOUBLE_MAX);
53 }
54 }
55 }
56
57 vtkVector3d globalSpacing = AllGather(spacing, controller);
58 if (!IsSpacingValid(globalSpacing))
59 {
60 vtkLogF(ERROR, "Cannot determine acceptable global spacing.");
61 return false;
62 }
63
64 // Compute global bounds to determine the global image origin.
65 vtkBoundingBox bbox;
66 for (auto* image : images)
67 {
68 bbox.AddBounds(image->GetBounds());
69 }
70
71 vtkBoundingBox globalBounds;
72 controller->AllReduce(bbox, globalBounds);
73 globalBounds.GetMinPoint(origin.GetData());
74
75 // globalOrigin is based on the extent set at (0, 0, 0) right now. we need to adjust
76 // globalOrigin based on minimumExtent though.
77 for (int cc = 0; cc < 3; ++cc)
78 {
79 origin[cc] -= minimumExtent[cc] * spacing[cc];
80 }
81
82 return true;
83}
84
85}
86

Callers 1

RequestDataMethod · 0.85

Calls 12

IsSpacingValidFunction · 0.85
GetMinPointMethod · 0.80
AllGatherFunction · 0.70
vtkVector3dClass · 0.50
emptyMethod · 0.45
GetSpacingMethod · 0.45
frontMethod · 0.45
GetNumberOfPointsMethod · 0.45
AddBoundsMethod · 0.45
GetBoundsMethod · 0.45
AllReduceMethod · 0.45
GetDataMethod · 0.45

Tested by

no test coverage detected