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

Method ComputeRequiredArrays

Common/DataModel/vtkDataSetAttributes.cxx:216–308  ·  view source on GitHub ↗

------------------------------------------------------------------------------ This method is used to determine which arrays will be copied to this object

Source from the content-addressed store, hash-verified

214// This method is used to determine which arrays
215// will be copied to this object
216vtkFieldData::BasicIterator vtkDataSetAttributes::ComputeRequiredArrays(
217 vtkDataSetAttributes* pd, int ctype)
218{
219 if ((ctype < COPYTUPLE) || (ctype > PASSDATA))
220 {
221 vtkErrorMacro("Must call compute required with COPYTUPLE, INTERPOLATE or PASSDATA");
222 ctype = COPYTUPLE;
223 }
224
225 // We need to do some juggling to find the number of arrays
226 // which will be passed.
227
228 // First, find the number of arrays to be copied because they
229 // are in the list of _fields_ to be copied (and the actual data
230 // pointer is non-nullptr). Also, we keep those indices in a list.
231 int* copyFlags = new int[pd->GetNumberOfArrays()];
232 int index, i, numArrays = 0;
233 for (i = 0; i < pd->GetNumberOfArrays(); ++i)
234 {
235 const char* arrayName = pd->GetArrayName(i);
236 // If there is no blocker for the given array
237 // and both CopyAllOff and CopyOn for that array are not true
238 if ((this->GetFlag(arrayName) != 0) &&
239 !(this->DoCopyAllOff && (this->GetFlag(arrayName) != 1)) && pd->GetAbstractArray(i))
240 {
241 // Cannot interpolate idtype arrays
242 if (ctype != INTERPOLATE || pd->GetAbstractArray(i)->GetDataType() != VTK_ID_TYPE)
243 {
244 copyFlags[numArrays] = i;
245 numArrays++;
246 }
247 }
248 }
249
250 // Next, we check the arrays to be copied because they are one of
251 // the _attributes_ to be copied (and the data array in non-nullptr).
252 // We make sure that we don't count anything twice.
253 bool alreadyCopied;
254 int attributeType;
255 for (attributeType = 0; attributeType < NUM_ATTRIBUTES; ++attributeType)
256 {
257 index = pd->AttributeIndices[attributeType];
258 int flag = this->GetFlag(pd->GetArrayName(index));
259 // If this attribute is to be copied
260 if (this->CopyAttributeFlags[ctype][attributeType] && flag)
261 {
262 // Find out if it is also in the list of fields to be copied
263 // Since attributes can only be vtkDataArray, we use GetArray() call.
264 if (pd->GetArray(index))
265 {
266 alreadyCopied = false;
267 for (i = 0; i < numArrays; ++i)
268 {
269 if (index == copyFlags[i])
270 {
271 alreadyCopied = true;
272 }
273 }

Callers 2

PassDataMethod · 0.95
InternalCopyAllocateMethod · 0.95

Calls 6

GetAbstractArrayMethod · 0.80
GetNumberOfArraysMethod · 0.45
GetArrayNameMethod · 0.45
GetFlagMethod · 0.45
GetDataTypeMethod · 0.45
GetArrayMethod · 0.45

Tested by

no test coverage detected