[vtkusers] bug in vtkXMLWriterC_SetCellsWithTypes ?

Frédéric Petit fredmfp at gmail.com
Fri Feb 23 08:29:25 EST 2007


>
> Hi,
>
> Ok, let's go for a short example (just the idea).
>
> 1) I suppose that _all_ my cells are VTK_VOXEL type.
>
> int nbpoints=(dim_x+1)*(dim_y+1)*(dim_z+1);
>
> int nbcells=dim_x*dim_y*dim_z;
>
> vtkXMLWriterC_SetDataObjectType(writer, VTK_UNSTRUCTURED_GRID);
>
> /* fill my vtk_points tab */
>
> vtk_points = malloc(3*nbpoints*sizeof(float));
>
> .../...
>
> vtkXMLWriterC_SetPoints(writer, VTK_FLOAT, vtk_points, nbpoints);
>
> /* fill my vtk_cells tab & vtk_cells_type */
>
> vtk_cells = malloc((VTK_NB_POINTS_VOXEL+1)*nbcells);
>
> .../...
>
> vtk_cells_type = malloc(nbcells*sizeof(int));
>
> for (p=0; p<nbcells; p++)
>
> vtk_cells_type[p] = VTK_VOXEL;
>
> vtkXMLWriterC_SetCellsWithTypes(writer,
>
> vtk_cells_type, nbcells, vtk_cells, VTK_NB_POINTS_VOXEL+1);
>
> This (should) work. It does, in fact ;-)
>
> 2) Now, I have nb_cells_quad VTK_QUAD (4 vertices) and dim_x*dim_y*dim_z
> VTK_VOXEL (8 vertices).
>
> int nbpoints=(dim_x+1)*(dim_y+1)*(dim_z+1);
>
> int nbcells=dim_x*dim_y*dim_z+nb_cells_quad;
>
> vtkXMLWriterC_SetDataObjectType(writer, VTK_UNSTRUCTURED_GRID);
>
> /* fill my vtk_points tab */
>
> vtk_points = malloc(3*nbpoints*sizeof(float));
>
> .../...
>
> vtkXMLWriterC_SetPoints(writer, VTK_FLOAT, vtk_points, nbpoints);
>
> /* fill my vtk_cells tab & vtk_cells_type */
>
> vtk_cells = malloc((VTK_NB_POINTS_VOXEL+1)*(dim_x*dim_y*dim_z) +
>
> (VTK_NB_POINTS_QUAD+1)*nb_cells_quad);
>
> .../...
>
> vtk_cells_type = malloc(nbcells*sizeof(int));
>
> for (p=0; p<(dim_x*dim_y*dim_z); p++)
>
> vtk_cells_type[p] = VTK_VOXEL;
>
> for (p=(dim_x*dim_y*dim_z); p<(dim_x*dim_y*dim_z)+nb_cells_quad; p++)
>
> vtk_cells_type[p] = VTK_QUAD;
>
> The problem is here: for size cells, vtkXMLWriterC_SetCellsWithTypes
> should be a pointer
>
> because I have several cells sizes; but it uses an integer, so only one
> value can be set;
>
> this obviously does not work (and my code core dumps).
>
> vtkXMLWriterC_SetCellsWithTypes(writer,
>
> vtk_cells_type, nbcells, vtk_cells, VTK_NB_POINTS_VOXEL+1);
>
> ^^^^^^^^^^^^^^^^^^^^^
>
> So I'm thinking of something like this:
>
> vtk_cells_size = malloc(nbcells*sizeof(int));
>
> for (p=0; p<(dim_x*dim_y*dim_z); p++)
>
> vtk_cells_size[p] = VTK_NB_POINTS_VOXEL + 1;
>
> for (p=(dim_x*dim_y*dim_z); p<(dim_x*dim_y*dim_z)+nb_cells_quad); p++)
>
> vtk_cells_size[p] = VTK_NB_POINTS_QUAD + 1;
>
> and then
>
> vtkXMLWriterC_SetCellsWithTypes(writer,
>
> vtk_cells_type, nbcells, vtk_cells, vtk_cells_size);
>
> ^^^^^^^^^^^^^^
>
> But vtkXMLWriterC_SetCellsWithTypes() should have to be modified to do
> that because you need
>
> to pass a pointer instead of an integer.
>
> Or may be I misunderstood how to use vtkXMLWriterC_SetCellsWithTypes() ?
>
> Another argument (from my own opinion ;-) is that
> vtkXMLWriterC_SetCellsWithType()
>
> (without s) uses cellType and cellsSize integer arguments.
>
> I think these two arguments must have the same dimension.
>
> So in vtkXMLWriterC_SetCellsWithTypes() (with s), as cellTypes is a
> pointer,
>
> cellSize should be a pointer too.
>
> Cheers,
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20070223/f73cffc6/attachment.htm>


More information about the vtkusers mailing list