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

Method CopyAttributeData

Common/ExecutionModel/vtkImageAlgorithm.cxx:208–359  ·  view source on GitHub ↗

------------------------------------------------------------------------------ by default copy the attr from the first input to the first output

Source from the content-addressed store, hash-verified

206//------------------------------------------------------------------------------
207// by default copy the attr from the first input to the first output
208void vtkImageAlgorithm::CopyAttributeData(
209 vtkImageData* input, vtkImageData* output, vtkInformationVector** inputVector)
210{
211 if (!input || !output)
212 {
213 return;
214 }
215
216 int inExt[6];
217 int outExt[6];
218 vtkDataArray* inArray;
219 vtkDataArray* outArray;
220
221 input->GetExtent(inExt);
222 output->GetExtent(outExt);
223
224 // Do not copy the array we will be generating.
225 inArray = this->GetInputArrayToProcess(0, inputVector);
226
227 // Conditionally copy point and cell data. Only copy if corresponding
228 // indexes refer to identical points.
229 double* oIn = input->GetOrigin();
230 double* sIn = input->GetSpacing();
231 double* oOut = output->GetOrigin();
232 double* sOut = output->GetSpacing();
233 if (oIn[0] == oOut[0] && oIn[1] == oOut[1] && oIn[2] == oOut[2] && sIn[0] == sOut[0] &&
234 sIn[1] == sOut[1] && sIn[2] == sOut[2])
235 {
236 output->GetPointData()->CopyAllOn();
237 output->GetCellData()->CopyAllOn();
238 if (inArray && inArray->GetName())
239 {
240 output->GetPointData()->CopyFieldOff(inArray->GetName());
241 }
242 else if (inArray == input->GetPointData()->GetScalars())
243 {
244 output->GetPointData()->CopyScalarsOff();
245 }
246
247 // If the extents are the same, then pass the attribute data for
248 // efficiency.
249 if (inExt[0] == outExt[0] && inExt[1] == outExt[1] && inExt[2] == outExt[2] &&
250 inExt[3] == outExt[3] && inExt[4] == outExt[4] && inExt[5] == outExt[5])
251 { // Pass
252 // set the name of the output to match the input name
253 outArray = output->GetPointData()->GetScalars();
254 if (inArray)
255 {
256 outArray->SetName(inArray->GetName());
257 for (int i = 0; i < inArray->GetNumberOfComponents(); ++i)
258 {
259 outArray->SetComponentName(i, inArray->GetComponentName(i));
260 }
261 }
262 // Cache the scalars otherwise it may get overwritten
263 // during CopyAttributes()
264 outArray->Register(this);
265 output->GetPointData()->SetScalars(nullptr);

Callers 2

PrepareImageDataMethod · 0.45
RequestDataMethod · 0.45

Calls 15

CopyFieldOffMethod · 0.80
SetComponentNameMethod · 0.80
GetComponentNameMethod · 0.80
SetScalarsMethod · 0.80
CopyAttributesMethod · 0.80
CopyStructuredDataMethod · 0.80
GetExtentMethod · 0.45
GetOriginMethod · 0.45
GetSpacingMethod · 0.45
CopyAllOnMethod · 0.45
GetPointDataMethod · 0.45

Tested by 1

RequestDataMethod · 0.36