<div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr">Polly,<div><br></div><div>It seems I was mistaken about the output of the vtkKMeansStatistics filter. It looks like it does not pass through the input columns with something like a cluster label. I have no experience with the filter, so I'm not sure how to guide you from here. David Thompson (CC'ed) would know more since he was an author of the filter. He may be able to help if he has time.</div><div><br></div><div>Some resources that may help:</div><div><br></div><div>Doxygen page:</div><div><a href="https://www.vtk.org/doc/nightly/html/classvtkKMeansStatistics.html#details" target="_blank">https://www.vtk.org/doc/nightly/html/classvtkKMeansStatistics.html#details</a><br></div><div><br></div><div>Example:</div><div><a href="https://www.vtk.org/gitweb?p=VTK.git;a=blob;f=Examples/Statistics/ExampleKMeansStatistics.cxx" target="_blank">https://www.vtk.org/gitweb?p=VTK.git;a=blob;f=Examples/Statistics/ExampleKMeansStatistics.cxx</a><br></div><div><br></div><div>Cory</div></div></div></div></div><br><div class="gmail_quote"><div dir="ltr">On Wed, Nov 21, 2018 at 1:16 AM Polly Pui <<a href="mailto:polly_sukting@hotmail.com" target="_blank">polly_sukting@hotmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">




