1 #include <IGESToBRep_Actor.ixx>
2 #include <IGESToBRep.hxx>
3 #include <IGESData_IGESEntity.hxx>
4 #include <IGESData_IGESModel.hxx>
5 #include <IGESData_GlobalSection.hxx>
6 #include <IGESToBRep_CurveAndSurface.hxx>
10 #include <Standard_Failure.hxx>
11 #include <Standard_ErrorHandler.hxx>
12 #include <ShapeExtend_Explorer.hxx>
13 #include <ShapeFix_ShapeTolerance.hxx>
15 #include <Interface_Macros.hxx>
16 #include <Interface_Static.hxx>
18 #include <Message_ProgressSentry.hxx>
20 #include <TopoDS_Shape.hxx>
21 #include <TransferBRep.hxx>
22 #include <TransferBRep_ShapeBinder.hxx>
25 #include <XSAlgo_AlgoContainer.hxx>
27 //=======================================================================
28 //function : IGESToBRep_Actor
30 //=======================================================================
31 IGESToBRep_Actor::IGESToBRep_Actor ()
32 { thecontinuity = 0; theeps = 0.0001; }
35 //=======================================================================
38 //=======================================================================
39 void IGESToBRep_Actor::SetModel (const Handle(Interface_InterfaceModel)& model)
42 theeps = Handle(IGESData_IGESModel)::DownCast(themodel)->GlobalSection().Resolution();
46 //=======================================================================
47 //function : SetContinuity
49 //=======================================================================
50 void IGESToBRep_Actor::SetContinuity (const Standard_Integer continuity)
52 thecontinuity = continuity;
56 //=======================================================================
57 //function : GetContinuity
59 //=======================================================================
60 Standard_Integer IGESToBRep_Actor::GetContinuity () const
65 //=======================================================================
66 //function : Recognize
68 //=======================================================================
69 Standard_Boolean IGESToBRep_Actor::Recognize
70 (const Handle(Standard_Transient)& start)
72 DeclareAndCast(IGESData_IGESModel,mymodel,themodel);
73 DeclareAndCast(IGESData_IGESEntity,ent,start);
74 if (ent.IsNull()) return Standard_False;
77 Standard_Integer typnum = ent->TypeNumber();
78 Standard_Integer fornum = ent->FormNumber();
79 if (IGESToBRep::IsCurveAndSurface(ent) ||
80 (typnum == 402 && (fornum == 1 || fornum == 7 ||
81 fornum == 14 || fornum == 15) ||
82 (typnum == 408 ) || (typnum == 308)))
85 // Cas restants : non reconnus
86 return Standard_False;
88 //=======================================================================
89 //function : EncodeRegul
90 //purpose : INTERNAL to encode regularity on edges
91 //=======================================================================
93 static Standard_Boolean EncodeRegul (const TopoDS_Shape& sh)
95 Standard_Real tolang = Interface_Static::RVal("read.encoderegularity.angle");
96 if (sh.IsNull()) return Standard_True;
97 if (tolang <= 0) return Standard_True;
100 BRepLib::EncodeRegularity (sh,tolang);
102 catch(Standard_Failure) {
103 return Standard_False;
105 return Standard_True;
107 //=======================================================================
108 //function : TrimTolerances
109 //purpose : Trims tolerances of the shape according to static parameters
111 //=======================================================================
113 static void TrimTolerances (const TopoDS_Shape& shape,
114 const Standard_Real tol)
116 if( Interface_Static::IVal("read.maxprecision.mode")==1) {
117 ShapeFix_ShapeTolerance SFST;
118 SFST.LimitTolerance (shape, 0, Max(tol,Interface_Static::RVal ("read.maxprecision.val")));
124 //=======================================================================
125 //function : Transfer
127 //=======================================================================
128 Handle(Transfer_Binder) IGESToBRep_Actor::Transfer
129 (const Handle(Standard_Transient)& start, const Handle(Transfer_TransientProcess)& TP)
131 DeclareAndCast(IGESData_IGESModel,mymodel,themodel);
132 DeclareAndCast(IGESData_IGESEntity,ent,start);
133 if (mymodel.IsNull() || ent.IsNull()) return NullResult();
134 Standard_Integer anum = mymodel->Number(start);
136 if(!Interface_Static::IVal("read.iges.faulty.entities") && mymodel->IsErrorEntity(anum))
140 // appeler le transfert seulement si type OK
141 Standard_Integer typnum = ent->TypeNumber();
142 Standard_Integer fornum = ent->FormNumber();
144 if (IGESToBRep::IsCurveAndSurface(ent) ||
145 (typnum == 402 && (fornum == 1 || fornum == 7||
146 fornum == 14 || fornum == 15)) ||
147 (typnum == 408) || (typnum == 308)) {
149 // Start progress scope (no need to check if progress exists -- it is safe)
150 Message_ProgressSentry aPSentry(TP->GetProgress(), "Transfer stage", 0, 2, 1);
152 XSAlgo::AlgoContainer()->PrepareForTransfer();
153 IGESToBRep_CurveAndSurface CAS;
154 CAS.SetModel(mymodel);
155 CAS.SetContinuity(thecontinuity);
156 CAS.SetTransferProcess(TP);
157 Standard_Integer Ival = Interface_Static::IVal("read.precision.mode");
159 eps = mymodel->GlobalSection().Resolution();
161 eps = Interface_Static::RVal("read.precision.val"); //:10 ABV 11 Nov 97
162 //:10 eps = BRepAPI::Precision();
163 Ival = Interface_Static::IVal("read.iges.bspline.approxd1.mode");
164 CAS.SetModeApprox ( (Ival > 0) );
165 Ival = Interface_Static::IVal("read.surfacecurve.mode");
166 CAS.SetSurfaceCurve (Ival);
170 theeps = eps*CAS.GetUnitFactor();
171 // Interface_Static::SetRVal("lastpreci",theeps);
173 Standard_Integer nbTPitems = TP->NbMapped();
177 shape = CAS.TransferGeometry(ent);
179 catch(Standard_Failure) {
184 // Switch to fix stage.
188 Handle(Standard_Transient) info;
189 shape = XSAlgo::AlgoContainer()->ProcessShape( shape, theeps, CAS.GetMaxTol(),
190 "read.iges.resource.name",
191 "read.iges.sequence", info,
193 XSAlgo::AlgoContainer()->MergeTransferInfo(TP, info, nbTPitems);
196 ShapeExtend_Explorer SBE;
197 if (SBE.ShapeType(shape,Standard_True) != TopAbs_SHAPE) {
198 if (!shape.IsNull()) {
200 //#74 rln 03.03.99 S4135
201 TrimTolerances (shape, UsedTolerance());
202 // Shapes().Append(shape);
205 Handle(TransferBRep_ShapeBinder) binder;
206 if (!shape.IsNull()) binder = new TransferBRep_ShapeBinder(shape);
211 Standard_Real IGESToBRep_Actor::UsedTolerance () const