Java wrapper code changes

Recently some significant changes have been merged to the VTK master branch for the Java wrapper code generation. The number of exported data types has been extended to include byte, short, long and float types, so that the generated methods closely match those in the VTK API. Overloaded function declarations are also now output. Array marshalling has been improved and the javac deprecation warnings have been eliminated.

It would be helpful if any developers building the Java wrappers from the master branch could try out the new code and give some feedback about any issues they run into.

1 Like

Hi,

I am currently using VTK 9.0.3 with the Java Wrapper that I built few weeks ago. I have VTU files containing <DataArray type="Float64" NumberOfComponents="3" format="binary"> and I have no problem loading them.

However I don’t see any method for retrieving vtkDataArray as Java float directly, only as double or double[], so I do the cast by myself. Do you expect I find new Java methods for retrieving byte, short, long and float types?

float[] output = ((vtkFloatArray) array).GetJavaArray();

Thanks Todd. The file I have declare Float64 data type, but data is parsed as java double (seams correct). The method you suggest works but if you are looking for feedback on float loading, may I ask you pointers toward files that lead to java float when loaded?

Sorry I don’t understand the question.

What do you mean when you say Float64 is parsed as double? What C++ code is being called?

By definition we have

float32 => float
float64 => double

In that case a vtkDoubleArray is created by the reader rather than a vtkFloatArray so


double[] output = ((vtkDoubleArray) array).GetJavaArray();

Yes, I understood vtk Float64 are parsed as java double. My point is that you asked for feedbacks on byte , short , long and float types (which I understood to be java types), but I only have files containing vtk Float64. If you provide me a file containing Float32, I can give a try and let you know if this works correctly.

Ah. Sorry. I don’t have any data files for that.

I was mainly referring to methods which now pass parameters of those types like
vtkBrush.SetColor(byte r,byte g,byte b) which previously used integers.

I unfortunately can’t test this : I am on MacOS, where vtk renderers crash in Java, so I use another rendering framework. I mainly use vtk in Java for IO and filtering so far.