[vtkusers] VTK and zlib

Sébastien Blaise seb.belese at laposte.net
Mon Feb 9 03:57:33 EST 2009


Hi,

I try to write a VTK compressed file (uncompressed works fine), but I 
have the following error when I open it in Paraview:

ERROR: In /build/buildd/paraview-3.2.2/VTK/IO/vtkXMLDataParser.cxx, line 
434
vtkXMLDataParser (0xa02c998): Error reading beginning of compression 
header. Read 0 of 12 bytes.

ERROR: In 
/build/buildd/paraview-3.2.2/VTK/IO/vtkXMLUnstructuredDataReader.cxx, 
line 515
vtkXMLUnstructuredGridReader (0xa030228): Cannot read points array from 
Points in piece 0. The data array in the element may be too short.


I don't understand what is wrong. I followed instructions from 
(http://www.vtkedge.org/Wiki/VTK_XML_Formats), using only one block et 
the moment. I read the header with GHex and it seems OK. The critical 
part of the code is (zlib_compress is a function I implemented to 
compress the buffer). :

#ifdef HAVE_ZLIB
               if (compression_level!=0){
                   unsigned int header[4];
                   header[0]=1;
                   header[1]=data_size;
                   header[2]=0;
                   header[3]=zlib_compress((unsigned 
char*)buffer_sol.str().c_str(),&compressed_sol,data_size,compression_level); 

                   fstream_sol.write((char *)header,4*sizeof(unsigned 
int));
                   
fstream_sol.write(compressed_sol.str().c_str(),header[3]);
                   fstream_sol.flush();
               }else
#endif
                   {
                       fstream_sol.write((char 
*)(&data_size),sizeof(unsigned int));
                       
fstream_sol.write(buffer_sol.str().c_str(),data_size);
                   }

Do you have any idea of what can be wrong?

Thanks for any help,
Sébastien



More information about the vtkusers mailing list