0022731: Error on attempt to write in IGES 5.3 the attached brep model
[occt.git] / src / IGESControl / IGESControl_ActorWrite.cxx
CommitLineData
7fd59977 1#include <IGESControl_ActorWrite.ixx>
2#include <TransferBRep_ShapeMapper.hxx>
3#include <Interface_Macros.hxx>
4#include <IGESData_IGESModel.hxx>
5
6#include <BRepToIGES_BREntity.hxx>
7#include <BRepToIGESBRep_Entity.hxx>
8
9#include <Transfer_TransientMapper.hxx>
10#include <Geom_Curve.hxx>
11#include <Geom_Surface.hxx>
12#include <GeomToIGES_GeomCurve.hxx>
13#include <GeomToIGES_GeomSurface.hxx>
14#include <XSAlgo.hxx>
15#include <XSAlgo_AlgoContainer.hxx>
16#include <Interface_Static.hxx>
17
18IGESControl_ActorWrite::IGESControl_ActorWrite () { ModeTrans() = 0; }
19
20Standard_Boolean IGESControl_ActorWrite::Recognize
21 (const Handle(Transfer_Finder)& start)
22{
23 DeclareAndCast(TransferBRep_ShapeMapper,shmap,start);
24 if (!shmap.IsNull()) return Standard_True;
25 DeclareAndCast(Transfer_TransientMapper,gemap,start);
26 if (!gemap.IsNull()) {
27 Handle(Standard_Transient) geom = gemap->Value();
28 DeclareAndCast(Geom_Curve,Curve,geom);
29 DeclareAndCast(Geom_Surface,Surf,geom);
30 if (!Curve.IsNull() || !Surf.IsNull()) return Standard_True;
31 }
32 return Standard_False;
33}
34
35Handle(Transfer_Binder) IGESControl_ActorWrite::Transfer
36 (const Handle(Transfer_Finder)& start,
37 const Handle(Transfer_FinderProcess)& FP)
38{
39 XSAlgo::AlgoContainer()->PrepareForTransfer();
40
41 DeclareAndCast(IGESData_IGESModel,modl,FP->Model());
42 if (modl.IsNull()) return NullResult();
43 if (themodetrans < 0 || themodetrans > 1) return NullResult();
44 Handle(Standard_Transient) ent;
45
46 DeclareAndCast(TransferBRep_ShapeMapper,shmap,start);
47 if (!shmap.IsNull()) {
48 TopoDS_Shape shape = shmap->Value();
49 if (shape.IsNull()) return NullResult();
50// modified by NIZHNY-EAP Tue Aug 29 11:16:54 2000 ___BEGIN___
51 Handle(Standard_Transient) info;
52 Standard_Real Tol = Interface_Static::RVal("write.precision.val");
53 Standard_Real maxTol = Interface_Static::RVal("read.maxprecision.val");
54 shape = XSAlgo::AlgoContainer()->ProcessShape( shape, Tol, maxTol,
55 "write.iges.resource.name",
b485ee79
KD
56 "write.iges.sequence", info,
57 FP->GetProgress() );
7fd59977 58// modified by NIZHNY-EAP Tue Aug 29 11:17:01 2000 ___END___
59
60 BRepToIGES_BREntity BR0; BR0.SetModel(modl); BR0.SetTransferProcess(FP);
61 BRepToIGESBRep_Entity BR1; BR1.SetModel(modl); BR1.SetTransferProcess(FP);
62
63 if (themodetrans == 0) ent = BR0.TransferShape(shape);
64 if (themodetrans == 1) ent = BR1.TransferShape(shape);
65// modified by NIZHNY-EAP Tue Aug 29 11:37:18 2000 ___BEGIN___
66 XSAlgo::AlgoContainer()->MergeTransferInfo(FP, info);
67// modified by NIZHNY-EAP Tue Aug 29 11:37:25 2000 ___END___
68 if (!ent.IsNull()) return TransientResult(ent);
69 }
70 DeclareAndCast(Transfer_TransientMapper,gemap,start);
71 if (!gemap.IsNull()) {
72 Handle(Standard_Transient) geom = gemap->Value();
73 DeclareAndCast(Geom_Curve,Curve,geom);
74 DeclareAndCast(Geom_Surface,Surf,geom);
75
76// On reconnait : Curve et Surface de Geom
77// quid de Point; Geom2d ?
78
79// GeomToIGES_GeomPoint GP;
80 GeomToIGES_GeomCurve GC; GC.SetModel(modl);
81 GeomToIGES_GeomSurface GS; GS.SetModel(modl);
82 if (!Curve.IsNull())
83 ent = GC.TransferCurve(Curve,Curve->FirstParameter(),Curve->LastParameter())
84;
85 else if (!Surf.IsNull()) {
86 Standard_Real U1,U2,V1,V2;
87 Surf->Bounds(U1,U2,V1,V2);
88 ent = GS.TransferSurface(Surf,U1,U2,V1,V2);
89 }
90 if (!ent.IsNull()) return TransientResult(ent);
91 }
92
93 return NullResult();
94}