0024530: TKMesh - remove unused package IntPoly
[occt.git] / src / BRepToIGES / BRepToIGES_BREntity.cxx
CommitLineData
b311480e 1// Created on: 1995-01-30
2// Created by: Marie Jose MARTZ
3// Copyright (c) 1995-1999 Matra Datavision
973c2be1 4// Copyright (c) 1999-2014 OPEN CASCADE SAS
b311480e 5//
973c2be1 6// This file is part of Open CASCADE Technology software library.
b311480e 7//
973c2be1 8// This library is free software; you can redistribute it and / or modify it
9// under the terms of the GNU Lesser General Public version 2.1 as published
10// by the Free Software Foundation, with special exception defined in the file
11// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12// distribution for complete text of the license and disclaimer of any warranty.
b311480e 13//
973c2be1 14// Alternatively, this file may be used under the terms of Open CASCADE
15// commercial license or contractual agreement.
b311480e 16
7fd59977 17//szv#4 S4163
18//eap: Tue Aug 29 11:02:56 2000: Shape Processing moved to upper levels
19
20#include <BRepToIGES_BREntity.ixx>
21
22#include <BRepToIGES_BRWire.hxx>
23#include <BRepToIGES_BRShell.hxx>
24#include <BRepToIGES_BRSolid.hxx>
25
26#include <BRep_Builder.hxx>
27
28#include <gp_Trsf.hxx>
29
30#include <Geom_Geometry.hxx>
31
32#include <IGESData_IGESEntity.hxx>
33
34#include <Interface_Macros.hxx>
35#include <Interface_Static.hxx>
36
37//#include <ShapeCustom.hxx>
38
39#include <TopLoc_Location.hxx>
40
41#include <TopoDS.hxx>
42#include <TopoDS_Compound.hxx>
43#include <TopoDS_CompSolid.hxx>
44#include <TopoDS_Edge.hxx>
45#include <TopoDS_Face.hxx>
46#include <TopoDS_Solid.hxx>
47#include <TopoDS_Shape.hxx>
48#include <TopoDS_Shell.hxx>
49#include <TopoDS_Vertex.hxx>
50#include <TopoDS_Wire.hxx>
51
52#include <Transfer_FinderProcess.hxx>
53#include <TransferBRep_ShapeMapper.hxx>
54#include <TransferBRep_OrientedShapeMapper.hxx>
55#include <Transfer_TransientMapper.hxx>
56#include <Transfer_SimpleBinderOfTransient.hxx>
57
58char Name[100];
59
60//=======================================================================
61//function : BRepToIGES_BREntity
62//purpose :
63//=======================================================================
64
65BRepToIGES_BREntity::BRepToIGES_BREntity()
66{
67 Init();
68}
69
70//=======================================================================
71//function : Init
72//purpose :
73//=======================================================================
74
75void BRepToIGES_BREntity::Init()
76{
77 TheMap = new Transfer_FinderProcess();
78 TheUnitFactor = 1.;
79 myConvSurface = Interface_Static::IVal("write.convertsurface.mode");
80 myPCurveMode = Interface_Static::IVal("write.surfacecurve.mode");
81}
82
83//=======================================================================
84//function : SetModel
85//purpose :
86//=======================================================================
87void BRepToIGES_BREntity::SetModel(const Handle(IGESData_IGESModel)& model)
88{
89 TheModel = model;
90 Standard_Real unitfactor = TheModel->GlobalSection().UnitValue();
91 if (unitfactor != 1.)
92 TheUnitFactor = unitfactor;
93}
94
95
96//=======================================================================
97//function : GetModel
98//purpose :
99//=======================================================================
100Handle(IGESData_IGESModel) BRepToIGES_BREntity::GetModel() const
101{ return TheModel; }
102
103
104//=======================================================================
105//function : GetUnit
106//purpose :
107//=======================================================================
108Standard_Real BRepToIGES_BREntity::GetUnit() const
109{
110 return TheUnitFactor;
111}
112
113
114//=======================================================================
115//function : SetTransferProcess
116//purpose :
117//=======================================================================
118void BRepToIGES_BREntity::SetTransferProcess(const Handle(Transfer_FinderProcess)& TP)
119{ TheMap = TP; }
120
121
122//=======================================================================
123//function : GetTransferProcess
124//purpose :
125//=======================================================================
126Handle(Transfer_FinderProcess) BRepToIGES_BREntity::GetTransferProcess() const
127{ return TheMap; }
128
129
130//=======================================================================
131//function : TransferShape
132//purpose :
133//=======================================================================
134Handle(IGESData_IGESEntity) BRepToIGES_BREntity::TransferShape
135(const TopoDS_Shape& start)
136{
137 Handle(IGESData_IGESEntity) res;
138// TopoDS_Shape theShape;
139 //Standard_Integer Nb = 1; //szv#4:S4163:12Mar99 not needed
140
141 if (start.IsNull()) return res;
142
143 if (start.ShapeType() == TopAbs_VERTEX) {
144 TopoDS_Vertex V = TopoDS::Vertex(start);
145 BRepToIGES_BRWire BW(*this);
146 BW.SetModel(GetModel());
147 res = BW.TransferVertex(V);
148 }
149 else if (start.ShapeType() == TopAbs_EDGE) {
150 TopoDS_Edge E = TopoDS::Edge(start);
151 BRepToIGES_BRWire BW(*this);
152 BW.SetModel(GetModel());
153 res = BW.TransferEdge(E, Standard_False);
154 }
155 else if (start.ShapeType() == TopAbs_WIRE) {
156 TopoDS_Wire W = TopoDS::Wire(start);
157 BRepToIGES_BRWire BW(*this);
158 BW.SetModel(GetModel());
159 res = BW.TransferWire(W);
160 }
161 else {
162 // la fonction suivante force les surfaces indirectes en
163 // surfaces directes (obligatoire dans IGES)
164// theShape = ShapeCustom::DirectFaces(start);
165 //sprintf(Name,"res_%d",Nb++);
166 //DBRep::Set(Name,theShape);
167
168 if (start.ShapeType() == TopAbs_FACE) {
169 TopoDS_Face F = TopoDS::Face(start);
170 BRepToIGES_BRShell BS(*this);
171 BS.SetModel(GetModel());
172 res = BS.TransferFace(F);
173 }
174 else if (start.ShapeType() == TopAbs_SHELL) {
175 TopoDS_Shell S = TopoDS::Shell(start);
176 BRepToIGES_BRShell BS(*this);
177 BS.SetModel(GetModel());
178 res = BS.TransferShell(S);
179 }
180 else if (start.ShapeType() == TopAbs_SOLID) {
181 TopoDS_Solid M = TopoDS::Solid(start);
182 BRepToIGES_BRSolid BS(*this);
183 BS.SetModel(GetModel());
184 res = BS.TransferSolid(M);
185 }
186 else if (start.ShapeType() == TopAbs_COMPSOLID) {
187 TopoDS_CompSolid C = TopoDS::CompSolid(start);
188 BRepToIGES_BRSolid BS(*this);
189 BS.SetModel(GetModel());
190 res = BS.TransferCompSolid(C);
191 }
192 else if (start.ShapeType() == TopAbs_COMPOUND) {
193 TopoDS_Compound C = TopoDS::Compound(start);
194 BRepToIGES_BRSolid BS(*this);
195 BS.SetModel(GetModel());
196 res = BS.TransferCompound(C);
197 }
198 else {
199 // message d`erreur
200 }
201 }
202
203 return res;
204}
205
206
207//=======================================================================
208//function : AddFail
209//purpose :
210//=======================================================================
211
212void BRepToIGES_BREntity::AddFail
213 (const TopoDS_Shape& start,
214 const Standard_CString amess)
215{
216 Handle(TransferBRep_ShapeMapper) Mapper = new TransferBRep_ShapeMapper(start);
217 TheMap->AddFail(Mapper, amess);
218}
219
220
221//=======================================================================
222//function : AddWarning
223//purpose :
224//=======================================================================
225
226void BRepToIGES_BREntity::AddWarning
227 (const TopoDS_Shape& start,
228 const Standard_CString amess)
229{
230 Handle(TransferBRep_ShapeMapper) Mapper = new TransferBRep_ShapeMapper(start);
231 TheMap->AddWarning(Mapper, amess);
232}
233
234
235//=======================================================================
236//function : AddFail
237//purpose :
238//=======================================================================
239
240void BRepToIGES_BREntity::AddFail
241 (const Handle(Standard_Transient)& start,
242 const Standard_CString amess)
243{
244 Handle(Transfer_TransientMapper) Mapper = new Transfer_TransientMapper(start);
245 TheMap->AddFail(Mapper, amess);
246}
247
248
249//=======================================================================
250//function : AddWarning
251//purpose :
252//=======================================================================
253
254void BRepToIGES_BREntity::AddWarning
255 (const Handle(Standard_Transient)& start,
256 const Standard_CString amess)
257{
258 Handle(Transfer_TransientMapper) Mapper = new Transfer_TransientMapper(start);
259 TheMap->AddWarning(Mapper, amess);
260}
261
262
263//=======================================================================
264//function : HasShapeResult
265//purpose :
266//=======================================================================
267
268Standard_Boolean BRepToIGES_BREntity::HasShapeResult
269 (const TopoDS_Shape& start) const
270{
271 Handle(TransferBRep_ShapeMapper) Mapper = new TransferBRep_ShapeMapper(start);
272 DeclareAndCast(Transfer_SimpleBinderOfTransient, binder, TheMap->Find(Mapper));
273 if (binder.IsNull()) return Standard_False;
274 return binder->HasResult();
275}
276
277
278//=======================================================================
279//function : GetShapeResult
280//purpose :
281//=======================================================================
282
283Handle(Standard_Transient) BRepToIGES_BREntity::GetShapeResult
284 (const TopoDS_Shape& start) const
285{
286 Handle(Standard_Transient) res;
287
288 Handle(TransferBRep_ShapeMapper) Mapper = new TransferBRep_ShapeMapper(start);
289 DeclareAndCast(Transfer_SimpleBinderOfTransient, binder, TheMap->Find(Mapper));
290 if (binder.IsNull()) return res;
291 if (binder->HasResult())
292 res = binder->Result();
293 return res;
294}
295
296
297//=======================================================================
298//function : SetShapeResult
299//purpose :
300//=======================================================================
301
302void BRepToIGES_BREntity::SetShapeResult
303 ( const TopoDS_Shape& start,
304 const Handle(Standard_Transient)& result)
305{
306 Handle(TransferBRep_ShapeMapper) Mapper = new TransferBRep_ShapeMapper(start);
307 Handle(Transfer_SimpleBinderOfTransient) binder = new Transfer_SimpleBinderOfTransient;
308 binder->SetResult(result);
309 TheMap->Bind(Mapper,binder);
310}
311
312//=======================================================================
313//function : HasShapeResult
314//purpose :
315//=======================================================================
316
317Standard_Boolean BRepToIGES_BREntity::HasShapeResult
318 (const Handle(Standard_Transient)& start) const
319{
320 Handle(Transfer_TransientMapper) Mapper = new Transfer_TransientMapper(start);
321 DeclareAndCast(Transfer_SimpleBinderOfTransient, binder, TheMap->Find(Mapper));
322 if (binder.IsNull()) return Standard_False;
323 return binder->HasResult();
324}
325
326
327//=======================================================================
328//function : GetShapeResult
329//purpose :
330//=======================================================================
331
332Handle(Standard_Transient) BRepToIGES_BREntity::GetShapeResult
333 (const Handle(Standard_Transient)& start) const
334{
335 Handle(Standard_Transient) res;
336
337 Handle(Transfer_TransientMapper) Mapper = new Transfer_TransientMapper(start);
338 DeclareAndCast(Transfer_SimpleBinderOfTransient, binder, TheMap->Find(Mapper));
339 if (binder.IsNull()) return res;
340 if (binder->HasResult())
341 res = binder->Result();
342 return res;
343}
344
345
346//=======================================================================
347//function : SetShapeResult
348//purpose :
349//=======================================================================
350
351void BRepToIGES_BREntity::SetShapeResult
352 ( const Handle(Standard_Transient)& start,
353 const Handle(Standard_Transient)& result)
354{
355 Handle(Transfer_TransientMapper) Mapper = new Transfer_TransientMapper(start);
356 Handle(Transfer_SimpleBinderOfTransient) binder = new Transfer_SimpleBinderOfTransient;
357 TheMap->Bind(Mapper,binder);
358 binder->SetResult(result);
359}
360
361//=======================================================================
362//function : GetConvertSurfaceMode
363//purpose :
364//=======================================================================
365
366Standard_Boolean BRepToIGES_BREntity::GetConvertSurfaceMode () const
367{
368 return myConvSurface;
369}
370
371//=======================================================================
372//function : GetPCurveMode
373//purpose :
374//=======================================================================
375
376Standard_Boolean BRepToIGES_BREntity::GetPCurveMode () const
377{
378 return myPCurveMode;
379}
380
381//=======================================================================
382//function : Delete
383//purpose :
384//=======================================================================
385
386void BRepToIGES_BREntity::Delete()
387{}