<div dir="ltr">vtkTable's GetRow method returns a vtkVariantArray (<a href="https://www.vtk.org/doc/nightly/html/classvtkTable.html">https://www.vtk.org/doc/nightly/html/classvtkTable.html</a>) which may be what is causing trouble. This is necessary because though columns have a single type, rows cut across columns so must be variant arrays. Perhaps try GetColumn() instead, which you may have better luck using as a standard array?</div><br><div class="gmail_quote"><div dir="ltr">On Fri, Dec 22, 2017 at 9:02 AM Jean-Max Redonnet <<a href="mailto:jmax.red@gmail.com">jmax.red@gmail.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><div><div>Hi,<br><br></div>I did a K-Means clustering following the C++ example (<a href="https://lorensen.github.io/VTKExamples/site/Cxx/InfoVis/KMeansClustering/" target="_blank">https://lorensen.github.io/VTKExamples/site/Cxx/InfoVis/KMeansClustering/</a>).<br><br>        vtkTable kmeansInputData = new vtkTable();<br>        kmeansInputData.AddColumn(output.GetPointData().GetVectors()); // output object is a polydata with vectors attached resulting from previous calculation<br><br>        vtkKMeansStatistics kMeansStatistics = new vtkKMeansStatistics();<br>        kMeansStatistics.SetInputData(kmeansInputData);<br>        kMeansStatistics.SetColumnStatus(kmeansInputData.GetColumnName(0), 1);<br>        kMeansStatistics.SetColumnStatus(kmeansInputData.GetColumnName(1), 1);<br>        kMeansStatistics.SetColumnStatus(kmeansInputData.GetColumnName(2), 1);<br>        // kMeansStatistics.SetColumnStatus( "Testing", 1 );<br>        kMeansStatistics.RequestSelectedColumns();<br>        kMeansStatistics.SetAssessOption(true);<br>        kMeansStatistics.SetDefaultNumberOfClusters(3);<br>        kMeansStatistics.Update();<br><br>        kMeansStatistics.GetOutput().Dump(32, -1); // dump shows the clustering is OK<br><br>        vtkIntArray clusterArray = new vtkIntArray();<br>        clusterArray.SetNumberOfComponents(1);<br>        clusterArray.SetName("ClusterId");<br><br>        for(int r = 0; r < kMeansStatistics.GetOutput().GetNumberOfRows(); r++){<span class="m_913332703861705051gmail-hll"><span class="m_913332703861705051gmail-n"><br>         // at this point the C++ instruction to retrieve information is <br>         // vtkVariant</span> <span class="m_913332703861705051gmail-n">v</span> <span class="m_913332703861705051gmail-o">=</span> <span class="m_913332703861705051gmail-n">kMeansStatistics</span><span class="m_913332703861705051gmail-o">-></span><span class="m_913332703861705051gmail-n">GetOutput</span><span class="m_913332703861705051gmail-p">()</span><span class="m_913332703861705051gmail-o">-></span><span class="m_913332703861705051gmail-n">GetValue</span><span class="m_913332703861705051gmail-p">(</span><span class="m_913332703861705051gmail-n">r</span><span class="m_913332703861705051gmail-p">,</span><span class="m_913332703861705051gmail-n">kMeansStatistics</span><span class="m_913332703861705051gmail-o">-></span><span class="m_913332703861705051gmail-n">GetOutput</span><span class="m_913332703861705051gmail-p">()</span><span class="m_913332703861705051gmail-o">-></span><span class="m_913332703861705051gmail-n">GetNumberOfColumns</span><span class="m_913332703861705051gmail-p">()</span> <span class="m_913332703861705051gmail-o">-</span> <span class="m_913332703861705051gmail-mi">1</span><span class="m_913332703861705051gmail-p">);<br>         // ...<br></span></span></div>        }<br><div><br><div><span class="m_913332703861705051gmail-hll"><span class="m_913332703861705051gmail-p">AFAIK vtkVariant does not exists in Java. I tried to get row first using <br>          vtkAbstractArray a = kMeansStatistics.GetOutput().GetRow(r);<br></span></span></div><div><span class="m_913332703861705051gmail-hll"><span class="m_913332703861705051gmail-p"><span class="m_913332703861705051gmail-hll"><span class="m_913332703861705051gmail-p">My debugger indicates array a is instance of vtkFloatArray, but java cast doesn't work, thus I can't</span></span> retrieve the value<br></span></span></div>I guess SafeDownCast is the good method to do that, but can't find it in java wrapper.<br></div><br></div><div>So, I can't figure out the right way to retrieve individual value from a vtkTable in Java.<br><br></div><div>Any help would be really appreciated<br><br></div><div>jMax<br></div><div><br><br></div><br></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://vtk.org/mailman/listinfo/vtkusers" rel="noreferrer" target="_blank">https://vtk.org/mailman/listinfo/vtkusers</a><br>
</blockquote></div>