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