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

Method LoadVariableData

IO/Geometry/vtkWindBladeReader.cxx:528–574  ·  view source on GitHub ↗

------------------------------------------------------------------------------ Load one variable data array of BLOCK structure into ParaView ------------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

526// Load one variable data array of BLOCK structure into ParaView
527//------------------------------------------------------------------------------
528void vtkWindBladeReader::LoadVariableData(int var)
529{
530 this->Data[var]->Delete();
531 this->Data[var] = vtkFloatArray::New();
532 this->Data[var]->SetName(VariableName[var].c_str());
533
534 // Skip to the appropriate variable block and read byte count
535 // not used? int byteCount;
536 fseek(this->Internal->FilePtr, this->VariableOffset[var], SEEK_SET);
537
538 int numberOfComponents = 0, planeSize = 0, rowSize;
539 float* varData = nullptr;
540 float* block = new float[this->BlockSize];
541 this->InitVariableData(var, numberOfComponents, varData, planeSize, rowSize);
542 for (int comp = 0; comp < numberOfComponents; comp++)
543 {
544 // Read the block of data
545 size_t cnt;
546 if ((cnt = fread(block, sizeof(float), this->BlockSize, this->Internal->FilePtr)) !=
547 this->BlockSize)
548 {
549 // This is really an error, but for the time being we report a
550 // warning
551 vtkWarningMacro("WindBladeReader error reading file: "
552 << this->Filename << " Premature EOF while reading block of data."
553 << " Expected " << this->BlockSize << " but got " << cnt);
554 }
555
556 int pos = comp;
557 for (int k = this->SubExtent[4]; k <= this->SubExtent[5]; k++)
558 {
559 for (int j = this->SubExtent[2]; j <= this->SubExtent[3]; j++)
560 {
561 for (int i = this->SubExtent[0]; i <= this->SubExtent[1]; i++)
562 {
563 int index = (k * planeSize) + (j * rowSize) + i;
564 varData[pos] = block[index];
565 pos += numberOfComponents;
566 }
567 }
568 }
569
570 // Skip closing and opening byte sizes
571 fseek(this->Internal->FilePtr, (2 * sizeof(int)), SEEK_CUR);
572 }
573 delete[] block;
574}
575
576//------------------------------------------------------------------------------
577// Load one variable data array of BLOCK structure into ParaView

Callers 1

SetUpFieldVarsMethod · 0.95

Calls 5

InitVariableDataMethod · 0.95
DeleteMethod · 0.65
NewFunction · 0.50
SetNameMethod · 0.45
c_strMethod · 0.45

Tested by

no test coverage detected