[Paraview] Open vtk with zlib

Sébastien Blaise seb.belese at laposte.net
Mon Feb 23 09:56:32 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 at 
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] = ((int)(data_size*1.002))+13;
        unsigned char *compressed_sol = (unsigned char*)malloc (header[3]);
        zlib_compress((unsigned 
char*)buffer_sol.str().c_str(),compressed_sol,data_size,&header[3],compression_level); 

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

Do you have any idea of what can be wrong?

Thanks for any help,
Sébastien


More information about the ParaView mailing list