SheafSystem  0.0.0.0
NativeVtk.cc
1 
2 //
3 // Copyright (c) 2014 Limit Point Systems, Inc.
4 //
5 // Licensed under the Apache License, Version 2.0 (the "License");
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 // http://www.apache.org/licenses/LICENSE-2.0
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 //
17 
18 // JNI code for NativeVtk.java
19 
20 #include <jni.h>
21 #include "vtkObject.h"
22 #include "vtkJavaUtil.h"
23 #include "vtkSystemIncludes.h"
24 
25 #ifdef __cplusplus
26 extern "C"
27 {
28 #endif
29 
30  /*
31  * Class: NativeVtk
32  * Method: getCppPointerNative (static method)
33  * Signature: (Lvtk/vtkObject;Ljava/lang/String;)J
34  */
35  JNIEXPORT jlong JNICALL
36  Java_tools_viewer_common_NativeVtk_getCppPointerNative
37  (JNIEnv* xenv, jclass xclass, jobject xvtk_object, jstring xclass_name)
38  {
39  const char* jname = xenv->GetStringUTFChars(xclass_name, NULL);
40  char* cname = const_cast<char*>(jname);
41  // VTK 5.0.3
42  // void* ptr = vtkJavaGetPointerFromObject(xenv, xvtk_object, cname);
43  // VTK 5.6.1
44  void* ptr = vtkJavaGetPointerFromObject(xenv, xvtk_object);
45  xenv->ReleaseStringUTFChars(xclass_name, jname);
46 
47  jlong result = reinterpret_cast<jlong>(ptr);
48 
49  return result;
50  }
51 
52 #ifdef __cplusplus
53 }
54 #endif