[vtkusers] VTK and Java - JNI issue

A A azata42 at gmail.com
Mon Aug 20 22:25:34 EDT 2012


Personally, I would try to avoid hand coding JNI glue code myself. Since
VTK already provided facilities for auto-generating JNI code, I would make
use of that. You can simply create a subclasses of vtkObject which consists
of a static function, say,

void triangulation(vtkPolyData* inputCloud)

In the implementation of this function, you now have a pointer the
vtkPolyData object which you instantiated in the java side. You could
compile this class with Java wrapping turned on (See the Examples/Build
folder in the VTK source for examples) and link in the PCL library, and all
the JNI code will be generated for you. At the beginning of the java
program, you will need to make sure to load (with the loadLibrary function)
the 2 generated shared libaries plus the PCL library.


On Thu, Aug 16, 2012 at 11:06 AM, Monnier, Gilles <Gilles.Monnier at oce.com>wrote:

> **
>
> Hi,
>
> **** **
>
> I’m currently facing an issue using VTK with java.
>
> ** **
>
> Actually, I’m trying to integrate a C++ library into my software. This
> library is PCL (Point Cloud Library), which offer some interesting features
> concerning triangulation and registration. Here is below how my application
> is designed:
>
> **
>
> **
>
> ** **
>
> Kitware already provide the JNI interface for VTK, but PCL does not. What
> I would like to do is to be able to request PCL to perform a triangulation
> on the vtkPolyData I instanciated into my java code.
>
> ** **
>
> Therefore, I started to create the PCL JNI interface by creating a simple
> method on the java side:
>
> ** **
>
> *public* *native* *int* nativePCL_triangulation(vtkPolyData inputCloud);**
> **
>
> ** **
>
> Then after having generated the header file, I need to implement the C++
> code of the interface:****
>
> ** **
>
> #include <vtkPolyData.h>****
>
> ****
>
> JNIEXPORT jint JNICALL nativePCL_triangulation(JNIEnv * env, jobject obj,
> jobject polyDataJava)****
>
> {****
>
>        //vtkPolyData* vp = dynamic_cast<vtkPolyData*>(polyDataJava);****
>
>        return 0;****
>
> }****
>
> ** **
>
> And here is my issue : How can I retrieve the pointer on the polyData I
> instanciated into my java code?
>
> To be clear, I would like to access the C++ object instanciated by VTK
> from the C++ part of the interface I want to implement (the best would be a
> stuff like a dynamic_cast as in the comment above…). I have absolutely no
> idea how to achieve that.
>
>
>
> Thanks much,
>
> Gilles Monnier
>
> This message and attachment(s) are intended solely for use by the
> addressee and may contain information that is privileged, confidential or
> otherwise exempt from disclosure under applicable law. If you are not the
> intended recipient or agent thereof responsible for delivering this message
> to the intended recipient, you are hereby notified that any dissemination,
> distribution or copying of this communication is strictly prohibited. If
> you have received this communication in error, please notify the sender
> immediately by telephone and with a 'reply' message. Thank you for your
> co-operation.
>
> _______________________________________________
> 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
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20120820/8ef89ebf/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: image/png
Size: 9362 bytes
Desc: not available
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20120820/8ef89ebf/attachment.png>


More information about the vtkusers mailing list