[vtkusers] Bug in vtkStructuredPointsWriter when using Field Data

Richard Strelitz strelitz at lanl.gov
Thu Apr 24 10:20:55 EDT 2003


There is a sequencing problem in this routine such that the
field data is written after the data set header but before the
Dimensions, Spacing, and especially Point Data lines.

I have included a program that demonstrates this, plus 2 files:
  the first has the field data and the incorrect sequencing; the
  second data file only writes out a single scalar field; the
  output here is correct.  The program attached generated this file.

While I understand that the Field Data class is scheduled to be
deprecated, I would still like this issue addressed.

Thanks,
   Richard Strelitz
   Vis. Team, Advanced Computing Lab, CCS-1
   LANL

----------------------------------
Program:

#include "vtkStructuredPoints.h"
#include "vtkStructuredPointsWriter.h"
#include "vtkFloatArray.h"
#include "vtkFieldData.h"
#include "vtkRenderer.h"
#include "vtkRenderWindow.h"
#include "vtkRenderWindowInteractor.h"

  void main(int argc, char **argv)
{   int Nvals= 2*3*4;

vtkFloatArray *pQC = vtkFloatArray::New();
              pQC-SetName("QC");
                 pQC->Allocate(Nvals);
                 pQC->SetNumberOfComponents(1);
                 pQC->SetNumberOfValues(Nvals);

vtkFloatArray *pQR = vtkFloatArray::New();
              pQR->SetName("QR");
                 pQR->Allocate(Nvals);
              pQR->SetNumberOfComponents(1);
                 pQR->SetNumberOfValues(Nvals);
                 float dummy[24]={1,2,3,4,5,6,7,8,9,10,11,12,
                         13,14,15,16,17,18,19,20,21,22,23,24};

         vtkFieldData *pField = vtkFieldData::New();
            pField->AllocateArrays(2);

         for(int j=0;j<Nvals;j++){       pQC-SetComponent(j,0,dummy[j]);}
         pField->AddArray(pQC);


         for(int j=0;j<Nvals;j++) {pQR-SetComponent(j,0,dummy[23-j]); }
                         pField-AddArray(pQR);

     float rangeC[2],rangeR[2];
         pQC->GetRange(rangeC);pQR-GetRange(rangeR);
         printf(" RANGE %8.3f %8.3f \n",rangeC[1],rangeR[1]);


vtkStructuredPoints *pGridr = vtkStructuredPoints::New();
            pGridr->SetDimensions(2,3,4);
            pGridr->AllocateScalars();
            pGridr->GetPointData()-SetScalars(pQC);
         //   pGridr->SetFieldData(pField);
            pGridr->Update();


            vtkStructuredPointsWriter *pWR =
vtkStructuredPointsWriter::New();
            pWR->SetFileName("F:/Wilhelmson/Small2.vtk");
            pWR->SetInput(pGridr);
            pWR->SetFileTypeToASCII();
            pWR->Write();
}
---------------
---------------Data File 1: Small.vtk  [BAD]
# vtk DataFile Version 3.0
vtk output
ASCII
DATASET STRUCTURED_POINTS
FIELD FieldData 2
QC 1 24 float
1 2 3 4 5 6 7 8 9
10 11 12 13 14 15 16 17 18
19 20 21 22 23 24
QR 1 24 float
24 23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8 7
6 5 4 3 2 1
DIMENSIONS 2 3 4
SPACING 1 1 1
ORIGIN 0 0 0
CELL_DATA 6
POINT_DATA 24

--------------------
--------------------DataFile 2: Small2.vtk
# vtk DataFile Version 3.0
vtk output
ASCII
DATASET STRUCTURED_POINTS
DIMENSIONS 2 3 4
SPACING 1 1 1
ORIGIN 0 0 0
CELL_DATA 6
POINT_DATA 24
SCALARS scalars float
LOOKUP_TABLE default
1 2 3 4 5 6 7 8 9
10 11 12 13 14 15 16 17 18
19 20 21 22 23 24






More information about the vtkusers mailing list