------------------------------------------------------------------------------ Read normal point attributes. Return 0 if error.
| 2352 | //------------------------------------------------------------------------------ |
| 2353 | // Read normal point attributes. Return 0 if error. |
| 2354 | int vtkDataReader::ReadNormalData(vtkDataSetAttributes* a, vtkIdType numPts) |
| 2355 | { |
| 2356 | int skipNormal = 0; |
| 2357 | char line[256], name[256]; |
| 2358 | vtkDataArray* data; |
| 2359 | char buffer[256]; |
| 2360 | |
| 2361 | if (!(this->ReadString(buffer) && this->ReadString(line))) |
| 2362 | { |
| 2363 | const char* fname = this->CurrentFileName.c_str(); |
| 2364 | vtkErrorMacro(<< "Cannot read normal data!" |
| 2365 | << " for file: " << (fname ? fname : "(Null FileName)")); |
| 2366 | return 0; |
| 2367 | } |
| 2368 | this->DecodeString(name, buffer); |
| 2369 | |
| 2370 | // |
| 2371 | // See whether normal has been already read or normal name (if specified) |
| 2372 | // matches name in file. |
| 2373 | // |
| 2374 | if (a->GetNormals() != nullptr || (this->NormalsName && strcmp(name, this->NormalsName) != 0)) |
| 2375 | { |
| 2376 | skipNormal = 1; |
| 2377 | } |
| 2378 | |
| 2379 | data = vtkArrayDownCast<vtkDataArray>(this->ReadArray(line, numPts, 3)); |
| 2380 | if (data != nullptr) |
| 2381 | { |
| 2382 | data->SetName(name); |
| 2383 | if (!skipNormal) |
| 2384 | { |
| 2385 | a->SetNormals(data); |
| 2386 | } |
| 2387 | else if (this->ReadAllNormals) |
| 2388 | { |
| 2389 | a->AddArray(data); |
| 2390 | } |
| 2391 | data->Delete(); |
| 2392 | } |
| 2393 | else |
| 2394 | { |
| 2395 | return 0; |
| 2396 | } |
| 2397 | |
| 2398 | float progress = this->GetProgress(); |
| 2399 | this->UpdateProgress(progress + 0.5 * (1.0 - progress)); |
| 2400 | |
| 2401 | return 1; |
| 2402 | } |
| 2403 | |
| 2404 | //------------------------------------------------------------------------------ |
| 2405 | // Read tensor point attributes. Return 0 if error. |
no test coverage detected