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, <br>
<br>void triangulation(vtkPolyData* inputCloud)<br><br>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.<br>
<br><br><div class="gmail_quote">On Thu, Aug 16, 2012 at 11:06 AM, Monnier, Gilles <span dir="ltr"><<a href="mailto:Gilles.Monnier@oce.com" target="_blank">Gilles.Monnier@oce.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<u></u>
<div>
<div><font face="Arial">
<p style="MARGIN:0in 0in 0pt" class="MsoNormal"><font face="Times New Roman" size="3">Hi,</font></p>
<p style="MARGIN:0in 0in 0pt" class="MsoNormal"><u></u><u></u><font face="Times New Roman" size="3"> </font><u></u></p>
<p style="MARGIN:0in 0in 0pt" class="MsoNormal"><font face="Times New Roman" size="3">I’m currently facing an issue using VTK with
java.</font></p>
<p style="MARGIN:0in 0in 0pt" class="MsoNormal"><u></u><font face="Times New Roman" size="3"> </font><u></u></p>
<p style="TEXT-ALIGN:justify;MARGIN:0in 0in 0pt" class="MsoNormal"><font face="Times New Roman" size="3">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:</font></p>
<p style="TEXT-ALIGN:justify;MARGIN:0in 0in 0pt" class="MsoNormal"><u></u><font face="Times New Roman" size="3"> </font></p>
<p align="center"><font face="Arial"><img alt="" src="cid:249390515@16082012-0AFC" align="bottom" border="0" height="233" hspace="0" width="379"></font></p></font><u></u>
<p style="TEXT-ALIGN:center;MARGIN:0in 0in 0pt" class="MsoNormal" align="center"><font face="Times New Roman" size="3"></font></p>
<p style="TEXT-ALIGN:center;MARGIN:0in 0in 0pt" class="MsoNormal" align="center"><u></u><font face="Times New Roman" size="3"> </font><u></u></p>
<p style="TEXT-ALIGN:justify;MARGIN:0in 0in 0pt" class="MsoNormal"><font face="Times New Roman" size="3">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.</font></p>
<p style="TEXT-ALIGN:justify;MARGIN:0in 0in 0pt" class="MsoNormal"><u></u><font face="Times New Roman" size="3"> </font><u></u></p>
<p style="TEXT-ALIGN:justify;MARGIN:0in 0in 0pt" class="MsoNormal"><font face="Times New Roman" size="3">Therefore, I started to create the PCL JNI interface by
creating a simple method on the java side:</font></p>
<p style="TEXT-ALIGN:justify;MARGIN:0in 0in 0pt" class="MsoNormal"><u></u><font face="Times New Roman" size="3"> </font><u></u></p>
<p style="TEXT-ALIGN:justify;MARGIN:0in 0in 0pt" class="MsoNormal"><b><span style="FONT-FAMILY:'Courier New';COLOR:#7f0055;FONT-SIZE:10pt">public</span></b><span style="font-size:10pt;font-family:'Courier New'">
</span><b><span style="FONT-FAMILY:'Courier New';COLOR:#7f0055;FONT-SIZE:10pt">native</span></b><span style="font-size:10pt;font-family:'Courier New'">
</span><b><span style="FONT-FAMILY:'Courier New';COLOR:#7f0055;FONT-SIZE:10pt">int</span></b><span style="font-size:10pt;font-family:'Courier New'">
nativePCL_triangulation(vtkPolyData inputCloud);<u></u><u></u></span></p>
<p style="TEXT-ALIGN:justify;MARGIN:0in 0in 0pt" class="MsoNormal"><span style="font-size:10pt;font-family:'Courier New'"><u></u> <u></u></span></p>
<p style="TEXT-ALIGN:justify;MARGIN:0in 0in 0pt" class="MsoNormal"><span style><font size="3"><font face="Times New Roman">Then after having
generated the header file, I need to implement the C++ code of the
interface:<u></u><u></u></font></font></span></p>
<p style="TEXT-ALIGN:justify;MARGIN:0in 0in 0pt" class="MsoNormal"><span style><u></u><font face="Times New Roman" size="3"> </font><u></u></span></p>
<p style="MARGIN:0in 0in 0pt" class="MsoNormal"><span style="FONT-FAMILY:Consolas;COLOR:blue;FONT-SIZE:9.5pt">#include</span><span style="FONT-FAMILY:Consolas;FONT-SIZE:9.5pt">
<span style="COLOR:#a31515"><vtkPolyData.h><u></u><u></u></span></span></p>
<p style="TEXT-ALIGN:justify;MARGIN:0in 0in 0pt" class="MsoNormal"><span style><u></u><font face="Times New Roman" size="3"></font><u></u></span></p>
<p style="MARGIN:0in 0in 0pt" class="MsoNormal"><span style="FONT-FAMILY:Consolas;FONT-SIZE:9.5pt">JNIEXPORT
jint JNICALL nativePCL_triangulation(JNIEnv * env, jobject obj, jobject
polyDataJava)<u></u><u></u></span></p>
<p style="MARGIN:0in 0in 0pt" class="MsoNormal"><span style="FONT-FAMILY:Consolas;FONT-SIZE:9.5pt">{<u></u><u></u></span></p>
<p style="MARGIN:0in 0in 0pt" class="MsoNormal"><span style="FONT-FAMILY:Consolas;FONT-SIZE:9.5pt"><span> </span><span style="COLOR:green">//vtkPolyData* vp =
dynamic_cast<vtkPolyData*>(polyDataJava);<u></u><u></u></span></span></p>
<p style="MARGIN:0in 0in 0pt" class="MsoNormal"><span style="FONT-FAMILY:Consolas;FONT-SIZE:9.5pt"><span> </span><span style="COLOR:blue">return</span> 0;<u></u><u></u></span></p>
<p style="MARGIN:0in 0in 0pt" class="MsoNormal"><span style="FONT-FAMILY:Consolas;FONT-SIZE:9.5pt">}<u></u><u></u></span></p>
<p style="TEXT-ALIGN:justify;MARGIN:0in 0in 0pt" class="MsoNormal"><u></u><font face="Times New Roman" size="3"> </font><u></u></p>
<p style="TEXT-ALIGN:justify;MARGIN:0in 0in 0pt" class="MsoNormal"><font face="Times New Roman" size="3">And here is my issue : How can I retrieve the pointer on
the polyData I instanciated into my java code? </font></p>
<p style="TEXT-ALIGN:justify;MARGIN:0in 0in 0pt" class="MsoNormal"><font face="Times New Roman"><font size="3">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…).<span> I have absolutely no idea how to achieve
that.</span></font></font></p>
<p style="TEXT-ALIGN:justify;MARGIN:0in 0in 0pt" class="MsoNormal"><font face="Times New Roman" size="3"></font> </p>
<p style="TEXT-ALIGN:justify;MARGIN:0in 0in 0pt" class="MsoNormal"><span><font face="Times New Roman" size="3">Thanks
much,</font></span></p>
<p style="TEXT-ALIGN:justify;MARGIN:0in 0in 0pt" class="MsoNormal"><span><font face="Times New Roman" size="3">Gilles
Monnier</font></span></p></div><br clear="all"> 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.
</div>
<br>_______________________________________________<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Please keep messages on-topic and check the VTK FAQ at: <a href="http://www.vtk.org/Wiki/VTK_FAQ" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.vtk.org/mailman/listinfo/vtkusers" target="_blank">http://www.vtk.org/mailman/listinfo/vtkusers</a><br>
<br></blockquote></div><br>