------------------------------------------------------------------------------
| 303 | |
| 304 | //------------------------------------------------------------------------------ |
| 305 | vtkInformation* vtkDataObject::SetActiveAttribute( |
| 306 | vtkInformation* info, int fieldAssociation, const char* attributeName, int attributeType) |
| 307 | { |
| 308 | int i; |
| 309 | vtkInformation* fieldDataInfo; |
| 310 | vtkInformationVector* fieldDataInfoVector; |
| 311 | |
| 312 | if (fieldAssociation == FIELD_ASSOCIATION_POINTS) |
| 313 | { |
| 314 | fieldDataInfoVector = info->Get(POINT_DATA_VECTOR()); |
| 315 | } |
| 316 | else if (fieldAssociation == FIELD_ASSOCIATION_CELLS) |
| 317 | { |
| 318 | fieldDataInfoVector = info->Get(CELL_DATA_VECTOR()); |
| 319 | } |
| 320 | else if (fieldAssociation == FIELD_ASSOCIATION_VERTICES) |
| 321 | { |
| 322 | fieldDataInfoVector = info->Get(VERTEX_DATA_VECTOR()); |
| 323 | } |
| 324 | else if (fieldAssociation == FIELD_ASSOCIATION_EDGES) |
| 325 | { |
| 326 | fieldDataInfoVector = info->Get(EDGE_DATA_VECTOR()); |
| 327 | } |
| 328 | else |
| 329 | { |
| 330 | vtkGenericWarningMacro("Unrecognized field association!"); |
| 331 | return nullptr; |
| 332 | } |
| 333 | if (!fieldDataInfoVector) |
| 334 | { |
| 335 | fieldDataInfoVector = vtkInformationVector::New(); |
| 336 | if (fieldAssociation == FIELD_ASSOCIATION_POINTS) |
| 337 | { |
| 338 | info->Set(POINT_DATA_VECTOR(), fieldDataInfoVector); |
| 339 | } |
| 340 | else if (fieldAssociation == FIELD_ASSOCIATION_CELLS) |
| 341 | { |
| 342 | info->Set(CELL_DATA_VECTOR(), fieldDataInfoVector); |
| 343 | } |
| 344 | else if (fieldAssociation == FIELD_ASSOCIATION_VERTICES) |
| 345 | { |
| 346 | info->Set(VERTEX_DATA_VECTOR(), fieldDataInfoVector); |
| 347 | } |
| 348 | else // if (fieldAssociation == FIELD_ASSOCIATION_EDGES) |
| 349 | { |
| 350 | info->Set(EDGE_DATA_VECTOR(), fieldDataInfoVector); |
| 351 | } |
| 352 | fieldDataInfoVector->FastDelete(); |
| 353 | } |
| 354 | |
| 355 | // if we find a matching field, turn it on (active); if another field of same |
| 356 | // attribute type was active, turn it off (not active) |
| 357 | vtkInformation* activeField = nullptr; |
| 358 | int activeAttribute; |
| 359 | const char* fieldName; |
| 360 | for (i = 0; i < fieldDataInfoVector->GetNumberOfInformationObjects(); i++) |
| 361 | { |
| 362 | fieldDataInfo = fieldDataInfoVector->GetInformationObject(i); |