[vtkusers] File compression using vtkZlibCompressor

Mathieu Malaterre mathieu.malaterre at kitware.com
Wed Jun 9 13:59:12 EDT 2004


Henry,

	Why can't you use a vtkUnstructuredGrid for that ? For example :

   vtkUnstructuredGrid *cube = vtkUnstructuredGrid::New();
   vtkPoints *points = vtkPoints::New();
   points->SetNumberOfPoints(numPts);
   vtkCellArray *polys = vtkCellArray::New();
   vtkDoubleArray *scalars = vtkDoubleArray::New();
   scalars->SetNumberOfComponents( numComp );
   scalars->SetNumberOfTuples(numPts);


   //Loop now over my data structure:
   for(i=0;i<numPts;i++)
   {
      double pts[3];
      my_library_call_get_point(i, pts)
      points->InsertPoint(i, pts);
   }
   //cell
...


   // We now assign the pieces to the vtkUnstructuredGrid.
   cube->SetPoints(points);
   points->Delete();
   cube->SetCells(VTK_TETRA, polys);
   polys->Delete();
   cube->GetPointData()->SetScalars(scalars);
   scalars->Delete();

   vtkXMLUnstructuredGridWriter *writer = 
vtkXMLUnstructuredGridWriter::New();
   writer->SetInput( cube );
   writer->SetFileName( "convert.vtk" );
   writer->SetFileTypeToBinary();
   writer->Write();

HTH
Mathieu


Henry J. Karpf wrote:
> Hello,
> Thank you for the response.  What i am doing is converting polygon data 
> from another program to the vtkXMLUnstructuredGrid format, and not even 
> using vtk to generate the file.  Right now it is huge as all the point 
> values and cell information is stored in ascii, which is a waste, and i 
> was wonderign if there was any quick c++ program to convert from an 
> uncompressed file to a compressed one, and automatically recalculate the 
> offsets for the cells into the points array?
> Any information is welcome.
> 
> Mathieu Malaterre wrote:
> 
>> Henry,
>>
>>     Did you try the vtkXML*Writer family ? They use compression by 
>> default.
>>
>>     Typical use is:
>>
>> package require vtk
>> package require vtkinteraction
>> package require vtktesting
>>
>> vtkVolume16Reader v16
>>   v16 SetDataDimensions 64 64
>>   [v16 GetOutput] SetOrigin 0.0 0.0 0.0
>>   v16 SetDataByteOrderToLittleEndian
>>   v16 SetFilePrefix "$VTK_DATA_ROOT/Data/headsq/quarter"
>>   v16 SetImageRange 1 93
>>   v16 SetDataSpacing 3.2 3.2 1.5
>>   v16 Update
>>
>>
>> vtkXMLImageDataWriter writer
>>   writer SetInput [v16 GetOutput]
>>   writer SetFileName compress.vtk
>>   writer Write
>>
>>
>> HTH
>> Mathieu
>>
>> Henry J. Karpf wrote:
>>
>>> I have files that are fairly large and it takes a while to read them. 
>>> When i resave them using compression they open much quiker.  Is there 
>>> a way that i can avoid this process of writing my files, opening them 
>>> adn then resaving them.  Like how do i write out automatically to a 
>>> compressed file?  Any examples would be great.  Also when compressed 
>>> how do you calculate the offsets in the appended data? Thanks.
>>>
>>>
>>> _______________________________________________
>>> This is the private VTK discussion list. Please keep messages 
>>> on-topic. Check the FAQ at: <http://public.kitware.com/cgi-bin/vtkfaq>
>>> Follow this link to subscribe/unsubscribe:
>>> http://www.vtk.org/mailman/listinfo/vtkusers
>>>
>>
>>
>>
> 
> 
> 
> _______________________________________________
> This is the private VTK discussion list. Please keep messages on-topic. 
> Check the FAQ at: <http://public.kitware.com/cgi-bin/vtkfaq>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
> 






More information about the vtkusers mailing list