----------------------------------------------------------------------------
| 286 | |
| 287 | //---------------------------------------------------------------------------- |
| 288 | void vtkPVArrayInformation::CopyFromArrayInternal( |
| 289 | vtkAbstractArray* array, GetRangeFunctor& getRangeFn) |
| 290 | { |
| 291 | assert(array != nullptr); |
| 292 | this->Name = array->GetName() ? array->GetName() : ""; |
| 293 | this->DataType = array->GetDataType(); |
| 294 | this->NumberOfTuples = array->GetNumberOfTuples(); |
| 295 | |
| 296 | const int numComponents = array->GetNumberOfComponents(); |
| 297 | this->Components.resize(numComponents + 1); // extra 1 for magnitude. |
| 298 | |
| 299 | // set default names. |
| 300 | for (int comp = -1; comp < numComponents; ++comp) |
| 301 | { |
| 302 | auto& compInfo = this->Components.at(comp + 1); |
| 303 | compInfo.DefaultName = vtkPVPostFilter::DefaultComponentName(comp, numComponents); |
| 304 | } |
| 305 | |
| 306 | // set custom component names, if non-null. |
| 307 | if (array->HasAComponentName()) |
| 308 | { |
| 309 | for (int comp = 0; comp < numComponents; ++comp) |
| 310 | { |
| 311 | auto& compInfo = this->Components.at(comp + 1); |
| 312 | if (auto name = array->GetComponentName(comp)) |
| 313 | { |
| 314 | compInfo.Name = name; |
| 315 | } |
| 316 | } |
| 317 | } |
| 318 | |
| 319 | auto dataArray = vtkDataArray::SafeDownCast(array); |
| 320 | if (dataArray && dataArray->IsNumeric()) |
| 321 | { |
| 322 | for (int comp = -1; comp < numComponents; ++comp) |
| 323 | { |
| 324 | auto& compInfo = this->Components.at(comp + 1); |
| 325 | getRangeFn(dataArray, comp, compInfo); |
| 326 | } |
| 327 | } |
| 328 | else if (auto sarray = vtkStringArray::SafeDownCast(array)) |
| 329 | { |
| 330 | for (vtkIdType cc = 0; |
| 331 | this->StringValues.size() < MAX_STRING_VALUES && cc < sarray->GetNumberOfValues(); ++cc) |
| 332 | { |
| 333 | auto value = sarray->GetValue(cc); |
| 334 | if (!value.empty()) |
| 335 | { |
| 336 | this->StringValues.push_back(value); |
| 337 | } |
| 338 | } |
| 339 | } |
| 340 | |
| 341 | if (array->HasInformation()) |
| 342 | { |
| 343 | vtkInformation* info = array->GetInformation(); |
| 344 | vtkInformationIterator* it = vtkInformationIterator::New(); |
| 345 | it->SetInformationWeak(info); |
no test coverage detected