VTK
/Users/kitware/Dashboards/MyTests/VTK_BLD_Release_docs/Utilities/Doxygen/dox/Wrapping/Java/vtkJavaUtil.h
Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    vtkJavaUtil.h
00005 
00006   Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
00007   All rights reserved.
00008   See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
00009 
00010      This software is distributed WITHOUT ANY WARRANTY; without even
00011      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
00012      PURPOSE.  See the above copyright notice for more information.
00013 
00014 =========================================================================*/
00015 
00016 #ifndef vtkJavaUtil_h
00017 #define vtkJavaUtil_h
00018 
00019 #include "vtkSystemIncludes.h"
00020 #include <jni.h>
00021 #include "vtkCommand.h"
00022 #include "vtkWrappingJavaModule.h"
00023 
00024 #include <string>
00025 
00026 extern VTKWRAPPINGJAVA_EXPORT jlong q(JNIEnv *env,jobject obj);
00027 
00028 extern VTKWRAPPINGJAVA_EXPORT void *vtkJavaGetPointerFromObject(JNIEnv *env,jobject obj);
00029 extern VTKWRAPPINGJAVA_EXPORT char *vtkJavaUTFToChar(JNIEnv *env, jstring in);
00030 extern VTKWRAPPINGJAVA_EXPORT bool vtkJavaUTFToString(JNIEnv *env, jstring in, std::string &out);
00031 extern VTKWRAPPINGJAVA_EXPORT jstring vtkJavaMakeJavaString(JNIEnv *env, const char *in);
00032 
00033 extern VTKWRAPPINGJAVA_EXPORT jarray vtkJavaMakeJArrayOfFloatFromFloat(JNIEnv *env,
00034              float *arr, int size);
00035 extern VTKWRAPPINGJAVA_EXPORT jarray vtkJavaMakeJArrayOfDoubleFromFloat(JNIEnv *env,
00036              float *arr, int size);
00037 extern VTKWRAPPINGJAVA_EXPORT jarray vtkJavaMakeJArrayOfDoubleFromDouble(JNIEnv *env,
00038               double *arr, int size);
00039 extern VTKWRAPPINGJAVA_EXPORT jarray vtkJavaMakeJArrayOfShortFromShort(JNIEnv *env, short *arr, int size);
00040 extern VTKWRAPPINGJAVA_EXPORT jarray vtkJavaMakeJArrayOfIntFromInt(JNIEnv *env, int *arr, int size);
00041 extern VTKWRAPPINGJAVA_EXPORT jarray vtkJavaMakeJArrayOfIntFromIdType(JNIEnv *env, vtkIdType *arr, int size);
00042 #if defined(VTK_TYPE_USE_LONG_LONG)
00043 extern VTKWRAPPINGJAVA_EXPORT jarray vtkJavaMakeJArrayOfIntFromLongLong(JNIEnv *env, long long *arr, int size);
00044 #endif
00045 #if defined(VTK_TYPE_USE___INT64)
00046 extern VTKWRAPPINGJAVA_EXPORT jarray vtkJavaMakeJArrayOfIntFrom__Int64(JNIEnv *env, __int64 *arr, int size);
00047 #endif
00048 extern VTKWRAPPINGJAVA_EXPORT jarray vtkJavaMakeJArrayOfIntFromSignedChar(JNIEnv *env, signed char *arr, int size);
00049 extern VTKWRAPPINGJAVA_EXPORT jarray vtkJavaMakeJArrayOfLongFromLong(JNIEnv *env, long *arr, int size);
00050 extern VTKWRAPPINGJAVA_EXPORT jarray vtkJavaMakeJArrayOfByteFromUnsignedChar(JNIEnv *env, unsigned char *arr, int size);
00051 extern VTKWRAPPINGJAVA_EXPORT jarray vtkJavaMakeJArrayOfByteFromChar(JNIEnv *env, char *arr, int size);
00052 extern VTKWRAPPINGJAVA_EXPORT jarray vtkJavaMakeJArrayOfCharFromChar(JNIEnv *env, char *arr, int size);
00053 extern VTKWRAPPINGJAVA_EXPORT jarray vtkJavaMakeJArrayOfUnsignedCharFromUnsignedChar(JNIEnv *env, unsigned char *arr, int size);
00054 extern VTKWRAPPINGJAVA_EXPORT jarray vtkJavaMakeJArrayOfUnsignedIntFromUnsignedInt(JNIEnv *env, unsigned int *arr, int size);
00055 extern VTKWRAPPINGJAVA_EXPORT jarray vtkJavaMakeJArrayOfUnsignedShortFromUnsignedShort(JNIEnv *env,unsigned short *ptr,int size);
00056 extern VTKWRAPPINGJAVA_EXPORT jarray vtkJavaMakeJArrayOfUnsignedLongFromUnsignedLong(JNIEnv *env, unsigned long *arr, int size);
00057 
00058 // this is the void pointer parameter passed to the vtk callback routines on
00059 // behalf of the Java interface for callbacks.
00060 struct vtkJavaVoidFuncArg
00061 {
00062   JavaVM *vm;
00063   jobject  uobj;
00064   jmethodID mid;
00065 } ;
00066 
00067 extern VTKWRAPPINGJAVA_EXPORT void vtkJavaVoidFunc(void *);
00068 extern VTKWRAPPINGJAVA_EXPORT void vtkJavaVoidFuncArgDelete(void *);
00069 
00070 class VTKWRAPPINGJAVA_EXPORT vtkJavaCommand : public vtkCommand
00071 {
00072 public:
00073   static vtkJavaCommand *New() { return new vtkJavaCommand; };
00074 
00075   void SetGlobalRef(jobject obj) { this->uobj = obj; };
00076   void SetMethodID(jmethodID id) { this->mid = id; };
00077   void AssignJavaVM(JNIEnv *env) { env->GetJavaVM(&(this->vm)); };
00078 
00079   void Execute(vtkObject *, unsigned long, void *);
00080 
00081   JavaVM *vm;
00082   jobject  uobj;
00083   jmethodID mid;
00084 protected:
00085   vtkJavaCommand();
00086   ~vtkJavaCommand();
00087 };
00088 
00089 #endif
00090 // VTK-HeaderTest-Exclude: vtkJavaUtil.h