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