]> gerrit.simantics Code Review - simantics/3d.git/blob - org.jcae.opencascade/src/OccJava.i
Fix enabled state of wall thickness
[simantics/3d.git] / org.jcae.opencascade / src / OccJava.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  * (C) Copyright 2008, 2009, by EADS France
20  */
21
22 %module OccJava
23
24 %{
25 #ifdef HAVE_CONFIG_H
26 //config.h generated by autotools from config.h.in (see an example in Opencascade).
27 #include "config.h"
28 #endif
29 #include <Adaptor3d_Curve.hxx>
30 #include <TopExp.hxx>
31 #include <Poly_Triangulation.hxx>
32 %}
33
34 // Handle enums with Java enums
35 %javaconst(1);
36 %include "enums.swg"
37
38 // Handle C arrays as Java arrays
39 %include "arrays_java.i";
40 %apply double[] {double *};
41 %apply double[] {double &};
42
43 // load the native library
44 %pragma(java) jniclasscode=%{
45         static
46         {
47             System.loadLibrary("TKERNEL");
48                 System.loadLibrary("TKMATH");
49                 System.loadLibrary("TKG2D");
50                 System.loadLibrary("TKG3D");            
51                 System.loadLibrary("TKGEOMBASE");
52                 System.loadLibrary("TKBREP");
53                 System.loadLibrary("TKGEOMALGO");       
54                 System.loadLibrary("TKTOPALGO");
55                 System.loadLibrary("TKMESH");
56                 
57                 System.loadLibrary("TKPRIM");
58                 System.loadLibrary("TKSHHEALING");      
59                 System.loadLibrary("TKBO");             
60                 
61                 System.loadLibrary("TKBOOL");
62                 System.loadLibrary("TKFILLET");
63                 System.loadLibrary("TKOFFSET"); 
64                 
65                 System.loadLibrary("TKXSBASE");
66                 System.loadLibrary("TKIGES");
67                 System.loadLibrary("TKSTEPBASE");
68                 System.loadLibrary("TKSTEPATTR");
69                 System.loadLibrary("TKSTEP209");
70                 System.loadLibrary("TKSTEP");
71
72                 System.loadLibrary("OccJava");
73                 String mmg_opt= System.getenv("MMGT_OPT");
74                 if(mmg_opt != null && !"0".equals(mmg_opt))
75                         throw new RuntimeException("The MMGT_OPT environment variable must be set to 0 before using occjava.");
76         }
77 %}
78
79 %include "Standard.i"
80 %include "gp.i"
81 %include "TCol.i"
82 %include "TopAbs.i"
83 %include "TopoDS.i"
84 %include "GeomAbs.i"
85 %include "TopTools.i"
86 %include "BRep.i"
87 %include "GeomLProp_SLProps.i"
88 %include "BRepTools.i"
89 %include "BRepBuilderAPI.i"
90 %include "BRepOffsetAPI.i"
91 %include "BRepPrimAPI.i"
92 %include "BRepAlgoAPI.i"
93 %include "Poly.i"
94 %include "Geom.i"
95 %include "BRepLib.i"
96 %include "BRepFilletAPI.i"
97 %include "BRepCheck.i"
98 %include "ShapeBuild.i"
99 %include "XSControl.i"
100 %include "ShapeFix.i"
101 %include "APIHeaderSection_MakeHeader.i"
102 // This one require Opencascade 6.2
103 %include "ShapeUpgrade.i"
104 //Jens Schmidt, req. f. Thesis
105 %include "GeomAPI.i"
106 %include "GC.i"
107
108
109 %typemap(javacode) TopExp
110 %{
111         public static TopoDS_Vertex[] vertices(TopoDS_Edge edge)
112         {
113                 TopoDS_Vertex first=new TopoDS_Vertex();
114                 TopoDS_Vertex second=new TopoDS_Vertex();
115                 vertices(edge, first, second);
116                 return new TopoDS_Vertex[]{first, second};
117         }
118 %}
119
120 class TopLoc_Location
121 {
122         %rename(isIdentity) IsIdentity;
123         %rename(transformation) Transformation;
124         public:
125         Standard_Boolean IsIdentity();
126         const gp_Trsf& Transformation();
127 };
128
129 class TopExp
130 {
131         public:
132         %rename(vertices) Vertices;
133         static void Vertices(const TopoDS_Edge& E,TopoDS_Vertex& Vfirst,TopoDS_Vertex& Vlast,const Standard_Boolean CumOri = Standard_False) ;
134 };
135
136 /**
137  * TopExp_Explorer
138  */
139 %{#include "TopExp_Explorer.hxx"%}
140 class TopExp_Explorer
141 {
142         public:
143         TopExp_Explorer();
144         TopExp_Explorer(const TopoDS_Shape& S,const TopAbs_ShapeEnum ToFind,
145                 const TopAbs_ShapeEnum ToAvoid = TopAbs_SHAPE);
146         %rename(init) Init;
147         %rename(more) More;
148         %rename(next) Next;
149         %rename(current) Current;
150         void Init(const TopoDS_Shape& S, const TopAbs_ShapeEnum ToFind, 
151                 const TopAbs_ShapeEnum ToAvoid = TopAbs_SHAPE) ;
152         Standard_Boolean More() const;
153         void Next() ;
154         const TopoDS_Shape & Current();
155 };
156
157 /**
158  * Bnd_Box
159  */
160 %{#include "Bnd_Box.hxx"%}
161 %typemap(javacode) Bnd_Box
162 %{
163     /**
164      * Return the array { Xmin, Ymin, Zmin, Xmax, Ymax, Zmax }
165      */ 
166         public double[] get()
167         {
168                 double[] toReturn=new double[6];
169                 get(toReturn);
170                 return toReturn;
171         }
172 %}
173
174 class Bnd_Box
175 {
176         %rename(isVoid) IsVoid;
177         public:
178         Bnd_Box();
179         Standard_Boolean IsVoid() const;
180 };
181
182 %extend Bnd_Box
183 {
184         void get(double box[6])
185         {
186                 if(!self->IsVoid())
187                         self->Get(box[0], box[1], box[2], box[3], box[4], box[5]);
188         }
189 };
190
191 /**
192  * BRepBndLib
193  */
194 %{#include "BRepBndLib.hxx"%}
195 class BRepBndLib
196 {
197         public:
198         %rename(add) Add;
199         static void Add(const TopoDS_Shape& shape,Bnd_Box& bndBox);
200 };
201
202 /**
203  * Adaptor2d_Curve2d
204  */
205 %{#include "Adaptor2d_Curve2d.hxx"%}
206
207 class Adaptor2d_Curve2d
208 {               
209         Adaptor2d_Curve2d()=0;
210         public:
211         %rename(value) Value;
212         virtual gp_Pnt2d Value(const Standard_Real U) const;
213 };
214
215 /**
216  * Geom2dAdaptor_Curve
217  */
218 %{#include "Geom2dAdaptor_Curve.hxx"%}
219 class Geom2dAdaptor_Curve: public Adaptor2d_Curve2d
220 {
221         %rename(load) Load;
222         public:
223         Geom2dAdaptor_Curve();
224         Geom2dAdaptor_Curve(const Handle_Geom2d_Curve & C);
225         Geom2dAdaptor_Curve(const Handle_Geom2d_Curve & C,const Standard_Real UFirst,const Standard_Real ULast);
226         void Load(const Handle_Geom2d_Curve & C) ;
227         void Load(const Handle_Geom2d_Curve & C,const Standard_Real UFirst,const Standard_Real ULast) ;
228 };
229
230 /**
231  * Adaptor3d_Curve
232  */
233 %{#include "Adaptor3d_Curve.hxx"%}
234
235 class Adaptor3d_Curve
236 {               
237         Adaptor3d_Curve()=0;
238         public:
239         %rename(value) Value;
240         const gp_Pnt Value(const Standard_Real U) const;
241 };
242
243 //extends the Adaptor3d_Curve class to reduce the JNI overhead when
244 //calling a lot of Adaptor3d_Curve.Value
245 %extend Adaptor3d_Curve
246 {
247         public:
248         void arrayValues(int size, double u[])
249         {
250                 for (int i = 0; i < size; i++)
251                 {
252                         gp_Pnt gp=self->Value(u[3*i]);
253                         u[3*i]   = gp.X();
254                         u[3*i+1] = gp.Y();
255                         u[3*i+2] = gp.Z();
256                 }       
257         }
258 };
259
260 /**
261  * GeomAdaptor_Curve
262  */
263 %{#include "GeomAdaptor_Curve.hxx"%}
264
265 class GeomAdaptor_Curve: public Adaptor3d_Curve
266 {
267         %rename(load) Load;
268         public:
269         GeomAdaptor_Curve();
270         GeomAdaptor_Curve(const Handle_Geom_Curve & C);
271         GeomAdaptor_Curve(const Handle_Geom_Curve & C,
272                 const Standard_Real UFirst,const Standard_Real ULast);
273         void Load(const Handle_Geom_Curve & C) ;
274         void Load(const Handle_Geom_Curve & C,
275                 const Standard_Real UFirst,const Standard_Real ULast) ;
276
277 };
278
279
280 /**
281  * GProp_GProps
282  */
283  %{#include "GProp_GProps.hxx"%}
284 // class GProp_GProps
285 // {
286 //       public:
287 //       %rename(mass) Mass;
288 //       GProp_GProps();
289 //       Standard_Real Mass() const;
290 //};
291 class GProp_GProps
292 {
293         public:
294         %rename(mass) Mass;
295         %rename(centreOfMass) CentreOfMass;
296         %rename(matrixOfInertia) MatrixOfInertia;
297         GProp_GProps();
298         Standard_Real Mass() const;
299         gp_Pnt CentreOfMass() const;
300         gp_Mat MatrixOfInertia() const;
301 };
302
303 %{#include "GProp_PGProps.hxx"%}
304 class GProp_PGProps : public GProp_GProps
305 {       
306 };
307 %{#include "GProp_CelGProps.hxx"%}
308 class GProp_CelGProps: public GProp_GProps
309 {       
310 };
311
312 %{#include "GProp_SelGProps.hxx"%}
313 class GProp_SelGProps: public GProp_GProps
314 {       
315 };
316
317 %{#include "GProp_VelGProps.hxx"%}
318 class GProp_VelGProps: public GProp_GProps
319 {
320 };
321
322
323 //%{#include "GProp_CGProps.gxx"%}
324 //class GProp_CGProps: public GProp_GProps
325 //{     
326 //};
327
328 //%{#include "GProp_SGProps.gxx"%}
329 //class GProp_SGProps: public GProp_GProps
330 //{     
331 //};
332
333 //%{#include "GProp_VGProps.gxx"%}
334 //class GProp_VGProps
335 //{
336 //};
337
338  
339 /**
340  * BRepGProp
341  */
342 %{#include "BRepGProp.hxx"%}
343 class BRepGProp
344 {
345         public:
346         %rename(linearProperties) LinearProperties;
347         %rename(surfaceProperties) SurfaceProperties;
348         %rename(volumeProperties) VolumeProperties;
349         %rename(volumePropertiesGK) VolumePropertiesGK;
350         static void LinearProperties(const TopoDS_Shape& shape, GProp_GProps& properties);
351         static void VolumeProperties(const TopoDS_Shape& shape, GProp_GProps& properties, const Standard_Boolean onlyClosed = Standard_False) ;
352         static Standard_Real VolumeProperties(const TopoDS_Shape& shape, GProp_GProps& properties, const Standard_Real Eps, const Standard_Boolean onlyClosed = Standard_False) ;
353         static void SurfaceProperties(const TopoDS_Shape& shape, GProp_GProps& properties) ;
354         static Standard_Real SurfaceProperties(const TopoDS_Shape& shape, GProp_GProps& properties, const Standard_Real Eps) ;
355                 static Standard_Real VolumePropertiesGK(const TopoDS_Shape& shape, GProp_GProps& properties, const Standard_Real Eps, const Standard_Boolean onlyClosed = Standard_False, const Standard_Boolean isUseSpan = Standard_False, const Standard_Boolean cgFlag = Standard_False, const Standard_Boolean iFlag = Standard_False) ;
356 };
357
358 /**
359  *
360  */
361 %rename(VOID) IFSelect_RetVoid;
362 %rename(DONE) IFSelect_RetDone;
363 %rename(ERROR) IFSelect_RetError;
364 %rename(FAIL) IFSelect_RetFail;
365 %rename(STOP) IFSelect_RetStop;
366 enum IFSelect_ReturnStatus {
367  IFSelect_RetVoid,
368  IFSelect_RetDone,
369  IFSelect_RetError,
370  IFSelect_RetFail,
371  IFSelect_RetStop
372 };
373  
374 %{#include <ShapeAnalysis_FreeBounds.hxx>%}
375 class ShapeAnalysis_FreeBounds
376 {
377         %rename(getClosedWires) GetClosedWires;
378         %rename(getOpenWires) GetOpenWires;
379         public:
380         ShapeAnalysis_FreeBounds(const TopoDS_Shape& shape,
381                 const Standard_Boolean splitclosed = Standard_False,
382                 const Standard_Boolean splitopen = Standard_True);
383         const TopoDS_Compound& GetClosedWires() const;
384         const TopoDS_Compound& GetOpenWires() const;
385 };
386
387 %{#include <GCPnts_UniformDeflection.hxx>%}
388 class GCPnts_UniformDeflection
389 {
390         %rename(initialize) Initialize;
391         %rename(nbPoints) NbPoints;
392         %rename(parameter) Parameter;
393         public:
394         GCPnts_UniformDeflection();
395         void Initialize(Adaptor3d_Curve& C,const Standard_Real Deflection,
396                 const Standard_Real U1,const Standard_Real U2,
397                 const Standard_Boolean WithControl = Standard_True) ;
398         Standard_Integer NbPoints() const;
399         Standard_Real Parameter(const Standard_Integer Index) const;
400 };
401
402 %{#include <BRepMesh_DiscretRoot.hxx>%}
403 class BRepMesh_DiscretRoot
404 {
405         //%rename(setDeflection) SetDeflection;
406         //%rename(setAngle) SetAngle;
407         //%rename(deflection) Deflection;
408         //%rename(angle) Angle;
409         %rename(perform) Perform;
410         
411         protected:
412         BRepMesh_DiscretRoot();
413         public:
414         //void SetDeflection(const Standard_Real D) ;
415         //void SetAngle(const Standard_Real Ang) ;
416         //Standard_Real Deflection() const;
417         //Standard_Real Angle() const;
418         virtual void Perform();
419 };
420
421 %{#include <BRepMesh_IncrementalMesh.hxx>%}
422 class BRepMesh_IncrementalMesh : public BRepMesh_DiscretRoot
423 {
424         %rename(perform) Perform;
425         %rename(isModified) IsModified;
426         
427         public:
428         BRepMesh_IncrementalMesh();
429         BRepMesh_IncrementalMesh(const TopoDS_Shape& S,const Standard_Real D,
430                 const Standard_Boolean Relatif = Standard_False,
431                 const Standard_Real Ang = 0.5);
432                 
433         void Perform();
434         Standard_Boolean IsModified() const;
435 };
436
437 %{#include <GeomAPI_ProjectPointOnSurf.hxx>%}
438
439 %typemap(javacode) GeomAPI_ProjectPointOnSurf
440 %{
441         public void lowerDistanceParameters(double[] uv)
442         {
443                 double[] d2=new double[1];
444                 lowerDistanceParameters(uv, d2);
445                 uv[1]=d2[0];
446         }
447 %}
448
449 class GeomAPI_ProjectPointOnSurf
450 {
451         %rename(init) Init;
452         %rename(nbPoints) NbPoints;
453         %rename(lowerDistanceParameters) LowerDistanceParameters;
454         %rename(lowerDistance) LowerDistance;
455         %rename(point) Point;
456         %rename(parameters) Parameters;
457         %rename(nearestPoint) NearestPoint;
458         public:
459         GeomAPI_ProjectPointOnSurf(const gp_Pnt& P,
460                 const Handle_Geom_Surface & Surface);
461         void Init(const gp_Pnt& P,const Handle_Geom_Surface & surface);
462         Standard_Integer NbPoints() const;      
463         Standard_Real LowerDistance() const;
464         const gp_Pnt Point(const Standard_Integer Index) const; 
465         void LowerDistanceParameters(Standard_Real& U,Standard_Real& V) const;
466         void Parameters(const Standard_Integer Index,Standard_Real& U,Standard_Real& V) const;
467         gp_Pnt NearestPoint() const;
468 };
469
470 /**
471  * BRepAlgo
472  */
473 %{#include <BRepAlgo.hxx>%}
474 class BRepAlgo
475 {
476         %rename(isValid) IsValid;
477         %rename(isTopologicallyValid) IsTopologicallyValid;
478         public: 
479         static Standard_Boolean IsValid(const TopoDS_Shape& S);
480         static Standard_Boolean IsTopologicallyValid(const TopoDS_Shape& S);
481 };