[vtkusers] Returning datas as java array

Jeff Lee jeff at cdnorthamerica.com
Wed Nov 6 06:55:19 EST 2002


Simon Chatelain wrote:

> Jarek Sacha wrote:
>
>> --- Simon Chatelain <simon.chatelain at epfl.ch> wrote:
>>  
>>
>>> Hello,
>>> i'm still trying to transfer my vtkimageData via Java-RMI. But now, i'am
>>>
>>> trying to subclass vtkImageData to add a method who return
>>> all the datas as a byte array. And i want to call this method from 
>>> Java to reiceve a java Byte Array (byte[]) but if the C++ method 
>>> return a
>>> char*
>>> the wrapper understand that as returning a java String.
>>>   
>>
>>
>> [I did not follow what you were doing before, not sure what wrapper you
>> mean above.]
>>
>> You can convert String to byte[] either using String.getBytes() 
>> method or
>> CharacterEncoder class (new Java 1.4).
>>
>> Jarek
>>
>>  
>>
> Hello,
>
> The wrapper i mentionned is the vtkWrappJava executable who generate 
> the JNI c++ and java class.
> And the problem is that c++ char type is a 8 bits type and the Java 
> char who compose a String is 16 bit unicode
> character. So i cannot recast the string into byte, the datas are not 
> similar.
>
> The general problem is to transfer a vtkImageData from a java 
> application to another via the Java-RMI system.

Have you tried vtkSocketCommunicator/vtkSocketController?  This already 
supports interprocess communciation, but with no rmi.  If you are only 
trying to send the data from one process to another, this might be an 
alternative to rmi.
-Jeff

>
> The first solution is to serialize the object, but as the java 
> vtkImageData  object is a wrapp class to an c++ object,
> i do'nt know how to serialize it. If i do this simply, only the java 
> object is transferred and not the data stored into
> the C++ object.
>
> So,now, the idea is to get the datas of the imageData as a raw byte 
> array, who is a type easily serializable, then i transfer
> this raw data via RMI, and i reconstruct a vtkImageData object on the 
> other side.
> My question is how to code a method in C++ who return this raw byte 
> array independently of the data type
> (float, int, unsigned int, etc...),  and who (after the generation of 
> wrapping class process) return a jarray of byte and not a String ?
>
> Thanks
>
> Simon
>
>
>
>
>
>
> _______________________________________________
> This is the private VTK discussion list. Please keep messages 
> on-topic. Check the FAQ at: <http://public.kitware.com/cgi-bin/vtkfaq>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/vtkusers
>
>






More information about the vtkusers mailing list