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

Method ReadTextureFile

IO/Geometry/vtkBYUReader.cxx:357–403  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

355}
356
357void vtkBYUReader::ReadTextureFile(int numPts, vtkInformation* outInfo)
358{
359 FILE* textureFp;
360 int i;
361 float t[2];
362 vtkFloatArray* newTCoords;
363 vtkPolyData* output = vtkPolyData::SafeDownCast(outInfo->Get(vtkDataObject::DATA_OBJECT()));
364
365 if (this->ReadTexture && this->TextureFileName)
366 {
367 if (!(textureFp = vtksys::SystemTools::Fopen(this->TextureFileName, "r")))
368 {
369 vtkErrorMacro(<< "Couldn't open texture file");
370 return;
371 }
372 }
373 else
374 {
375 return;
376 }
377 //
378 // Allocate and read data
379 //
380 newTCoords = vtkFloatArray::New();
381 newTCoords->SetNumberOfComponents(3);
382 newTCoords->SetNumberOfTuples(numPts);
383
384 for (i = 0; i < numPts; i++)
385 {
386 auto resultTCoord = vtk::scan<float, float>(textureFp, "{:e} {:e}");
387 if (!resultTCoord)
388 {
389 vtkErrorMacro(<< "Error reading texture file: " << this->TextureFileName
390 << "Message: " << resultTCoord.error().msg());
391 fclose(textureFp);
392 return;
393 }
394 std::tie(t[0], t[1]) = resultTCoord->values();
395 newTCoords->SetTypedTuple(i, t);
396 }
397
398 fclose(textureFp);
399 vtkDebugMacro(<< "Read " << numPts << " texture coordinates");
400
401 output->GetPointData()->SetTCoords(newTCoords);
402 newTCoords->Delete();
403}
404
405//------------------------------------------------------------------------------
406// This source does not know how to generate pieces yet.

Callers 1

RequestDataMethod · 0.95

Calls 10

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

Tested by

no test coverage detected