Visual Servoing Platform  version 3.2.0
listconverters.cpp
1 // This file is part of ViSP project.
2 #define LOG_TAG "org.visp.utils.Converters"
3 #include "common.h"
4 
5 jlongArray vector_vpColVector_to_List(JNIEnv* env, std::vector<vpColVector> V)
6 {
7  jlongArray result;
8  result = env->NewLongArray(V.size());
9  jlong *body = env->GetLongArrayElements(result, 0);
10 
11  for(unsigned int i=0;i<V.size();++i)
12  body[i] = (long) new vpColVector(V[i]);
13 
14  env->ReleaseLongArrayElements(result, body, 0);
15 
16  return result;
17 }
18 
19 std::vector<vpHomogeneousMatrix> List_to_vector_vpHomogeneousMatrix(JNIEnv* env, jlongArray arr)
20 {
21  std::vector<vpHomogeneousMatrix> V;
22  jlong *body = env->GetLongArrayElements(arr, 0);
23  int len = env->GetArrayLength(arr);
24 
25  for(int i=0;i<len;++i){
26  vpHomogeneousMatrix *temp = (vpHomogeneousMatrix*) body[i];
27  V.push_back(*temp);
28  }
29 
30  env->ReleaseLongArrayElements(arr, body, 0);
31  return V;
32 }
33 
34 std::vector<float> List_to_vector_float(JNIEnv* env, jfloatArray arr)
35 {
36  std::vector<float> V;
37  jfloat *body = env->GetFloatArrayElements(arr, 0);
38  int len = env->GetArrayLength(arr);
39 
40  for(int i=0;i<len;++i)
41  V.push_back(body[i]);
42 
43  env->ReleaseFloatArrayElements(arr, body, 0);
44  return V;
45 }
46 
47 jlongArray vector_vpHomogeneousMatrix_to_List(JNIEnv* env, std::vector<vpHomogeneousMatrix> V)
48 {
49  jlongArray result;
50  result = env->NewLongArray(V.size());
51  jlong *body = env->GetLongArrayElements(result, 0);
52 
53  for(unsigned int i=0;i<V.size();++i)
54  body[i] = (long) new vpHomogeneousMatrix(V[i]);
55 
56  env->ReleaseLongArrayElements(result, body, 0);
57 
58  return result;
59 }
60 
61 std::vector<double> List_to_vector_double(JNIEnv* env, jdoubleArray arr)
62 {
63  std::vector<double> V;
64  jdouble *body = env->GetDoubleArrayElements(arr, 0);
65  int len = env->GetArrayLength(arr);
66 
67  for(int i=0;i<len;++i)
68  V.push_back(body[i]);
69 
70  env->ReleaseDoubleArrayElements(arr, body, 0);
71 
72  return V;
73 }
74 
75 std::vector<int> List_to_vector_int(JNIEnv* env, jintArray arr)
76 {
77  std::vector<int> V;
78  jint *body = env->GetIntArrayElements(arr, 0);
79  int len = env->GetArrayLength(arr);
80 
81  for(int i=0;i<len;++i)
82  V.push_back(body[i]);
83 
84  env->ReleaseIntArrayElements(arr, body, 0);
85 
86  return V;
87 }
vpColVector
Implementation of column vector and the associated operations.
Definition: vpColVector.h:71
vpHomogeneousMatrix
Implementation of an homogeneous matrix and operations on such kind of matrices.
Definition: vpHomogeneousMatrix.h:91