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

Method Process

Filters/Geometry/vtkImageDataToUniformGrid.cxx:164–258  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

162
163//------------------------------------------------------------------------------
164int vtkImageDataToUniformGrid::Process(
165 vtkImageData* input, int association, const char* arrayName, vtkUniformGrid* output)
166{
167 if (vtkUniformGrid* uniformGrid = vtkUniformGrid::SafeDownCast(input))
168 {
169 output->ShallowCopy(uniformGrid);
170 }
171 else
172 {
173 output->ShallowCopy(input);
174 }
175
176 vtkDataArray* inScalars = nullptr;
177 if (association == vtkDataObject::FIELD_ASSOCIATION_POINTS)
178 {
179 inScalars = input->GetPointData()->GetArray(arrayName);
180 }
181 else if (association == vtkDataObject::FIELD_ASSOCIATION_CELLS)
182 {
183 inScalars = input->GetCellData()->GetArray(arrayName);
184 }
185 else
186 {
187 vtkErrorMacro("Wrong association type: " << association);
188 return VTK_ERROR;
189 }
190
191 if (!inScalars)
192 {
193 vtkErrorMacro("No scalar data to use for blanking.");
194 return VTK_ERROR;
195 }
196 else if (inScalars->GetNumberOfComponents() != 1)
197 {
198 vtkErrorMacro("Scalar data must be a single component array.");
199 return VTK_ERROR;
200 }
201
202 vtkNew<vtkUnsignedCharArray> blankingArray;
203 blankingArray->SetNumberOfTuples(inScalars->GetNumberOfTuples());
204 blankingArray->SetNumberOfComponents(1);
205 blankingArray->FillValue(0);
206 blankingArray->SetName(vtkDataSetAttributes::GhostArrayName());
207
208 unsigned char value1;
209 unsigned char value2;
210 if (association == vtkDataObject::FIELD_ASSOCIATION_CELLS)
211 {
212 if (this->Reverse)
213 {
214 value1 = 0;
215 value2 = vtkDataSetAttributes::HIDDENCELL;
216 }
217 else
218 {
219 value1 = vtkDataSetAttributes::HIDDENCELL;
220 value2 = 0;
221 }

Callers 1

RequestDataMethod · 0.95

Calls 14

GhostArrayNameFunction · 0.85
CheckAbortMethod · 0.80
GetTuple1Method · 0.80
ShallowCopyMethod · 0.45
GetArrayMethod · 0.45
GetPointDataMethod · 0.45
GetCellDataMethod · 0.45
GetNumberOfComponentsMethod · 0.45
SetNumberOfTuplesMethod · 0.45
GetNumberOfTuplesMethod · 0.45
SetNumberOfComponentsMethod · 0.45
SetNameMethod · 0.45

Tested by

no test coverage detected