[vtkusers] How to retrieve individual value from a vtkTable in Java
Jean-Max Redonnet
jmax.red at gmail.com
Fri Dec 22 09:02:18 EST 2017
Hi,
I did a K-Means clustering following the C++ example (
https://lorensen.github.io/VTKExamples/site/Cxx/InfoVis/KMeansClustering/).
vtkTable kmeansInputData = new vtkTable();
kmeansInputData.AddColumn(output.GetPointData().GetVectors()); //
output object is a polydata with vectors attached resulting from previous
calculation
vtkKMeansStatistics kMeansStatistics = new vtkKMeansStatistics();
kMeansStatistics.SetInputData(kmeansInputData);
kMeansStatistics.SetColumnStatus(kmeansInputData.GetColumnName(0),
1);
kMeansStatistics.SetColumnStatus(kmeansInputData.GetColumnName(1),
1);
kMeansStatistics.SetColumnStatus(kmeansInputData.GetColumnName(2),
1);
// kMeansStatistics.SetColumnStatus( "Testing", 1 );
kMeansStatistics.RequestSelectedColumns();
kMeansStatistics.SetAssessOption(true);
kMeansStatistics.SetDefaultNumberOfClusters(3);
kMeansStatistics.Update();
kMeansStatistics.GetOutput().Dump(32, -1); // dump shows the
clustering is OK
vtkIntArray clusterArray = new vtkIntArray();
clusterArray.SetNumberOfComponents(1);
clusterArray.SetName("ClusterId");
for(int r = 0; r < kMeansStatistics.GetOutput().GetNumberOfRows();
r++){
// at this point the C++ instruction to retrieve information is
// vtkVariant v = kMeansStatistics->GetOutput()->GetValue(r,
kMeansStatistics->GetOutput()->GetNumberOfColumns() - 1);
// ...
}
AFAIK vtkVariant does not exists in Java. I tried to get row first using
vtkAbstractArray a = kMeansStatistics.GetOutput().GetRow(r);
My debugger indicates array a is instance of vtkFloatArray, but java cast
doesn't work, thus I can't retrieve the value
I guess SafeDownCast is the good method to do that, but can't find it in
java wrapper.
So, I can't figure out the right way to retrieve individual value from a
vtkTable in Java.
Any help would be really appreciated
jMax
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://vtk.org/pipermail/vtkusers/attachments/20171222/4782572a/attachment.html>
More information about the vtkusers
mailing list