MCPcopy Create free account
hub / github.com/Kitware/VTK / ReadDisplacementFile

Method ReadDisplacementFile

IO/Geometry/vtkBYUReader.cxx:262–308  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

260}
261
262void 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
310void vtkBYUReader::ReadScalarFile(int numPts, vtkInformation* outInfo)
311{

Callers 1

RequestDataMethod · 0.95

Calls 10

SetVectorsMethod · 0.80
DeleteMethod · 0.65
NewFunction · 0.50
GetMethod · 0.45
SetNumberOfComponentsMethod · 0.45
SetNumberOfTuplesMethod · 0.45
errorMethod · 0.45
valuesMethod · 0.45
SetTypedTupleMethod · 0.45
GetPointDataMethod · 0.45

Tested by

no test coverage detected