]> gerrit.simantics Code Review - simantics/3d.git/blob - org.jcae.opencascade/src/TopTools.i
Equipment/Component library customization
[simantics/3d.git] / org.jcae.opencascade / src / TopTools.i
1 /*
2  * Project Info:  http://jcae.sourceforge.net
3  * 
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)
7  * any later version.
8  *
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
12  * details.
13  *
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.
17  *
18  * (C) Copyright 2005, by EADS CRC
19  */
20
21
22 %typemap(jni) const TopTools_ListOfShape& "jlongArray"
23 %typemap(jtype) const TopTools_ListOfShape& "long[]"
24 %typemap(jstype) const TopTools_ListOfShape& "TopoDS_Shape[]"
25
26 %typemap(javain) const TopTools_ListOfShape& "TopoDS_Shape.cArrayUnwrap($javainput)"
27 %typemap(javaout) const TopTools_ListOfShape& 
28 {
29         return TopoDS_Shape.cArrayWrap($jnicall);
30 }
31 %typemap(in) const TopTools_ListOfShape& (jlong *jarr, jsize sz)
32 {
33         int i;
34         if (!$input)
35         {
36                 SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null array");
37                 return $null;
38         }
39         sz = JCALL1(GetArrayLength, jenv, $input);
40         jarr = JCALL2(GetLongArrayElements, jenv, $input, 0);
41         if (!jarr)
42         {
43                 return $null;
44         }
45         $1 = new TopTools_ListOfShape();
46         for (i=0; i<sz; i++)
47         {
48                 $1->Append(*(TopoDS_Shape*)jarr[i]);
49         }
50 }
51
52 %typemap(freearg) const TopTools_ListOfShape&
53 %{
54         delete $1;
55 %}
56
57 %{#include <TopTools_ListIteratorOfListOfShape.hxx>%}
58 %typemap(out) const TopTools_ListOfShape&
59 {
60         int j,n;
61         const TopTools_ListOfShape& l = *$1;
62         n = l.Extent();
63         jlong * as=(jlong*) malloc (sizeof(jlong) * n * 2);
64         TopTools_ListIteratorOfListOfShape it(l);
65         j=0;
66         while(it.More())
67         {
68                 const TopoDS_Shape & s=it.Value();
69                 TopoDS_Shape * tsp=new TopoDS_Shape();
70                 tsp->TShape(s.TShape());
71                 tsp->Location(s.Location());
72                 tsp->Orientation(s.Orientation());
73                 as[j++]=(jlong)tsp;
74                 as[j++]=s.ShapeType();
75                 it.Next();
76         }
77         jlongArray jarray=JCALL1(NewLongArray, jenv, n*2);
78         JCALL4(SetLongArrayRegion, jenv, jarray, 0, n*2, as);
79         free(as);
80         $result=jarray;
81 }