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

Method Initialize

Common/DataModel/vtkExtractStructuredGridHelper.cxx:109–195  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

107
108//------------------------------------------------------------------------------
109void vtkExtractStructuredGridHelper::Initialize(
110 int inVoi[6], int wholeExtent[6], int sampleRate[3], bool includeBoundary)
111{
112 assert("pre: nullptr index map" && (this->IndexMap != nullptr));
113
114 // Copy the VOI because we'll clamp it later:
115 int voi[6];
116 std::copy(inVoi, inVoi + 6, voi);
117
118 // Have the parameters actually changed?
119 if (std::equal(voi, voi + 6, this->VOI) &&
120 std::equal(wholeExtent, wholeExtent + 6, this->InputWholeExtent) &&
121 std::equal(sampleRate, sampleRate + 3, this->SampleRate) &&
122 includeBoundary == this->IncludeBoundary)
123 {
124 // Nope.
125 return;
126 }
127
128 // Is the VOI valid?
129 if (voi[1] < voi[0] || voi[3] < voi[2] || voi[5] < voi[4])
130 {
131 this->Invalidate();
132 vtkWarningMacro("Invalid volume of interest: ["
133 << " [ " << voi[0] << ", " << voi[1] << " ], "
134 << " [ " << voi[2] << ", " << voi[3] << " ], "
135 << " [ " << voi[4] << ", " << voi[5] << " ] ]");
136 return;
137 }
138
139 // Save the input parameters so we'll know when the map is out of date
140 std::copy(voi, voi + 6, this->VOI);
141 std::copy(wholeExtent, wholeExtent + 6, this->InputWholeExtent);
142 std::copy(sampleRate, sampleRate + 3, this->SampleRate);
143 this->IncludeBoundary = includeBoundary;
144
145 vtkBoundingBox wExtB(
146 wholeExtent[0], wholeExtent[1], wholeExtent[2], wholeExtent[3], wholeExtent[4], wholeExtent[5]);
147 vtkBoundingBox voiB(voi[0], voi[1], voi[2], voi[3], voi[4], voi[5]);
148
149 if (!wExtB.Intersects(voiB))
150 {
151 this->Invalidate();
152 vtkDebugMacro(<< "Extent [" << wholeExtent[0] << ", " << wholeExtent[1] << ", "
153 << wholeExtent[2] << ", " << wholeExtent[3] << ", " << wholeExtent[4] << ", "
154 << wholeExtent[5] << "] does not contain VOI [" << voi[0] << ", " << voi[1]
155 << ", " << voi[2] << ", " << voi[3] << ", " << voi[4] << ", " << voi[5] << "].");
156 return;
157 }
158
159 // Clamp VOI to Whole Extent
160 vtkStructuredExtent::Clamp(voi, wholeExtent);
161
162 // Create mapping between output extent and input extent.
163 // Compute the output whole extent in the process.
164 for (int dim = 0; dim < 3; ++dim)
165 {
166 // +2: +1 to include start/end points, +1 in case we need to append an

Callers

nothing calls this directly

Calls 8

InvalidateMethod · 0.95
assertFunction · 0.50
copyFunction · 0.50
equalFunction · 0.50
ClampFunction · 0.50
IntersectsMethod · 0.45
resizeMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected