------------------------------------------------------------------------------ Read vector point attributes. Return 0 if error.
| 2300 | //------------------------------------------------------------------------------ |
| 2301 | // Read vector point attributes. Return 0 if error. |
| 2302 | int vtkDataReader::ReadVectorData(vtkDataSetAttributes* a, vtkIdType numPts) |
| 2303 | { |
| 2304 | int skipVector = 0; |
| 2305 | char line[256], name[256]; |
| 2306 | vtkDataArray* data; |
| 2307 | char buffer[256]; |
| 2308 | |
| 2309 | if (!(this->ReadString(buffer) && this->ReadString(line))) |
| 2310 | { |
| 2311 | const char* fname = this->CurrentFileName.c_str(); |
| 2312 | vtkErrorMacro(<< "Cannot read vector data!" |
| 2313 | << " for file: " << (fname ? fname : "(Null FileName)")); |
| 2314 | return 0; |
| 2315 | } |
| 2316 | this->DecodeString(name, buffer); |
| 2317 | |
| 2318 | // |
| 2319 | // See whether vector has been already read or vector name (if specified) |
| 2320 | // matches name in file. |
| 2321 | // |
| 2322 | if (a->GetVectors() != nullptr || (this->VectorsName && strcmp(name, this->VectorsName) != 0)) |
| 2323 | { |
| 2324 | skipVector = 1; |
| 2325 | } |
| 2326 | |
| 2327 | data = vtkArrayDownCast<vtkDataArray>(this->ReadArray(line, numPts, 3)); |
| 2328 | if (data != nullptr) |
| 2329 | { |
| 2330 | data->SetName(name); |
| 2331 | if (!skipVector) |
| 2332 | { |
| 2333 | a->SetVectors(data); |
| 2334 | } |
| 2335 | else if (this->ReadAllVectors) |
| 2336 | { |
| 2337 | a->AddArray(data); |
| 2338 | } |
| 2339 | data->Delete(); |
| 2340 | } |
| 2341 | else |
| 2342 | { |
| 2343 | return 0; |
| 2344 | } |
| 2345 | |
| 2346 | float progress = this->GetProgress(); |
| 2347 | this->UpdateProgress(progress + 0.5 * (1.0 - progress)); |
| 2348 | |
| 2349 | return 1; |
| 2350 | } |
| 2351 | |
| 2352 | //------------------------------------------------------------------------------ |
| 2353 | // Read normal point attributes. Return 0 if error. |
no test coverage detected