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