[vtkusers] error vtkXMLWriterC_SetCellsWithTypes

hadrien calmet hadrien.calmet at bsc.es
Fri Nov 8 10:32:11 EST 2013


Hi everybody

I think I found a bug in the function /IO/XML/vtkXMLWriterC.cxx/ 
vtkXMLWriterC_SetCellsWithTypes/ vtkXMLWriterC_NewCellArray


//---------------------------------------------------------------------------- 

static
vtkSmartPointer<vtkCellArray>
vtkXMLWriterC_NewCellArray(const char* method, vtkIdType ncells,
                            vtkIdType* cells, vtkIdType cellsSize)
{
   // Create a vtkIdTypeArray to reference the cells.
   vtkSmartPointer<vtkIdTypeArray> array =
     vtkSmartPointer<vtkIdTypeArray>::New();
   if(!array)
     {
     vtkGenericWarningMacro(
       "vtkXMLWriterC_" << method << " failed to allocate a 
vtkIdTypeArray."
       );
     return 0;
     }
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
the error is here
   //array->SetArray(cells, ncells*cellsSize, 1);
my correction is
   array->SetArray(cells, cellsSize, 1);
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
   // Create the cell array.
   vtkSmartPointer<vtkCellArray> cellArray =
     vtkSmartPointer<vtkCellArray>::New();
   if(!cellArray)
     {
     vtkGenericWarningMacro(
       "vtkXMLWriterC_" << method << " failed to allocate a vtkCellArray."
       );
     return 0;
     }
   cellArray->SetCells(ncells, array);
   return cellArray;
}

//---------------------------------------------------------------------------- 


I just want that someone less newbie than me confirm my correction.
I modified the hello program to test it.
It is Fortran, but finally it is the same call
thank you



PROGRAM Hello
   INTEGER writer
   INTEGER success
   INTEGER*8 numpoints/10/
   INTEGER*8 numcells/2/
   INTEGER*8 cellsSize/16/
   REAL*4 pdata(10)/0,0,0,0,1,1,1,1,0,0/
   REAL*4 points(30)/0,0,0, 1,0,0, 1,1,0, 0,1,0, 0,0,1, 1,0,1, 1,1,1, 
0,1,1, 0,0,2, 0,1,2/
   INTEGER*8 cells(16)/8,0,1,2,3,4,5,6,7,6,4,5,8,7,6,9/
   INTEGER*4 cellTypes(2)/12,13/

   call vtkXMLWriterF_New(writer)
   call vtkXMLWriterF_SetDataObjectType(writer, 4)
   call vtkXMLWriterF_SetDataModeType(writer, 0)
   call vtkXMLWriterF_SetFileName(writer, 'test1.vtu')
   call vtkXMLWriterF_SetPoints(writer, 10, points, numpoints)
   call vtkXMLWriterF_SetCellsWithTypes(writer, cellTypes ,numcells, 
cells, cellsSize)
   call vtkXMLWriterF_SetPointData(writer, 'example data', 10, pdata, 
numpoints, 1, 'SCALARS')
   call vtkXMLWriterF_Write(writer, success)
   call vtkXMLWriterF_Delete(writer)
   PRINT *, 'success =', success
END PROGRAM Hello

-- 
Hadrien Calmet
Dpt. Computer Applications in Science and Engineering
Barcelona Supercomputing Center (BSC-CNS)
Edificio NEXUS I, Office 204
c) Gran Capitan 2-4
08034 Barcelona, Spain
Tel: +34 93 405 4289
Fax: +34 93 413 7721
Www: www.bsc.es



WARNING / LEGAL TEXT: This message is intended only for the use of the
individual or entity to which it is addressed and may contain
information which is privileged, confidential, proprietary, or exempt
from disclosure under applicable law. If you are not the intended
recipient or the person responsible for delivering the message to the
intended recipient, you are strictly prohibited from disclosing,
distributing, copying, or in any way using this message. If you have
received this communication in error, please notify the sender and
destroy and delete any copies you may have received.

http://www.bsc.es/disclaimer
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20131108/f2ce4190/attachment.htm>


More information about the vtkusers mailing list