0022627: Change OCCT memory management defaults
[occt.git] / src / IGESToBRep / IGESToBRep_TopoSurface.cxx
CommitLineData
7fd59977 1//=======================================================================
2//file : IGESToBRep_TopoSurface
3//modified:
4// Integration to ensure SCCS base integrity
5// 21.12.98 rln, gka S4054
6// 28.12.98 dce S3767 New messaging system
7//#55,#56 rln 25.12.98 UKI60878
8//:l1 abv 10.01.99: USA60022 7289: fix missing seam
9//#63 rln 19.01.99 UKI60878 no offset if C0 surface is converted into the grid of C1 surfaces
10//%13 pdn 15.02.99 USA60293 entities 792, 8604 .. handling of C0 ruled surfaces, tabulated cylindres,
11// and surfaces of revolution.
12//:p4 abv, pdn 23.02.99: PRO9234 #15720: call BRepTools::Update() for faces
13//%14 pdn 24.02.99 implementing of ShapeFix_Face on IGES
14// pdn 17.04.99 S4181: Implementing of reading IGES elementary surfaces.
15// pdn 10.05.99 S4137: Using modified ShapeDivide tools
16//#11 smh 22.12.99 BUC60625 Transform axis.
17//#12 smh 12.12.99 FRA62468 - Using conversion to B-Spline for Offset surface
18//=======================================================================
19
20#include <IGESToBRep_TopoSurface.ixx>
21
22#include <Standard_ErrorHandler.hxx>
23#include <IGESToBRep.hxx>
24#include <IGESToBRep_CurveAndSurface.hxx>
25#include <IGESToBRep_TopoCurve.hxx>
26#include <IGESToBRep_BasicCurve.hxx>
27#include <IGESToBRep_BasicSurface.hxx>
28
29#include <BRepAdaptor_Curve.hxx>
30#include <BRepPrimAPI_MakePrism.hxx>
31#include <BRepPrimAPI_MakeRevol.hxx>
32//S4054: ShapeTool_MakeWire -> ShapeExtend_WireData //:g8: BRepLib_MakeWire -> ShapeTool_MakeWire
33#include <BRepGProp.hxx>
34#include <BRepFill.hxx>
35#include <BRepLib_MakeFace.hxx>
36#include <BRep_Builder.hxx>
37#include <BRep_Tool.hxx>
38
39#include <ElSLib.hxx>
40
41#include <GProp.hxx>
42#include <GProp_GProps.hxx>
43
44#include <GeomAbs_Shape.hxx>
45
46#include <Geom2d_Line.hxx>
47#include <Geom2d_Curve.hxx>
48
49#include <Geom_BezierCurve.hxx>
50#include <Geom_Curve.hxx>
51#include <Geom_ConicalSurface.hxx>
52#include <Geom_CylindricalSurface.hxx>
53#include <Geom_OffsetSurface.hxx>
54#include <Geom_Plane.hxx>
55#include <Geom_Surface.hxx>
56#include <Geom_SurfaceOfLinearExtrusion.hxx>
57#include <Geom_RectangularTrimmedSurface.hxx>
58#include <Geom_SphericalSurface.hxx>
59#include <Geom_ToroidalSurface.hxx>
60
61#include <IGESData_IGESEntity.hxx>
62#include <IGESData_ToolLocation.hxx>
63
64#include <IGESGeom_BSplineSurface.hxx>
65#include <IGESGeom_BoundedSurface.hxx>
66#include <IGESGeom_CurveOnSurface.hxx>
67#include <IGESGeom_Line.hxx>
68#include <IGESGeom_Point.hxx>
69#include <IGESGeom_Direction.hxx>
70
71#include <IGESSolid_CylindricalSurface.hxx>
72#include <IGESSolid_ConicalSurface.hxx>
73#include <IGESSolid_ToroidalSurface.hxx>
74#include <IGESSolid_SphericalSurface.hxx>
75#include <IGESSolid_PlaneSurface.hxx>
76
77#include <Interface_Macros.hxx>
78
79#include <gp_GTrsf.hxx>
80
81#include <Precision.hxx>
82
83#include <TopAbs.hxx>
84
85#include <TopoDS.hxx>
86#include <TopoDS_Edge.hxx>
87#include <TopoDS_Face.hxx>
88#include <TopoDS_Iterator.hxx>
89#include <TopoDS_Shape.hxx>
90#include <TopoDS_Shell.hxx>
91#include <TopoDS_Vertex.hxx>
92#include <TopoDS_Wire.hxx>
93
94#include <TopExp.hxx>
95#include <TopExp_Explorer.hxx>
96
97#include <TopLoc_Location.hxx>
98
99#include <gp.hxx>
100#include <gp_Ax1.hxx>
101#include <gp_Cylinder.hxx>
102#include <gp_Cone.hxx>
103#include <gp_Dir.hxx>
104#include <gp_Dir2d.hxx>
105#include <gp_Pln.hxx>
106#include <gp_Pnt.hxx>
107#include <gp_Sphere.hxx>
108#include <gp_Torus.hxx>
109#include <gp_Trsf.hxx>
110#include <gp_Vec.hxx>
111#include <stdio.h>
112
113//:e3
114#include <TColgp_Array1OfPnt.hxx>
115#include <TColStd_Array1OfReal.hxx>
116#include <TColStd_Array1OfInteger.hxx>
117#include <Geom_BSplineCurve.hxx>
118#include <Geom_Line.hxx>
119#include <BRepTools.hxx>//#16
120#include <ShapeAnalysis.hxx>
121//S4054
122#include <ShapeExtend_WireData.hxx>
123#include <ShapeFix_Wire.hxx>
124#include <Geom_TrimmedCurve.hxx>
125#include <GeomConvert.hxx>
126#include <GeomLib.hxx>
127#include <BSplCLib.hxx>
128//S3767
129#include <Message_Msg.hxx>
130#include <IGESData_IGESModel.hxx>
131
132#include <IGESGeom_CircularArc.hxx>
133#include <ElCLib.hxx>
134
135#include <BRepOffset_MakeOffset.hxx>
136#include <BRep_Tool.hxx>
137#include <Geom_BSplineSurface.hxx>
138#include <ShapeAlgo.hxx>
139#include <ShapeAlgo_AlgoContainer.hxx>
140#include <BRepBuilderAPI_MakeFace.hxx>
141#include <Geom_SurfaceOfRevolution.hxx>
142
143//=======================================================================
144//function : IGESToBRep_TopoSurface
145//purpose :
146//=======================================================================
147
148IGESToBRep_TopoSurface::IGESToBRep_TopoSurface()
149 :IGESToBRep_CurveAndSurface()
150{
151}
152
153
154//=======================================================================
155//function : IGESToBRep_TopoSurface
156//purpose :
157//=======================================================================
158
159IGESToBRep_TopoSurface::IGESToBRep_TopoSurface
160 (const IGESToBRep_CurveAndSurface& CS)
161 :IGESToBRep_CurveAndSurface(CS)
162{
163}
164
165
166//=======================================================================
167//function : IGESToBRep_TopoSurface
168//purpose :
169//=======================================================================
170
171IGESToBRep_TopoSurface::IGESToBRep_TopoSurface
172 (const Standard_Real eps,
173 const Standard_Real epsCoeff,
174 const Standard_Real epsGeom,
175 const Standard_Boolean mode,
176 const Standard_Boolean modeapprox,
177 const Standard_Boolean optimized)
178 :IGESToBRep_CurveAndSurface(eps, epsCoeff, epsGeom, mode,
179 modeapprox, optimized)
180{
181}
182
183static Standard_Boolean extractCurve3d (const TopoDS_Shape& theEdges,
184 Handle(Geom_Curve)& theCurve)
185{
186 TopExp_Explorer anExp(theEdges, TopAbs_EDGE);
187 Standard_Integer howMuch = 0;
188 Standard_Real f, l;
189 for (; anExp.More(); anExp.Next()) {
190 TopoDS_Edge anEdge = TopoDS::Edge(anExp.Current());
191 if (anEdge.IsNull())
192 continue;
193 howMuch++;
194 theCurve = BRep_Tool::Curve(anEdge, f, l);
195 }
196 if ( howMuch != 1 || theCurve.IsNull() )
197 return Standard_False;
198
199 if ( f != theCurve->FirstParameter() || l != theCurve->LastParameter() )
200 theCurve = new Geom_TrimmedCurve ( theCurve, f, l );
201 return Standard_True;
202}
203
204
205//=======================================================================
206//function : TransferTopoSurface
207//purpose :
208//=======================================================================
209
210TopoDS_Shape IGESToBRep_TopoSurface::TransferTopoSurface
211 (const Handle(IGESData_IGESEntity)& st)
212{ // Declaration of messages//
213 // DCE 22/12/98
214 //Message_Msg msg1005("IGES_1005");
215 ////////////////////////////
216
217 TopoDS_Shape res;
218 TheULength = 1.;
219 //S4054
220 if (st.IsNull()) {
221 Message_Msg msg1005("IGES_1005");
222 SendFail(st, msg1005);
223 }
224 ////modified by jgv, 20.11.2009 for OCC21487///
225 else if (HasShapeResult(st))
226 {
227 res = GetShapeResult(st);
228 return res;
229 }
230 ///////////////////////////////////////////////
231 else if (IGESToBRep::IsBasicSurface(st)) {
232 res = TransferTopoBasicSurface(st);
233 }
234 else if (st->IsKind(STANDARD_TYPE(IGESGeom_TrimmedSurface))) {
235 DeclareAndCast(IGESGeom_TrimmedSurface, st144, st);
236 res = TransferTrimmedSurface(st144);
237 }
238 else if (st->IsKind(STANDARD_TYPE(IGESGeom_SurfaceOfRevolution))) {
239 DeclareAndCast(IGESGeom_SurfaceOfRevolution, st120, st);
240 res = TransferSurfaceOfRevolution(st120);
241 }
242 else if (st->IsKind(STANDARD_TYPE(IGESGeom_TabulatedCylinder))) {
243 DeclareAndCast(IGESGeom_TabulatedCylinder, st122, st);
244 res = TransferTabulatedCylinder(st122);
245 }
246 else if (st->IsKind(STANDARD_TYPE(IGESGeom_RuledSurface))) {
247 DeclareAndCast(IGESGeom_RuledSurface, st118, st);
248 res = TransferRuledSurface(st118);
249 }
250 else if (st->IsKind(STANDARD_TYPE(IGESGeom_Plane))) {
251 DeclareAndCast(IGESGeom_Plane, st108, st);
252 res = TransferPlane(st108);
253 }
254 else if (st->IsKind(STANDARD_TYPE(IGESGeom_BoundedSurface))) {
255 DeclareAndCast(IGESGeom_BoundedSurface, st143, st);
256 res = TransferBoundedSurface(st143);
257 }
258 else if (st->IsKind(STANDARD_TYPE(IGESGeom_OffsetSurface))) {
259 DeclareAndCast(IGESGeom_OffsetSurface, st140, st);
260 res = TransferOffsetSurface(st140);
261 }
262 //S4181 pdn IGESSolid_PlaneSurface recognized as basic surface
263 else if (st->IsKind(STANDARD_TYPE(IGESBasic_SingleParent))) {
264 DeclareAndCast(IGESBasic_SingleParent,st402_9,st);
265 res = TransferPerforate(st402_9); // limite : Planes seulement
266 }
267 else {
268 // AddFail(st, "The IGESEntity is not a Topologic Surface.");
269 }
270 SetShapeResult (st, res);
271 return res;
272}
273
274//=======================================================================
275//function : TransferTopoBasicSurface
276//purpose :
277//=======================================================================
278
279TopoDS_Shape IGESToBRep_TopoSurface::TransferTopoBasicSurface
280 (const Handle(IGESData_IGESEntity)& st)
281{ // Declaration of messages//
282 // DCE 22/12/98
283 //Message_Msg msg1005("IGES_1005");
284 ////////////////////////////
285
286 TopoDS_Shape res;
287
288 if (st.IsNull()) {
289 Message_Msg msg1005("IGES_1005");
290 SendFail(st, msg1005);
291 return res;
292 }
293 if (!IGESToBRep::IsBasicSurface(st)) {
294 // AddFail(st, "BasicSurface Transfer Error : Not Allowed IGESEntity"); This message can not occur.
295 return res;
296 }
297
298 IGESToBRep_BasicSurface BS(*this);
299
300 Handle(Geom_Surface) surf = BS.TransferBasicSurface(st);
301 if (surf.IsNull()) {
302 // AddFail(st, "Surface Conversion Error"); Messages have ever been Added in the called function.
303 return res;
304 }
305
306 //#9 rln 26/02/98 UKI60106
307 if (surf->Continuity() < GeomAbs_C1) {
308 Message_Msg msg1250("IGES_1250");
309 SendWarning(st, msg1250);
310 }
311 if(surf->IsKind(STANDARD_TYPE(Geom_Plane))){
312 BRep_Builder B;
313 TopoDS_Face plane;
314 B.MakeFace(plane);
315 B.UpdateFace(plane, surf, TopLoc_Location(), Precision::Confusion());
316 res = plane;
317 }
318 else {
1c72dff6 319 BRepLib_MakeFace makeFace(surf, Precision::Confusion());
7fd59977 320 res = makeFace.Face();
321 }
322
323 if (st->HasTransf()) {
324 gp_Trsf trsf;
325 SetEpsilon(1.E-04);
326 if (IGESData_ToolLocation::ConvertLocation
327 (GetEpsilon(),st->CompoundLocation(),trsf,GetUnitFactor())) {
328 TopLoc_Location locFace(trsf);
329 res.Move(locFace);
330 }
331 else {
332 Message_Msg msg1035("IGES_1035");
333 SendWarning(st, msg1035);
334 }
335 }
336 return res;
337}
338
339
340//=======================================================================
341//function : TransferRuledSurface
342//purpose :
343//=======================================================================
344static void reparamBSpline(Handle(Geom_Curve)& curve,
345 const Standard_Real First,
346 const Standard_Real Last)
347{
348 Handle (Geom_BSplineCurve) bscurve;
349 if (!curve->IsKind (STANDARD_TYPE (Geom_BSplineCurve))) {
350 if (curve->FirstParameter() < First || curve->LastParameter() > Last)
351 curve = new Geom_TrimmedCurve (curve, First, Last);
352 bscurve = GeomConvert::CurveToBSplineCurve (curve, Convert_RationalC1);
353 }
354 else {
355 bscurve = Handle (Geom_BSplineCurve)::DownCast (curve);
356 bscurve->Segment (First, Last);
357 }
358
359 if (bscurve.IsNull())
360 return;
361
362 TColStd_Array1OfReal Knots(1, bscurve->NbKnots());
363 bscurve->Knots(Knots);
364 BSplCLib::Reparametrize (0., 1., Knots);
365 bscurve->SetKnots(Knots);
366 curve = bscurve;
367}
368
369static void ReparamCurve(TopoDS_Edge& edge)
370{
371 TopLoc_Location L;
372 Standard_Real First, Last;
373
374 Handle (Geom_Curve) curve = Handle (Geom_Curve)::DownCast (BRep_Tool::Curve ( edge, L, First, Last )->Copy());
375 //if ( Abs (First) <= Precision::PConfusion() && Abs (Last - 1.) <= Precision::PConfusion() ) return;
376 if(!curve->IsKind(STANDARD_TYPE(Geom_Line))) return;
377
378 reparamBSpline( curve, First, Last );
379
380 BRep_Builder B;
381 B.UpdateEdge ( edge, curve, L, Precision::Confusion() );
382 B.Range ( edge, 0., 1 );
383}
384
385
386//=======================================================================
387//function : TransferRuledSurface
388//purpose :
389//=======================================================================
390
391TopoDS_Shape IGESToBRep_TopoSurface::TransferRuledSurface
392 (const Handle(IGESGeom_RuledSurface)& st)
393{ // Declaration of messages//
394 // DCE 22/12/98
395 //Message_Msg msg1005("IGES_1005");
396 ////////////////////////////////
397 TopoDS_Shape res;
398
399 if (st.IsNull()) {
400 Message_Msg msg1005("IGES_1005");
401 SendFail(st, msg1005);
402 return res;
403 }
404
405 IGESToBRep_TopoCurve TC(*this);
406 //%13 pdn 12.02.99
407 TC.SetContinuity (0);
408 Handle(IGESData_IGESEntity) igesCurve1 = st->FirstCurve();
409 Handle(IGESData_IGESEntity) igesCurve2 = st->SecondCurve();
410
411 if (igesCurve1.IsNull()) {
412 Message_Msg msg148("XSTEP_148");
413 SendFail(st, msg148); // Curve Reading Error : Null IGESEntity
414 return res;
415 }
416 if (igesCurve2.IsNull()) {
417 Message_Msg msg149("XSTEP_149");
418 SendFail(st, msg149); // Curve Reading Error : Null IGESEntity
419 return res;
420 }
421
422 Standard_Integer nbEdges1, nbEdges2;
423 TopoDS_Shape shape1, shape2;
424 TopoDS_Wire wire1, wire2;
425 TopoDS_Wire newWire1, newWire2;
426 //TopoDS_Edge edge1, edge2; // skl
427
428 if (IGESToBRep::IsTopoCurve(igesCurve1)) {
429 shape1 = TC.TransferTopoCurve(igesCurve1);
430 if (shape1.IsNull()) {
431 Message_Msg msg1156("IGES_1156");
432 const Standard_CString typeName(igesCurve1->DynamicType()->Name());
433 Handle(TCollection_HAsciiString) label = GetModel()->StringLabel(igesCurve1);
434 msg1156.Arg(typeName);
435 msg1156.Arg(label);
436 SendFail(st, msg1156);
437 return res;
438 }
439
440 //%13 pdn 15.02.99
441 //added by rln on 03/12/97
442 //if shape1 is a wire it means that the curve1 in file was of continuity C0
443 //in order to get a face instead of shell when to BRepFill shape1
444 //should be retransfered with contionuity C0 (to get an edge). Once shape1
445 //has been built with C0, it is useless to require C1 from shape2 because
446 //anyway resulting surface was of continuity C0. Thus shape2 is built with C0
447// if (shape1.ShapeType() != TopAbs_EDGE) {
448// TC.SetContinuity (0);
449// shape1 = TC.TransferTopoCurve(igesCurve1);
450// if (shape1.IsNull()) {
451// Message_Msg msg1156("IGES_1156");
452// const Standard_CString typeName(igesCurve1->DynamicType()->Name());
453// Handle(TCollection_HAsciiString) label = GetModel()->StringLabel(igesCurve1);
454// msg1156.Arg(typeName);
455// msg1156.Arg(label);
456// SendFail(st, msg1156);
457// return res;
458// }
459// else {
460// Message_Msg msg1250("IGES_1250");
461// SendWarning (st, msg1250); // RuledSurface was built with continuity C0
462// }
463// }
464
465 TopAbs_ShapeEnum shapeEnum1 = shape1.ShapeType();
466 switch (shapeEnum1) {
467 case TopAbs_EDGE :
468 {
469 TopoDS_Edge edge1 = TopoDS::Edge(shape1);
470 ReparamCurve(edge1);
471 nbEdges1 = 1;
472 }
473 break;
474 case TopAbs_WIRE :
475 {
476 wire1 = TopoDS::Wire(shape1);
477 nbEdges1 = 0;
478 for (TopoDS_Iterator hulot(wire1); hulot.More(); hulot.Next()) {
479 TopoDS_Edge edge1 = TopoDS::Edge(hulot.Value());
480 ReparamCurve(edge1);
481 nbEdges1++;
482 }
483 }
484 break;
485 default:
486 {
487 // AddFail(st, "Curve Conversion Error."); This message can not occur.
488 return res;
489 }
490 //break; //szv#4:S4163:12Mar99 unreachable
491 }
492 }
493 else {
494 Message_Msg msg148("XSTEP_148");
495 SendFail(st, msg148);
496 // Curve Type not Allowed.
497 return res;
498 }
499
500 if (IGESToBRep::IsTopoCurve(igesCurve2)) {
501 shape2 = TC.TransferTopoCurve(igesCurve2);
502 // dirflg = 0 join first to first, last to last
503 // dirflg = 1 join first to last, last to first
504
505 if (shape2.IsNull()) {
506 Message_Msg msg1156("IGES_1156");
507 const Standard_CString typeName(igesCurve2->DynamicType()->Name());
508 Handle(TCollection_HAsciiString) label = GetModel()->StringLabel(igesCurve2);
509 msg1156.Arg(typeName);
510 msg1156.Arg(label);
511 SendFail(st, msg1156);
512 // Curve Conversion Error.
513 return res;
514 }
515 Standard_Integer dirflag = st->DirectionFlag ();
516 // if (dirflag == 1){ // gka BUC60685
517
518 // shape2.Reverse();
519 //}
520
521 TopAbs_ShapeEnum shapeEnum2 = shape2.ShapeType();
522 switch (shapeEnum2) {
523 case TopAbs_EDGE :
524 {
525 TopoDS_Edge edge2 = TopoDS::Edge(shape2);
526 ReparamCurve(edge2);
527 if (dirflag == 1)
528 shape2.Reverse();
529 nbEdges2 = 1;
530 }
531 break;
532 case TopAbs_WIRE :
533 {
534 wire2 = TopoDS::Wire(shape2);
535 nbEdges2 = 0;
536 for (TopoDS_Iterator cousto(wire2); cousto.More(); cousto.Next()) {
537 TopoDS_Edge edge2 = TopoDS::Edge(cousto.Value());
538 ReparamCurve(edge2);
539 nbEdges2++;
540 }
541 if (dirflag == 1) { //gka BUC60685
542 Handle(ShapeExtend_WireData) sewd2 = new ShapeExtend_WireData;
543 sewd2->Add(shape2);
544 sewd2->Reverse();
545 wire2 = sewd2->Wire();
546 }
547 }
548 break;
549 default:
550 {
551 // AddFail(st, "Curve Conversion Error.");
552 return res;
553 }
554 //break; //szv#4:S4163:12Mar99 unreachable
555 }
556 }
557 else {
558 Message_Msg msg149("XSTEP_149");
559 SendFail(st, msg149);
560 // Curve Type not Allowed
561 return res;
562 }
563
564
565 if (nbEdges1 != nbEdges2) {
566 if (nbEdges1 == 1) {
567 Handle(ShapeExtend_WireData) sewd1 = new ShapeExtend_WireData;
568 sewd1->Add(shape1);
569 wire1 = sewd1->Wire();
570 }
571 else if (nbEdges2 == 1) {
572 Handle(ShapeExtend_WireData) sewd2 = new ShapeExtend_WireData;
573 sewd2->Add(shape2);
574 wire2 = sewd2->Wire();
575 }
576
577 if (!st->IsRuledByParameter()) {
578 // AddWarning (st,"Compute by parametric constant ratio");
579 }
580 if (!ShapeAlgo::AlgoContainer()->HomoWires
581 (wire1, wire2, newWire1, newWire2, st->IsRuledByParameter())) {
582 Message_Msg msg1255("IGES_1255");// "Ruled Surface Construction Error");
583 SendFail(st, msg1255);
584 return res;
585 }
586 nbEdges1 = 2; // a number > 1
587 }
588
589 else if (nbEdges1 != 1) {
590 newWire1 = wire1;
591 newWire2 = wire2;
592 }
593
594
595 if (nbEdges1 == 1) {
596
597 //:e3 abv 31 Mar 98: UK4.igs 3170: ruled surface with directixes - line
598 // In IGES, line is parametrised [0;1] - this should have been kept !
599 // Let us detect the case and remake curve as bspline [0;1]
600 for ( Standard_Integer i=1; i <=2; i++ ) {
601 //#43 rln 20.11.98 S4054 BUC50047 entity D463 (circles as generatrices [0, 2*PI])
602 //reparameterisation should be for all curves not with range [0, 1] (see IGES)
603 TopoDS_Edge edge = TopoDS::Edge ( i==1 ? shape1 : shape2 );
604 //ReparamCurve(edge);
605 TopLoc_Location L;
606 Standard_Real First, Last;
607 Handle (Geom_Curve) curve = Handle (Geom_Curve)::DownCast (BRep_Tool::Curve ( edge, L, First, Last )->Copy());
608 if ( Abs (First) <= Precision::PConfusion() && Abs (Last - 1.) <= Precision::PConfusion() ) continue;
609
610 Handle (Geom_BSplineCurve) bscurve;
611 if (!curve->IsKind (STANDARD_TYPE (Geom_BSplineCurve))) {
612 if (curve->FirstParameter() < First || curve->LastParameter() > Last)
613 curve = new Geom_TrimmedCurve (curve, First, Last);
614 bscurve = GeomConvert::CurveToBSplineCurve (curve, Convert_RationalC1);
615 }
616 else {
617 bscurve = Handle (Geom_BSplineCurve)::DownCast (curve);
618 bscurve->Segment (First, Last);
619 }
620 TColStd_Array1OfReal Knots(1, bscurve->NbKnots());
621 bscurve->Knots(Knots);
622 BSplCLib::Reparametrize (0., 1., Knots);
623 bscurve->SetKnots(Knots);
624
625 BRep_Builder B;
626 B.UpdateEdge ( edge, bscurve, L, Precision::Confusion() );
627 B.Range ( edge, 0., 1 );
628 if ( i ==1 ) shape1 = edge;
629 else shape2 = edge;
630 }
631
632 res = BRepFill::Face(TopoDS::Edge(shape1), TopoDS::Edge(shape2));
633 Handle(Geom_Surface) surf = BRep_Tool::Surface(TopoDS::Face(res));
634 if(surf->Continuity()==GeomAbs_C0) {
635 Message_Msg msg1250("IGES_1250");
636 SendWarning (st, msg1250);
637 }
638 }
639 else {
640 res = BRepFill::Shell(newWire1, newWire2);
641 }
642 if (res.IsNull()) {
643 Message_Msg msg1255("IGES_1255");// "Ruled Surface Construction Error");
644 SendFail(st, msg1255);
645 return res;
646 }
647
648
649 if (st->HasTransf()) {
650 gp_Trsf trsf;
651 SetEpsilon(1.E-04);
652 if (IGESData_ToolLocation::ConvertLocation
653 (GetEpsilon(),st->CompoundLocation(), trsf,GetUnitFactor())) {
654 TopLoc_Location shapeLoc(trsf);
655 res.Move(shapeLoc);
656 }
657 else {
658 Message_Msg msg1035("IGES_1035");
659 SendWarning(st,msg1035); // Transformation : not a similarity
660 }
661 }
662 return res;
663}
664
665
666//=======================================================================
667//function : TransferSurfaceOfRevolution
668//purpose :
669//=======================================================================
670
671TopoDS_Shape IGESToBRep_TopoSurface::TransferSurfaceOfRevolution
672 (const Handle(IGESGeom_SurfaceOfRevolution)& st)
673{ // Declaration of messages//
674 // DCE 22/12/98
675 //Message_Msg msg1005("IGES_1005");
676 ////////////////////////////////
677 TopoDS_Shape res;
678 if (st.IsNull()) {
679 Message_Msg msg1005("IGES_1005");
680 SendFail(st, msg1005);
681 return res;
682 }
683
684 IGESToBRep_TopoCurve TC(*this);
685 IGESToBRep_BasicCurve BC(*this);
686 Handle(IGESData_IGESEntity) igesGeneratrix = st->Generatrix();
687 Handle(IGESGeom_Line) igesAxis = st->AxisOfRevolution();
688
689 if (igesGeneratrix.IsNull() || !IGESToBRep::IsTopoCurve(igesGeneratrix) ) {
690 Message_Msg msg153("XSTEP_153");
691 SendFail(st, msg153);
692 // Generatrix Reading Error : Null IGESEntity
693 // Generatrix : Not Allowed IGESEntity.
694 return res;
695 }
696
697 DeclareAndCast(IGESGeom_Line,srgen,st->Generatrix());
698 if (!srgen.IsNull()) {
699 gp_Pnt gen1 = srgen->StartPoint();
700 gp_Pnt gen2 = srgen->EndPoint();
701 TheULength = gen1.Distance(gen2)*GetUnitFactor();
702 }
703
704 if (igesAxis.IsNull()) {
705 Message_Msg msg152("XSTEP_152");
706 SendFail(st, msg152);
707 return res;
708 }
709
710 //%13 pdn 15.02.99
711 TC.SetContinuity(0);
712 TopoDS_Shape generatrix = TC.TransferTopoCurve(igesGeneratrix);
713 if (generatrix.IsNull()) {
714 Message_Msg msg1156("IGES_1156");
715 const Standard_CString typeName("generatrix");
716 Handle(TCollection_HAsciiString) label = GetModel()->StringLabel(igesGeneratrix);
717 msg1156.Arg(typeName);
718 msg1156.Arg(label);
719 SendFail(st, msg1156);
720 // Generatrix Conversion Error.
721 return res;
722 }
723
724 gp_Trsf startLoc;
725 gp_Pnt pt1 = igesAxis->TransformedStartPoint(); //smh#11
726 gp_Pnt pt2 = igesAxis->TransformedEndPoint(); //smh#11
727 pt1.Scale(gp_Pnt(0,0,0),GetUnitFactor());
728 pt2.Scale(gp_Pnt(0,0,0),GetUnitFactor());
729 //#30 rln 19.10.98 To keep IGES surface normal CAS.CADE axis = reversed IGES axis
730 //CAS.CADE SA = 2*PI - IGES TA
731 //CAS.CADE TA = 2*PI - IGES SA
732 //gp_Ax1 revolAxis(pt1, gp_Dir(gp_Vec(pt1, pt2)));
733 //Standard_Real startAngle = st->StartAngle();
734 //Standard_Real endAngle = st->EndAngle();
735 gp_Ax1 revolAxis(pt1, gp_Dir( gp_Vec (pt2, pt1)));
c6541a0c
D
736 Standard_Real startAngle = 2 * M_PI - st->EndAngle();
737 Standard_Real endAngle = 2 * M_PI - st->StartAngle();
7fd59977 738 Standard_Real deltaAngle = endAngle - startAngle;
c6541a0c
D
739 Standard_Boolean IsFullAngle = ( deltaAngle > 2.*M_PI-Precision::PConfusion() );
740 if (IsFullAngle) deltaAngle = 2.*M_PI; // ** CKY 18-SEP-1996
7fd59977 741 // il faudra translater les courbes 2d de startAngle pour
742 // etre en phase IGES et BRep
743 startLoc.SetRotation(revolAxis, startAngle);
744 generatrix.Move(startLoc);
745
746 // PTV file D44-11325-6.igs OCC660 depends on OCC450
747 // PTV 29.05.2002 OCC450 create Surface of Revolution by native API
748 // file NIC_file5.igs
749 // (BRepPrimAPI_MakeRevol replace surface of revolution by plane then 3D and 2D curves are inconsistent;
750 // and 3D is ignored. As result shape is rectangle instead circle shape.
751 Handle(Geom_Curve) aBasisCurve;
752 {
753 try {
754 OCC_CATCH_SIGNALS
755 if (extractCurve3d(generatrix, aBasisCurve)) {
756 Handle(Geom_Surface) aResultSurf = new Geom_SurfaceOfRevolution(aBasisCurve, revolAxis);
757 if ( !aResultSurf.IsNull() && !IsFullAngle ) {
758 Standard_Real VF = aBasisCurve->FirstParameter();
759 Standard_Real VL = aBasisCurve->LastParameter();
760 // PTV 29.08.2002 begin of OCC663 Trim surface by correct parameters
761 Standard_Real UF = 0;
762 Standard_Real UL = endAngle - startAngle;;
763 //aResultSurf = new Geom_RectangularTrimmedSurface(aResultSurf, startAngle, endAngle, VF, VL);
764 aResultSurf = new Geom_RectangularTrimmedSurface(aResultSurf, UF, UL, VF, VL);
765 // PTV 29.08.2002 end of OCC663
766 }
767 if (!aResultSurf.IsNull()) {
1c72dff6 768 BRepBuilderAPI_MakeFace aMakeF(aResultSurf, Precision::Confusion());
7fd59977 769 if (aMakeF.IsDone()) res = aMakeF.Face();
770 }
771 }
772 }
773 catch (Standard_Failure) {
774#ifdef DEB
775 cout << "Warning: IgesToBRep_TopoSurface::TransferSurfaceOfRevolution(): exception by Geom: ";
776 Standard_Failure::Caught()->Print ( cout ); cout << endl;
777#endif
778 }
779 }
780
781 if ( res.IsNull() ) {
782 // do as usual.
783
784 BRepPrimAPI_MakeRevol revol(generatrix, revolAxis, deltaAngle);
785//mjm: si debug IsDone()est fait :
786// if (!revol.IsDone()) {
787// AddFail(st, "Revol Construction Error.");
788// return res;
789// }
790 res = revol.Shape();
791 }
792 //%13 pdn 15.02.99
793 if (res.ShapeType() == TopAbs_FACE) {
794 Handle(Geom_Surface) surf = BRep_Tool::Surface(TopoDS::Face(res));
795 if(surf->Continuity()==GeomAbs_C0) {
796 Message_Msg msg1250("IGES_1250");
797 SendWarning (st, msg1250);
798 }
799 }
800
801 if (st->HasTransf()) {
802 gp_Trsf trsf;
803 SetEpsilon(1.E-04);
804 if (IGESData_ToolLocation::ConvertLocation
805 (GetEpsilon(), st->CompoundLocation(), trsf, GetUnitFactor())) {
806 TopLoc_Location shapeLoc(trsf);
807 res.Move(shapeLoc);
808 }
809 else {
810 Message_Msg msg1035("IGES_1035");
811 SendWarning(st,msg1035); // Transformation : not a similarity
812 }
813 }
814
815 return res;
816}
817
818
819//=======================================================================
820//function : TransferTabulatedCylinder
821//purpose :
822//=======================================================================
823
824TopoDS_Shape IGESToBRep_TopoSurface::TransferTabulatedCylinder
825 (const Handle(IGESGeom_TabulatedCylinder)& st)
826{ // Declaration of messages//
827 // DCE 22/12/98
828 //Message_Msg msg1005("IGES_1005");
829 ////////////////////////////////
830 TopoDS_Shape res;
831 if (st.IsNull()) {
832 Message_Msg msg1005("IGES_1005");
833 SendFail(st, msg1005);
834 return res;
835 }
836
837 IGESToBRep_TopoCurve TC(*this);
838// TopoDS_Edge firstEdge;//commented by rln on 02/12/97
839
840 Handle(IGESData_IGESEntity) igesDirectrix = st->Directrix();
841 if (igesDirectrix.IsNull() || !IGESToBRep::IsTopoCurve(igesDirectrix) ) {
842 Message_Msg msg153("XSTEP_153");
843 SendFail(st, msg153);
844 // Directrix Reading Error : Null IGESEntity
845 //Directrix, not allowed IGESEntity
846 return res;
847 }
848
849 //%13 pdn 15.02.99
850 TC.SetContinuity(0);
851 TopoDS_Shape directrix = TC.TransferTopoCurve(igesDirectrix);
852 if (directrix.IsNull()) {
853 Message_Msg msg1156("IGES_1156");
854 const Standard_CString typeName("directrix");
855 Handle(TCollection_HAsciiString) label = GetModel()->StringLabel(igesDirectrix);
856 msg1156.Arg(typeName);
857 msg1156.Arg(label);
858 SendFail(st, msg1156);
859 // Directrix Conversion Error.
860 return res;
861 }
862
863 //modified by rln on 03/12/97
864 //TopoDS_Vertex firstVertex = TopExp::FirstVertex(firstEdge);
865 TopoDS_Vertex firstVertex, lastVertex;
866 ShapeAnalysis::FindBounds (directrix, firstVertex, lastVertex);
867 gp_Pnt pt1 = BRep_Tool::Pnt(firstVertex);
868 gp_Pnt pt2 = st->EndPoint();
869 pt2.Scale(gp_Pnt(0,0,0),GetUnitFactor());
870
871 TheULength = pt1.Distance(pt2);
872 if(TheULength < Precision::Confusion()) {
873 Message_Msg msg("Tabulated cylinder with zero length");
874 SendFail (st, msg); // TabulatedCylinder was built with continuity C0
875 return res;
876 }
877
878 // PTV file D44-11325-6.igs OCC660 depends on OCC450
879 // PTV 29.05.2002 OCC450 create Surface of LinearExtrusion by native API
880 // see description about problem in Surface of Revolution
881 Handle(Geom_Curve) aBasisCurve;
882 {
883 try {
884 OCC_CATCH_SIGNALS
885 if (extractCurve3d(directrix, aBasisCurve)) {
886 // PTV 29.08.2002 OCC663 file D44-11325-6.igs, entity 4640
887 if (igesDirectrix->IsKind(STANDARD_TYPE(IGESGeom_ConicArc))) {
888 // PTV 30.08.2002 remove regression on xloop k1.brep in face and brep mode.
889 Standard_Real tmpF, tmpL, tmpToler;
890 tmpF = aBasisCurve->FirstParameter();
891 tmpL = aBasisCurve->LastParameter();
892 tmpToler = Precision::PConfusion();
c6541a0c 893 if ( (fabs(tmpF) >= tmpToler) && (fabs(tmpL - 2*M_PI) >= tmpToler) )
7fd59977 894 reparamBSpline (aBasisCurve, tmpF, tmpL);
895 }
896 gp_Vec dir (pt1, pt2);
897 Handle(Geom_Surface) aResultSurf =
898 new Geom_SurfaceOfLinearExtrusion(aBasisCurve, dir);
899 if (!aResultSurf.IsNull()) {
900 aResultSurf =
901 new Geom_RectangularTrimmedSurface(aResultSurf,
902 aBasisCurve->FirstParameter(),
903 aBasisCurve->LastParameter(),
904 0., dir.Magnitude() );
1c72dff6 905 BRepBuilderAPI_MakeFace aMakeF(aResultSurf, Precision::Confusion());
7fd59977 906 if (aMakeF.IsDone()) res = aMakeF.Face();
907 }
908 }
909 }
910 catch (Standard_Failure) {
911#ifdef DEB
912 cout << "Warning: IgesToBRep_TopoSurface::TransferTabulatedCylinder(): exception by Geom: ";
913 Standard_Failure::Caught()->Print ( cout ); cout << endl;
914#endif
915 }
916 }
917
918 if ( res.IsNull() ) {
919 // do as usual.
920 BRepPrimAPI_MakePrism prism(directrix, gp_Vec(pt1, pt2));
921//mjm: si debug IsDone() est fait
922// if (!prism.IsDone()) {
923// AddFail(st, "Prism Construction Error.");
924// return res;
925// }
926 res = prism.Shape();
927 }
928 //#16 rln 08/04/98 coq-inf-support.igs entity 2105
929 //CAS.CADE can parametrize SurfaceOfLinearExtrusion with generatrix opposite to Vec(pt1, pt2)
930 //and with parametrization V > 0, while in IGES TabulatedCylinder is parametrized with positive V
931 //direction exactly in the direction Vec(pt1, pt2)
932 if (res.ShapeType() == TopAbs_FACE) {
933 Standard_Real UMin, UMax, VMin, VMax;
934 BRepTools::UVBounds (TopoDS::Face (res), UMin, UMax, VMin, VMax);
935 if (VMax <= Precision::PConfusion() && VMin < -Precision::PConfusion()) {
936 TheULength *= -1;
937 res.Reverse();
938 }
939 Handle(Geom_Surface) surf = BRep_Tool::Surface(TopoDS::Face(res));
940 if(surf->Continuity()==GeomAbs_C0) {
941 Message_Msg msg1250("IGES_1250");
942 SendWarning (st, msg1250);
943 }
944 }
945
946 if (st->HasTransf()) {
947 gp_Trsf trsf;
948 SetEpsilon(1.E-04);
949 if (IGESData_ToolLocation::ConvertLocation
950 (GetEpsilon(),st->CompoundLocation(), trsf, GetUnitFactor())) {
951 TopLoc_Location shapeLoc(trsf);
952 res.Move(shapeLoc);
953 }
954 else {
955 Message_Msg msg1035("IGES_1035");
956 SendWarning(st,msg1035); // Transformation : not a similarity
957 }
958 }
959 return res;
960}
961
962
963//=======================================================================
964//function : TransferOffsetSurface
965//purpose :
966//=======================================================================
967
968TopoDS_Shape IGESToBRep_TopoSurface::TransferOffsetSurface
969 (const Handle(IGESGeom_OffsetSurface)& st)
970{ // Declaration of messages//
971 // DCE 22/12/98
972 //Message_Msg msg1005("IGES_1005");
973 ////////////////////////////////
974 TopoDS_Shape res;
975 if (st.IsNull()) {
976 Message_Msg msg1005("IGES_1005");
977 SendFail(st, msg1005);
978 return res;
979 }
980
981 TopoDS_Shape igesShape;
982 TopoDS_Face face;
983 TopLoc_Location basisLoc;
984
985 Handle (IGESData_IGESEntity) igesSrf = st->Surface();
986 if (igesSrf.IsNull() || !IGESToBRep::IsTopoSurface(igesSrf) ) {
987 Message_Msg msg164("XSTEP_164");
988 SendFail(st, msg164);
989 // Basis Surface Reading Error : Null IGESEntity
990 // Basis Surface Transfer Error : Not Allowed IGESEntity
991 return res;
992 }
993
994 igesShape = TransferTopoSurface(igesSrf);
995 if (igesShape.IsNull()) {
996 Message_Msg msg1156("IGES_1156");
997 const Standard_CString typeName("basis surface");
998 Handle(TCollection_HAsciiString) label = GetModel()->StringLabel(igesSrf);
999 msg1156.Arg(typeName);
1000 msg1156.Arg(label);
1001 SendFail(st, msg1156); // Basis Surface Conversion Error.
1002 return res;
1003 }
1004
1005 TopAbs_ShapeEnum shapeEnum = igesShape.ShapeType();
1006 switch (shapeEnum) {
1007 case TopAbs_FACE :
1008 {
1009 face = TopoDS::Face(igesShape);
1010 break;
1011 }
1012 case TopAbs_SHELL :
1013 {
1014 SendWarning(st, "The First Surface only will be transfered.");
1015 TopoDS_Iterator dabovil(igesShape);
1016 if (dabovil.More()) {
1017 face = TopoDS::Face(dabovil.Value());
1018 break;
1019 }
1020 /* else AddF("... */
1021 }
1022 default:
1023 {
1024 Message_Msg msg1156("IGES_1156");
1025 const Standard_CString typeName("basis surface");
1026 Handle(TCollection_HAsciiString) label = GetModel()->StringLabel(igesSrf);
1027 msg1156.Arg(typeName);
1028 msg1156.Arg(label);
1029 SendFail(st, msg1156); // Basis Surface Conversion Error.
1030 return res;
1031 }
1032 }
1033
1034
1035 //Handle(Geom_Surface) geomSupport = BRep_Tool::Surface(face, basisLoc);
1036 // attention on ne peut construire une Geom_OffsetSurface que
1037 // si la surface de base est au moins C1, sinon on plante !
1038 //#56 rln 25.12.98 UKI60878 entity D593 (Offset surface on C0 B-Spline)
1039 //Trying to eliminate previous limitation on processing only C1 surfaces
1040 Handle(Geom_Surface) geomSupport = BRep_Tool::Surface(face);
1041 Handle(Geom_OffsetSurface) basisSrf;
1042
1043 if (geomSupport->IsKind(STANDARD_TYPE(Geom_OffsetSurface))) {
1044 DeclareAndCast(Geom_OffsetSurface, geom140, geomSupport);
1045 geom140->SetOffsetValue(basisSrf->Offset() +
1046 st->Distance()*GetUnitFactor());
1047 basisSrf = geom140;
1048 }
1049 else {
1050 if (geomSupport->Continuity() == GeomAbs_C0) {
1051 res = ShapeAlgo::AlgoContainer()->C0ShapeToC1Shape (face, Abs (st->Distance()) * GetUnitFactor());
1052 if(res.ShapeType()!=TopAbs_FACE) {
1053 Message_Msg msg1266("IGES_1266");
1054 SendFail(st, msg1266);//Basis surface is C0-continuous and cannot be corrected to C1-continuous.
1055 return res;
1056 }
1057 else {
1058 geomSupport = BRep_Tool::Surface (TopoDS::Face(res));
1059 if (geomSupport->Continuity() == GeomAbs_C0) {
1060 Message_Msg msg1266("IGES_1266");
1061 SendFail(st, msg1266);//Basis surface is C0-continuous and cannot be corrected to C1-continuous.
1062 res.Nullify();
1063 return res;
1064 }
1065 }
1066 Message_Msg msg1267("IGES_1267");
1067 SendWarning(st, msg1267);//Basis surface is C0-continuous but was corrected to C1-continuous
1068 }
1069 //smh#12
1070 if (res.IsNull()) res = face;
1071 geomSupport = BRep_Tool::Surface (TopoDS::Face(res));
1072 Standard_Real umin, umax, vmin, vmax;
1073 geomSupport->Bounds (umin, umax, vmin, vmax);
1074 if (Precision::IsInfinite (umin) || Precision::IsInfinite (umax) ||
1075 Precision::IsInfinite (vmin) || Precision::IsInfinite (vmax)) {
1076 // convert to C1 B-Spline
1077 BRepTools::UVBounds (face, umin, umax, vmin, vmax);
1078 Handle(Geom_RectangularTrimmedSurface) TS = new Geom_RectangularTrimmedSurface (geomSupport, umin, umax, vmin, vmax);
1079 Handle (Geom_BSplineSurface) BS = ShapeAlgo::AlgoContainer()->ConvertSurfaceToBSpline(TS, umin, umax, vmin, vmax);
1080 if (BS.IsNull() || BS->Continuity() == GeomAbs_C0) {
1081 Message_Msg msg1265("IGES_1265");
1082 SendFail(st, msg1265); // OffsetSurface Construction Error.
1083 return res;
1084 }
1085 else {
1086 geomSupport = BS;
1087 }
1088 }
1089 basisSrf = new Geom_OffsetSurface(geomSupport, st->Distance()*GetUnitFactor());
1090 }
1091
1c72dff6 1092 BRepLib_MakeFace MF(basisSrf, Precision::Confusion());
7fd59977 1093 if(!MF.IsDone()) {
1094 Message_Msg msg1265("IGES_1265");
1095 SendFail(st, msg1265); // OffsetSurface Construction Error.
1096 return res;
1097 }
1098
1099 res = MF.Face();
1100
1101 if (st->HasTransf()) {
1102 gp_Trsf trsf;
1103 SetEpsilon(1.E-04);
1104 if (IGESData_ToolLocation::ConvertLocation
1105 (GetEpsilon(),st->CompoundLocation(),trsf, GetUnitFactor())) {
1106 TopLoc_Location loc2(trsf);
1107 res.Move(loc2);
1108 }
1109 else {
1110 Message_Msg msg1035("IGES_1035");
1111 SendWarning(st,msg1035); // Transformation : not a similarity
1112 }
1113 }
1114 return res;
1115}
1116
1117
1118//=======================================================================
1119//function : TransferTrimmedSurface
1120//purpose :
1121//=======================================================================
1122
1123TopoDS_Shape IGESToBRep_TopoSurface::TransferTrimmedSurface
1124 (const Handle(IGESGeom_TrimmedSurface)& st)
1125{ // Declaration of messages//
1126 // DCE 22/12/98
1127 //Message_Msg msg1005("IGES_1005");
1128 ////////////////////////////////
1129 TopoDS_Shape res;
1130 if (st.IsNull()) {
1131 Message_Msg msg1005("IGES_1005");
1132 SendFail(st, msg1005);
1133 return res;
1134 }
1135
1136 TopAbs_ShapeEnum shapeEnum;
1137 IGESToBRep_TopoCurve TC(*this);
1138
1139 Handle (IGESData_IGESEntity) igesSurface = st->Surface();
1140 if (igesSurface.IsNull() || !IGESToBRep::IsTopoSurface(igesSurface) ) {
1141 Message_Msg msg169("XSTEP_169");
1142 SendFail(st, msg169);
1143 // BasicSurface Transfer Error : Null IGESEntity
1144 // Basis Surface, not Allowed IGESEntity.
1145 return res;
1146 }
1147 gp_Trsf2d trans;
1148 Standard_Real uFact;
1149 TopoDS_Face face, faceres;
1150
1151 TopoDS_Shape myshape = ParamSurface(igesSurface, trans, uFact);
1152
1153 if (!myshape.IsNull()) {
1154 shapeEnum = myshape.ShapeType();
1155 switch (shapeEnum) {
1156 case TopAbs_FACE :
1157 {
1158 face = TopoDS::Face(myshape);
1159 faceres = face;
1160 break;
1161 }
1162 case TopAbs_SHELL :
1163 {
1164 TopoDS_Iterator IT(myshape);
1165 Standard_Integer nbfaces = 0;
1166 for (; IT.More(); IT.Next()) {
1167 nbfaces++;
1168 face = TopoDS::Face(IT.Value());
1169 faceres = face;
1170 }
1171 //szv#4:S4163:12Mar99 optimized
1172 if (nbfaces != 1) {
1173 Message_Msg msg1156("IGES_1156");
1174 const Standard_CString typeName("basis surface");
1175 Handle(TCollection_HAsciiString) label = GetModel()->StringLabel(igesSurface);
1176 msg1156.Arg(typeName);
1177 msg1156.Arg(label);
1178 SendFail(st, msg1156); // Not Implemented Trimmed Composite Surface.
1179 return myshape;
1180 }
1181 }
1182 break;
1183 default:
1184 {
1185 Message_Msg msg1156("IGES_1156");
1186 const Standard_CString typeName("basis surface");
1187 Handle(TCollection_HAsciiString) label = GetModel()->StringLabel(igesSurface);
1188 msg1156.Arg(typeName);
1189 msg1156.Arg(label);
1190 SendFail(st, msg1156); // Basis Surface Conversion Error.
1191 return res;
1192 }
1193 }
1194 }
1195 else {
1196 return res;
1197 }
1198
1199 //obtaining a surface
1200 TopLoc_Location L;
1201 Handle(Geom_Surface) aSurf = BRep_Tool::Surface(face, L);
1202 TC.SetSurface(aSurf);
1203
1204 if (st->HasOuterContour()) {
1205 face.EmptyCopy();
1206 TopoDS_Shape myshape1 = TC.TransferCurveOnFace (face, st->OuterContour(), trans, uFact, Standard_False);
1207 // si ca se passe mal , on recupere au moins la face avec NaturalRestriction
1208 if (myshape1 .IsNull()) face = faceres;
1209 }
1210 for (Standard_Integer i = 1; i <= st->NbInnerContours(); i++) {
1211 TopoDS_Shape myshape2 = TC.TransferCurveOnFace (face, st->InnerContour(i), trans, uFact, Standard_False);
1212 }
1213 BRepTools::Update ( face ); //:p4
1214 //%16 pdn 08.04.99
1215 return face;
1216}
1217
1218
1219//=======================================================================
1220//function : TransferBoundedSurface
1221//purpose :
1222//=======================================================================
1223
1224TopoDS_Shape IGESToBRep_TopoSurface::TransferBoundedSurface
1225 (const Handle(IGESGeom_BoundedSurface)& st)
1226{ // Declaration of messages//
1227 // DCE 22/12/98
1228 //Message_Msg msg1005("IGES_1005");
1229 ////////////////////////////////
1230 TopoDS_Shape res;
1231 if (st.IsNull()) {
1232 Message_Msg msg1005("IGES_1005");
1233 SendFail(st, msg1005);
1234 return res;
1235 }
1236
1237 if (st->RepresentationType()==0) {
1238 Message_Msg msg1275("IGES_1275");
1239 SendWarning(st, msg1275);
1240 // Model Space Representation Not Implemented : the result will be the basis surface
1241 }
1242
1243 TopAbs_ShapeEnum shapeEnum;
1244 IGESToBRep_TopoCurve TC(*this);
1245 Handle (IGESData_IGESEntity) igesSrf = st->Surface();
1246 if (igesSrf.IsNull() || !IGESToBRep::IsTopoSurface(igesSrf) ) {
1247 Message_Msg msg166("XSTEP_166");
1248 SendFail( st, msg166);
1249 // Basis Surface Transfer Error : Null IGESEntity.
1250 // Basis Surface Transfer Error : Not Allowed IGESEntity.
1251 return res;
1252 }
1253 gp_Trsf2d trans;
1254 Standard_Real uFact;
1255 TopoDS_Face face;
1256
1257 TopoDS_Shape myshape = ParamSurface(igesSrf, trans, uFact);
1258
1259 if (myshape.IsNull()) {
1260 //#55 rln 24.12.98 UKI60878 entity D593
1261#ifdef DEB
1262 cout << "Fail: IGESToBRep_TopoSurface::TransferBoundedSurface UntrimmedSurface is translated into Null" << endl;
1263#endif
1264 return res;
1265 }
1266 else {
1267 shapeEnum = myshape.ShapeType();
1268 switch (shapeEnum) {
1269 case TopAbs_FACE :
1270 {
1271 face = TopoDS::Face(myshape);
1272 }
1273 break;
1274 case TopAbs_SHELL :
1275 {
1276 TopoDS_Iterator IT(myshape);
1277 Standard_Integer nbfaces = 0;
1278 for (; IT.More(); IT.Next()) {
1279 nbfaces++;
1280 face = TopoDS::Face(IT.Value());
1281 }
1282 //szv#4:S4163:12Mar99 optimized
1283 if (nbfaces != 1) {
1284 Message_Msg msg1156("IGES_1156");
1285 const Standard_CString typeName("basis surface");
1286 Handle(TCollection_HAsciiString) label = GetModel()->StringLabel(igesSrf);
1287 msg1156.Arg(typeName);
1288 msg1156.Arg(label);
1289 SendFail(st, msg1156);
1290 // Not Implemented Trimmed Composite Surface.
1291 return myshape;
1292 }
1293 }
1294 break;
1295 default:
1296 {
1297 Message_Msg msg1156("IGES_1156");
1298 const Standard_CString typeName("basis surface");
1299 Handle(TCollection_HAsciiString) label = GetModel()->StringLabel(igesSrf);
1300 msg1156.Arg(typeName);
1301 msg1156.Arg(label);
1302 SendFail(st, msg1156);
1303 return res;
1304 }
1305 }
1306 }
1307
1308 face.EmptyCopy();
1309 for (Standard_Integer i = 1; i <= st->NbBoundaries(); i++)
1310 TC.TransferBoundaryOnFace(face, st->Boundary(i), trans, uFact);
1311
1312 BRepTools::Update ( face ); //:p4
1313 //#22 rln 01.06.98 UK3.igs entity 1279
1314// ShapeFix_Face sff ( face );
1315// sff.FixMissingSeam(); //:l1 abv 10 Jan 99: USA60022 7289: fix missing seam
1316// if(sff.FixSmallAreaWire()) { //%14 pdn 24.02,99: USA60293: fix small area wires.
1317// AddFail(st, "Small area wire detected, dropped");
1318// }
1319// sff.FixOrientation();
1320// face = sff.Face();
1321 //%16 pdn 08.04.99
1322 return face;
1323}
1324
1325
1326//=======================================================================
1327//function : TransferPlane
1328//purpose :
1329//=======================================================================
1330
1331TopoDS_Shape IGESToBRep_TopoSurface::TransferPlane
1332 (const Handle(IGESGeom_Plane)& st)
1333{ // Declaration of messages//
1334 // DCE 22/12/98
1335 //Message_Msg msg1005("IGES_1005");
1336 ////////////////////////////////
1337 TopoDS_Shape res;
1338 if (st.IsNull()) {
1339 Message_Msg msg1005("IGES_1005");
1340 SendFail(st, msg1005);
1341 return res;
1342 }
1343
1344 gp_Pln pln;
1345 gp_Trsf trsf;
1346 res = TransferPlaneParts (st, pln,trsf,Standard_True);
1347// res contient (en principe ...) une Face avec eventuellement un Wire
1348// il reste a la mettre en position
1349 if (trsf.Form() != gp_Identity) {
1350 TopLoc_Location loc(trsf);
1351 res.Location(loc);
1352 }
1353 return res;
1354}
1355
1356
1357//=======================================================================
1358//function : TransferPlaneSurface
1359//purpose : this function transferred into IGESToBRep_BasicSurface
1360//=======================================================================
1361
1362
1363//=======================================================================
1364//function : TransferPerforate
1365//purpose :
1366//=======================================================================
1367
1368TopoDS_Shape IGESToBRep_TopoSurface::TransferPerforate
1369 (const Handle(IGESBasic_SingleParent)& st)
1370{ // Declaration of messages//
1371 // DCE 22/12/98
1372 //Message_Msg msg1005("IGES_1005");
1373 ////////////////////////////////
1374 TopoDS_Shape res;
1375 if (st.IsNull()) {
1376 Message_Msg msg1005("IGES_1005");
1377 SendFail(st, msg1005);
1378 return res;
1379 }
1380
1381 //char mess[100];
1382 gp_Pln pln;
1383 gp_Trsf trsf;
1384 DeclareAndCast(IGESGeom_Plane,p0,st->SingleParent());
1385 BRep_Builder B;
1386 if (p0.IsNull()) {
1387 Message_Msg msg206("XSTEP_206");
1388 SendFail(st, msg206);
1389 // SingleParent does not describe a holed face
1390 return res;
1391 }
1392 res = TransferPlaneParts (p0,pln,trsf,Standard_True);
1393//res demarre avec la face et son contour externe
1394 Standard_Integer nb = st->NbChildren();
1395 for (Standard_Integer i = 1; i <= nb; i ++) {
1396 DeclareAndCast(IGESGeom_Plane,pi,st->Child(i));
1397 if (pi.IsNull()) {
1398 Message_Msg msg1285("IGES_1285");
1399 msg1285.Arg(i);
1400 // A child is not a Plane, skipped, n0 %d
1401 SendWarning(st,msg1285);
1402 continue;
1403 }
1404 gp_Pln pli;
1405 gp_Trsf trsi;
1406 TopoDS_Shape wire = TransferPlaneParts (pi,pli,trsi,Standard_False);
1407// si ce n est pas un Wire, sauter
1408 if (wire.ShapeType() != TopAbs_WIRE) {
1409 Message_Msg msg1156("IGES_1156");
1410 const Standard_CString typeName("hole");
1411 Handle(TCollection_HAsciiString) label = GetModel()->StringLabel(pi);
1412 msg1156.Arg(typeName);
1413 msg1156.Arg(label);
1414 SendWarning(st, msg1156);
1415 // A hole could not be transferred, skipped, n0 %d
1416 continue;
1417 }
1418// coplanaires ? verifier
1419 if (!pln.Position().IsCoplanar(pli.Position(),GetEpsGeom(),GetEpsilon())) {
1420 Message_Msg msg1295("IGES_1295");
1421 msg1295.Arg(i);
1422 SendWarning(st,msg1295);
1423 // "A hole is not well coplanar to the face, n0 %d",i);
1424 }
1425// Ne pas oublier de composer la transformation locale a ce Wire
1426 if (trsi.Form() != gp_Identity) {
1427 TopLoc_Location locw(trsi);
1428 wire.Location(locw);
1429 }
1430 B.Add (res,wire);
1431 }
1432// Enfin, appliquer la trsf globale
1433 if (trsf.Form() != gp_Identity) {
1434 TopLoc_Location loc(trsf);
1435 res.Location(loc);
1436 }
1437 return res;
1438}
1439
1440
1441//=======================================================================
1442//function : TransferPlaneParts
1443//purpose :
1444//=======================================================================
1445TopoDS_Shape IGESToBRep_TopoSurface::TransferPlaneParts(const Handle(IGESGeom_Plane)& st,
1446 gp_Pln& pln,
1447 gp_Trsf& trsf,
1448 const Standard_Boolean first)
1449{ // Declaration of messages//
1450 // DCE 22/12/98
1451 //Message_Msg msg1005("IGES_1005");
1452 ////////////////////////////////
1453 TopoDS_Shape res;
1454 if (st.IsNull()) {
1455 Message_Msg msg1005("IGES_1005");
1456 SendFail(st, msg1005);
1457 return res;
1458 }
1459
1460 Standard_Real a, b, c, d;
1461 // equation de Geom : ax + by + cz + d = 0.0;
1462 // equation de IGES : ax + by + cz = d;
1463 st->Equation(a, b, c, d);
1464 pln = gp_Pln(a, b, c, -d);
1465
1466 TopoDS_Face plane;
1467 TopoDS_Wire wire;
1468 BRep_Builder B;
1469 if (first) {
1470 B.MakeFace(plane); // Just to create a empty Plane with a Tshape.
1471 Handle (Geom_Plane) geomPln = new Geom_Plane(pln);
1472 geomPln->Scale(gp_Pnt(0,0,0),GetUnitFactor());
1473// ATTENTION, ici on CALCULE la trsf, on ne l`applique pas ...
1474 //S4054: B.UpdateFace (plane, geomPln, TopLoc_Location(),
1475 //GetEpsGeom()*GetUnitFactor());
1476 B.UpdateFace (plane, geomPln, TopLoc_Location(), Precision::Confusion());
1477 //:3 by ABV 5 Nov 97: set Infinite() flag (see below for unsetting)
1478 plane.Infinite ( Standard_True ); //:3
1479 }
1480
1481// ATTENTION, ici on CALCULE la trsf, on ne l'appliquera qu'a la fin !
1482 if (st->HasTransf()) {
1483 SetEpsilon(1.E-04);
1484 if (!IGESData_ToolLocation::ConvertLocation
1485 (GetEpsilon(), st->CompoundLocation(),trsf,GetUnitFactor())) {
1486 Message_Msg msg1035("IGES_1035");
1487 SendWarning(st,msg1035); // Transformation : not a similarity
1488 }
1489 }
1490
1491 if (st->HasBoundingCurve()) {
1492 IGESToBRep_TopoCurve TC(*this);
1493 Handle(IGESData_IGESEntity) crv = st->BoundingCurve();
1494
1495 if (crv.IsNull()) {
1496 Message_Msg msg1300("IGES_1300");
1497 SendWarning(st,msg1300);
1498 //:4 by ABV 5 Nov 97: plane cannot be trimmed - let it be infinite
1499 //:4 NOTE: NB "else"
1500 //:4 return res;
1501 }
1502 else //:4
1503
1504 if (IGESToBRep::IsTopoCurve(crv)) {
1505 gp_Trsf trans;
1506 if (crv->IsKind(STANDARD_TYPE(IGESGeom_CurveOnSurface))) {
1507 DeclareAndCast(IGESGeom_CurveOnSurface, crv142, crv);
1508 if(st->HasBoundingCurveHole()) {
1509 TopoDS_Shape myshape = TC.TransferCurveOnFace (plane, crv142, trans, TheULength, Standard_False);
1510 }
1511 else {
1512 TopoDS_Shape myshape = TC.TransferCurveOnFace (plane, crv142, trans, TheULength, Standard_False);
1513 }
1514 //:3 by ABV 5 Nov 97: set plane to be finite
1515 if ( first ) {
1516 TopExp_Explorer ws ( plane, TopAbs_WIRE );
1517 if ( ws.More() ) plane.Infinite ( Standard_False );
1518 }
1519 }
1520 else {
1521 TopoDS_Shape shape = TC.TransferTopoCurve(crv);
1522 TopAbs_ShapeEnum shapeEnum = shape.ShapeType();
1523 switch (shapeEnum) {
1524 case TopAbs_EDGE :
1525 {
1526 TopoDS_Edge edge = TopoDS::Edge(shape);
1527 Handle(ShapeExtend_WireData) sewd = new ShapeExtend_WireData;
1528 sewd->Add(edge);
1529 wire = sewd->Wire();
1530 }
1531 break;
1532 case TopAbs_WIRE :
1533 {
1534 wire = TopoDS::Wire(shape);
1535 }
1536 break;
1537 default:
1538 {
1539 Message_Msg msg1156("IGES_1156");
1540 const Standard_CString typeName("Bounding curve");
1541 Handle(TCollection_HAsciiString) label = GetModel()->StringLabel(crv);
1542 msg1156.Arg(typeName);
1543 msg1156.Arg(label);
1544 SendWarning(st, msg1156);
1545 if (first) res = plane;
1546 else res = wire;
1547 return res;
1548 }
1549 }
1550 //S4054 CTS18953 entity 14
1551 Handle(ShapeFix_Wire) sfw = new ShapeFix_Wire;
1552 sfw->Load (wire);
1553 sfw->FixConnected (GetMaxTol());
1554 wire = sfw->Wire();
1555 BRepLib_MakeFace MF(pln, wire, Standard_False);
1556 if (!MF.IsDone()) {
1557 // AddFail(st, "Plane Construction Error.");
1558 return res;
1559 }
1560
1561 TopoDS_Face F = MF.Face();
1562 GProp_GProps G;
1563 BRepGProp::SurfaceProperties(F,G);
1564 if (G.Mass() < 0) {
1565 if(!st->HasBoundingCurveHole())
1566 wire.Reverse();
1567 }
1568 else
1569 if( st->HasBoundingCurveHole())
1570 wire.Reverse();
1571 //:3 by ABV 5 Nov 97: set plane to be finite
1572 //:3 if (first) B.Add (plane,wire);
1573 if ( first ) {
1574 B.Add ( plane, wire );
1575 plane.Infinite ( Standard_False );
1576 }
1577 //BRepLib_MakeFace MP(pln, wire);
1578 //plane = MP.Face();
1579 }
1580 }
1581 else {
1582 Message_Msg msg1156("IGES_1156");
1583 const Standard_CString typeName("Bounding curve");
1584 Handle(TCollection_HAsciiString) label = GetModel()->StringLabel(crv);
1585 msg1156.Arg(typeName);
1586 msg1156.Arg(label);
1587 SendWarning(st, msg1156);
1588 // Plane Cannot Be Trimmed.
1589 }
1590 }
1591
1592 if (first) res = plane;
1593 else res = wire;
1594 return res;
1595}
1596
1597
1598//=======================================================================
1599//function : ParamSurface
1600//purpose :
1601//=======================================================================
1602TopoDS_Shape IGESToBRep_TopoSurface::ParamSurface(const Handle(IGESData_IGESEntity)& st,
1603 gp_Trsf2d& trans,
1604 Standard_Real& uFact)
1605{ // Declaration of messages//
1606 // DCE 22/12/98
1607 //Message_Msg msg1005("IGES_1005");
1608 ////////////////////////////////
1609
1610 TopoDS_Shape res;
1611
1612 TopoDS_Shape basisSurface = TransferTopoSurface(st);
1613 Standard_Real uscale = 1.;
1614 Standard_Real cscale = TheULength;
1615 if (basisSurface.IsNull()) {
1616 Message_Msg msg1005("IGES_1005");
1617 SendFail(st, msg1005);
1618 return res;
1619 }
1620
1621 TopAbs_ShapeEnum shapeEnum;
1622 shapeEnum = basisSurface.ShapeType();
1623 TopoDS_Face face;
1624 switch (shapeEnum) {
1625 case TopAbs_FACE :
1626 {
1627 face = TopoDS::Face(basisSurface);
1628 break;
1629 }
1630 case TopAbs_SHELL :
1631 {
1632 TopoDS_Iterator IT(basisSurface);
1633 Standard_Integer nbfaces = 0;
1634 for (; IT.More(); IT.Next()) {
1635 nbfaces++;
1636 face = TopoDS::Face(IT.Value());
1637 }
1638 //szv#4:S4163:12Mar99 optimized
1639 if (nbfaces != 1) {
1640 Message_Msg msg1156("IGES_1156");
1641 const Standard_CString typeName("basis surface");
1642 Handle(TCollection_HAsciiString) label = GetModel()->StringLabel(st);
1643 msg1156.Arg(typeName);
1644 msg1156.Arg(label);
1645 SendWarning(st, msg1156);
1646 return basisSurface;
1647 }
1648 }
1649 break;
1650 default:
1651 {
1652 //AddFail(st, "Basis Surface Transfer Error.");
1653 return res;
1654 }
1655 }
1656
1657 //S4181 pdn 19.04.99 defining shift of parametric space on base
1658 // of CAS.CADE type of surface
1659 Standard_Real paramu = 0., paramv = 0.;
1660 TopLoc_Location L;
1661 TopoDS_Edge theedge;
1662 Handle(Geom_Surface) Surf = BRep_Tool::Surface(face);
1663
1664 if (Surf->IsKind(STANDARD_TYPE(Geom_RectangularTrimmedSurface))) {
1665 DeclareAndCast(Geom_RectangularTrimmedSurface, rectang, Surf);
1666 Surf = rectang->BasisSurface();
1667 }
1668
1669 if ((Surf->IsKind(STANDARD_TYPE(Geom_CylindricalSurface))) ||
1670 (Surf->IsKind(STANDARD_TYPE(Geom_ConicalSurface))) ||
1671 (Surf->IsKind(STANDARD_TYPE(Geom_ToroidalSurface))) ||
1672 (Surf->IsKind(STANDARD_TYPE(Geom_SphericalSurface)))) {
1673 TopExp_Explorer TE;
1674 for ( TE.Init(face,TopAbs_EDGE); TE.More(); TE.Next()){
1675 TopoDS_Edge myedge = TopoDS::Edge(TE.Current());
1676 Standard_Real First, Last;
1677 Handle(Geom2d_Curve) Curve2d = BRep_Tool::CurveOnSurface
1678 (myedge, face, First, Last);
1679 if ( Curve2d->IsKind(STANDARD_TYPE(Geom2d_Line))) {
1680 DeclareAndCast(Geom2d_Line, Line2d, Curve2d);
1681 if (Line2d->Direction().IsParallel(gp::DY2d(),Precision::Angular())){
1682 theedge = myedge;
1683 break;
1684 }
1685 }
1686 }
1687
1688 Standard_Real First, Last;
1689 Handle(Geom_Curve) Curve3d = BRep_Tool::Curve(theedge, First, Last);
1690 if (Precision::IsNegativeInfinite(First)) First = 0.;
1691
1692 if (Surf->IsKind(STANDARD_TYPE(Geom_CylindricalSurface))){
1693 DeclareAndCast(Geom_CylindricalSurface, Cyl, Surf);
1694 gp_Cylinder TheCyl = Cyl->Cylinder();
1695 ElSLib::CylinderParameters(TheCyl.Position(),
1696 TheCyl.Radius(),
1697 Curve3d->Value(First), paramu , paramv );
1698 }
1699
1700 else if (Surf->IsKind(STANDARD_TYPE(Geom_ConicalSurface))){
1701 DeclareAndCast(Geom_ConicalSurface, Cone, Surf);
1702 gp_Cone TheCone = Cone->Cone();
1703 ElSLib::ConeParameters(TheCone.Position(),
1704 TheCone.RefRadius(),
1705 TheCone.SemiAngle(),
1706 Curve3d->Value(First), paramu , paramv );
1707 }
1708
1709 else if (Surf->IsKind(STANDARD_TYPE(Geom_ToroidalSurface))){
1710 DeclareAndCast(Geom_ToroidalSurface, Tore, Surf);
1711 gp_Torus TheTore = Tore->Torus();
1712 ElSLib::TorusParameters(TheTore.Position(),
1713 TheTore.MajorRadius(),
1714 TheTore.MinorRadius(),
1715 Curve3d->Value(First), paramu , paramv );
1716 }
1717 else if (Surf->IsKind(STANDARD_TYPE(Geom_SphericalSurface)) &&
1718 //: abv 18.06.02: loopback on s1.brep BRep mode, face 32 - the spherical surface (192)
1719 //: in IGES is from [-90,90] by V, i.e. similar to OCC, thus only scaling is enough
1720 ! st->IsKind (STANDARD_TYPE(IGESSolid_SphericalSurface)) ) {
1721 DeclareAndCast(Geom_SphericalSurface, Sphere, Surf);
1722 gp_Sphere TheSphere = Sphere->Sphere();
1723 ElSLib::SphereParameters(TheSphere.Position(),
1724 TheSphere.Radius(),
1725 Curve3d->Value(First), paramu , paramv );
1726 }
1727
1728 //#88 rln 06.04.99 CTS60168, BLEND.IGS entity 68
1729 //Generatrix is Transformed Circular Arc. When creating CAS.CADE surface parameterization
1730 //has changed.
1731 if (st->IsKind (STANDARD_TYPE (IGESGeom_SurfaceOfRevolution))) {
1732 DeclareAndCast (IGESGeom_SurfaceOfRevolution, revol, st);
1733 Handle(IGESData_IGESEntity) generatrix = revol->Generatrix();
1734 if (generatrix->IsKind (STANDARD_TYPE (IGESGeom_CircularArc))) {
1735 DeclareAndCast (IGESGeom_CircularArc, circ, generatrix);
1736 gp_Pnt2d startpoint = circ->StartPoint();
1737 paramv -= ElCLib::Parameter (gp_Circ2d (gp_Ax2d (circ->Center(), gp_Dir2d(1,0)), circ->Radius()), startpoint);
1738 if (Surf->IsKind (STANDARD_TYPE(Geom_SphericalSurface)))
c6541a0c 1739 paramv += ShapeAnalysis::AdjustToPeriod(paramv, - M_PI, M_PI);
7fd59977 1740 else if (Surf->IsKind (STANDARD_TYPE(Geom_ToroidalSurface)))
c6541a0c 1741 paramv += ShapeAnalysis::AdjustToPeriod(paramv, 0, M_PI * 2);
7fd59977 1742 }
1743 }
1744 else if (st->IsKind (STANDARD_TYPE (IGESGeom_TabulatedCylinder))) {
1745 DeclareAndCast (IGESGeom_TabulatedCylinder, cylinder, st);
1746 Handle(IGESData_IGESEntity) directrix = cylinder->Directrix();
1747 if (directrix->IsKind (STANDARD_TYPE (IGESGeom_CircularArc))) {
1748 DeclareAndCast (IGESGeom_CircularArc, circ, directrix);
1749 gp_Pnt2d startpoint = circ->StartPoint();
1750 paramu -= ElCLib::Parameter (gp_Circ2d (gp_Ax2d (circ->Center(), gp_Dir2d(1,0)), circ->Radius()), startpoint);
c6541a0c 1751 paramu += ShapeAnalysis::AdjustToPeriod(paramu, 0, M_PI * 2);
7fd59977 1752 }
1753 }
1754
1755 }
1756
1757 if ( Abs(paramu) <= Precision::Confusion()) paramu = 0.;
1758 if ( Abs(paramv) <= Precision::Confusion()) paramv = 0.;
1759
1760 //S4181 pdn 16.04.99 computation of transformation depending on
1761 //IGES Type of surface
1762 Handle(IGESData_IGESEntity) isrf = st;
1763 if (isrf->IsKind(STANDARD_TYPE(IGESGeom_OffsetSurface))){
1764 DeclareAndCast(IGESGeom_OffsetSurface, offsurf, isrf);
1765 isrf = offsurf->Surface();
1766 }
1767 if (isrf->IsKind(STANDARD_TYPE(IGESGeom_SurfaceOfRevolution))) {
1768 DeclareAndCast(IGESGeom_SurfaceOfRevolution, st120, isrf);
1769 //S4181 pdn 19.04.99 defining transformation matrix
1770 gp_Trsf2d tmp;
c6541a0c 1771 tmp.SetTranslation(gp_Vec2d (0, -2 * M_PI));
7fd59977 1772 trans.PreMultiply(tmp);
1773 tmp.SetMirror(gp::OX2d());
1774 trans.PreMultiply(tmp);
1775 tmp.SetMirror(gp_Ax2d (gp::Origin2d(), gp_Dir2d (1.,1.)));
1776 trans.PreMultiply(tmp);
1777 uscale = 1./cscale;
1778 //#30 rln 19.10.98
1779 //CAS.CADE SA = 2*PI - IGES TA
1780 //paramu = st120->StartAngle();
c6541a0c 1781 paramu = -(2 * M_PI - st120->EndAngle());
7fd59977 1782 }
1783 else
1784 paramu = 0.;
1785
1786 if (isrf->IsKind(STANDARD_TYPE(IGESGeom_RuledSurface))) {
1787 uscale = 1./cscale;
1788 }
1789
1790 // corrected skl 13.11.2001 for BUC61054
1791 if (isrf->IsKind(STANDARD_TYPE(IGESGeom_TabulatedCylinder))) {
1792 Handle(IGESGeom_TabulatedCylinder) igtc = Handle(IGESGeom_TabulatedCylinder)::DownCast(isrf);
1793 Handle(IGESData_IGESEntity) idie = igtc->Directrix();
1794 Standard_Real uln=1;
1795 if(idie->TypeNumber()==110) {
1796 Handle(IGESGeom_Line) igl = Handle(IGESGeom_Line)::DownCast(idie);
1797 gp_Pnt SP = igl->StartPoint();
1798 gp_Pnt EP = igl->EndPoint();
1799 // PTV OCC659
1800 // PTV file D44-11325-6.igs. Faces with parametric curves need * GetUnitFactor();
1801 uln=SP.Distance(EP) * GetUnitFactor();
1802 }
1803 uscale = uln/cscale;
1804 }
1805
1806 if (isrf->IsKind(STANDARD_TYPE(IGESSolid_CylindricalSurface))||
1807 isrf->IsKind(STANDARD_TYPE(IGESSolid_ConicalSurface))) {
c6541a0c 1808 uscale = M_PI/180.;
7fd59977 1809 }
1810
1811 if (isrf->IsKind(STANDARD_TYPE(IGESSolid_SphericalSurface))) {
c6541a0c 1812 cscale = M_PI/180.;
7fd59977 1813 uscale = 1.;
1814 }
1815
1816 if (isrf->IsKind(STANDARD_TYPE(IGESSolid_ToroidalSurface))) {
1817 gp_Trsf2d tmp;
1818 tmp.SetTranslation(gp_Vec2d (0, -360.)); // in IGES terms
1819 trans.PreMultiply(tmp);
1820 tmp.SetMirror(gp::OX2d());
1821 trans.PreMultiply(tmp);
1822 tmp.SetMirror(gp_Ax2d (gp::Origin2d(), gp_Dir2d (1.,1.)));
1823 trans.PreMultiply(tmp);
1824 if(paramv > 0)
c6541a0c
D
1825 paramv = paramv*180./M_PI;
1826 cscale = M_PI/180.;
7fd59977 1827 uscale = 1.;
1828 }
1829
1830 gp_Trsf2d tmp;
1831 tmp.SetTranslation(gp_Pnt2d(0.,0.), gp_Pnt2d(paramu,paramv));
1832 trans.PreMultiply(tmp);
1833
1834 tmp.SetScale(gp_Pnt2d(0,0),cscale);
1835 trans.PreMultiply(tmp);
1836 uFact = uscale;
1837 return face;
1838}
1839