]> gerrit.simantics Code Review - simantics/3d.git/blob - org.jcae.opencascade/src/BRepTools.i
Merge "Allow property editing with just a single mouse click"
[simantics/3d.git] / org.jcae.opencascade / src / BRepTools.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 <BRepTools.hxx>
23 #include <BRepTools_ShapeSet.hxx>    
24 %}
25
26 // define another read method that match the one of libOccJava (the one below don't).
27 %typemap(javacode) BRepTools
28 %{
29         /**
30          * Read a shape from a file.
31          * This is an helper method. It do not exists in Opencascade.
32          * @param file the file to read
33          * @param builder the builder which will be used to create the shape (i.e. <code>new BRep_Builder()</code>).
34          */
35         public static TopoDS_Shape read(String file, BRep_Builder builder)
36         {
37                 TopoDS_Shape toReturn=new TopoDS_Shape();
38                 if(read(toReturn, file, builder))
39                         return TopoDS_Shape.downcast(toReturn);
40                 else
41                         return null;
42         }
43 %}
44
45 %typemap(javaimports) BRepTools "
46 /** Provides various utilities for BRep. */"
47
48 %typemap(javadestruct, methodname="delete", methodmodifiers="private synchronized") BRepTools {};
49
50 class BRepTools
51 {
52         %javamethodmodifiers Read(TopoDS_Shape& ,const Standard_CString, const BRep_Builder&) "
53         /**
54          * Reads a shape from a file.
55          * @param shape an empty shape created with <code>new TopoDS_Shape()</code>
56          * @param builder used to build the shape (i.e. <code>new BRep_Builder()</code>).
57          * @return false on IO or file format errors.
58          */
59         public";
60
61         //Hide the constructor to make this class entirely static.
62         BRepTools()=0;
63         public:
64         
65         %rename(read) Read;
66         static Standard_Boolean Read(TopoDS_Shape& shape,
67                 const Standard_CString file, const BRep_Builder& builder) ;
68         
69         %javamethodmodifiers Write(const TopoDS_Shape&, const Standard_CString)"
70         /**
71          * Write a shape to a file.
72          * @param shape the shape to write
73          * @param file the file where to write the shape
74          * @return false on IO error.
75          */
76         public";
77
78         %rename(write) Write;
79         static Standard_Boolean Write(const TopoDS_Shape& shape,
80                 const Standard_CString file);
81
82         static  void Write(const TopoDS_Shape& Sh,Standard_OStream& S) ;
83         %rename(clean) Clean;
84         static  void Clean(const TopoDS_Shape& S) ;
85 };
86
87 %extend BRepTools
88 {
89         //in the original version of this method opencascade suppose that the format of the stream is
90         //correct and don't do any verification. It cause segfault when the stream is wrong.
91         static Standard_Boolean read(TopoDS_Shape& shape, Standard_IStream& input, const BRep_Builder& builder)
92         {
93                 BRepTools_ShapeSet SS(builder);
94                 SS.Read(input);
95                 if(!SS.NbShapes()) return Standard_False;
96                 SS.Read(shape,input);
97                 return Standard_True;
98         }
99 }
100
101
102 /**
103  * BRepTools_WireExplorer
104  */
105 %{#include <BRepTools_WireExplorer.hxx>%}
106 class BRepTools_WireExplorer
107 {
108         %rename(init) Init;
109         %rename(more) More;
110         %rename(next) Next;
111         %rename(current) Current;
112         %rename(orientation) Orientation;
113         %rename(currentVertex) CurrentVertex;
114         %rename(clear) Clear;
115         public:
116         BRepTools_WireExplorer();
117         BRepTools_WireExplorer(const TopoDS_Wire& W);
118         BRepTools_WireExplorer(const TopoDS_Wire& W,const TopoDS_Face& F);
119         void Init(const TopoDS_Wire& W) ;
120         void Init(const TopoDS_Wire& W,const TopoDS_Face& F) ;
121         Standard_Boolean More() const;
122         void Next() ;
123         const TopoDS_Edge& Current() const;
124         TopAbs_Orientation Orientation() const;
125         const TopoDS_Vertex& CurrentVertex() const;
126         void Clear() ;
127 };
128
129 %{#include <BRepTools_Quilt.hxx>%}
130 class BRepTools_Quilt
131 {
132         %rename(bind) Bind;
133         %rename(add) Add;
134         %rename(isCopied) IsCopied;
135         %rename(copy) Copy;
136         %rename(shells) Shells;
137         public:
138         BRepTools_Quilt();
139         void Bind(const TopoDS_Edge& Eold,const TopoDS_Edge& Enew) ;
140         void Bind(const TopoDS_Vertex& Vold,const TopoDS_Vertex& Vnew) ;
141         void Add(const TopoDS_Shape& S) ;
142         Standard_Boolean IsCopied(const TopoDS_Shape& S) const;
143         const TopoDS_Shape& Copy(const TopoDS_Shape& S) const;
144         TopoDS_Shape Shells() const;
145 };