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