<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content="text/html; charset=iso-8859-1" http-equiv=Content-Type>
<META name=GENERATOR content="MSHTML 8.00.6001.19258"></HEAD>
<BODY>
<DIV dir=ltr align=left><SPAN class=404592008-21082012><FONT color=#0000ff
size=2 face=Arial>Oups, the code I posted is not axacly right, here it
is:</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=404592008-21082012><FONT color=#0000ff
size=2 face=Arial></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=404592008-21082012>
<DIV dir=ltr align=left><SPAN class=444015807-21082012><FONT size=2
face=Consolas><FONT size=2 face=Consolas><FONT color=#0000ff face=Arial><SPAN
class=444015807-21082012></SPAN></FONT></FONT></FONT></SPAN> </DIV>
<DIV><FONT size=2 face=Consolas>JNIEXPORT j<SPAN
class=404592008-21082012>long</SPAN><SPAN class=444015807-21082012>
</SPAN>JNICALL Java_nativePCL_1triangulation<BR> (JNIEnv * env, jobject
obj, jobject polyDataJava)<BR>{</FONT></DIV>
<DIV><FONT size=2 face=Consolas></FONT><FONT face=Consolas> </DIV>
<DIV><FONT color=#0000ff face=Arial></FONT><FONT size=2><FONT
color=#008000> // <SPAN class=444015807-21082012>Get the pointer on
the input polyData object</SPAN></FONT></FONT></DIV>
<DIV><FONT size=2><FONT color=#008000><SPAN
class=444015807-21082012></SPAN></FONT> vtkSmartPointer<vtkPolyData>
inPolyDataSmartPtr =
(vtkPolyData*)(vtkJavaGetPointerFromObject(env,polyDataJava));</FONT></FONT></DIV>
<DIV><FONT size=2 face=Consolas></FONT> </DIV>
<DIV><FONT color=#0000ff size=2 face=Consolas> <FONT
color=#000000>if(inPolyDataSmartPtr != NULL) {</FONT></FONT></DIV>
<DIV><FONT face=Consolas><FONT color=#008000><FONT size=2> <SPAN
class=444015807-21082012> </SPAN>// Triangulate the input vtk point
cloud<SPAN class=444015807-21082012> </SPAN></FONT></FONT></FONT></DIV>
<DIV><FONT color=#0000ff><SPAN class=444015807-21082012></SPAN><FONT
face=Consolas><FONT size=2> <FONT color=#000000> <SPAN
class=444015807-21082012> </SPAN>vtkSmartPointer<vtkPolyData>
outPolyDataSmartPtr =
Triangulation::triangulate(inPolyDataSmartPtr);</FONT></FONT></FONT></FONT></DIV>
<DIV><FONT color=#0000ff><FONT face=Consolas><FONT size=2><FONT
color=#000000></FONT></FONT></FONT></FONT> </DIV>
<DIV><FONT color=#0000ff><FONT face=Consolas><FONT size=2><FONT
color=#000000> <SPAN class=444015807-21082012> </SPAN>return
(jlong)(size_t)
outPolyDataSmartPtr.GetPointer();<BR> <BR></FONT> </FONT></FONT><FONT
color=#000000><FONT face=Consolas><FONT size=2>} else {<BR> <SPAN
class=444015807-21082012><FONT color=#008000>
</FONT></SPAN></FONT></FONT><FONT face=Consolas><FONT size=2><FONT
color=#008000>// No input data was retrieved<BR></FONT> <SPAN
class=444015807-21082012> </SPAN>return <SPAN
class=404592008-21082012>0</SPAN>;<BR> }</FONT></FONT></FONT></FONT></DIV>
<DIV><FONT size=2 face=Consolas> return <SPAN
class=404592008-21082012>0</SPAN>;<BR>}</FONT></DIV>
<DIV><FONT size=2 face=Consolas></FONT> </DIV></SPAN></DIV>
<DIV dir=ltr align=left>
<HR tabIndex=-1>
</DIV>
<DIV dir=ltr align=left><FONT size=2 face=Tahoma><B>From:</B>
vtkusers-bounces@vtk.org [mailto:vtkusers-bounces@vtk.org] <B>On Behalf Of
</B>Monnier, Gilles<BR><B>Sent:</B> mardi 21 août 2012 10:18<BR><B>To:</B> A A;
vtkusers@vtk.org<BR><B>Subject:</B> Re: [vtkusers] VTK and Java - JNI
issue<BR></FONT><BR></DIV>
<DIV></DIV>
<DIV dir=ltr align=left><SPAN class=444015807-21082012><FONT color=#0000ff
size=2 face=Arial>Hi,</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=444015807-21082012><FONT color=#0000ff
size=2 face=Arial></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=444015807-21082012><FONT color=#0000ff
size=2 face=Arial>Thanks for the response. Actually, I succeeded to do what I
want with the following method :</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=444015807-21082012><FONT size=2
face=Consolas><FONT size=2 face=Consolas></FONT></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=444015807-21082012><FONT size=2
face=Consolas><FONT size=2
face=Consolas>vtkJavaGetPointerFromObject</FONT></FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=444015807-21082012><FONT size=2
face=Consolas><FONT size=2 face=Consolas></FONT></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=444015807-21082012><FONT size=2
face=Consolas><FONT size=2 face=Consolas><FONT color=#0000ff face=Arial><SPAN
class=444015807-21082012><FONT color=#0000ff size=2 face=Arial>This method is
defined into vtkJavaUtil.h (exported in vtkCommonJava.dll). So finally my code
is the following to perform a quite fast triangulation with PCL
:</FONT></SPAN></FONT></FONT></FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=444015807-21082012><FONT size=2
face=Consolas><FONT size=2 face=Consolas><FONT color=#0000ff face=Arial><SPAN
class=444015807-21082012></SPAN></FONT></FONT></FONT></SPAN> </DIV>
<DIV><FONT size=2 face=Consolas>JNIEXPORT jobject<SPAN class=444015807-21082012>
</SPAN>JNICALL Java_nativePCL_1triangulation<BR> (JNIEnv * env, jobject
obj, jobject polyDataJava)<BR>{</FONT></DIV>
<DIV><FONT size=2 face=Consolas></FONT><FONT face=Consolas> </DIV>
<DIV><FONT color=#0000ff face=Arial></FONT><FONT size=2><FONT
color=#008000> // <SPAN class=444015807-21082012>Get the pointer on
the input polyData object</SPAN></FONT></FONT></DIV>
<DIV><FONT size=2><FONT color=#008000><SPAN
class=444015807-21082012></SPAN></FONT> vtkSmartPointer<vtkPolyData>
inPolyDataSmartPtr =
(vtkPolyData*)(vtkJavaGetPointerFromObject(env,polyDataJava));</FONT></FONT></DIV>
<DIV><FONT size=2 face=Consolas></FONT> </DIV>
<DIV><FONT color=#0000ff size=2 face=Consolas> <FONT
color=#000000>if(inPolyDataSmartPtr != NULL) {</FONT></FONT></DIV>
<DIV><FONT face=Consolas><FONT color=#008000><FONT size=2> <SPAN
class=444015807-21082012> </SPAN>// Triangulate the input vtk point
cloud<SPAN class=444015807-21082012> </SPAN></FONT></FONT></FONT></DIV>
<DIV><FONT color=#0000ff><SPAN class=444015807-21082012></SPAN><FONT
face=Consolas><FONT size=2> <FONT color=#000000> <SPAN
class=444015807-21082012> </SPAN>vtkSmartPointer<vtkPolyData>
outPolyDataSmartPtr =
Triangulation::triangulate(inPolyDataSmartPtr);</FONT></FONT></FONT></FONT></DIV>
<DIV><FONT face=Consolas></FONT> </DIV>
<DIV><FONT size=2 face=Consolas> <SPAN
class=444015807-21082012> </SPAN>vtkPolyData* polydatatest =
(vtkPolyData*) out2PolyDataSmartPtr.GetPointer();</FONT></DIV>
<DIV><FONT color=#0000ff><FONT face=Consolas><FONT size=2><FONT
color=#000000> <SPAN class=444015807-21082012> </SPAN>return
(jlong)(size_t)
outPolyDataSmartPtr.GetPointer();<BR> <BR></FONT> </FONT></FONT><FONT
color=#000000><FONT face=Consolas><FONT size=2>} else {<BR> <SPAN
class=444015807-21082012><FONT color=#008000>
</FONT></SPAN></FONT></FONT><FONT face=Consolas><FONT size=2><FONT
color=#008000>// No input data was retrieved<BR></FONT> <SPAN
class=444015807-21082012> </SPAN>return
NULL;<BR> }</FONT></FONT></FONT></FONT></DIV>
<DIV><FONT size=2 face=Consolas> return NULL;<BR>}</FONT></DIV>
<DIV dir=ltr align=left><SPAN class=444015807-21082012><FONT size=2
face=Consolas><FONT size=2 face=Consolas><FONT color=#0000ff face=Arial><SPAN
class=444015807-21082012></SPAN></FONT></FONT></FONT></SPAN> </DIV><SPAN
class=444015807-21082012><FONT color=#0000ff size=2 face=Arial></FONT></SPAN>
<DIV dir=ltr align=left><SPAN class=444015807-21082012><FONT size=2
face=Consolas><FONT size=2 face=Consolas><FONT color=#0000ff face=Arial><SPAN
class=444015807-21082012>I didn't know about the auto-generating of JNI from
vtk, but I think this will produce quite the same result, and I will make use of
that next time, so thanks for the tip.</SPAN></FONT></FONT></FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=444015807-21082012><FONT size=2
face=Consolas><FONT size=2 face=Consolas><FONT color=#0000ff face=Arial><SPAN
class=444015807-21082012></SPAN></FONT></FONT></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=444015807-21082012><FONT size=2
face=Consolas><FONT size=2 face=Consolas><FONT color=#0000ff face=Arial><SPAN
class=444015807-21082012>Regards,</SPAN></FONT></FONT></FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=444015807-21082012><FONT size=2
face=Consolas><FONT size=2 face=Consolas><FONT color=#0000ff face=Arial><SPAN
class=444015807-21082012>Gilles
Monnier.</SPAN></FONT></FONT></FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=444015807-21082012><FONT size=2
face=Consolas><FONT size=2 face=Consolas><FONT color=#0000ff face=Arial><SPAN
class=444015807-21082012></SPAN></FONT></FONT></FONT></SPAN> </DIV>
<DIV dir=ltr align=left>
<HR tabIndex=-1>
</DIV>
<DIV dir=ltr align=left><FONT size=2 face=Tahoma><B>From:</B>
vtkusers-bounces@vtk.org [mailto:vtkusers-bounces@vtk.org] <B>On Behalf Of </B>A
A<BR><B>Sent:</B> mardi 21 août 2012 04:26<BR><B>To:</B>
vtkusers@vtk.org<BR><B>Subject:</B> Re: [vtkusers] VTK and Java - JNI
issue<BR></FONT><BR></DIV>
<DIV></DIV>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
style="BORDER-LEFT: #ccc 1px solid; MARGIN: 0px 0px 0px 0.8ex; PADDING-LEFT: 1ex"
class=gmail_quote><U></U>
<DIV>
<DIV><FONT face=Arial>
<P style="MARGIN: 0in 0in 0pt" class=MsoNormal><FONT size=3
face="Times New Roman">Hi,</FONT></P>
<P style="MARGIN: 0in 0in 0pt" class=MsoNormal><U></U><U></U><FONT size=3
face="Times New Roman"></FONT><U></U> </P>
<P style="MARGIN: 0in 0in 0pt" class=MsoNormal><FONT size=3
face="Times New Roman">I’m currently facing an issue using VTK with
java.</FONT></P>
<P style="MARGIN: 0in 0in 0pt" class=MsoNormal><U></U><FONT size=3
face="Times New Roman"></FONT><U></U> </P>
<P style="TEXT-ALIGN: justify; MARGIN: 0in 0in 0pt" class=MsoNormal><FONT
size=3 face="Times New Roman">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 size=3 face="Times New Roman"></FONT> </P>
<P align=center><FONT face=Arial><IMG border=0 hspace=0 alt="" align=bottom
src="cid:404592008@21082012-2AF2" width=379
height=233></FONT></P></FONT><U></U>
<P style="TEXT-ALIGN: center; MARGIN: 0in 0in 0pt" class=MsoNormal
align=center><FONT size=3 face="Times New Roman"></FONT></P>
<P style="TEXT-ALIGN: center; MARGIN: 0in 0in 0pt" class=MsoNormal
align=center><U></U><FONT size=3
face="Times New Roman"></FONT><U></U> </P>
<P style="TEXT-ALIGN: justify; MARGIN: 0in 0in 0pt" class=MsoNormal><FONT
size=3 face="Times New Roman">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 size=3
face="Times New Roman"></FONT><U></U> </P>
<P style="TEXT-ALIGN: justify; MARGIN: 0in 0in 0pt" class=MsoNormal><FONT
size=3 face="Times New Roman">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 size=3
face="Times New Roman"></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-FAMILY: 'Courier New'; FONT-SIZE: 10pt"> </SPAN><B><SPAN
style="FONT-FAMILY: 'Courier New'; COLOR: #7f0055; FONT-SIZE: 10pt">native</SPAN></B><SPAN
style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt"> </SPAN><B><SPAN
style="FONT-FAMILY: 'Courier New'; COLOR: #7f0055; FONT-SIZE: 10pt">int</SPAN></B><SPAN
style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt">
nativePCL_triangulation(vtkPolyData inputCloud);<U></U><U></U></SPAN></P>
<P style="TEXT-ALIGN: justify; MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN
style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt"><U></U><U></U></SPAN> </P>
<P style="TEXT-ALIGN: justify; MARGIN: 0in 0in 0pt"
class=MsoNormal><SPAN><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><U></U><FONT size=3
face="Times New Roman"></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><U></U><FONT size=3
face="Times New Roman"></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 size=3
face="Times New Roman"></FONT><U></U> </P>
<P style="TEXT-ALIGN: justify; MARGIN: 0in 0in 0pt" class=MsoNormal><FONT
size=3 face="Times New Roman">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
size=3 face="Times New Roman"></FONT> </P>
<P style="TEXT-ALIGN: justify; MARGIN: 0in 0in 0pt"
class=MsoNormal><SPAN><FONT size=3 face="Times New Roman">Thanks
much,</FONT></SPAN></P>
<P style="TEXT-ALIGN: justify; MARGIN: 0in 0in 0pt"
class=MsoNormal><SPAN><FONT size=3 face="Times New Roman">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><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.
<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.
</BODY></HTML>