1 //=======================================================================
2 //file : IGESToBRep_TopoSurface
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 //=======================================================================
20 #include <IGESToBRep_TopoSurface.ixx>
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>
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>
42 #include <GProp_GProps.hxx>
44 #include <GeomAbs_Shape.hxx>
46 #include <Geom2d_Line.hxx>
47 #include <Geom2d_Curve.hxx>
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>
61 #include <IGESData_IGESEntity.hxx>
62 #include <IGESData_ToolLocation.hxx>
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>
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>
77 #include <Interface_Macros.hxx>
79 #include <gp_GTrsf.hxx>
81 #include <Precision.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>
95 #include <TopExp_Explorer.hxx>
97 #include <TopLoc_Location.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>
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>
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>
129 #include <Message_Msg.hxx>
130 #include <IGESData_IGESModel.hxx>
132 #include <IGESGeom_CircularArc.hxx>
133 #include <ElCLib.hxx>
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>
143 //=======================================================================
144 //function : IGESToBRep_TopoSurface
146 //=======================================================================
148 IGESToBRep_TopoSurface::IGESToBRep_TopoSurface()
149 :IGESToBRep_CurveAndSurface()
154 //=======================================================================
155 //function : IGESToBRep_TopoSurface
157 //=======================================================================
159 IGESToBRep_TopoSurface::IGESToBRep_TopoSurface
160 (const IGESToBRep_CurveAndSurface& CS)
161 :IGESToBRep_CurveAndSurface(CS)
166 //=======================================================================
167 //function : IGESToBRep_TopoSurface
169 //=======================================================================
171 IGESToBRep_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)
183 static Standard_Boolean extractCurve3d (const TopoDS_Shape& theEdges,
184 Handle(Geom_Curve)& theCurve)
186 TopExp_Explorer anExp(theEdges, TopAbs_EDGE);
187 Standard_Integer howMuch = 0;
189 for (; anExp.More(); anExp.Next()) {
190 TopoDS_Edge anEdge = TopoDS::Edge(anExp.Current());
194 theCurve = BRep_Tool::Curve(anEdge, f, l);
196 if ( howMuch != 1 || theCurve.IsNull() )
197 return Standard_False;
199 if ( f != theCurve->FirstParameter() || l != theCurve->LastParameter() )
200 theCurve = new Geom_TrimmedCurve ( theCurve, f, l );
201 return Standard_True;
205 //=======================================================================
206 //function : TransferTopoSurface
208 //=======================================================================
210 TopoDS_Shape IGESToBRep_TopoSurface::TransferTopoSurface
211 (const Handle(IGESData_IGESEntity)& st)
212 { // Declaration of messages//
214 //Message_Msg msg1005("IGES_1005");
215 ////////////////////////////
221 Message_Msg msg1005("IGES_1005");
222 SendFail(st, msg1005);
224 ////modified by jgv, 20.11.2009 for OCC21487///
225 else if (HasShapeResult(st))
227 res = GetShapeResult(st);
230 ///////////////////////////////////////////////
231 else if (IGESToBRep::IsBasicSurface(st)) {
232 res = TransferTopoBasicSurface(st);
234 else if (st->IsKind(STANDARD_TYPE(IGESGeom_TrimmedSurface))) {
235 DeclareAndCast(IGESGeom_TrimmedSurface, st144, st);
236 res = TransferTrimmedSurface(st144);
238 else if (st->IsKind(STANDARD_TYPE(IGESGeom_SurfaceOfRevolution))) {
239 DeclareAndCast(IGESGeom_SurfaceOfRevolution, st120, st);
240 res = TransferSurfaceOfRevolution(st120);
242 else if (st->IsKind(STANDARD_TYPE(IGESGeom_TabulatedCylinder))) {
243 DeclareAndCast(IGESGeom_TabulatedCylinder, st122, st);
244 res = TransferTabulatedCylinder(st122);
246 else if (st->IsKind(STANDARD_TYPE(IGESGeom_RuledSurface))) {
247 DeclareAndCast(IGESGeom_RuledSurface, st118, st);
248 res = TransferRuledSurface(st118);
250 else if (st->IsKind(STANDARD_TYPE(IGESGeom_Plane))) {
251 DeclareAndCast(IGESGeom_Plane, st108, st);
252 res = TransferPlane(st108);
254 else if (st->IsKind(STANDARD_TYPE(IGESGeom_BoundedSurface))) {
255 DeclareAndCast(IGESGeom_BoundedSurface, st143, st);
256 res = TransferBoundedSurface(st143);
258 else if (st->IsKind(STANDARD_TYPE(IGESGeom_OffsetSurface))) {
259 DeclareAndCast(IGESGeom_OffsetSurface, st140, st);
260 res = TransferOffsetSurface(st140);
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
268 // AddFail(st, "The IGESEntity is not a Topologic Surface.");
270 SetShapeResult (st, res);
274 //=======================================================================
275 //function : TransferTopoBasicSurface
277 //=======================================================================
279 TopoDS_Shape IGESToBRep_TopoSurface::TransferTopoBasicSurface
280 (const Handle(IGESData_IGESEntity)& st)
281 { // Declaration of messages//
283 //Message_Msg msg1005("IGES_1005");
284 ////////////////////////////
289 Message_Msg msg1005("IGES_1005");
290 SendFail(st, msg1005);
293 if (!IGESToBRep::IsBasicSurface(st)) {
294 // AddFail(st, "BasicSurface Transfer Error : Not Allowed IGESEntity"); This message can not occur.
298 IGESToBRep_BasicSurface BS(*this);
300 Handle(Geom_Surface) surf = BS.TransferBasicSurface(st);
302 // AddFail(st, "Surface Conversion Error"); Messages have ever been Added in the called function.
306 //#9 rln 26/02/98 UKI60106
307 if (surf->Continuity() < GeomAbs_C1) {
308 Message_Msg msg1250("IGES_1250");
309 SendWarning(st, msg1250);
311 if(surf->IsKind(STANDARD_TYPE(Geom_Plane))){
315 B.UpdateFace(plane, surf, TopLoc_Location(), Precision::Confusion());
319 BRepLib_MakeFace makeFace(surf, Precision::Confusion());
320 res = makeFace.Face();
323 if (st->HasTransf()) {
326 if (IGESData_ToolLocation::ConvertLocation
327 (GetEpsilon(),st->CompoundLocation(),trsf,GetUnitFactor())) {
328 TopLoc_Location locFace(trsf);
332 Message_Msg msg1035("IGES_1035");
333 SendWarning(st, msg1035);
340 //=======================================================================
341 //function : TransferRuledSurface
343 //=======================================================================
344 static void reparamBSpline(Handle(Geom_Curve)& curve,
345 const Standard_Real First,
346 const Standard_Real Last)
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);
355 bscurve = Handle (Geom_BSplineCurve)::DownCast (curve);
356 bscurve->Segment (First, Last);
359 if (bscurve.IsNull())
362 TColStd_Array1OfReal Knots(1, bscurve->NbKnots());
363 bscurve->Knots(Knots);
364 BSplCLib::Reparametrize (0., 1., Knots);
365 bscurve->SetKnots(Knots);
369 static void ReparamCurve(TopoDS_Edge& edge)
372 Standard_Real First, Last;
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;
378 reparamBSpline( curve, First, Last );
381 B.UpdateEdge ( edge, curve, L, Precision::Confusion() );
382 B.Range ( edge, 0., 1 );
386 //=======================================================================
387 //function : TransferRuledSurface
389 //=======================================================================
391 TopoDS_Shape IGESToBRep_TopoSurface::TransferRuledSurface
392 (const Handle(IGESGeom_RuledSurface)& st)
393 { // Declaration of messages//
395 //Message_Msg msg1005("IGES_1005");
396 ////////////////////////////////
400 Message_Msg msg1005("IGES_1005");
401 SendFail(st, msg1005);
405 IGESToBRep_TopoCurve TC(*this);
407 TC.SetContinuity (0);
408 Handle(IGESData_IGESEntity) igesCurve1 = st->FirstCurve();
409 Handle(IGESData_IGESEntity) igesCurve2 = st->SecondCurve();
411 if (igesCurve1.IsNull()) {
412 Message_Msg msg148("XSTEP_148");
413 SendFail(st, msg148); // Curve Reading Error : Null IGESEntity
416 if (igesCurve2.IsNull()) {
417 Message_Msg msg149("XSTEP_149");
418 SendFail(st, msg149); // Curve Reading Error : Null IGESEntity
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
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);
436 SendFail(st, msg1156);
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);
460 // Message_Msg msg1250("IGES_1250");
461 // SendWarning (st, msg1250); // RuledSurface was built with continuity C0
465 TopAbs_ShapeEnum shapeEnum1 = shape1.ShapeType();
466 switch (shapeEnum1) {
469 TopoDS_Edge edge1 = TopoDS::Edge(shape1);
476 wire1 = TopoDS::Wire(shape1);
478 for (TopoDS_Iterator hulot(wire1); hulot.More(); hulot.Next()) {
479 TopoDS_Edge edge1 = TopoDS::Edge(hulot.Value());
487 // AddFail(st, "Curve Conversion Error."); This message can not occur.
490 //break; //szv#4:S4163:12Mar99 unreachable
494 Message_Msg msg148("XSTEP_148");
495 SendFail(st, msg148);
496 // Curve Type not Allowed.
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
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);
511 SendFail(st, msg1156);
512 // Curve Conversion Error.
515 Standard_Integer dirflag = st->DirectionFlag ();
516 // if (dirflag == 1){ // gka BUC60685
521 TopAbs_ShapeEnum shapeEnum2 = shape2.ShapeType();
522 switch (shapeEnum2) {
525 TopoDS_Edge edge2 = TopoDS::Edge(shape2);
534 wire2 = TopoDS::Wire(shape2);
536 for (TopoDS_Iterator cousto(wire2); cousto.More(); cousto.Next()) {
537 TopoDS_Edge edge2 = TopoDS::Edge(cousto.Value());
541 if (dirflag == 1) { //gka BUC60685
542 Handle(ShapeExtend_WireData) sewd2 = new ShapeExtend_WireData;
545 wire2 = sewd2->Wire();
551 // AddFail(st, "Curve Conversion Error.");
554 //break; //szv#4:S4163:12Mar99 unreachable
558 Message_Msg msg149("XSTEP_149");
559 SendFail(st, msg149);
560 // Curve Type not Allowed
565 if (nbEdges1 != nbEdges2) {
567 Handle(ShapeExtend_WireData) sewd1 = new ShapeExtend_WireData;
569 wire1 = sewd1->Wire();
571 else if (nbEdges2 == 1) {
572 Handle(ShapeExtend_WireData) sewd2 = new ShapeExtend_WireData;
574 wire2 = sewd2->Wire();
577 if (!st->IsRuledByParameter()) {
578 // AddWarning (st,"Compute by parametric constant ratio");
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);
586 nbEdges1 = 2; // a number > 1
589 else if (nbEdges1 != 1) {
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);
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;
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);
617 bscurve = Handle (Geom_BSplineCurve)::DownCast (curve);
618 bscurve->Segment (First, Last);
620 TColStd_Array1OfReal Knots(1, bscurve->NbKnots());
621 bscurve->Knots(Knots);
622 BSplCLib::Reparametrize (0., 1., Knots);
623 bscurve->SetKnots(Knots);
626 B.UpdateEdge ( edge, bscurve, L, Precision::Confusion() );
627 B.Range ( edge, 0., 1 );
628 if ( i ==1 ) shape1 = edge;
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);
640 res = BRepFill::Shell(newWire1, newWire2);
643 Message_Msg msg1255("IGES_1255");// "Ruled Surface Construction Error");
644 SendFail(st, msg1255);
649 if (st->HasTransf()) {
652 if (IGESData_ToolLocation::ConvertLocation
653 (GetEpsilon(),st->CompoundLocation(), trsf,GetUnitFactor())) {
654 TopLoc_Location shapeLoc(trsf);
658 Message_Msg msg1035("IGES_1035");
659 SendWarning(st,msg1035); // Transformation : not a similarity
666 //=======================================================================
667 //function : TransferSurfaceOfRevolution
669 //=======================================================================
671 TopoDS_Shape IGESToBRep_TopoSurface::TransferSurfaceOfRevolution
672 (const Handle(IGESGeom_SurfaceOfRevolution)& st)
673 { // Declaration of messages//
675 //Message_Msg msg1005("IGES_1005");
676 ////////////////////////////////
679 Message_Msg msg1005("IGES_1005");
680 SendFail(st, msg1005);
684 IGESToBRep_TopoCurve TC(*this);
685 IGESToBRep_BasicCurve BC(*this);
686 Handle(IGESData_IGESEntity) igesGeneratrix = st->Generatrix();
687 Handle(IGESGeom_Line) igesAxis = st->AxisOfRevolution();
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.
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();
704 if (igesAxis.IsNull()) {
705 Message_Msg msg152("XSTEP_152");
706 SendFail(st, msg152);
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);
719 SendFail(st, msg1156);
720 // Generatrix Conversion Error.
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)));
736 Standard_Real startAngle = 2 * PI - st->EndAngle();
737 Standard_Real endAngle = 2 * PI - st->StartAngle();
738 Standard_Real deltaAngle = endAngle - startAngle;
739 Standard_Boolean IsFullAngle = ( deltaAngle > 2.*PI-Precision::PConfusion() );
740 if (IsFullAngle) deltaAngle = 2.*PI; // ** CKY 18-SEP-1996
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);
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;
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
767 if (!aResultSurf.IsNull()) {
768 BRepBuilderAPI_MakeFace aMakeF(aResultSurf, Precision::Confusion());
769 if (aMakeF.IsDone()) res = aMakeF.Face();
773 catch (Standard_Failure) {
775 cout << "Warning: IgesToBRep_TopoSurface::TransferSurfaceOfRevolution(): exception by Geom: ";
776 Standard_Failure::Caught()->Print ( cout ); cout << endl;
781 if ( res.IsNull() ) {
784 BRepPrimAPI_MakeRevol revol(generatrix, revolAxis, deltaAngle);
785 //mjm: si debug IsDone()est fait :
786 // if (!revol.IsDone()) {
787 // AddFail(st, "Revol Construction Error.");
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);
801 if (st->HasTransf()) {
804 if (IGESData_ToolLocation::ConvertLocation
805 (GetEpsilon(), st->CompoundLocation(), trsf, GetUnitFactor())) {
806 TopLoc_Location shapeLoc(trsf);
810 Message_Msg msg1035("IGES_1035");
811 SendWarning(st,msg1035); // Transformation : not a similarity
819 //=======================================================================
820 //function : TransferTabulatedCylinder
822 //=======================================================================
824 TopoDS_Shape IGESToBRep_TopoSurface::TransferTabulatedCylinder
825 (const Handle(IGESGeom_TabulatedCylinder)& st)
826 { // Declaration of messages//
828 //Message_Msg msg1005("IGES_1005");
829 ////////////////////////////////
832 Message_Msg msg1005("IGES_1005");
833 SendFail(st, msg1005);
837 IGESToBRep_TopoCurve TC(*this);
838 // TopoDS_Edge firstEdge;//commented by rln on 02/12/97
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
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);
858 SendFail(st, msg1156);
859 // Directrix Conversion Error.
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());
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
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;
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();
893 if ( (fabs(tmpF) >= tmpToler) && (fabs(tmpL - 2*PI) >= tmpToler) )
894 reparamBSpline (aBasisCurve, tmpF, tmpL);
896 gp_Vec dir (pt1, pt2);
897 Handle(Geom_Surface) aResultSurf =
898 new Geom_SurfaceOfLinearExtrusion(aBasisCurve, dir);
899 if (!aResultSurf.IsNull()) {
901 new Geom_RectangularTrimmedSurface(aResultSurf,
902 aBasisCurve->FirstParameter(),
903 aBasisCurve->LastParameter(),
904 0., dir.Magnitude() );
905 BRepBuilderAPI_MakeFace aMakeF(aResultSurf, Precision::Confusion());
906 if (aMakeF.IsDone()) res = aMakeF.Face();
910 catch (Standard_Failure) {
912 cout << "Warning: IgesToBRep_TopoSurface::TransferTabulatedCylinder(): exception by Geom: ";
913 Standard_Failure::Caught()->Print ( cout ); cout << endl;
918 if ( res.IsNull() ) {
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.");
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()) {
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);
946 if (st->HasTransf()) {
949 if (IGESData_ToolLocation::ConvertLocation
950 (GetEpsilon(),st->CompoundLocation(), trsf, GetUnitFactor())) {
951 TopLoc_Location shapeLoc(trsf);
955 Message_Msg msg1035("IGES_1035");
956 SendWarning(st,msg1035); // Transformation : not a similarity
963 //=======================================================================
964 //function : TransferOffsetSurface
966 //=======================================================================
968 TopoDS_Shape IGESToBRep_TopoSurface::TransferOffsetSurface
969 (const Handle(IGESGeom_OffsetSurface)& st)
970 { // Declaration of messages//
972 //Message_Msg msg1005("IGES_1005");
973 ////////////////////////////////
976 Message_Msg msg1005("IGES_1005");
977 SendFail(st, msg1005);
981 TopoDS_Shape igesShape;
983 TopLoc_Location basisLoc;
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
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);
1001 SendFail(st, msg1156); // Basis Surface Conversion Error.
1005 TopAbs_ShapeEnum shapeEnum = igesShape.ShapeType();
1006 switch (shapeEnum) {
1009 face = TopoDS::Face(igesShape);
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());
1020 /* else AddF("... */
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);
1029 SendFail(st, msg1156); // Basis Surface Conversion Error.
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;
1043 if (geomSupport->IsKind(STANDARD_TYPE(Geom_OffsetSurface))) {
1044 DeclareAndCast(Geom_OffsetSurface, geom140, geomSupport);
1045 geom140->SetOffsetValue(basisSrf->Offset() +
1046 st->Distance()*GetUnitFactor());
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.
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.
1066 Message_Msg msg1267("IGES_1267");
1067 SendWarning(st, msg1267);//Basis surface is C0-continuous but was corrected to C1-continuous
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.
1089 basisSrf = new Geom_OffsetSurface(geomSupport, st->Distance()*GetUnitFactor());
1092 BRepLib_MakeFace MF(basisSrf, Precision::Confusion());
1094 Message_Msg msg1265("IGES_1265");
1095 SendFail(st, msg1265); // OffsetSurface Construction Error.
1101 if (st->HasTransf()) {
1104 if (IGESData_ToolLocation::ConvertLocation
1105 (GetEpsilon(),st->CompoundLocation(),trsf, GetUnitFactor())) {
1106 TopLoc_Location loc2(trsf);
1110 Message_Msg msg1035("IGES_1035");
1111 SendWarning(st,msg1035); // Transformation : not a similarity
1118 //=======================================================================
1119 //function : TransferTrimmedSurface
1121 //=======================================================================
1123 TopoDS_Shape IGESToBRep_TopoSurface::TransferTrimmedSurface
1124 (const Handle(IGESGeom_TrimmedSurface)& st)
1125 { // Declaration of messages//
1127 //Message_Msg msg1005("IGES_1005");
1128 ////////////////////////////////
1131 Message_Msg msg1005("IGES_1005");
1132 SendFail(st, msg1005);
1136 TopAbs_ShapeEnum shapeEnum;
1137 IGESToBRep_TopoCurve TC(*this);
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.
1148 Standard_Real uFact;
1149 TopoDS_Face face, faceres;
1151 TopoDS_Shape myshape = ParamSurface(igesSurface, trans, uFact);
1153 if (!myshape.IsNull()) {
1154 shapeEnum = myshape.ShapeType();
1155 switch (shapeEnum) {
1158 face = TopoDS::Face(myshape);
1164 TopoDS_Iterator IT(myshape);
1165 Standard_Integer nbfaces = 0;
1166 for (; IT.More(); IT.Next()) {
1168 face = TopoDS::Face(IT.Value());
1171 //szv#4:S4163:12Mar99 optimized
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);
1178 SendFail(st, msg1156); // Not Implemented Trimmed Composite Surface.
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);
1190 SendFail(st, msg1156); // Basis Surface Conversion Error.
1199 //obtaining a surface
1201 Handle(Geom_Surface) aSurf = BRep_Tool::Surface(face, L);
1202 TC.SetSurface(aSurf);
1204 if (st->HasOuterContour()) {
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;
1210 for (Standard_Integer i = 1; i <= st->NbInnerContours(); i++) {
1211 TopoDS_Shape myshape2 = TC.TransferCurveOnFace (face, st->InnerContour(i), trans, uFact, Standard_False);
1213 BRepTools::Update ( face ); //:p4
1219 //=======================================================================
1220 //function : TransferBoundedSurface
1222 //=======================================================================
1224 TopoDS_Shape IGESToBRep_TopoSurface::TransferBoundedSurface
1225 (const Handle(IGESGeom_BoundedSurface)& st)
1226 { // Declaration of messages//
1228 //Message_Msg msg1005("IGES_1005");
1229 ////////////////////////////////
1232 Message_Msg msg1005("IGES_1005");
1233 SendFail(st, msg1005);
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
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.
1254 Standard_Real uFact;
1257 TopoDS_Shape myshape = ParamSurface(igesSrf, trans, uFact);
1259 if (myshape.IsNull()) {
1260 //#55 rln 24.12.98 UKI60878 entity D593
1262 cout << "Fail: IGESToBRep_TopoSurface::TransferBoundedSurface UntrimmedSurface is translated into Null" << endl;
1267 shapeEnum = myshape.ShapeType();
1268 switch (shapeEnum) {
1271 face = TopoDS::Face(myshape);
1276 TopoDS_Iterator IT(myshape);
1277 Standard_Integer nbfaces = 0;
1278 for (; IT.More(); IT.Next()) {
1280 face = TopoDS::Face(IT.Value());
1282 //szv#4:S4163:12Mar99 optimized
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);
1289 SendFail(st, msg1156);
1290 // Not Implemented Trimmed Composite Surface.
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);
1302 SendFail(st, msg1156);
1309 for (Standard_Integer i = 1; i <= st->NbBoundaries(); i++)
1310 TC.TransferBoundaryOnFace(face, st->Boundary(i), trans, uFact);
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");
1319 // sff.FixOrientation();
1320 // face = sff.Face();
1326 //=======================================================================
1327 //function : TransferPlane
1329 //=======================================================================
1331 TopoDS_Shape IGESToBRep_TopoSurface::TransferPlane
1332 (const Handle(IGESGeom_Plane)& st)
1333 { // Declaration of messages//
1335 //Message_Msg msg1005("IGES_1005");
1336 ////////////////////////////////
1339 Message_Msg msg1005("IGES_1005");
1340 SendFail(st, msg1005);
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);
1357 //=======================================================================
1358 //function : TransferPlaneSurface
1359 //purpose : this function transferred into IGESToBRep_BasicSurface
1360 //=======================================================================
1363 //=======================================================================
1364 //function : TransferPerforate
1366 //=======================================================================
1368 TopoDS_Shape IGESToBRep_TopoSurface::TransferPerforate
1369 (const Handle(IGESBasic_SingleParent)& st)
1370 { // Declaration of messages//
1372 //Message_Msg msg1005("IGES_1005");
1373 ////////////////////////////////
1376 Message_Msg msg1005("IGES_1005");
1377 SendFail(st, msg1005);
1384 DeclareAndCast(IGESGeom_Plane,p0,st->SingleParent());
1387 Message_Msg msg206("XSTEP_206");
1388 SendFail(st, msg206);
1389 // SingleParent does not describe a holed face
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));
1398 Message_Msg msg1285("IGES_1285");
1400 // A child is not a Plane, skipped, n0 %d
1401 SendWarning(st,msg1285);
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);
1414 SendWarning(st, msg1156);
1415 // A hole could not be transferred, skipped, n0 %d
1418 // coplanaires ? verifier
1419 if (!pln.Position().IsCoplanar(pli.Position(),GetEpsGeom(),GetEpsilon())) {
1420 Message_Msg msg1295("IGES_1295");
1422 SendWarning(st,msg1295);
1423 // "A hole is not well coplanar to the face, n0 %d",i);
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);
1432 // Enfin, appliquer la trsf globale
1433 if (trsf.Form() != gp_Identity) {
1434 TopLoc_Location loc(trsf);
1441 //=======================================================================
1442 //function : TransferPlaneParts
1444 //=======================================================================
1445 TopoDS_Shape IGESToBRep_TopoSurface::TransferPlaneParts(const Handle(IGESGeom_Plane)& st,
1448 const Standard_Boolean first)
1449 { // Declaration of messages//
1451 //Message_Msg msg1005("IGES_1005");
1452 ////////////////////////////////
1455 Message_Msg msg1005("IGES_1005");
1456 SendFail(st, msg1005);
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);
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
1481 // ATTENTION, ici on CALCULE la trsf, on ne l'appliquera qu'a la fin !
1482 if (st->HasTransf()) {
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
1491 if (st->HasBoundingCurve()) {
1492 IGESToBRep_TopoCurve TC(*this);
1493 Handle(IGESData_IGESEntity) crv = st->BoundingCurve();
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"
1504 if (IGESToBRep::IsTopoCurve(crv)) {
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);
1512 TopoDS_Shape myshape = TC.TransferCurveOnFace (plane, crv142, trans, TheULength, Standard_False);
1514 //:3 by ABV 5 Nov 97: set plane to be finite
1516 TopExp_Explorer ws ( plane, TopAbs_WIRE );
1517 if ( ws.More() ) plane.Infinite ( Standard_False );
1521 TopoDS_Shape shape = TC.TransferTopoCurve(crv);
1522 TopAbs_ShapeEnum shapeEnum = shape.ShapeType();
1523 switch (shapeEnum) {
1526 TopoDS_Edge edge = TopoDS::Edge(shape);
1527 Handle(ShapeExtend_WireData) sewd = new ShapeExtend_WireData;
1529 wire = sewd->Wire();
1534 wire = TopoDS::Wire(shape);
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);
1544 SendWarning(st, msg1156);
1545 if (first) res = plane;
1550 //S4054 CTS18953 entity 14
1551 Handle(ShapeFix_Wire) sfw = new ShapeFix_Wire;
1553 sfw->FixConnected (GetMaxTol());
1555 BRepLib_MakeFace MF(pln, wire, Standard_False);
1557 // AddFail(st, "Plane Construction Error.");
1561 TopoDS_Face F = MF.Face();
1563 BRepGProp::SurfaceProperties(F,G);
1565 if(!st->HasBoundingCurveHole())
1569 if( st->HasBoundingCurveHole())
1571 //:3 by ABV 5 Nov 97: set plane to be finite
1572 //:3 if (first) B.Add (plane,wire);
1574 B.Add ( plane, wire );
1575 plane.Infinite ( Standard_False );
1577 //BRepLib_MakeFace MP(pln, wire);
1578 //plane = MP.Face();
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);
1587 SendWarning(st, msg1156);
1588 // Plane Cannot Be Trimmed.
1592 if (first) res = plane;
1598 //=======================================================================
1599 //function : ParamSurface
1601 //=======================================================================
1602 TopoDS_Shape IGESToBRep_TopoSurface::ParamSurface(const Handle(IGESData_IGESEntity)& st,
1604 Standard_Real& uFact)
1605 { // Declaration of messages//
1607 //Message_Msg msg1005("IGES_1005");
1608 ////////////////////////////////
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);
1621 TopAbs_ShapeEnum shapeEnum;
1622 shapeEnum = basisSurface.ShapeType();
1624 switch (shapeEnum) {
1627 face = TopoDS::Face(basisSurface);
1632 TopoDS_Iterator IT(basisSurface);
1633 Standard_Integer nbfaces = 0;
1634 for (; IT.More(); IT.Next()) {
1636 face = TopoDS::Face(IT.Value());
1638 //szv#4:S4163:12Mar99 optimized
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);
1645 SendWarning(st, msg1156);
1646 return basisSurface;
1652 //AddFail(st, "Basis Surface Transfer Error.");
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.;
1661 TopoDS_Edge theedge;
1662 Handle(Geom_Surface) Surf = BRep_Tool::Surface(face);
1664 if (Surf->IsKind(STANDARD_TYPE(Geom_RectangularTrimmedSurface))) {
1665 DeclareAndCast(Geom_RectangularTrimmedSurface, rectang, Surf);
1666 Surf = rectang->BasisSurface();
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)))) {
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())){
1688 Standard_Real First, Last;
1689 Handle(Geom_Curve) Curve3d = BRep_Tool::Curve(theedge, First, Last);
1690 if (Precision::IsNegativeInfinite(First)) First = 0.;
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(),
1697 Curve3d->Value(First), paramu , paramv );
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 );
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 );
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(),
1725 Curve3d->Value(First), paramu , paramv );
1728 //#88 rln 06.04.99 CTS60168, BLEND.IGS entity 68
1729 //Generatrix is Transformed Circular Arc. When creating CAS.CADE surface parameterization
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)))
1739 paramv += ShapeAnalysis::AdjustToPeriod(paramv, - PI, PI);
1740 else if (Surf->IsKind (STANDARD_TYPE(Geom_ToroidalSurface)))
1741 paramv += ShapeAnalysis::AdjustToPeriod(paramv, 0, PI * 2);
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);
1751 paramu += ShapeAnalysis::AdjustToPeriod(paramu, 0, PI * 2);
1757 if ( Abs(paramu) <= Precision::Confusion()) paramu = 0.;
1758 if ( Abs(paramv) <= Precision::Confusion()) paramv = 0.;
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();
1767 if (isrf->IsKind(STANDARD_TYPE(IGESGeom_SurfaceOfRevolution))) {
1768 DeclareAndCast(IGESGeom_SurfaceOfRevolution, st120, isrf);
1769 //S4181 pdn 19.04.99 defining transformation matrix
1771 tmp.SetTranslation(gp_Vec2d (0, -2 * PI));
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);
1779 //CAS.CADE SA = 2*PI - IGES TA
1780 //paramu = st120->StartAngle();
1781 paramu = -(2 * PI - st120->EndAngle());
1786 if (isrf->IsKind(STANDARD_TYPE(IGESGeom_RuledSurface))) {
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();
1800 // PTV file D44-11325-6.igs. Faces with parametric curves need * GetUnitFactor();
1801 uln=SP.Distance(EP) * GetUnitFactor();
1803 uscale = uln/cscale;
1806 if (isrf->IsKind(STANDARD_TYPE(IGESSolid_CylindricalSurface))||
1807 isrf->IsKind(STANDARD_TYPE(IGESSolid_ConicalSurface))) {
1811 if (isrf->IsKind(STANDARD_TYPE(IGESSolid_SphericalSurface))) {
1816 if (isrf->IsKind(STANDARD_TYPE(IGESSolid_ToroidalSurface))) {
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);
1825 paramv = paramv*180./PI;
1831 tmp.SetTranslation(gp_Pnt2d(0.,0.), gp_Pnt2d(paramu,paramv));
1832 trans.PreMultiply(tmp);
1834 tmp.SetScale(gp_Pnt2d(0,0),cscale);
1835 trans.PreMultiply(tmp);