<div dir="ltr">
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
And also I tried to remove the lines in order to test if the columns are called successfully. I received the error stated "Failed to locate the columns to use for the point coordinates".</div>
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
These are the codes:</div>
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<span>std::string inputFilename = argv[1];<br>
</span>
<div><br>
</div>
<div>vtkSmartPointer<vtkDelimitedTextReader> reader =<br>
</div>
<div> vtkSmartPointer<vtkDelimitedTextReader>::New();<br>
</div>
<div>reader->SetFileName(inputFilename.c_str());<br>
</div>
<div>reader->SetFieldDelimiterCharacters(",");<br>
</div>
<div>reader->DetectNumericColumnsOn();<br>
</div>
<div>//reader->GetHaveHeaders();<br>
</div>
<div>reader->Update();<br>
</div>
<div><br>
</div>
<div>reader->GetOutput()->Dump();<br>
</div>
<div>///////KmeansCluster<br>
</div>
<div><br>
</div>
<div>vtkSmartPointer<vtkKMeansStatistics> kMeansStatistics =<br>
</div>
<div> vtkSmartPointer<vtkKMeansStatistics>::New();<br>
</div>
<div>kMeansStatistics->SetInputConnection(reader->GetOutputPort());<br>
</div>
<div>kMeansStatistics->SetColumnStatus("X", 1);<br>
</div>
<div>kMeansStatistics->SetColumnStatus("Y", 1);<br>
</div>
<div>kMeansStatistics->SetColumnStatus("Z", 1);<br>
</div>
<div>kMeansStatistics->RequestSelectedColumns();<br>
</div>
<div>kMeansStatistics->SetAssessOption(true);<br>
</div>
<div>kMeansStatistics->SetDefaultNumberOfClusters(5);<br>
</div>
<div>//kMeansStatistics->SetLearnOption(1);//to learn the cluster value<br>
</div>
<div>kMeansStatistics->SetMaxNumIterations(15);<br>
</div>
<span>kMeansStatistics->Update();</span><br>
</div>
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<span><br>
</span></div>
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<span><span>vtkSmartPointer<vtkTableToPolyData> t2pd = vtkSmartPointer<vtkTableToPolyData>::New();<br>
</span>
<div>t2pd->SetInputConnection(kMeansStatistics->GetOutputPort());<br>
</div>
<div>t2pd->SetXColumn("X");<br>
</div>
<div>t2pd->SetYColumn("Y");<br>
</div>
<div>t2pd->SetZColumn("Z");<br>
</div>
<div><br>
</div>
<div>vtkSmartPointer<vtkPolyDataMapper> mapper =<br>
</div>
<div> vtkSmartPointer<vtkPolyDataMapper>::New();<br>
</div>
<div>mapper->SetInputConnection(t2pd->GetOutputPort());<br>
</div>
<div><br>
</div>
<div>vtkSmartPointer<vtkActor> actor =<br>
</div>
<div> vtkSmartPointer<vtkActor>::New();<br>
</div>
<div>actor->SetMapper(mapper);<br>
</div>
<div>actor->GetProperty()->SetPointSize(3);<br>
</div>
<div>actor->GetProperty()->SetColor(1, 1, 1);<br>
</div>
<div><br>
</div>
<div>vtkSmartPointer<vtkRenderer> renderer =<br>
</div>
<div> vtkSmartPointer<vtkRenderer>::New();<br>
</div>
<div>vtkSmartPointer<vtkRenderWindow> renderWindow =<br>
</div>
<div> vtkSmartPointer<vtkRenderWindow>::New();<br>
</div>
<div>renderWindow->AddRenderer(renderer);<br>
</div>
<div>renderWindow->SetSize(640, 480);<br>
</div>
<div><br>
</div>
<div>vtkSmartPointer<vtkRenderWindowInteractor> renderWindowInteractor =<br>
</div>
<div> vtkSmartPointer<vtkRenderWindowInteractor>::New();<br>
</div>
<div>renderWindowInteractor->SetRenderWindow(renderWindow);<br>
</div>
<div><br>
</div>
<div>renderer->AddActor(actor);<br>
</div>
<div>renderer->SetBackground(0, 0, 0); // Background color black<br>
</div>
<div><br>
</div>
<div>renderWindow->Render();<br>
</div>
<div>renderWindowInteractor->Start();<br>
</div>
<div><br>
</div>
<div>return EXIT_SUCCESS;<br>
</div>
<span>}</span><br>
</span></div>
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<span><span><br>
</span></span></div>
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<span><span>I supposed the column of interest to be called are "X", "Y" and "Z".</span></span></div>
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
Please advice.</div>
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
Thank you very much.</div>
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
Regards,</div>
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
Polly</div>
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
</div>
<hr style="display:inline-block;width:98%">
<div id="m_874574472220400630m_-1221774421176816375divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" color="#000000" style="font-size:11pt"><b>From:</b> vtkusers <<a href="mailto:vtkusers-bounces@public.kitware.com" target="_blank">vtkusers-bounces@public.kitware.com</a>> on behalf of Polly Pui <<a href="mailto:polly_sukting@hotmail.com" target="_blank">polly_sukting@hotmail.com</a>><br>
<b>Sent:</b> Wednesday, November 21, 2018 2:01 PM<br>
<b>To:</b> Cory Quammen<br>
<b>Cc:</b> vtkusers<br>
<b>Subject:</b> Re: [vtkusers] Extract csv row and column into points</font>
<div> </div>
</div>
<div dir="ltr">
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
Hi Cory,</div>
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
Thanks for your reply.</div>
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
I followed your advice and changed the lines as you mentioned.</div>
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
But I still couldn't get the output successfully.</div>
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
I would like to clarify if I called the column of interest correctly.</div>
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
Please refer to the attachment. The columns that to be called as X,Y,Z coordinates are named as "X", "Y", "Z".</div>
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
When i run the exe file. It failed to load and couldn't get the correct cluster.</div>
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
This is the codes that I am using.</div>
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
..............</div>
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<div>int main(int argc, char* argv[])<br>
</div>
<div>{</div>
<div>std::string inputFilename = argv[1];<br>
</div>
<div><br>
</div>
<div>vtkSmartPointer<vtkDelimitedTextReader> reader =<br>
</div>
<div> vtkSmartPointer<vtkDelimitedTextReader>::New();<br>
</div>
<div>reader->SetFileName(inputFilename.c_str());<br>
</div>
<div>reader->SetFieldDelimiterCharacters(",");<br>
</div>
<div>reader->DetectNumericColumnsOn();<br>
</div>
<div>//reader->GetHaveHeaders();<br>
</div>
<div>reader->Update();<br>
</div>
<div><br>
</div>
<div>///////KmeansCluster<br>
</div>
<div><br>
</div>
<div>vtkSmartPointer<vtkKMeansStatistics> kMeansStatistics =<br>
</div>
<div> vtkSmartPointer<vtkKMeansStatistics>::New();<br>
</div>
<div>kMeansStatistics->SetInputConnection(reader->GetOutputPort());<br>
</div>
<div>kMeansStatistics->SetColumnStatus("X", 1);<br>
</div>
<div>kMeansStatistics->SetColumnStatus("Y", 1);<br>
</div>
<div>kMeansStatistics->SetColumnStatus("Z", 1);<br>
</div>
<div>kMeansStatistics->RequestSelectedColumns();<br>
</div>
<div>kMeansStatistics->SetAssessOption(true);<br>
</div>
<div>kMeansStatistics->SetDefaultNumberOfClusters(5);<br>
</div>
<div>//kMeansStatistics->SetLearnOption(1);//to learn the cluster value<br>
</div>
<div>kMeansStatistics->SetMaxNumIterations(15);<br>
</div>
<div>kMeansStatistics->Update();<br>
</div>
<div><br>
</div>
<div>//// Display the results in CMD (each row)</div>
<div>kMeansStatistics->GetOutput()->Dump();<br>
</div>
<div><br>
</div>
<div>////Group the points according to ID number<br>
</div>
<div>vtkSmartPointer<vtkIntArray> clusterArray =<br>
</div>
<div> vtkSmartPointer<vtkIntArray>::New();<br>
</div>
<div>clusterArray->SetNumberOfComponents(1);<br>
</div>
<div>clusterArray->SetName("ClusterId");<br>
</div>
<div><br>
</div>
<div>for (int r = 0; r < kMeansStatistics->GetOutput()->GetNumberOfRows(); r++)<br>
</div>
<div>{<br>
</div>
<div> vtkVariant v = kMeansStatistics->GetOutput()->GetValue(r, kMeansStatistics->GetOutput()->GetNumberOfColumns() - 1);<br>
</div>
<div> std::cout << "Point " << r << " is in cluster " << v.ToInt() << std::endl;<br>
</div>
<div> clusterArray->InsertNextValue(v.ToInt());<br>
</div>
<div>}<br>
</div>
<div><br>
</div>
<div>//// Create a lookup table to map cell data to colors<br>
</div>
<div>vtkSmartPointer<vtkLookupTable> lut =<br>
</div>
<div> vtkSmartPointer<vtkLookupTable>::New();<br>
</div>
<div>int tableSize = (kMeansStatistics + 1, 10);<br>
</div>
<div>lut->SetNumberOfTableValues(tableSize);<br>
</div>
<div>lut->Build();<br>
</div>
<div><br>
</div>
<div>////ColorCells <br>
</div>
<div>vtkSmartPointer<vtkNamedColors> colors =<br>
</div>
<div> vtkSmartPointer<vtkNamedColors>::New();<br>
</div>
<div>lut->SetTableValue(0, colors->GetColor4d("Black").GetData());<br>
</div>
<div>lut->SetTableValue(1, colors->GetColor4d("Banana").GetData());<br>
</div>
<div>lut->SetTableValue(2, colors->GetColor4d("Tomato").GetData());<br>
</div>
<div>lut->SetTableValue(3, colors->GetColor4d("Peacock").GetData());<br>
</div>
<div>lut->SetTableValue(4, colors->GetColor4d("Lavender").GetData());<br>
</div>
<div>lut->SetTableValue(5, colors->GetColor4d("Flesh").GetData());<br>
</div>
<div>lut->SetTableValue(6, colors->GetColor4d("Raspberry").GetData());<br>
</div>
<div>lut->SetTableValue(7, colors->GetColor4d("Salmon").GetData());<br>
</div>
<div>lut->SetTableValue(8, colors->GetColor4d("Mint").GetData());<br>
</div>
<div>lut->SetTableValue(9, colors->GetColor4d("Wheat").GetData());<br>
</div>
<div><br>
</div>
<div>// Output the cluster centers<br>
</div>
<div><br>
</div>
<div>vtkMultiBlockDataSet* outputMetaDS = vtkMultiBlockDataSet::SafeDownCast(kMeansStatistics->GetOutputDataObject(vtkStatisticsAlgorithm::OUTPUT_MODEL));<br>
</div>
<div>vtkTable* outputMeta = vtkTable::SafeDownCast(outputMetaDS->GetBlock(0));<br>
</div>
<div><br>
</div>
<div>vtkDoubleArray* coord0 = vtkDoubleArray::SafeDownCast(outputMeta->GetColumnByName("X"));<br>
</div>
<div>vtkDoubleArray* coord1 = vtkDoubleArray::SafeDownCast(outputMeta->GetColumnByName("Y"));<br>
</div>
<div>vtkDoubleArray* coord2 = vtkDoubleArray::SafeDownCast(outputMeta->GetColumnByName("Z"));<br>
</div>
<div><br>
</div>
<div>for (unsigned int i = 0; i < coord0->GetNumberOfTuples(); ++i)<br>
</div>
<div>{<br>
</div>
<div> std::cout << coord0->GetValue(i) << " " << coord1->GetValue(i) << " " << coord2->GetValue(i) << std::endl;<br>
</div>
<div>}<br>
</div>
<div><br>
</div>
<div>vtkSmartPointer<vtkTableToPolyData> t2pd = vtkSmartPointer<vtkTableToPolyData>::New();<br>
</div>
<div>t2pd->SetInputConnection(kMeansStatistics->GetOutputPort());<br>
</div>
<div>t2pd->SetXColumn("X");<br>
</div>
<div>t2pd->SetYColumn("Y");<br>
</div>
<div>t2pd->SetZColumn("Z");<br>
</div>
<div><br>
</div>
<div>vtkSmartPointer<vtkPolyDataMapper> mapper =<br>
</div>
<div> vtkSmartPointer<vtkPolyDataMapper>::New();<br>
</div>
<div>mapper->SetInputConnection(t2pd->GetOutputPort());<br>
</div>
<div><br>
</div>
<div>vtkSmartPointer<vtkActor> actor =<br>
</div>
<div> vtkSmartPointer<vtkActor>::New();<br>
</div>
<div>actor->SetMapper(mapper);<br>
</div>
<div>actor->GetProperty()->SetPointSize(3);<br>
</div>
<div>actor->GetProperty()->SetColor(1, 1, 1);<br>
</div>
<div><br>
</div>
<div>vtkSmartPointer<vtkRenderer> renderer =<br>
</div>
<div> vtkSmartPointer<vtkRenderer>::New();<br>
</div>
<div>vtkSmartPointer<vtkRenderWindow> renderWindow =<br>
</div>
<div> vtkSmartPointer<vtkRenderWindow>::New();<br>
</div>
<div>renderWindow->AddRenderer(renderer);<br>
</div>
<div>renderWindow->SetSize(640, 480);<br>
</div>
<div><br>
</div>
<div>vtkSmartPointer<vtkRenderWindowInteractor> renderWindowInteractor =<br>
</div>
<div> vtkSmartPointer<vtkRenderWindowInteractor>::New();<br>
</div>
<div>renderWindowInteractor->SetRenderWindow(renderWindow);<br>
</div>
<div><br>
</div>
<div>//renderer->AddActor(actor);<br>
</div>
<div>renderer->SetBackground(0, 0, 0); // Background color black<br>
</div>
<div><br>
</div>
<div>renderWindow->Render();<br>
</div>
<div>renderWindowInteractor->Start();<br>
</div>
<div><br>
</div>
<div>return EXIT_SUCCESS;<br>
</div>
<div>}<br>
</div>
<div>.........</div>
<div>Please advice. Thank you again!</div>
<div><br>
</div>
<div>Regards,</div>
<div>Polly</div>
<span></span><br>
</div>
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
</div>
<hr style="display:inline-block;width:98%">
<div id="m_874574472220400630m_-1221774421176816375x_divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" color="#000000" style="font-size:11pt"><b>From:</b> Cory Quammen <<a href="mailto:cory.quammen@kitware.com" target="_blank">cory.quammen@kitware.com</a>><br>
<b>Sent:</b> Monday, November 19, 2018 10:52 PM<br>
<b>To:</b> Polly Pui<br>
<b>Cc:</b> vtkusers<br>
<b>Subject:</b> Re: [vtkusers] Extract csv row and column into points</font>
<div> </div>
</div>
<div>
<div dir="ltr"><br>
<br>
<div class="m_874574472220400630m_-1221774421176816375x_x_gmail_quote">
<div dir="ltr">On Thu, Nov 15, 2018 at 1:26 AM Polly Pui <<a href="mailto:polly_sukting@hotmail.com" target="_blank">polly_sukting@hotmail.com</a>> wrote:<br>
</div>
<blockquote class="m_874574472220400630m_-1221774421176816375x_x_gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr">
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
Hi Cory,</div>
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
Thanks for your reply.</div>
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<span style="font-size:16px;background-color:rgb(255,255,255);display:inline!important">I edited my codes by following your advice. However, I am not able to visualize the point of cluster and got an error message.</span><br>
</div>
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<span style="font-size:16px;background-color:rgb(255,255,255);display:inline!important"><br>
</span></div>
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
I have a few questions here.</div>
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
Is it possible to call VTK unstructured grid data into vtkKmeansStatistics?</div>
</div>
</blockquote>
<div><br>
</div>
<div>No, vtkKMeansStatistics requires a vtkTable input (it is a subclass of vtkTableAlgorithm). vtkTable is different from a vtkPolyData, which is what you are trying to create. See more inline comments further down.</div>
<div> </div>
<blockquote class="m_874574472220400630m_-1221774421176816375x_x_gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr">
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
</div>
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
Actually what i wanted to do is very simple. </div>
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
I want to read my csv or vtk file and then cluster the points using kmeansclustering.</div>
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
Initially, I extracted points from csv file manually and I could get my desired output. But it is too time consuming. </div>
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
Currently, I want to input the csv or vtk file and get the cluster automatically and store in a datasheet.</div>
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
I attach my code as follows:</div>
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<div>#include <vtkVersion.h><br>
</div>
<div>#include "library.h"<br>
</div>
<div><br>
</div>
<div>#include <vtkSmartPointer.h><br>
</div>
<div>#include <vtkProperty.h><br>
</div>
<div>#include <vtkPointData.h><br>
</div>
<div>#include <vtkPolyData.h><br>
</div>
<div>#include <vtkXMLPolyDataWriter.h><br>
</div>
<div><br>
</div>
<div><br>
</div>
<div>std::string inputFilename = argv[1];<br>
</div>
<div><br>
</div>
<div>vtkSmartPointer<vtkDelimitedTextReader> reader =<br>
</div>
<div> vtkSmartPointer<vtkDelimitedTextReader>::New();<br>
</div>
<div>reader->SetFileName(inputFilename.c_str());<br>
</div>
<div>reader->SetFieldDelimiterCharacters(",");<br>
</div>
<div>reader->DetectNumericColumnsOn();<br>
</div>
<div>reader->Update();<br>
</div>
<div><br>
</div>
<div>///////KmeansCluster<br>
</div>
<div><br>
</div>
<div>vtkSmartPointer<vtkKMeansStatistics> kMeansStatistics =<br>
</div>
<div> vtkSmartPointer<vtkKMeansStatistics>::New();<br>
</div>
<div>kMeansStatistics->SetInputConnection(reader->GetOutputPort());<br>
</div>
<div>kMeansStatistics->SetColumnStatus("Column 3", 1);<br>
</div>
<div>kMeansStatistics->SetColumnStatus("Column 4", 1);<br>
</div>
<div>kMeansStatistics->SetColumnStatus("Column 5", 1);<br>
</div>
<div>kMeansStatistics->RequestSelectedColumns();<br>
</div>
<div>kMeansStatistics->SetAssessOption(true);<br>
</div>
<div>kMeansStatistics->SetDefaultNumberOfClusters(2);<br>
</div>
<div>//kMeansStatistics->SetMaxNumIterations(15);<br>
</div>
<div>kMeansStatistics->Update();<br>
</div>
<div><br>
</div>
<div>// Display the results in CMD (each row)<br>
</div>
<div>kMeansStatistics->GetOutput()->Dump();</div>
</div>
</div>
</blockquote>
<div> <br>
</div>
<blockquote class="m_874574472220400630m_-1221774421176816375x_x_gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr">
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<div></div>
<div><br>
</div>
<div>//Group the points according to ID number<br>
</div>
<div>vtkSmartPointer<vtkIntArray> clusterArray =<br>
</div>
<div> vtkSmartPointer<vtkIntArray>::New();<br>
</div>
<div>clusterArray->SetNumberOfComponents(1);<br>
</div>
<div>clusterArray->SetName("ClusterId");<br>
</div>
<div><br>
</div>
<div>for (int r = 0; r < kMeansStatistics->GetOutput()->GetNumberOfRows(); r++)<br>
</div>
<div>{<br>
</div>
<div> vtkVariant v = kMeansStatistics->GetOutput()->GetValue(r, kMeansStatistics->GetOutput()->GetNumberOfColumns() - 1);<br>
</div>
<div> std::cout << "Point " << r << " is in cluster " << v.ToInt() << std::endl;<br>
</div>
<div> clusterArray->InsertNextValue(v.ToInt());<br>
</div>
<div>}<br>
</div>
<div><br>
</div>
<div>// Create a lookup table to map cell data to colors<br>
</div>
<div>vtkSmartPointer<vtkLookupTable> lut =<br>
</div>
<div> vtkSmartPointer<vtkLookupTable>::New();<br>
</div>
<div>int tableSize = (kMeansStatistics + 1, 10);<br>
</div>
<div>lut->SetNumberOfTableValues(tableSize);<br>
</div>
<div>lut->Build();<br>
</div>
<div><br>
</div>
<div>//ColorCells <br>
</div>
<div>vtkSmartPointer<vtkNamedColors> colors =<br>
</div>
<div> vtkSmartPointer<vtkNamedColors>::New();<br>
</div>
<div>lut->SetTableValue(0, colors->GetColor4d("Black").GetData());<br>
</div>
<div>lut->SetTableValue(1, colors->GetColor4d("Banana").GetData());<br>
</div>
<div>lut->SetTableValue(2, colors->GetColor4d("Tomato").GetData());<br>
</div>
<div>lut->SetTableValue(3, colors->GetColor4d("Peacock").GetData());<br>
</div>
<div>lut->SetTableValue(4, colors->GetColor4d("Lavender").GetData());<br>
</div>
<div>lut->SetTableValue(5, colors->GetColor4d("Flesh").GetData());<br>
</div>
<div>lut->SetTableValue(6, colors->GetColor4d("Raspberry").GetData());<br>
</div>
<div>lut->SetTableValue(7, colors->GetColor4d("Salmon").GetData());<br>
</div>
<div>lut->SetTableValue(8, colors->GetColor4d("Mint").GetData());<br>
</div>
<div>lut->SetTableValue(9, colors->GetColor4d("Wheat").GetData());<br>
</div>
<div><br>
</div>
<div>// Output the cluster centers<br>
</div>
<div><br>
</div>
<div>vtkMultiBlockDataSet* outputMetaDS = vtkMultiBlockDataSet::SafeDownCast(kMeansStatistics->GetOutputDataObject(vtkStatisticsAlgorithm::OUTPUT_MODEL));<br>
</div>
<div>vtkSmartPointer<vtkTable> outputMeta = vtkTable::SafeDownCast(outputMetaDS->GetBlock(0));<br>
</div>
<div>//vtkSmartPointer<vtkTable> outputMeta = vtkTable::SafeDownCast( outputMetaDS->GetBlock( 1 ) );<br>
</div>
<div>vtkDoubleArray* coord0 = vtkDoubleArray::SafeDownCast(outputMeta->GetColumnByName("Column 0"));<br>
</div>
<div>vtkDoubleArray* coord1 = vtkDoubleArray::SafeDownCast(outputMeta->GetColumnByName("Column 1"));<br>
</div>
<div>vtkDoubleArray* coord2 = vtkDoubleArray::SafeDownCast(outputMeta->GetColumnByName("Column 2"));<br>
</div>
<div><br>
</div>
<div>for (unsigned int i = 0; i < coord0->GetNumberOfTuples(); ++i)<br>
</div>
<div>{<br>
</div>
<div> std::cout << coord0->GetValue(i) << " " << coord1->GetValue(i) << " " << coord2->GetValue(i) << std::endl;<br>
</div>
<div><br>
</div>
<div>}<br>
</div>
<div><br>
</div>
<div>vtkSmartPointer<vtkPolyData> polydata =<br>
</div>
<div> vtkSmartPointer<vtkPolyData>::New();<br>
</div>
<div>polydata->GetPointData()->SetScalars(clusterArray);<br>
</div>
<div><br>
</div>
</div>
</div>
</blockquote>
<div><br>
</div>
<div>The below won't work. vtkKMeansStatistics produces a vtkTable, while the vtkPolyDataMapper requires a vtkPolyData. To convert a vtkTable to a vtkPolyData, which is the key piece you are missing, use vtkTableToPolyData. This class iterates over the rows,
 treats the columns you designate as X, Y, Z coordinates, and adds the remaining columns as point data arrays in the output vtkPolyData.</div>
