]> gerrit.simantics Code Review - simantics/3d.git/blob - org.jcae.opencascade/src/BRep.i
Remove misplaced call to GLContext.makeCurrent()
[simantics/3d.git] / org.jcae.opencascade / src / BRep.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 #include <BRep_Tool.hxx>
23 #include <Geom_Curve.hxx>
24 #include <BRep_Builder.hxx>
25 #include <TopoDS_Builder.hxx>
26 %}
27
28 %typemap(javacode) BRep_Tool
29 %{
30         public static double[] range(TopoDS_Edge edge)
31         {
32                 double[] toReturn=new double[2];
33                 range(edge, toReturn);
34                 return toReturn;
35         }
36
37         public static Geom2d_Curve curveOnSurface(TopoDS_Edge e, TopoDS_Face f, double[] range)
38         {
39                 double[] d2=new double[1];
40                 Geom2d_Curve toReturn=curveOnSurface(e, f, range, d2);
41                 range[1]=d2[0];
42                 return toReturn;
43         }
44
45         public static Geom_Curve curve(TopoDS_Edge e, double[] range)
46         {
47                 double[] d2=new double[1];
48                 Geom_Curve toReturn=curve(e, range, d2);
49                 range[1]=d2[0];
50                 return toReturn;
51         }
52 %}
53
54 %catches(Standard_NoSuchObject) BRep_Tool::Parameters;
55
56 class BRep_Tool
57 {
58         %rename(pnt) Pnt;
59         %rename(parameters) Parameters;
60         %rename(parameter) Parameter;
61         %rename(degenerated) Degenerated;
62         %rename(hasContinuity) HasContinuity;
63         %rename(continuity) Continuity;
64         %rename(tolerance) Tolerance;
65         %rename(curve) Curve;
66         %rename(surface) Surface;
67         %rename(curveOnSurface) CurveOnSurface;
68         public:
69         static const gp_Pnt Pnt(const TopoDS_Vertex& V) ;
70         static gp_Pnt2d Parameters(const TopoDS_Vertex& V,const TopoDS_Face& F) ;
71         static Standard_Real Parameter(const TopoDS_Vertex& V,const TopoDS_Edge& E) ;
72         static Standard_Boolean Degenerated(const TopoDS_Edge& E) ;
73         static Standard_Boolean HasContinuity(const TopoDS_Edge& E,const TopoDS_Face& F1,const TopoDS_Face& F2) ;
74         static GeomAbs_Shape Continuity(const TopoDS_Edge& E,const TopoDS_Face& F1,const TopoDS_Face& F2) ;
75         static Standard_Real Tolerance(const TopoDS_Face& F) ;
76         static Standard_Real Tolerance(const TopoDS_Edge& E) ;
77         static Standard_Real Tolerance(const TopoDS_Vertex& V);
78         
79         /*static const Handle_Geom_Curve& Curve(const TopoDS_Edge& E,
80                 Standard_Real& First,Standard_Real& Last) ;
81         static const Handle_Geom_Surface& Surface(const TopoDS_Face& F) ;
82         static const Handle_Geom2d_Curve& CurveOnSurface(const TopoDS_Edge& E,
83                 const TopoDS_Face& F,Standard_Real& First,Standard_Real& Last) ;*/
84 };
85
86 // Publish methods which return pointer instead of Handle. We do not need
87 // Handle because Java do the memory managment for us.
88 %extend BRep_Tool
89 {
90         static Poly_Triangulation * triangulation(const TopoDS_Face& F,TopLoc_Location& L)
91         {
92                 Handle_Poly_Triangulation hgc=BRep_Tool::Triangulation(F,L);
93                 if(hgc.IsNull())
94                         return NULL;
95                 else
96                     // FIXME: 7.3.0
97                         //return (Poly_Triangulation*)(Standard_Transient*)hgc;
98                         return (Poly_Triangulation*)(Standard_Transient*)(hgc->This());
99         }
100
101         static void range(const TopoDS_Edge& E, double range[2])
102         {
103                 BRep_Tool::Range(E, range[0], range[1]);
104         }
105         
106         // new Handle is a little memory leak as this handle is never deleted
107         static Handle_Geom_Curve * curve(const TopoDS_Edge& E,
108                 Standard_Real& First,Standard_Real& Last)
109         {
110                 Handle_Geom_Curve * hgc=new Handle_Geom_Curve(BRep_Tool::Curve(E, First, Last));
111                 if(hgc->IsNull())
112                         return NULL;
113                 else
114                         return hgc;
115         }
116         
117         static Handle_Geom_Surface * surface(const TopoDS_Face& F)
118         {
119                 Handle_Geom_Surface * hgc=new Handle_Geom_Surface(BRep_Tool::Surface(F));
120                 if(hgc->IsNull())
121                         return NULL;
122                 else
123                         return hgc;
124         }
125         
126         static Handle_Geom2d_Curve * curveOnSurface(const TopoDS_Edge& E,
127                 const TopoDS_Face& F,Standard_Real& First,Standard_Real& Last)
128         {
129                 Handle_Geom2d_Curve * hgc=new Handle_Geom2d_Curve(BRep_Tool::CurveOnSurface(E, F, First, Last));
130                 if(hgc->IsNull())
131                         return NULL;
132                 else
133                         return hgc;
134         }
135 };
136
137 class BRep_Builder: public TopoDS_Builder
138 {
139         %rename(updateVertex) UpdateVertex;
140         public:
141         BRep_Builder();
142         void UpdateVertex(const TopoDS_Vertex& vertex, const Standard_Real u, const Standard_Real v, const TopoDS_Face& face, const Standard_Real tolerance) const;
143         void UpdateVertex(const TopoDS_Vertex& vertex, const Standard_Real tolerance) const;
144 };
145