1 #include <Standard_ErrorHandler.hxx>
2 #include <IGESToBRep_Actor.ixx>
3 #include <Standard_Failure.hxx>
5 #include <IGESToBRep.hxx>
6 #include <IGESData_IGESEntity.hxx>
7 #include <IGESData_IGESModel.hxx>
8 #include <IGESData_GlobalSection.hxx>
10 #include <IGESToBRep_CurveAndSurface.hxx>
12 #include <Interface_Macros.hxx>
13 #include <Interface_Static.hxx>
15 #include <TopoDS_Shape.hxx>
17 #include <TransferBRep.hxx>
18 #include <TransferBRep_ShapeBinder.hxx>
21 #include <XSAlgo_AlgoContainer.hxx>
22 #include <ShapeFix_ShapeTolerance.hxx>
23 #include <BRepLib.hxx>
24 #include <ShapeExtend_Explorer.hxx>
26 //=======================================================================
27 //function : IGESToBRep_Actor
29 //=======================================================================
30 IGESToBRep_Actor::IGESToBRep_Actor ()
31 { thecontinuity = 0; theeps = 0.0001; }
34 //=======================================================================
37 //=======================================================================
38 void IGESToBRep_Actor::SetModel (const Handle(Interface_InterfaceModel)& model)
41 theeps = Handle(IGESData_IGESModel)::DownCast(themodel)->GlobalSection().Resolution();
45 //=======================================================================
46 //function : SetContinuity
48 //=======================================================================
49 void IGESToBRep_Actor::SetContinuity (const Standard_Integer continuity)
51 thecontinuity = continuity;
55 //=======================================================================
56 //function : GetContinuity
58 //=======================================================================
59 Standard_Integer IGESToBRep_Actor::GetContinuity () const
64 //=======================================================================
65 //function : Recognize
67 //=======================================================================
68 Standard_Boolean IGESToBRep_Actor::Recognize
69 (const Handle(Standard_Transient)& start)
71 DeclareAndCast(IGESData_IGESModel,mymodel,themodel);
72 DeclareAndCast(IGESData_IGESEntity,ent,start);
73 if (ent.IsNull()) return Standard_False;
76 Standard_Integer typnum = ent->TypeNumber();
77 Standard_Integer fornum = ent->FormNumber();
78 if (IGESToBRep::IsCurveAndSurface(ent) ||
79 (typnum == 402 && (fornum == 1 || fornum == 7 ||
80 fornum == 14 || fornum == 15) ||
81 (typnum == 408 ) || (typnum == 308)))
84 // Cas restants : non reconnus
85 return Standard_False;
87 //=======================================================================
88 //function : EncodeRegul
89 //purpose : INTERNAL to encode regularity on edges
90 //=======================================================================
92 static Standard_Boolean EncodeRegul (const TopoDS_Shape& sh)
94 Standard_Real tolang = Interface_Static::RVal("read.encoderegularity.angle");
95 if (sh.IsNull()) return Standard_True;
96 if (tolang <= 0) return Standard_True;
99 BRepLib::EncodeRegularity (sh,tolang);
101 catch(Standard_Failure) {
102 return Standard_False;
104 return Standard_True;
106 //=======================================================================
107 //function : TrimTolerances
108 //purpose : Trims tolerances of the shape according to static parameters
110 //=======================================================================
112 static void TrimTolerances (const TopoDS_Shape& shape,
113 const Standard_Real tol)
115 if( Interface_Static::IVal("read.maxprecision.mode")==1) {
116 ShapeFix_ShapeTolerance SFST;
117 SFST.LimitTolerance (shape, 0, Max(tol,Interface_Static::RVal ("read.maxprecision.val")));
123 //=======================================================================
124 //function : Transfer
126 //=======================================================================
127 Handle(Transfer_Binder) IGESToBRep_Actor::Transfer
128 (const Handle(Standard_Transient)& start, const Handle(Transfer_TransientProcess)& TP)
130 DeclareAndCast(IGESData_IGESModel,mymodel,themodel);
131 DeclareAndCast(IGESData_IGESEntity,ent,start);
132 if (mymodel.IsNull() || ent.IsNull()) return NullResult();
133 Standard_Integer anum = mymodel->Number(start);
135 if(!Interface_Static::IVal("read.iges.faulty.entities") && mymodel->IsErrorEntity(anum))
139 // appeler le transfert seulement si type OK
140 Standard_Integer typnum = ent->TypeNumber();
141 Standard_Integer fornum = ent->FormNumber();
143 if (IGESToBRep::IsCurveAndSurface(ent) ||
144 (typnum == 402 && (fornum == 1 || fornum == 7||
145 fornum == 14 || fornum == 15)) ||
146 (typnum == 408) || (typnum == 308)) {
147 XSAlgo::AlgoContainer()->PrepareForTransfer();
148 IGESToBRep_CurveAndSurface CAS;
149 CAS.SetModel(mymodel);
150 CAS.SetContinuity(thecontinuity);
151 CAS.SetTransferProcess(TP);
152 Standard_Integer Ival = Interface_Static::IVal("read.precision.mode");
154 eps = mymodel->GlobalSection().Resolution();
156 eps = Interface_Static::RVal("read.precision.val"); //:10 ABV 11 Nov 97
157 //:10 eps = BRepAPI::Precision();
158 Ival = Interface_Static::IVal("read.iges.bspline.approxd1.mode");
159 CAS.SetModeApprox ( (Ival > 0) );
160 Ival = Interface_Static::IVal("read.surfacecurve.mode");
161 CAS.SetSurfaceCurve (Ival);
165 theeps = eps*CAS.GetUnitFactor();
166 // Interface_Static::SetRVal("lastpreci",theeps);
168 Standard_Integer nbTPitems = TP->NbMapped();
172 shape = CAS.TransferGeometry(ent);
174 catch(Standard_Failure) {
180 // shape = XSAlgo::AlgoContainer()->PerformFixShape( shape, TP, theeps, CAS.GetMaxTol() );
181 Handle(Standard_Transient) info;
182 shape = XSAlgo::AlgoContainer()->ProcessShape( shape, theeps, CAS.GetMaxTol(),
183 "read.iges.resource.name",
184 "read.iges.sequence", info );
185 XSAlgo::AlgoContainer()->MergeTransferInfo(TP, info, nbTPitems);
187 // if (!shape.IsNull()) TransferBRep::SameParameter (shape,Standard_False,eps);
188 ShapeExtend_Explorer SBE;
189 if (SBE.ShapeType(shape,Standard_True) != TopAbs_SHAPE) {
190 if (!shape.IsNull()) {
192 //#74 rln 03.03.99 S4135
193 TrimTolerances (shape, UsedTolerance());
194 // Shapes().Append(shape);
197 Handle(TransferBRep_ShapeBinder) binder;
198 if (!shape.IsNull()) binder = new TransferBRep_ShapeBinder(shape);
203 Standard_Real IGESToBRep_Actor::UsedTolerance () const