2 * Project Info: http://jcae.sourceforge.net
4 * This program is free software; you can redistribute it and/or modify it under
5 * the terms of the GNU Lesser General Public License as published by the Free
6 * Software Foundation; either version 2.1 of the License, or (at your option)
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with this program; if not, write to the Free Software Foundation, Inc.,
16 * 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
18 * (C) Copyright 2005, by EADS CRC
22 jdoubleArray XYZtoDoubleArray(JNIEnv* jenv, const gp_XYZ & xyz)
24 jdouble nativeArray[]={xyz.X(), xyz.Y(), xyz.Z()};
25 jdoubleArray toReturn=jenv->NewDoubleArray(3);
26 jenv->SetDoubleArrayRegion(toReturn, 0, 3, nativeArray);
35 %typemap(jni) gp_Pnt, const gp_Pnt& "jdoubleArray"
36 %typemap(jtype) gp_Pnt, const gp_Pnt& "double[]"
37 %typemap(jstype) gp_Pnt, const gp_Pnt& "double[]"
39 %typemap(in) gp_Pnt, const gp_Pnt&
41 if(JCALL1(GetArrayLength, jenv, $input)!=3)
42 SWIG_JavaThrowException(jenv, SWIG_JavaIllegalArgumentException, "array length must be 3");
43 jdouble * naxe=JCALL2(GetDoubleArrayElements, jenv, $input, NULL);
44 $1=new gp_Pnt(naxe[0],naxe[1],naxe[2]);
47 %typemap(out) const gp_Pnt&
49 $result=XYZtoDoubleArray(jenv, $1->XYZ());
54 $result=XYZtoDoubleArray(jenv, $1.XYZ());
57 %typemap(freearg) gp_Pnt, const gp_Pnt&
62 %typemap(javain) gp_Pnt, const gp_Pnt& "$javainput"
63 %typemap(javaout) gp_Pnt, const gp_Pnt&
72 %typemap(jni) gp_Pnt2d, const gp_Pnt2d& "jdoubleArray"
73 %typemap(jtype) gp_Pnt2d, const gp_Pnt2d& "double[]"
74 %typemap(jstype) gp_Pnt2d, const gp_Pnt2d& "double[]"
76 %typemap(in) gp_Pnt2d, const gp_Pnt2d&
78 if(JCALL1(GetArrayLength, jenv, $input)!=2)
79 SWIG_JavaThrowException(jenv, SWIG_JavaIllegalArgumentException, "array length must be 2");
80 jdouble * naxe=JCALL2(GetDoubleArrayElements, jenv, $input, NULL);
81 $1=new gp_Pnt2d(naxe[0],naxe[1]);
84 %typemap(freearg) gp_Pnt2d, const gp_Pnt2d&
89 %typemap(javain) gp_Pnt2d, const gp_Pnt2d& "$javainput"
90 %typemap(javaout) gp_Pnt2d, const gp_Pnt2d&
95 %typemap(out) gp_Pnt2d, const gp_Pnt2d&
97 jdouble nativeArray[]={$1.X(), $1.Y()};
98 jdoubleArray toReturn=JCALL1(NewDoubleArray, jenv, 2);
99 JCALL4(SetDoubleArrayRegion, jenv, toReturn, 0, 2, nativeArray);
105 %typemap(jni) gp_Pln, const gp_Pln& "jdoubleArray"
106 %typemap(jtype) gp_Pln, const gp_Pln& "double[]"
107 %typemap(jstype) gp_Pln, const gp_Pln& "double[]"
109 %typemap(in) gp_Pln, const gp_Pln&
111 if(JCALL1(GetArrayLength, jenv, $input)!=4)
112 SWIG_JavaThrowException(jenv, SWIG_JavaIllegalArgumentException, "array length must be 4");
113 jdouble * naxe=JCALL2(GetDoubleArrayElements, jenv, $input, NULL);
114 $1=new gp_Pln(naxe[0],naxe[1],naxe[2],naxe[4]);
117 %typemap(freearg) gp_Pln, const gp_Pln&
122 %typemap(javain) gp_Pln, const gp_Pln& "$javainput"
123 %typemap(javaout) gp_Pln, const gp_Pln&
128 %typemap(out) gp_Pln, const gp_Pln &
131 $1.Coefficients(a, b, c, d);
132 jdouble nativeArray[] = {a, b, c, d};
133 jdoubleArray toReturn = JCALL1(NewDoubleArray, jenv, 4);
134 JCALL4(SetDoubleArrayRegion, jenv, toReturn, 0, 4, nativeArray);
141 %typemap(jni) gp_Vec, const gp_Vec& "jdoubleArray"
142 %typemap(jtype) gp_Vec, const gp_Vec& "double[]"
143 %typemap(jstype) gp_Vec, const gp_Vec& "double[]"
145 %typemap(in) gp_Vec, const gp_Vec&
147 if(JCALL1(GetArrayLength, jenv, $input)!=3)
148 SWIG_JavaThrowException(jenv, SWIG_JavaIllegalArgumentException, "array length must be 3");
149 jdouble * naxe=JCALL2(GetDoubleArrayElements, jenv, $input, NULL);
150 $1=new gp_Vec(naxe[0],naxe[1],naxe[2]);
153 %typemap(freearg) gp_Vec, const gp_Vec&
158 %typemap(javain) gp_Vec, const gp_Vec& "$javainput"
159 %typemap(javaout) gp_Vec, const gp_Vec&
164 %typemap(out) gp_Vec, const gp_Vec&
166 $result=XYZtoDoubleArray(jenv, $1->XYZ());
172 %typemap(jni) gp_Dir, const gp_Dir&, gp_Dir& "jdoubleArray"
173 %typemap(jtype) gp_Dir, const gp_Dir&, gp_Dir& "double[]"
174 %typemap(jstype) gp_Dir, const gp_Dir&, gp_Dir& "double[]"
176 %typemap(in) gp_Dir, const gp_Dir&
178 if(JCALL1(GetArrayLength, jenv, $input)!=3)
179 SWIG_JavaThrowException(jenv, SWIG_JavaIllegalArgumentException, "array length must be 3");
180 jdouble * naxe=JCALL2(GetDoubleArrayElements, jenv, $input, NULL);
181 $1=new gp_Dir(naxe[0],naxe[1],naxe[2]);
184 %typemap(freearg) gp_Dir, const gp_Dir&
189 %typemap(out) const gp_Dir&
191 $result=XYZtoDoubleArray(jenv, $1->XYZ());
196 $result=XYZtoDoubleArray(jenv, $1.XYZ());
199 %typemap(javain) gp_Dir, const gp_Dir&, gp_Dir& "$javainput"
200 %typemap(javaout) gp_Dir, const gp_Dir&, gp_Dir&
208 %typemap(jni) gp_Ax2, const gp_Ax2& "jdoubleArray"
209 %typemap(jtype) gp_Ax2, const gp_Ax2& "double[]"
210 %typemap(jstype) gp_Ax2, const gp_Ax2& "double[]"
212 %typemap(in) gp_Ax2, const gp_Ax2&
214 int len = JCALL1(GetArrayLength, jenv, $input);
215 if(len !=6 && len != 9)
216 SWIG_JavaThrowException(jenv, SWIG_JavaIllegalArgumentException, "array length must be 6 or 9");
217 jdouble * naxe=JCALL2(GetDoubleArrayElements, jenv, $input, NULL);
219 $1=new gp_Ax2(gp_Pnt(naxe[0],naxe[1],naxe[2]), gp_Dir(naxe[3], naxe[4], naxe[5]));
221 $1=new gp_Ax2(gp_Pnt(naxe[0],naxe[1],naxe[2]), gp_Dir(naxe[3], naxe[4], naxe[5]), gp_Dir(naxe[6], naxe[7], naxe[8]));
224 %typemap(freearg) gp_Ax2, const gp_Ax2&
229 %typemap(out) gp_Ax2, const gp_Ax2&
234 %typemap(javain) gp_Ax2, const gp_Ax2& "$javainput"
235 %typemap(javaout) gp_Ax2, const gp_Ax2&
243 %typemap(jni) gp_Ax1, const gp_Ax1& "jdoubleArray"
244 %typemap(jtype) gp_Ax1, const gp_Ax1& "double[]"
245 %typemap(jstype) gp_Ax1, const gp_Ax1& "double[]"
247 %typemap(in) gp_Ax1, const gp_Ax1&
249 if(JCALL1(GetArrayLength, jenv, $input)!=6)
250 SWIG_JavaThrowException(jenv, SWIG_JavaIllegalArgumentException, "array length must be 6");
251 jdouble * naxe=JCALL2(GetDoubleArrayElements, jenv, $input, NULL);
252 $1=new gp_Ax1(gp_Pnt(naxe[0],naxe[1],naxe[2]), gp_Dir(naxe[3], naxe[4], naxe[5]));
255 %typemap(freearg) gp_Ax1, const gp_Ax1&
260 %typemap(out) gp_Ax1, const gp_Ax1&
265 %typemap(javain) gp_Ax1, const gp_Ax1& "$javainput"
266 %typemap(javaout) gp_Ax1, const gp_Ax1&
274 %{#include <gp_Trsf.hxx>%}
276 %rename(GP_Trsf) gp_Trsf;
278 %typemap(javacode) gp_Trsf
280 public void setValues(double[] matrix)
282 if(matrix.length!=12)
283 throw new IllegalArgumentException("matrix length must be 12");
285 matrix[0], matrix[1], matrix[2], matrix[3],
286 matrix[4], matrix[5], matrix[6], matrix[7],
287 matrix[8], matrix[9], matrix[10], matrix[11]);
293 %rename(setRotation) SetRotation;
294 %rename(setTranslation) SetTranslation;
295 %rename(setValues) SetValues;
298 void SetRotation(const gp_Ax1& A1,const Standard_Real Ang) ;
299 void SetTranslation(const gp_Vec& V) ;
300 void SetValues(const Standard_Real a11,const Standard_Real a12, const Standard_Real a13,const Standard_Real a14,
301 const Standard_Real a21,const Standard_Real a22,const Standard_Real a23,const Standard_Real a24,
302 const Standard_Real a31,const Standard_Real a32,const Standard_Real a33,const Standard_Real a34);
307 /** Easy to use with javax.vecmath.Matrix4D */
308 void getValues(double matrix[16])
311 for(int i=1; i<=3; i++)
312 for(int j=1; j<=4; j++)
313 matrix[k++]=self->Value(i,j);
324 %{#include <gp_Circ.hxx>%}
325 %rename(GP_Circ) gp_Circ;
329 gp_Circ(const gp_Ax2& axis, const Standard_Real radius);
335 %{#include <gp_Parab.hxx>%}
336 %rename(GP_Parab) gp_Parab;
340 gp_Parab(const gp_Ax2& A2,const Standard_Real Focal);
341 gp_Parab(const gp_Ax1& D,const gp_Pnt& F);
345 /*******************************************************************
349 *******************************************************************/
354 %{#include <gp_Elips.hxx>%}
356 %rename(GP_Elips) gp_Elips;
362 gp_Elips(const gp_Ax2& A2,const Standard_Real MajorRadius,const Standard_Real MinorRadius);
369 %{#include <gp_Lin.hxx>%}
371 %rename(GP_Lin) gp_Lin;
376 gp_Lin(const gp_Ax1& A1);
383 %{#include <gp_Mat.hxx>%}
384 %typemap(jni) gp_Mat, const gp_Mat& "jdoubleArray"
385 %typemap(jtype) gp_Mat, const gp_Mat& "double[]"
386 %typemap(jstype) gp_Mat, const gp_Mat& "double[]"
388 %typemap(in) gp_Mat, const gp_Mat&
390 if(JCALL1(GetArrayLength, jenv, $input)!=9)
391 SWIG_JavaThrowException(jenv, SWIG_JavaIllegalArgumentException, "array length must be 9");
392 jdouble * naxe=JCALL2(GetDoubleArrayElements, jenv, $input, NULL);
393 $1=new gp_Mat(naxe[0],naxe[1],naxe[2],naxe[3],naxe[4],naxe[5],naxe[6],naxe[7],naxe[8]);
396 %typemap(freearg) gp_Mat, const gp_Mat&
401 %typemap(javain) gp_Mat, const gp_Mat& "$javainput"
402 %typemap(javaout) gp_Mat, const gp_Mat&
408 jdoubleArray MatToDoubleArray(JNIEnv* jenv, const gp_Mat & mat)
410 jdouble nativeArray[]={mat.Value(1,1), mat.Value(1,2), mat.Value(1,3),
411 mat.Value(2,1), mat.Value(2,2), mat.Value(2,3),
412 mat.Value(3,1), mat.Value(3,2), mat.Value(3,3)};
413 jdoubleArray toReturn=jenv->NewDoubleArray(9);
414 jenv->SetDoubleArrayRegion(toReturn, 0, 9, nativeArray);
419 %typemap(out) gp_Mat, const gp_Mat&
421 $result=MatToDoubleArray(jenv, $1);