| 260 | } |
| 261 | |
| 262 | void vtkBYUReader::ReadDisplacementFile(int numPts, vtkInformation* outInfo) |
| 263 | { |
| 264 | FILE* dispFp; |
| 265 | int i; |
| 266 | float v[3]; |
| 267 | vtkFloatArray* newVectors; |
| 268 | vtkPolyData* output = vtkPolyData::SafeDownCast(outInfo->Get(vtkDataObject::DATA_OBJECT())); |
| 269 | |
| 270 | if (this->ReadDisplacement && this->DisplacementFileName) |
| 271 | { |
| 272 | if (!(dispFp = vtksys::SystemTools::Fopen(this->DisplacementFileName, "r"))) |
| 273 | { |
| 274 | vtkErrorMacro(<< "Couldn't open displacement file"); |
| 275 | return; |
| 276 | } |
| 277 | } |
| 278 | else |
| 279 | { |
| 280 | return; |
| 281 | } |
| 282 | // |
| 283 | // Allocate and read data |
| 284 | // |
| 285 | newVectors = vtkFloatArray::New(); |
| 286 | newVectors->SetNumberOfComponents(3); |
| 287 | newVectors->SetNumberOfTuples(numPts); |
| 288 | |
| 289 | for (i = 0; i < numPts; i++) |
| 290 | { |
| 291 | auto resultDisp = vtk::scan<float, float, float>(dispFp, "{} {} {}"); |
| 292 | if (!resultDisp) |
| 293 | { |
| 294 | vtkErrorMacro(<< "Error reading displacement file: " << this->DisplacementFileName |
| 295 | << "Message: " << resultDisp.error().msg()); |
| 296 | fclose(dispFp); |
| 297 | return; |
| 298 | } |
| 299 | std::tie(v[0], v[1], v[2]) = resultDisp->values(); |
| 300 | newVectors->SetTypedTuple(i, v); |
| 301 | } |
| 302 | |
| 303 | fclose(dispFp); |
| 304 | vtkDebugMacro(<< "Read " << numPts << " displacements"); |
| 305 | |
| 306 | output->GetPointData()->SetVectors(newVectors); |
| 307 | newVectors->Delete(); |
| 308 | } |
| 309 | |
| 310 | void vtkBYUReader::ReadScalarFile(int numPts, vtkInformation* outInfo) |
| 311 | { |
no test coverage detected