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
19 * (C) Copyright 2009, by EADS France
23 #include <TopoDS_CompSolid.hxx>
24 #include <TopoDS_Solid.hxx>
25 #include <TopoDS_Shell.hxx>
26 #include <TopoDS_Compound.hxx>
27 #include <TopoDS_Wire.hxx>
28 #include <TopoDS_Iterator.hxx>
29 #include <TopoDS_Builder.hxx>
35 // Ensure that the Java class will always be the good one, so we can use
36 // instanceof operator.
37 // Problem: Returning a shape require 2 initialisation (the TopoDS_Shape
38 // and after the real TopoDS_XXXXX. It may reduce performance comparing
41 %typemap(out) TopoDS_Shape
49 TopoDS_Shape * tsp=new TopoDS_Shape();
50 tsp->TShape($1.TShape());
51 tsp->Location($1.Location());
52 tsp->Orientation($1.Orientation());
57 %typemap(out) const TopoDS_Shape &, const TopoDS_Compound &
65 $1_basetype * tsp=new $1_basetype();
66 tsp->TShape($1->TShape());
67 tsp->Location($1->Location());
68 tsp->Orientation($1->Orientation());
73 %typemap(javaout) TopoDS_Shape*, TopoDS_Shape, const TopoDS_Shape&, const TopoDS_Compound &
76 return ($javaclassname)TopoDS_Shape.create(cPtr);
79 %typemap(javacode) TopoDS_Shape
81 private long myTShape;
82 protected static TopoDS_Shape downcast(TopoDS_Shape in)
84 TopoDS_Shape toReturn = create(getCPtr(in));
89 protected static TopoDS_Shape create(long in)
93 //second argument is not use in swig
94 TopAbs_ShapeEnum type = TopAbs_ShapeEnum.swigToEnum(OccJavaJNI.TopoDS_Shape_shapeType(in, null));
95 return create(in, type);
98 protected static TopoDS_Shape create(long in, TopAbs_ShapeEnum type)
100 TopoDS_Shape toReturn=null;
106 toReturn=new TopoDS_Compound(in, true);
109 toReturn=new TopoDS_CompSolid(in, true);
112 toReturn=new TopoDS_Solid(in, true);
115 toReturn=new TopoDS_Shell(in, true);
118 toReturn=new TopoDS_Face(in, true);
121 toReturn=new TopoDS_Wire(in, true);
124 toReturn=new TopoDS_Edge(in, true);
127 toReturn=new TopoDS_Vertex(in, true);
130 toReturn.myTShape=toReturn.getTShape();
133 public boolean isSame(TopoDS_Shape s)
136 myTShape=getTShape();
139 s.myTShape=s.getTShape();
141 if(myTShape==s.myTShape)
143 return nativeIsSame(s);
146 return nativeIsSame(s);
150 * Alias on the isSame method for an easy use of this class in java
153 public boolean equals(Object o)
155 if (o instanceof TopoDS_Shape)
157 return isSame((TopoDS_Shape)o);
162 public int hashCode()
164 return hashCode(Integer.MAX_VALUE);
167 protected static TopoDS_Shape[] cArrayWrap(long[] ptrs)
169 TopoDS_Shape[] toReturn = new TopoDS_Shape[ptrs.length/2];
172 for (int i=0, j=0; i<toReturn.length; i++)
175 type = (int)ptrs[j++];
176 toReturn[i] = create(ptr, TopAbs_ShapeEnum.swigToEnum(type));
181 protected static long[] cArrayUnwrap(TopoDS_Shape[] arrayWrapper)
183 long[] cArray = new long[arrayWrapper.length];
184 for (int i=0; i<arrayWrapper.length; i++)
185 cArray[i] = TopoDS_Shape.getCPtr(arrayWrapper[i]);
190 // Note that TopoDS_Shape is no longer abstract (it was in libOccJava)
195 %rename(shapeType) ShapeType;
196 %rename(nativeIsSame) IsSame;
197 %rename(orientation) Orientation;
198 %rename(reverse) Reverse;
199 %rename(reversed) Reversed;
200 %rename(hashCode) HashCode;
201 TopAbs_ShapeEnum ShapeType();
202 Standard_Boolean IsSame(const TopoDS_Shape& other) const;
203 TopAbs_Orientation Orientation() const;
205 TopoDS_Shape Reversed() const;
206 Standard_Integer HashCode(const Standard_Integer Upper) const;
207 Standard_Boolean Free() const;
208 void Free(const Standard_Boolean F) ;
214 //This will be used to speedup the equal operator as in libOccJava
217 return (jlong)&*self->TShape();
221 class TopoDS_Compound: public TopoDS_Shape
225 class TopoDS_CompSolid: public TopoDS_Shape
229 class TopoDS_Solid: public TopoDS_Shape
233 class TopoDS_Shell: public TopoDS_Shape
237 class TopoDS_Face: public TopoDS_Shape
241 class TopoDS_Wire: public TopoDS_Shape
245 class TopoDS_Edge: public TopoDS_Shape
249 class TopoDS_Vertex: public TopoDS_Shape
253 class TopoDS_Iterator
255 %rename(initialize) Initialize;
258 %rename(value) Value;
261 TopoDS_Iterator(const TopoDS_Shape& S,
262 const Standard_Boolean cumOri = Standard_True,
263 const Standard_Boolean cumLoc = Standard_True);
264 void Initialize(const TopoDS_Shape& S,
265 const Standard_Boolean cumOri = Standard_True,
266 const Standard_Boolean cumLoc = Standard_True) ;
267 Standard_Boolean More() const;
269 const TopoDS_Shape& Value() const;
274 %rename(makeWire) MakeWire;
275 %rename(makeCompound) MakeCompound;
277 %rename(remove) Remove;
281 void MakeWire(TopoDS_Wire& W) const;
282 void MakeCompound(TopoDS_Compound& C) const;
283 void Add(TopoDS_Shape& S,const TopoDS_Shape& C) const;
284 void Remove(TopoDS_Shape& S,const TopoDS_Shape& C) const;