[vtk-developers] vtkXMLCompositeDataWriter does not write vtkPolyData

Pierre Fillard pierre.fillard at gmail.com
Mon Dec 6 08:35:11 EST 2010


Hello,


I was trying to write a vtkMultiBlockDataSet using *
vtkXMLMultiBlockDataWriter*.


My vtkMultiBlockDataSet is composed with multiple vtkPolyData by calling:

*vtkMultiBlockDataSet *dataset = vtkMultiBlockDataSet::New();
dataset->SetBlock( id, some_vtk_polydata);*


Using the vtkXMLMultiBlockDataWriter to save it creates the xml file, but
the <DataSet> tag remains empty (and the vtkPolyData is not saved).


I tracked this problem down to the method:

*vtkStdString vtkXMLCompositeDataWriter::CreatePieceFileName(int piece)*

whose role is to return a valid filename given the block number to be
written. However, I noticed that the method starts by this check:

*if(this->Internal->DataTypes[piece] <= 0)
    {
    return fname;
    }
*

The array DataTypes is filled in the method:

*void vtkXMLCompositeDataWriter::FillDataTypes(vtkCompositeDataSet* hdInput)
*

and contains the vtk type of each block dataset (e.g., VTK_POLY_DATA,
VTK_UNSTRUCTED_GRID, etc.) such that the writer knows what extension to use,
and which writer to instanciate. If the vtkDataSet is not recognized,
*-1*is passed to the array.


Now, going back to *vtkXMLCompositeDataWriter::CreatePieceFileName()*, the
check: *if(this->Internal->DataTypes[piece] <= 0)* invalidates data whose
type is 0 (and less than 0 of course). It appears that VTK_POLY_DATA is
defined as 0! So with this check, it becomes impossible to write vtkPolyData
using vtkXMLMultiBlockDataWriter.


Changing the check to:
*
if(this->Internal->DataTypes[piece] < 0)*

solved the problem.


Maybe I am missing something obvious, but in case this is a bug, I attached
a patch to this mail (file IO/vtkXMLCompositeDataWriter.cxx).


Hope this will be useful.

Pierre.



-- 
Pierre Fillard, Ph.D.,
Research Scientist
INRIA Parietal - Neurospin
Bât 145, Point Courrier 156
91191 Gif/Yvette, France
tel: +33 1 69 08 79 92
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtk-developers/attachments/20101206/95676882/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: vtkXMLCompositeDataWriter.cxx.patch
Type: text/x-patch
Size: 103 bytes
Desc: not available
URL: <http://public.kitware.com/pipermail/vtk-developers/attachments/20101206/95676882/attachment-0001.bin>


More information about the vtk-developers mailing list