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 2007, by EADS France
21 //A workaround for charset encoding problems
22 %typemap(jni) jbyte[] "jbyteArray"
23 %typemap(jtype) jbyte[] "byte[]"
24 %typemap(jstype) jbyte[] "byte[]"
27 int length = JCALL1(GetArrayLength, jenv, $input);
28 jbyte * name = new jbyte[length+1];
29 JCALL4(GetByteArrayRegion, jenv, $input, 0, length, name);
33 %typemap(javain) jbyte[] "$javainput"
40 #include <STEPControl_Reader.hxx>
41 #include <IGESControl_Reader.hxx>
42 #include <XSControl_WorkSession.hxx>
43 #include <XSControl_TransferReader.hxx>
44 #include <StepRepr_RepresentationItem.hxx>
45 #include <TCollection_HAsciiString.hxx>
46 #include <IGESData_IGESEntity.hxx>
47 #include <TransferBRep.hxx>
48 #include <Transfer_Binder.hxx>
49 #include <Transfer_TransientProcess.hxx>
50 #include <Interface_InterfaceModel.hxx>
53 #include <Interface_Static.hxx>
56 class XSControl_Reader
58 %javamethodmodifiers ReadFile(const Standard_CString filename)"
60 * @deprecated May segfault if path name include none-ASCII caracters. Use
61 * readFile(stringPath.getBytes()) instead.
66 %rename(readFile) ReadFile;
67 %rename(transferRoots) TransferRoots;
68 %rename(clearShapes) ClearShapes;
69 %rename(nbRootsForTransfer) NbRootsForTransfer;
70 %rename(oneShape) OneShape;
72 IFSelect_ReturnStatus ReadFile(const Standard_CString filename);
73 //IFSelect_ReturnStatus ReadFile(jbyte filename[]);
74 Standard_Integer TransferRoots() ;
76 Standard_Integer NbRootsForTransfer();
77 TopoDS_Shape OneShape() const;
81 %extend XSControl_Reader
83 //A workaround for charset encoding problems
84 IFSelect_ReturnStatus readFile(jbyte filename[])
86 return self->ReadFile((char*)filename);
92 %extend XSControl_Reader
97 //return Interface_Static::SetCVal("read.scale.unit","M");
98 return Interface_Static::SetCVal("xstep.cascade.unit","M");
101 bool setReadUnitMM() {
102 //return Interface_Static::SetCVal("read.scale.unit","MM");
103 return Interface_Static::SetCVal("xstep.cascade.unit","MM");
107 class STEPControl_Reader: public XSControl_Reader
110 STEPControl_Reader();
113 %extend STEPControl_Reader
115 //dirty quick implementation of label step reading
116 //find how to generalize this to IGES
117 const char * getLabel(TopoDS_Shape * theShape)
119 const Handle(XSControl_WorkSession)& theSession = self->WS();
120 const Handle(XSControl_TransferReader)& aReader = theSession->TransferReader();
121 Handle(Standard_Transient) anEntity = aReader->EntityFromShapeResult(*theShape, 1);
122 if (anEntity.IsNull()) {
124 anEntity = aReader->EntityFromShapeResult (*theShape,-1);
127 if (anEntity.IsNull()) {
129 anEntity = aReader->EntityFromShapeResult (*theShape,4);
132 if (anEntity.IsNull()) {
133 cout<<"Warning: XSInterface_STEPReader::ReadAttributes() entity not found"<<endl;
138 Handle(StepRepr_RepresentationItem) aReprItem;
139 aReprItem = Handle(StepRepr_RepresentationItem)::DownCast(anEntity);
141 if (aReprItem.IsNull()) {
142 cout<<"Error: STEPReader::ReadAttributes(): StepRepr_RepresentationItem Is NULL"<<endl;
146 return aReprItem->Name()->ToCString();
151 class IGESControl_Reader: public XSControl_Reader
154 IGESControl_Reader();
157 %extend IGESControl_Reader
159 //dirty quick implementation of label iges reading
160 const char * getLabel(TopoDS_Shape theShape)
162 const Handle(XSControl_WorkSession)& theSession = self->WS();
163 const Handle(Interface_InterfaceModel)& theModel = theSession->Model();
164 const Handle(XSControl_TransferReader)& aReader = theSession->TransferReader();
165 const Handle(Transfer_TransientProcess)& tp = aReader->TransientProcess();
166 Standard_Integer nb = theModel->NbEntities();
167 for(Standard_Integer i=1; i<=nb; i++)
169 Handle(IGESData_IGESEntity) ent = Handle(IGESData_IGESEntity)::DownCast(theModel->Value(i));
174 Handle(Transfer_Binder) binder = tp->Find(ent);
178 TopoDS_Shape oneShape = TransferBRep::ShapeResult(binder);
179 if (oneShape.IsNull())
181 if (oneShape.IsEqual(theShape))
184 return ent->NameValue()->String().ToCString();
192 //get shape for label
193 TopoDS_Shape getShape(char* shapeName)
195 const TCollection_AsciiString ascShapeName(shapeName);
196 const Handle(XSControl_WorkSession)& theSession = self->WS();
197 const Handle(Interface_InterfaceModel)& theModel = theSession->Model();
198 const Handle(XSControl_TransferReader)& aReader = theSession->TransferReader();
199 const Handle(Transfer_TransientProcess)& tp = aReader->TransientProcess();
200 Standard_Integer nb = theModel->NbEntities();
201 TopoDS_Shape retShape;
202 for(Standard_Integer i=1; i<=nb; i++)
204 Handle(IGESData_IGESEntity) ent = Handle(IGESData_IGESEntity)::DownCast(theModel->Value(i));
208 Handle(Transfer_Binder) binder = tp->Find(ent);
212 TopoDS_Shape oneShape = TransferBRep::ShapeResult(binder);
214 if (oneShape.IsNull())
217 if (ent->HasName() && ent->NameValue()->String().IsEqual(ascShapeName))
226 const Handle(XSControl_WorkSession)& theSession = self->WS();
227 const Handle(Interface_InterfaceModel)& theModel = theSession->Model();
228 Standard_Integer nb = theModel->NbEntities();
229 for(Standard_Integer i=1; i<=nb; i++)
231 Handle(IGESData_IGESEntity) ent = Handle(IGESData_IGESEntity)::DownCast(theModel->Value(i));
232 if (ent.IsNull()) continue;
235 std::cout << ent->NameValue()->String().ToCString() << std::endl;
244 * STEPControl_Writer aWriter = new STEPControl_Writer()
245 * aWriter.transfer(shape, STEPControl_StepModelType.AsIs)
246 * aWriter.write("foo.stp")
249 //#include <APIHeaderSection_MakeHeader.hxx>
250 #include <STEPControl_Writer.hxx>
252 class STEPControl_Writer
254 %rename(write) Write;
255 %rename(transfer) Transfer;
256 %rename(model) Model;
258 STEPControl_Writer();
259 IFSelect_ReturnStatus Write(const Standard_CString filename);
260 IFSelect_ReturnStatus Transfer(TopoDS_Shape theShape, STEPControl_StepModelType mode);
261 // FIXME: 7.3.0 Handle_StepData_StepModel cannot be resolved
262 //Handle_StepData_StepModel Model(const Standard_Boolean newone);
263 //Handle(StepData_StepModel) Model(const Standard_Boolean newone);
267 %rename(AsIs) STEPControl_AsIs;
268 %rename(ManifoldSolidBrep) STEPControl_ManifoldSolidBrep;
269 %rename(BrepWithVoids) STEPControl_BrepWithVoids;
270 %rename(FacetedBrep) STEPControl_FacetedBrep;
271 %rename(FacetedBrepAndBrepWithVoids) STEPControl_FacetedBrepAndBrepWithVoids;
272 %rename(ShellBasedSurfaceModel) STEPControl_ShellBasedSurfaceModel;
273 %rename(GeometricCurveSet) STEPControl_GeometricCurveSet;
274 %rename(Hybrid) STEPControl_Hybrid;
275 enum STEPControl_StepModelType {
277 STEPControl_ManifoldSolidBrep,
278 STEPControl_BrepWithVoids,
279 STEPControl_FacetedBrep,
280 STEPControl_FacetedBrepAndBrepWithVoids,
281 STEPControl_ShellBasedSurfaceModel,
282 STEPControl_GeometricCurveSet,
289 * new IGESControl_Controller().init()
290 * IGESControl_Writer aWriter = new IGESControl_Writer("MM", 0)
291 * aWriter.addShape(shape)
292 * aWriter.computeModel()
293 * aWriter.write("foo.igs")
296 #include <IGESControl_Writer.hxx>
298 class IGESControl_Writer
300 %rename(write) Write;
301 %rename(addShape) AddShape;
302 %rename(computeModel) ComputeModel;
304 IGESControl_Writer();
305 IGESControl_Writer(const Standard_CString unit, const Standard_Integer modecr = 0);
306 Standard_Boolean Write(const Standard_CString filename);
307 Standard_Boolean AddShape(const TopoDS_Shape& sh);
312 #include <IGESControl_Controller.hxx>
314 class IGESControl_Controller
318 IGESControl_Controller();