1 // Copyright (c) 1999-2014 OPEN CASCADE SAS
3 // This file is part of Open CASCADE Technology software library.
5 // This library is free software; you can redistribute it and / or modify it
6 // under the terms of the GNU Lesser General Public version 2.1 as published
7 // by the Free Software Foundation, with special exception defined in the file
8 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
9 // distribution for complete text of the license and disclaimer of any warranty.
11 // Alternatively, this file may be used under the terms of Open CASCADE
12 // commercial license or contractual agreement.
14 #include <IGESControl_ActorWrite.ixx>
15 #include <TransferBRep_ShapeMapper.hxx>
16 #include <Interface_Macros.hxx>
17 #include <IGESData_IGESModel.hxx>
19 #include <BRepToIGES_BREntity.hxx>
20 #include <BRepToIGESBRep_Entity.hxx>
22 #include <Transfer_TransientMapper.hxx>
23 #include <Geom_Curve.hxx>
24 #include <Geom_Surface.hxx>
25 #include <GeomToIGES_GeomCurve.hxx>
26 #include <GeomToIGES_GeomSurface.hxx>
28 #include <XSAlgo_AlgoContainer.hxx>
29 #include <Interface_Static.hxx>
31 IGESControl_ActorWrite::IGESControl_ActorWrite () { ModeTrans() = 0; }
33 Standard_Boolean IGESControl_ActorWrite::Recognize
34 (const Handle(Transfer_Finder)& start)
36 DeclareAndCast(TransferBRep_ShapeMapper,shmap,start);
37 if (!shmap.IsNull()) return Standard_True;
38 DeclareAndCast(Transfer_TransientMapper,gemap,start);
39 if (!gemap.IsNull()) {
40 Handle(Standard_Transient) geom = gemap->Value();
41 DeclareAndCast(Geom_Curve,Curve,geom);
42 DeclareAndCast(Geom_Surface,Surf,geom);
43 if (!Curve.IsNull() || !Surf.IsNull()) return Standard_True;
45 return Standard_False;
48 Handle(Transfer_Binder) IGESControl_ActorWrite::Transfer
49 (const Handle(Transfer_Finder)& start,
50 const Handle(Transfer_FinderProcess)& FP)
52 XSAlgo::AlgoContainer()->PrepareForTransfer();
54 DeclareAndCast(IGESData_IGESModel,modl,FP->Model());
55 if (modl.IsNull()) return NullResult();
56 if (themodetrans < 0 || themodetrans > 1) return NullResult();
57 Handle(Standard_Transient) ent;
59 DeclareAndCast(TransferBRep_ShapeMapper,shmap,start);
60 if (!shmap.IsNull()) {
61 TopoDS_Shape shape = shmap->Value();
62 if (shape.IsNull()) return NullResult();
63 // modified by NIZHNY-EAP Tue Aug 29 11:16:54 2000 ___BEGIN___
64 Handle(Standard_Transient) info;
65 Standard_Real Tol = Interface_Static::RVal("write.precision.val");
66 Standard_Real maxTol = Interface_Static::RVal("read.maxprecision.val");
67 shape = XSAlgo::AlgoContainer()->ProcessShape( shape, Tol, maxTol,
68 "write.iges.resource.name",
69 "write.iges.sequence", info,
71 // modified by NIZHNY-EAP Tue Aug 29 11:17:01 2000 ___END___
73 BRepToIGES_BREntity BR0; BR0.SetModel(modl); BR0.SetTransferProcess(FP);
74 BRepToIGESBRep_Entity BR1; BR1.SetModel(modl); BR1.SetTransferProcess(FP);
76 if (themodetrans == 0) ent = BR0.TransferShape(shape);
77 if (themodetrans == 1) ent = BR1.TransferShape(shape);
78 // modified by NIZHNY-EAP Tue Aug 29 11:37:18 2000 ___BEGIN___
79 XSAlgo::AlgoContainer()->MergeTransferInfo(FP, info);
80 // modified by NIZHNY-EAP Tue Aug 29 11:37:25 2000 ___END___
81 if (!ent.IsNull()) return TransientResult(ent);
83 DeclareAndCast(Transfer_TransientMapper,gemap,start);
84 if (!gemap.IsNull()) {
85 Handle(Standard_Transient) geom = gemap->Value();
86 DeclareAndCast(Geom_Curve,Curve,geom);
87 DeclareAndCast(Geom_Surface,Surf,geom);
89 // On reconnait : Curve et Surface de Geom
90 // quid de Point; Geom2d ?
92 // GeomToIGES_GeomPoint GP;
93 GeomToIGES_GeomCurve GC; GC.SetModel(modl);
94 GeomToIGES_GeomSurface GS; GS.SetModel(modl);
96 ent = GC.TransferCurve(Curve,Curve->FirstParameter(),Curve->LastParameter())
98 else if (!Surf.IsNull()) {
99 Standard_Real U1,U2,V1,V2;
100 Surf->Bounds(U1,U2,V1,V2);
101 ent = GS.TransferSurface(Surf,U1,U2,V1,V2);
103 if (!ent.IsNull()) return TransientResult(ent);