[vtkusers] VTK Java/C Wrapping/Coding Problem

Ambar C ambarc at gmail.com
Thu Aug 19 03:13:02 EDT 2010


So I'll add some more on this.

What I need to do is be able to somehow get a hold of the
vtkGlobalJavaHash.PointerToReference (which seems to be a global hash)
in Java's VTK wrapping system, into my C++ code. I'm not quite sure
what kind of JNI drudgery I'd need to use - so any input on that or
whether I'm looking at the wrong part of the C++/Java wrapper would be
very helpful. My plan after being able to access this would be to feed
it the vtkID of the object I need to work with (both of which I've
managed to isolate) and then use the 'get' function from the
PointerToReference hash to get the actual C++ reference and attempt to
use some ugly casts on them.

Once again, any recommendation, link, resource, suggestion,
encouragement/discouragement (:) would be helpful.

Best.

On Wed, Aug 18, 2010 at 3:22 PM, Ambar C <ambarc at gmail.com> wrote:
> Hi Luke,
>
> From what I see - the field vtkID in the vtkObjectBase class is of
> type 'long' - how would I use this to cast into C++ recognizable
> objects? Is there some hash that the ID is a key to; or something of
> the sort?
>
> Thanks,
> Ambar
>
> On Thu, Aug 12, 2010 at 1:52 PM, Luke Dodd <i.like.bread at gmail.com> wrote:
>> Hi Ambar,
>>
>> If you look in vtkObjectBase.java (will only exist after comping vtk,
>> in the build directory - not the source) you will see that it has a
>> (protected) field called vtkId. This is essentially a C pointer to the
>> vtk object the java object is wrapping. If you retrieve value and get
>> it into C++ with a few horrible casts you could have a pointer to the
>> object. You'll have to work around trying to get the protected field -
>> this is possible in java (google it) or you could tweak
>> vtkObjectBase.java (this is annoying because vtk object base is
>> generated when building).
>>
>> Hopefully that should be enough to get you started. If you need more
>> detailed help just ask.
>>
>> Best Wishes,
>> Luke
>>
>> On 10 August 2010 23:12, Ambar C <ambarc at gmail.com> wrote:
>>> Hello VTK users,
>>>
>>> I currently have a project that's in both Java and C++, and part of
>>> the project involves a wrapper using the Java Native Interface (JNI)
>>> where I use functionality from my C++ libraries in the Java code.
>>>
>>> Now the problem that I face is, both my Java and C++ codes use VTK
>>> objects - and when I pass down, say a vtkPolyDataAlgorithm object
>>> created in Java through to the C++ code, I'm not quite sure how to
>>> cast/use it.
>>>
>>> Please feel free to ask any questions that would help you to answer my question.
>>>
>>> Best Regards,
>>> Ambar
>>> _______________________________________________
>>> Powered by www.kitware.com
>>>
>>> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
>>>
>>> Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
>>>
>>> Follow this link to subscribe/unsubscribe:
>>> http://www.vtk.org/mailman/listinfo/vtkusers
>>>
>>
>



More information about the vtkusers mailing list