[vtkusers] vtkDelimetedTextWriter error

Jeff Baumes jeff.baumes at kitware.com
Thu Jul 1 09:49:58 EDT 2010


The issue was that vtkArrayIteratorTemplateMacro did not handle the case for
vtkVariantArray. vtkDelimitedTextWriter is using this macro, so did not
print out vtkVariantArray data correctly. I added a case to the macro and
committed it, so this problem should be fixed now.

Jeff

On Tue, Jun 22, 2010 at 2:48 PM, David Doria
<daviddoria+vtk at gmail.com<daviddoria%2Bvtk at gmail.com>
> wrote:

> On Tue, Jun 22, 2010 at 2:05 PM, Dean Inglis <dean.inglis at camris.ca>
> wrote:
> > I'm trying to write out a vtkTable with vtkDelimetedTextWriter
> > into a comma separated value file (csv) but I can only recover
> > the first row of the table.  I modified the Wiki/Example Table.cxx
> > below as a test.   Can anyone else verify this behaviour?
> > (CMake 2.6 patch 4, Win Vista, VS 2005 Express, static build).
> >
> > Dean
> >
> >
> > #include <vtkTable.h>
> > #include <vtkDelimitedTextWriter.h>
> > #include <vtkVariant.h>
> > #include <vtkVariantArray.h>
> > #include <vtkSmartPointer.h>
> >
> > int main(int, char *[])
> > {
> >  //construct an empty table
> >  vtkSmartPointer<vtkTable> table =
> >   vtkSmartPointer<vtkTable>::New();
> >
> >  for ( unsigned int i = 0; i < 3; i++ )
> >   {
> >   vtkSmartPointer<vtkVariantArray> col =
> >     vtkSmartPointer<vtkVariantArray>::New();
> >   col->SetName(vtkVariant(i).ToString().c_str());
> >   col->InsertNextValue ( vtkVariant ( 0.0 ) );
> >   col->InsertNextValue ( vtkVariant ( 0.0 ) );
> >   col->InsertNextValue ( vtkVariant ( 0.0 ) );
> >   table->AddColumn ( col );
> >   }
> >
> >  //fill the table with values
> >  unsigned int counter = 0;
> >  for(vtkIdType r = 0; r < table->GetNumberOfRows(); r++ )
> >   {
> >   for(vtkIdType c = 0; c < table->GetNumberOfColumns(); c++ )
> >     {
> >     table->SetValue ( r,c, vtkVariant ( counter ) );
> >     counter++;
> >     }
> >   }
> >
> >  //print information about the table
> >  std::cout << "NumRows: " << table->GetNumberOfRows() << std::endl;
> >  std::cout << "NumCols: " << table->GetNumberOfColumns() << std::endl;
> >
> >  //display the table
> >  table->Dump ( 3 );
> >
> >  //access elements of the table
> >  for(vtkIdType r = 0; r < table->GetNumberOfRows(); r++ )
> >  {
> >   for(vtkIdType c = 0; c < table->GetNumberOfColumns(); c++ )
> >   {
> >     vtkVariant v = table->GetValue( r,c);
> >     std::cout << "(r,c) = (" << r << "," << c << ") = " << v <<
> std::endl;
> >   }
> >  }
> >
> >  vtkSmartPointer<vtkDelimitedTextWriter> delimitedWriter =
> > vtkSmartPointer<vtkDelimitedTextWriter>::New();
> >  delimitedWriter->DebugOn();
> >  delimitedWriter->SetFileName("test.csv");
> >  delimitedWriter->SetInput(table);
> >  delimitedWriter->Write();
> >
> >  return EXIT_SUCCESS;
> > }
>
> I can confirm this, the csv file that is created contains only
> "0","1","2"
>
> The table that is output in the code is 3x3, so we seem to only be
> getting the first row.
>
> David
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>



-- 
Jeff Baumes, Ph.D.
Technical Lead, Kitware Inc.
(518) 881-4932
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20100701/dd568d58/attachment.htm>


More information about the vtkusers mailing list