------------------------------------------------------------------------------ Read tensor point attributes. Return 0 if error.
| 2404 | //------------------------------------------------------------------------------ |
| 2405 | // Read tensor point attributes. Return 0 if error. |
| 2406 | int vtkDataReader::ReadTensorData(vtkDataSetAttributes* a, vtkIdType numPts, vtkIdType numComp) |
| 2407 | { |
| 2408 | int skipTensor = 0; |
| 2409 | char line[256], name[256]; |
| 2410 | vtkDataArray* data; |
| 2411 | char buffer[256]; |
| 2412 | |
| 2413 | if (!(this->ReadString(buffer) && this->ReadString(line))) |
| 2414 | { |
| 2415 | const char* fname = this->CurrentFileName.c_str(); |
| 2416 | vtkErrorMacro(<< "Cannot read tensor data!" |
| 2417 | << " for file: " << (fname ? fname : "(Null FileName)")); |
| 2418 | return 0; |
| 2419 | } |
| 2420 | this->DecodeString(name, buffer); |
| 2421 | // |
| 2422 | // See whether tensor has been already read or tensor name (if specified) |
| 2423 | // matches name in file. |
| 2424 | // |
| 2425 | if (a->GetTensors() != nullptr || (this->TensorsName && strcmp(name, this->TensorsName) != 0)) |
| 2426 | { |
| 2427 | skipTensor = 1; |
| 2428 | } |
| 2429 | |
| 2430 | data = vtkArrayDownCast<vtkDataArray>(this->ReadArray(line, numPts, numComp)); |
| 2431 | if (data != nullptr) |
| 2432 | { |
| 2433 | data->SetName(name); |
| 2434 | if (!skipTensor) |
| 2435 | { |
| 2436 | a->SetTensors(data); |
| 2437 | } |
| 2438 | else if (this->ReadAllTensors) |
| 2439 | { |
| 2440 | a->AddArray(data); |
| 2441 | } |
| 2442 | data->Delete(); |
| 2443 | } |
| 2444 | else |
| 2445 | { |
| 2446 | return 0; |
| 2447 | } |
| 2448 | |
| 2449 | float progress = this->GetProgress(); |
| 2450 | this->UpdateProgress(progress + 0.5 * (1.0 - progress)); |
| 2451 | |
| 2452 | return 1; |
| 2453 | } |
| 2454 | |
| 2455 | //------------------------------------------------------------------------------ |
| 2456 | // Read color scalar point attributes. Return 0 if error. |
no test coverage detected