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.<div>
<br></div><div>Jeff<br><br><div class="gmail_quote">On Tue, Jun 22, 2010 at 2:48 PM, David Doria <span dir="ltr"><<a href="mailto:daviddoria%2Bvtk@gmail.com">daviddoria+vtk@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div><div></div><div class="h5">On Tue, Jun 22, 2010 at 2:05 PM, Dean Inglis <<a href="mailto:dean.inglis@camris.ca">dean.inglis@camris.ca</a>> wrote:<br>
> I'm trying to write out a vtkTable with vtkDelimetedTextWriter<br>
> into a comma separated value file (csv) but I can only recover<br>
> the first row of the table. I modified the Wiki/Example Table.cxx<br>
> below as a test. Can anyone else verify this behaviour?<br>
> (CMake 2.6 patch 4, Win Vista, VS 2005 Express, static build).<br>
><br>
> Dean<br>
><br>
><br>
> #include <vtkTable.h><br>
> #include <vtkDelimitedTextWriter.h><br>
> #include <vtkVariant.h><br>
> #include <vtkVariantArray.h><br>
> #include <vtkSmartPointer.h><br>
><br>
> int main(int, char *[])<br>
> {<br>
> //construct an empty table<br>
> vtkSmartPointer<vtkTable> table =<br>
> vtkSmartPointer<vtkTable>::New();<br>
><br>
> for ( unsigned int i = 0; i < 3; i++ )<br>
> {<br>
> vtkSmartPointer<vtkVariantArray> col =<br>
> vtkSmartPointer<vtkVariantArray>::New();<br>
> col->SetName(vtkVariant(i).ToString().c_str());<br>
> col->InsertNextValue ( vtkVariant ( 0.0 ) );<br>
> col->InsertNextValue ( vtkVariant ( 0.0 ) );<br>
> col->InsertNextValue ( vtkVariant ( 0.0 ) );<br>
> table->AddColumn ( col );<br>
> }<br>
><br>
> //fill the table with values<br>
> unsigned int counter = 0;<br>
> for(vtkIdType r = 0; r < table->GetNumberOfRows(); r++ )<br>
> {<br>
> for(vtkIdType c = 0; c < table->GetNumberOfColumns(); c++ )<br>
> {<br>
> table->SetValue ( r,c, vtkVariant ( counter ) );<br>
> counter++;<br>
> }<br>
> }<br>
><br>
> //print information about the table<br>
> std::cout << "NumRows: " << table->GetNumberOfRows() << std::endl;<br>
> std::cout << "NumCols: " << table->GetNumberOfColumns() << std::endl;<br>
><br>
> //display the table<br>
> table->Dump ( 3 );<br>
><br>
> //access elements of the table<br>
> for(vtkIdType r = 0; r < table->GetNumberOfRows(); r++ )<br>
> {<br>
> for(vtkIdType c = 0; c < table->GetNumberOfColumns(); c++ )<br>
> {<br>
> vtkVariant v = table->GetValue( r,c);<br>
> std::cout << "(r,c) = (" << r << "," << c << ") = " << v << std::endl;<br>
> }<br>
> }<br>
><br>
> vtkSmartPointer<vtkDelimitedTextWriter> delimitedWriter =<br>
> vtkSmartPointer<vtkDelimitedTextWriter>::New();<br>
> delimitedWriter->DebugOn();<br>
> delimitedWriter->SetFileName("test.csv");<br>
> delimitedWriter->SetInput(table);<br>
> delimitedWriter->Write();<br>
><br>
> return EXIT_SUCCESS;<br>
> }<br>
<br>
</div></div>I can confirm this, the csv file that is created contains only<br>
"0","1","2"<br>
<br>
The table that is output in the code is 3x3, so we seem to only be<br>
getting the first row.<br>
<font color="#888888"><br>
David<br>
</font><div><div></div><div class="h5">_______________________________________________<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Please keep messages on-topic and check the VTK FAQ at: <a href="http://www.vtk.org/Wiki/VTK_FAQ" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.vtk.org/mailman/listinfo/vtkusers" target="_blank">http://www.vtk.org/mailman/listinfo/vtkusers</a><br>
</div></div></blockquote></div><br><br clear="all"><br>-- <br>Jeff Baumes, Ph.D.<br>Technical Lead, Kitware Inc.<br>(518) 881-4932<br>
</div>