<div><br>
</div>
<div>It will look something like this:</div>
<div><br>
</div>
<div>vtkSmartPointer<vtkTableToPolyData> t2pd = vtkSmartPointer<vtkTableToPolyData>::New();</div>
<div>t2pd->SetInputConnection(kMeansStatistics->GetOutputPort());</div>
<div>t2pd->SetXColumn("name of column to be used as x-coordinate");</div>
<div>t2pd->SetYColumn("name of column to be used as y-coordinate");<br>
</div>
<div>t2pd->SetZColumn("name of column to be used as z-coordinate");<br>
</div>
<div><br>
</div>
<div>Now, change, the code below from:</div>
<div> </div>
<blockquote class="m_874574472220400630m_-1221774421176816375x_x_gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr">
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<div></div>
<div>vtkSmartPointer<vtkPolyDataMapper> mapper =<br>
</div>
<div> vtkSmartPointer<vtkPolyDataMapper>::New();<br>
</div>
<div>mapper->SetInputConnection(kMeansStatistics->GetOutputPort());</div>
</div>
</div>
</blockquote>
<div><br>
</div>
<div>to</div>
<div><br>
</div>
<div>
<div style="color:rgb(0,0,0);font-family:Calibri,Helvetica,sans-serif;font-size:16px">
vtkSmartPointer<vtkPolyDataMapper> mapper =<br>
</div>
<div style="color:rgb(0,0,0);font-family:Calibri,Helvetica,sans-serif;font-size:16px">
 vtkSmartPointer<vtkPolyDataMapper>::New();<br>
