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

Method ReadTensorData

IO/Legacy/vtkDataReader.cxx:2406–2453  ·  view source on GitHub ↗

------------------------------------------------------------------------------ Read tensor point attributes. Return 0 if error.

Source from the content-addressed store, hash-verified

2404//------------------------------------------------------------------------------
2405// Read tensor point attributes. Return 0 if error.
2406int vtkDataReader::ReadTensorData(vtkDataSetAttributes* a, vtkIdType numPts, vtkIdType numComp)
2407{
2408 int skipTensor = 0;
2409 char line[256], name[256];
2410 vtkDataArray* data;
2411 char buffer[256];
2412
2413 if (!(this->ReadString(buffer) && this->ReadString(line)))
2414 {
2415 const char* fname = this->CurrentFileName.c_str();
2416 vtkErrorMacro(<< "Cannot read tensor data!"
2417 << " for file: " << (fname ? fname : "(Null FileName)"));
2418 return 0;
2419 }
2420 this->DecodeString(name, buffer);
2421 //
2422 // See whether tensor has been already read or tensor name (if specified)
2423 // matches name in file.
2424 //
2425 if (a->GetTensors() != nullptr || (this->TensorsName && strcmp(name, this->TensorsName) != 0))
2426 {
2427 skipTensor = 1;
2428 }
2429
2430 data = vtkArrayDownCast<vtkDataArray>(this->ReadArray(line, numPts, numComp));
2431 if (data != nullptr)
2432 {
2433 data->SetName(name);
2434 if (!skipTensor)
2435 {
2436 a->SetTensors(data);
2437 }
2438 else if (this->ReadAllTensors)
2439 {
2440 a->AddArray(data);
2441 }
2442 data->Delete();
2443 }
2444 else
2445 {
2446 return 0;
2447 }
2448
2449 float progress = this->GetProgress();
2450 this->UpdateProgress(progress + 0.5 * (1.0 - progress));
2451
2452 return 1;
2453}
2454
2455//------------------------------------------------------------------------------
2456// Read color scalar point attributes. Return 0 if error.

Callers 5

ReadCellDataMethod · 0.95
ReadPointDataMethod · 0.95
ReadVertexDataMethod · 0.95
ReadEdgeDataMethod · 0.95
ReadRowDataMethod · 0.95

Calls 11

ReadStringMethod · 0.95
DecodeStringMethod · 0.95
ReadArrayMethod · 0.95
SetTensorsMethod · 0.80
DeleteMethod · 0.65
c_strMethod · 0.45
GetTensorsMethod · 0.45
SetNameMethod · 0.45
AddArrayMethod · 0.45
GetProgressMethod · 0.45
UpdateProgressMethod · 0.45

Tested by

no test coverage detected