[vtkusers] Re: Bug in vtkPlot3DReader.cxx andinvtkMultiBlockPLOT3DReader.cxx

Mark B Stucky mstucky5 at cox.net
Tue Nov 14 17:43:51 EST 2006


I found an additional bug that shows up when reading
a multi-block solution (Fortran unformatted) file.

In the section of code that loops over "numBlocks"
the final

    this->SkipByteCount(qFp);

is missing.  See below for more detail...

I uploaded (to http://www.vtk.org/Bug ) a new patch
file with the new fix.

--Mark Stucky



int vtkMultiBlockPLOT3DReader::RequestData(
  vtkInformation*, vtkInformationVector**, vtkInformationVector* 
outputVector)
{

        [...]


  // Now read the solution.
  if (this->QFileName && this->QFileName[0] != '\0')
    {
    FILE* qFp;
    if ( this->CheckSolutionFile(qFp) != VTK_OK)
      {
      return 0;
      }

    if ( this->ReadQHeader(qFp) != VTK_OK )
      {
      fclose(qFp);
      return 0;
      }

    for(i=0; i<numBlocks; i++)
      {
      vtkStructuredGrid* nthOutput = this->Internal->Blocks[i];

      float fsmach, alpha, re, time;

      this->SkipByteCount(qFp);
      this->ReadFloatBlock(qFp, 1, &fsmach);
      this->ReadFloatBlock(qFp, 1, &alpha);
      this->ReadFloatBlock(qFp, 1, &re);
      this->ReadFloatBlock(qFp, 1, &time);
      this->SkipByteCount(qFp);

      // Save the properties first
      vtkFloatArray* properties = vtkFloatArray::New();
      properties->SetName("Properties");
      properties->SetNumberOfTuples(4);
      properties->SetTuple1(0, fsmach);
      properties->SetTuple1(1, alpha);
      properties->SetTuple1(2, re);
      properties->SetTuple1(3, time);
      nthOutput->GetFieldData()->AddArray(properties);
      properties->Delete();

      int dims[6];
      nthOutput->GetWholeExtent(dims);
      nthOutput->SetExtent(dims);
      nthOutput->GetDimensions(dims);

      this->SkipByteCount(qFp);            // The beginning "SkipByteCount" 
was present

          [...]

      vtkFloatArray* se = vtkFloatArray::New();
      se->SetNumberOfComponents(1);
      se->SetNumberOfTuples( dims[0]*dims[1]*dims[2] );
      se->SetName("StagnationEnergy");
      float* sen = se->GetPointer(0);
      if (this->ReadFloatBlock(qFp, dims[0]*dims[1]*dims[2], sen) == 0)
        {
        vtkErrorMacro("Encountered premature end-of-file while reading "
                      "the q file (or the file is corrupt).");
        fclose(qFp);
        return 0;
        }
      nthOutput->GetPointData()->AddArray(se);
      se->Delete();

      this->SkipByteCount(qFp);              // But the final 
"SkipByteCount" was missing

          [...]


------------------------------------------------------------------------

*** vtkPLOT3DReader.cxx.old Fri Nov 10 10:11:24 2006
--- vtkPLOT3DReader.cxx Tue Nov 14 14:52:34 2006
***************
*** 570,576 ****
      int ni, nj, nk;
      this->ReadIntBlock(fp, 1, &ni);
      this->ReadIntBlock(fp, 1, &nj);
!     this->ReadIntBlock(fp, 1, &nk);
      vtkDebugMacro("Q, block " << i << " dimensions: "
                    << ni << " " << nj << " " << nk);

--- 570,583 ----
      int ni, nj, nk;
      this->ReadIntBlock(fp, 1, &ni);
      this->ReadIntBlock(fp, 1, &nj);
!     if (!this->TwoDimensionalGeometry)
!       {
!       this->ReadIntBlock(fp, 1, &nk);
!       }
!     else
!       {
!       nk = 1;
!       }
      vtkDebugMacro("Q, block " << i << " dimensions: "
                    << ni << " " << nj << " " << nk);

***************
*** 958,963 ****
--- 965,971 ----
        nthOutput->GetPointData()->AddArray(se);
        se->Delete();

+       this->SkipByteCount(qFp);

        if ( this->FunctionList->GetNumberOfTuples() > 0 )
          {
*** vtkMultiBlockPLOT3DReader.cxx.old Fri Nov 10 10:11:32 2006
--- vtkMultiBlockPLOT3DReader.cxx Tue Nov 14 14:51:31 2006
***************
*** 589,595 ****
      int ni, nj, nk;
      this->ReadIntBlock(fp, 1, &ni);
      this->ReadIntBlock(fp, 1, &nj);
!     this->ReadIntBlock(fp, 1, &nk);
      vtkDebugMacro("Q, block " << i << " dimensions: "
                    << ni << " " << nj << " " << nk);

--- 589,602 ----
      int ni, nj, nk;
      this->ReadIntBlock(fp, 1, &ni);
      this->ReadIntBlock(fp, 1, &nj);
!     if (!this->TwoDimensionalGeometry)
!       {
!       this->ReadIntBlock(fp, 1, &nk);
!       }
!     else
!       {
!       nk = 1;
!       }
      vtkDebugMacro("Q, block " << i << " dimensions: "
                    << ni << " " << nj << " " << nk);

***************
*** 1012,1017 ****
--- 1019,1025 ----
        nthOutput->GetPointData()->AddArray(se);
        se->Delete();

+       this->SkipByteCount(qFp);

        if ( this->FunctionList->GetNumberOfTuples() > 0 )
          {






More information about the vtkusers mailing list