</div>
<div style="color:rgb(0,0,0);font-family:Calibri,Helvetica,sans-serif;font-size:16px">
mapper->SetInputConnection(t2pd->GetOutputPort());</div>
</div>
<div style="color:rgb(0,0,0);font-family:Calibri,Helvetica,sans-serif;font-size:16px">
<br>
</div>
<div style="color:rgb(0,0,0);font-family:Calibri,Helvetica,sans-serif;font-size:16px">
That should do it.</div>
<div style="color:rgb(0,0,0);font-family:Calibri,Helvetica,sans-serif;font-size:16px">
<br>
</div>
<div style="color:rgb(0,0,0);font-family:Calibri,Helvetica,sans-serif;font-size:16px">
Cory</div>
<div> </div>
<blockquote class="m_874574472220400630m_-1221774421176816375x_x_gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr">
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<div>vtkSmartPointer<vtkActor> actor =<br>
</div>
<div> vtkSmartPointer<vtkActor>::New();<br>
</div>
<div>actor->SetMapper(mapper);<br>
</div>
<div>actor->GetProperty()->SetPointSize(3);<br>
</div>
<div>actor->GetProperty()->SetColor(1, 0, 0);<br>
</div>
<div><br>
</div>
<div>vtkSmartPointer<vtkRenderer> renderer =<br>
</div>
<div> vtkSmartPointer<vtkRenderer>::New();<br>
</div>
<div>vtkSmartPointer<vtkRenderWindow> renderWindow =<br>
</div>
<div> vtkSmartPointer<vtkRenderWindow>::New();<br>
</div>
<div>renderWindow->AddRenderer(renderer);<br>
</div>
<div>renderWindow->SetSize(640, 480);<br>
</div>
<div><br>
</div>
<div>vtkSmartPointer<vtkRenderWindowInteractor> renderWindowInteractor =<br>
</div>
<div> vtkSmartPointer<vtkRenderWindowInteractor>::New();<br>
</div>
<div>renderWindowInteractor->SetRenderWindow(renderWindow);<br>
</div>
<div><br>
</div>
<div>renderer->AddActor(actor);<br>
</div>
<div>renderer->SetBackground(0, 0, 0); // Background color black<br>
</div>
<div><br>
</div>
<div>renderWindow->Render();<br>
</div>
<div>renderWindowInteractor->Start();<br>
</div>
<div><br>
</div>
<div>return EXIT_SUCCESS;<br>
</div>
<div>}<br>
</div>
<span></span><br>
</div>
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
Thank you so much.</div>
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
Regards,</div>
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
Polly</div>
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
</div>
<hr style="display:inline-block;width:98%">
<div id="m_874574472220400630m_-1221774421176816375x_x_m_449269900065465368divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" color="#000000" style="font-size:11pt"><b>From:</b> Cory Quammen <<a href="mailto:cory.quammen@kitware.com" target="_blank">cory.quammen@kitware.com</a>><br>
<b>Sent:</b> Tuesday, November 13, 2018 11:34 PM<br>
<b>To:</b> Polly Pui<br>
<b>Cc:</b> vtkusers<br>
<b>Subject:</b> Re: [vtkusers] Extract csv row and column into points</font>
<div> </div>
</div>
<div>
<div dir="ltr">
<div><span style="color:rgb(0,0,0);font-family:Calibri,Helvetica,sans-serif;font-size:16px">Ah, so you want to use the </span><span style="color:rgb(0,0,0);font-family:Calibri,Helvetica,sans-serif;font-size:16px">vtkKMeansStatistics filter. That filter
 operates on vtkTable data. To use it, you don't need to create points at all. Instead, you can connect the 
</span><span style="color:rgb(0,0,0);font-family:Calibri,Helvetica,sans-serif;font-size:16px">vtkDelimitedTextReader directly to the </span><span style="color:rgb(0,0,0);font-family:Calibri,Helvetica,sans-serif;font-size:16px">vtkKMeansStatistics filter
 like so:</span></div>
<div><br>
</div>
<div>
<div style="color:rgb(0,0,0);font-family:Calibri,Helvetica,sans-serif;font-size:16px">
vtkSmartPointer<vtkKMeansStatistics> kMeansStatistics =<br>
</div>
<div style="color:rgb(0,0,0);font-family:Calibri,Helvetica,sans-serif;font-size:16px">
 vtkSmartPointer<vtkKMeansStatistics>::New();</div>
</div>
<div style="color:rgb(0,0,0);font-family:Calibri,Helvetica,sans-serif;font-size:16px">
kMeansStatistics->SetInputConnection(reader->GetOutputPort());</div>
<div style="color:rgb(0,0,0);font-family:Calibri,Helvetica,sans-serif;font-size:16px">
<div style="font-size:12pt">
<div>kMeansStatistics->SetColumnStatus("column1", 1);<br>
</div>
<div>kMeansStatistics->SetColumnStatus("column2", 1);<br>
</div>
<div>kMeansStatistics->SetColumnStatus("column3, 1);<br>
</div>
<div>kMeansStatistics->RequestSelectedColumns();<br>
</div>
<div>kMeansStatistics->SetAssessOption(true);<br>
</div>
<div>kMeansStatistics->SetDefaultNumberOfClusters(1);<br>
</div>
<div>//kMeansStatistics->SetMaxNumIterations(15);<br>
</div>
kMeansStatistics->Update();<br>
</div>
<div style="font-size:12pt"><br>
</div>
<div style="font-size:12pt">Here, I've altered your calls to SetColumnStatus() under the assumption you know the column names of interest.</div>
<div style="font-size:12pt"><br>
</div>
<div style="font-size:12pt">HTH,</div>
<div style="font-size:12pt">Cory</div>
<br class="m_874574472220400630m_-1221774421176816375x_x_m_449269900065465368x_gmail-Apple-interchange-newline">
</div>
<br>
<div class="m_874574472220400630m_-1221774421176816375x_x_m_449269900065465368x_gmail_quote">
<div dir="ltr">On Fri, Nov 9, 2018 at 10:16 AM Polly Pui <<a href="mailto:polly_sukting@hotmail.com" target="_blank">polly_sukting@hotmail.com</a>> wrote:<br>
</div>
<blockquote class="m_874574472220400630m_-1221774421176816375x_x_m_449269900065465368x_gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr">
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
Hi,</div>
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
Thanks for your reply.</div>
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
Is it possible to have more elaborations from you?</div>
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
How can I get the number of points from vtkTableToPolyData?</div>
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
I got an error saying that vtkTableToPolyData has no members of GetNumberOfPoints.</div>
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
I need those points to proceed to KmeansStatistics.</div>
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
This is my code:</div>
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
......</div>
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<span>std::string inputFilename = argv[1];<br>
</span>
<div><br>
</div>
<div>vtkSmartPointer<vtkDelimitedTextReader> reader =<br>
</div>
<div> vtkSmartPointer<vtkDelimitedTextReader>::New();<br>
</div>
<div>reader->SetFileName(inputFilename.c_str());<br>
</div>
<div>reader->SetFieldDelimiterCharacters(" ");<br>
</div>
<div>reader->DetectNumericColumnsOn();<br>
</div>
<div>reader->Update();<br>
</div>
<div>int numberOfRows = reader->GetOutput()->GetNumberOfRows();<br>
</div>
<div><br>
</div>
<div>vtkSmartPointer<vtkTableToPolyData> inputData =<br>
</div>
<div> vtkSmartPointer<vtkTableToPolyData>::New();<br>
</div>
<div>inputData->SetInputConnection(reader->GetOutputPort);<br>
</div>
<div><br>
</div>
<div>for (int c = 0; c < 3; ++c)<br>
</div>
<div>{<br>
</div>
<div> std::stringstream colName;<br>
</div>
<div> colName << "coord " << c;<br>
</div>
<div> vtkSmartPointer<vtkDoubleArray> doubleArray =<br>
</div>
<div>  vtkSmartPointer<vtkDoubleArray>::New();<br>
</div>
<div> doubleArray->SetNumberOfComponents(1);<br>
</div>
<div> doubleArray->SetName(colName.str().c_str());<br>
</div>
<div> doubleArray->SetNumberOfTuples(inputData->GetNumberOfPoints());<br>
</div>
<div><br>
</div>
<div><br>
</div>
<div> for (int r = 0; r < inputData->GetNumberOfPoints(); ++r)<br>
</div>
<div> {<br>
</div>
<div>  double p[3];<br>
</div>
<div>  inputData->GetPoint(r, p);<br>
</div>
<div>  doubleArray->SetValue(r, p[c]);<br>
</div>
<div> }<br>
</div>
<div> inputData->AddColumn(doubleArray);<br>
</div>
<div>}<br>
</div>
<div><br>
</div>
<div>vtkSmartPointer<vtkKMeansStatistics> kMeansStatistics =<br>
</div>
<div> vtkSmartPointer<vtkKMeansStatistics>::New();<br>
</div>
<div><br>
</div>
<div>#if VTK_MAJOR_VERSION <= 5<br>
</div>
<div>kMeansStatistics->SetInput(vtkStatisticsAlgorithm::INPUT_DATA, inputData);<br>
</div>
<div>#else<br>
</div>
<div>kMeansStatistics->SetInputData(vtkStatisticsAlgorithm::INPUT_DATA, inputData);<br>
</div>
<div>#endif<br>
</div>
<div>kMeansStatistics->SetColumnStatus(inputData->GetColumnName(0), 1);<br>
</div>
<div>kMeansStatistics->SetColumnStatus(inputData->GetColumnName(1), 1);<br>
</div>
<div>kMeansStatistics->SetColumnStatus(inputData->GetColumnName(2), 1);<br>
</div>
<div>kMeansStatistics->RequestSelectedColumns();<br>
</div>
<div>kMeansStatistics->SetAssessOption(true);<br>
</div>
<div>kMeansStatistics->SetDefaultNumberOfClusters(1);<br>
</div>
<div>//kMeansStatistics->SetMaxNumIterations(15);<br>
</div>
<span>kMeansStatistics->Update();</span><br>
</div>
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<span><br>
</span></div>
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<span>Thanks again.</span></div>
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<span><br>
</span></div>
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<span>Regards,</span></div>
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<span>Polly</span></div>
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
</div>
<hr style="display:inline-block;width:98%">
<div id="m_874574472220400630m_-1221774421176816375x_x_m_449269900065465368x_m_3284076659041625668divRplyFwdMsg" dir="ltr">
<font face="Calibri, sans-serif" color="#000000" style="font-size:11pt"><b>From:</b> Cory Quammen <<a href="mailto:cory.quammen@kitware.com" target="_blank">cory.quammen@kitware.com</a>><br>
<b>Sent:</b> Friday, November 9, 2018 10:07 PM<br>
<b>To:</b> Polly Pui<br>
<b>Cc:</b> vtkusers<br>
<b>Subject:</b> Re: [vtkusers] Extract csv row and column into points</font>
<div> </div>
</div>
<div>
<div dir="ltr">vtkDelimitedTextReader -> vtkTableToPolyData is a pipeline that should make this much simpler.</div>
<br>
<div class="m_874574472220400630m_-1221774421176816375x_x_m_449269900065465368x_m_3284076659041625668x_gmail_quote">
<div dir="ltr">On Fri, Nov 9, 2018 at 1:14 AM Polly Pui <<a href="mailto:polly_sukting@hotmail.com" target="_blank">polly_sukting@hotmail.com</a>> wrote:<br>
</div>
<blockquote class="m_874574472220400630m_-1221774421176816375x_x_m_449269900065465368x_m_3284076659041625668x_gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr">
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
Hi,</div>
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
Is there any clue that i can extract the row and column data from a csv file and read them as points?</div>
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
Currently I am using <span style="font-size:16px;background-color:rgb(255,255,255);display:inline!important">
vtkpoints to </span>read points by inserting points manually to my .cpp .</div>
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
Is it possible for me to call the csv directly and read the data (eg. column 3-5, row 2-10)?</div>
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
I attach my code here.</div>
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
......</div>
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<span>int main(int, char*[])<br>
</span>
<div>{<br>
</div>
<div><br>
</div>
<div>vtkSmartPointer<vtkPoints> points =<br>
</div>
<div> vtkSmartPointer<vtkPoints>::New();<br>
</div>
<div>points->InsertNextPoint(8.4312, -36.489, -1500.7);<br>
</div>
<div>points->InsertNextPoint(8.8408, -37.726, -1500.4);<br>
</div>
<div>points->InsertNextPoint(11.372, -37.787, -1501.5);<br>
</div>
<div>points->InsertNextPoint(11.263, -36.384, -1501.9);<br>
</div>
<div>points->InsertNextPoint(9.3914, -40.819, -1500.8);<br>
</div>
<div>points->InsertNextPoint(11.685, -42.482, -1502.7);<br>
</div>
<div>points->InsertNextPoint(14.235, -38.096, -1503.5);<br>
</div>
<div>points->InsertNextPoint(13.972, -43.051, -1504.2);<br>
</div>
<span>points->InsertNextPoint(9.22, -43.904, -1504);</span><br>
</div>
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<span><br>
</span></div>
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<span><span>vtkSmartPointer<vtkTable> inputData =<br>
</span><span> vtkSmartPointer<vtkTable>::New();</span><br>
</span></div>
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<span><span><span>for (int c = 0; c < 3; ++c)<br>
</span>
<div>{<br>
</div>
<div> std::stringstream colName;<br>
</div>
<div> colName << "coord " << c;<br>
</div>
<div> vtkSmartPointer<vtkDoubleArray> doubleArray =<br>
</div>
<div>  vtkSmartPointer<vtkDoubleArray>::New();<br>
</div>
<div> doubleArray->SetNumberOfComponents(1);<br>
</div>
<div> doubleArray->SetName(colName.str().c_str());<br>
</div>
<div> doubleArray->SetNumberOfTuples(points->GetNumberOfPoints());<br>
</div>
<div><br>
</div>
<div> for (int r = 0; r < points->GetNumberOfPoints(); ++r)<br>
</div>
<div> {<br>
</div>
<div>  double p[3];<br>
</div>
<div>  points->GetPoint(r, p);<br>
</div>
<div>  doubleArray->SetValue(r, p[c]);<br>
</div>
<div> }<br>
</div>
<div> inputData->AddColumn(doubleArray);<br>
</div>
<span>}</span><br>
</span></span></div>
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
Thank you very much.</div>
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
Regards,</div>
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
Polly</div>
</div>
_______________________________________________<br>
Powered by <a href="http://www.kitware.com" rel="noreferrer" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" rel="noreferrer" 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" rel="noreferrer" target="_blank">
http://www.vtk.org/Wiki/VTK_FAQ</a><br>
<br>
Search the list archives at: <a href="http://markmail.org/search/?q=vtkusers" rel="noreferrer" target="_blank">
http://markmail.org/search/?q=vtkusers</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="https://public.kitware.com/mailman/listinfo/vtkusers" rel="noreferrer" target="_blank">https://public.kitware.com/mailman/listinfo/vtkusers</a><br>
</blockquote>
</div>
<br clear="all">
<div><br>
</div>
-- <br>
<div dir="ltr" class="m_874574472220400630m_-1221774421176816375x_x_m_449269900065465368x_m_3284076659041625668x_gmail_signature">
Cory Quammen<br>
Staff R&D Engineer<br>
Kitware, Inc.</div>
</div>
</div>
</blockquote>
</div>
<br clear="all">
<div><br>
</div>
-- <br>
<div dir="ltr" class="m_874574472220400630m_-1221774421176816375x_x_m_449269900065465368x_gmail_signature">Cory Quammen<br>
Staff R&D Engineer<br>
Kitware, Inc.</div>
</div>
</div>
</div>
</blockquote>
</div>
<br clear="all">
<div><br>
</div>
-- <br>
<div dir="ltr" class="m_874574472220400630m_-1221774421176816375x_x_gmail_signature">Cory Quammen<br>
Staff R&D Engineer<br>
Kitware, Inc.</div>
</div>
</div>
</div>
</div>

</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="m_874574472220400630gmail_signature" data-smartmail="gmail_signature">Cory Quammen<br>Staff R&D Engineer<br>Kitware, Inc.</div>