1 // Created on: 1993-06-15
2 // Created by: Martine LANGLOIS
3 // Copyright (c) 1993-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
6 // This file is part of Open CASCADE Technology software library.
8 // This library is free software; you can redistribute it and/or modify it under
9 // the terms of the GNU Lesser General Public License version 2.1 as published
10 // by the Free Software Foundation, with special exception defined in the file
11 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12 // distribution for complete text of the license and disclaimer of any warranty.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
17 #include <StepToGeom.hxx>
19 #include <BRep_Tool.hxx>
20 #include <BRepBuilderAPI_MakeFace.hxx>
23 #include <Geom_Axis1Placement.hxx>
24 #include <Geom_Axis2Placement.hxx>
25 #include <Geom_BoundedCurve.hxx>
26 #include <Geom_BoundedSurface.hxx>
27 #include <Geom_BSplineCurve.hxx>
28 #include <Geom_BSplineSurface.hxx>
29 #include <Geom_CartesianPoint.hxx>
30 #include <Geom_Circle.hxx>
31 #include <Geom_Conic.hxx>
32 #include <Geom_ConicalSurface.hxx>
33 #include <Geom_Curve.hxx>
34 #include <Geom_CylindricalSurface.hxx>
35 #include <Geom_Direction.hxx>
36 #include <Geom_ElementarySurface.hxx>
37 #include <Geom_Ellipse.hxx>
38 #include <Geom_Hyperbola.hxx>
39 #include <Geom_Line.hxx>
40 #include <Geom_OffsetCurve.hxx>
41 #include <Geom_OffsetSurface.hxx>
42 #include <Geom_Parabola.hxx>
43 #include <Geom_Plane.hxx>
44 #include <Geom_RectangularTrimmedSurface.hxx>
45 #include <Geom_SphericalSurface.hxx>
46 #include <Geom_Surface.hxx>
47 #include <Geom_SurfaceOfLinearExtrusion.hxx>
48 #include <Geom_SurfaceOfRevolution.hxx>
49 #include <Geom_SweptSurface.hxx>
50 #include <Geom_ToroidalSurface.hxx>
51 #include <Geom_TrimmedCurve.hxx>
52 #include <Geom_VectorWithMagnitude.hxx>
54 #include <Geom2d_AxisPlacement.hxx>
55 #include <Geom2d_BoundedCurve.hxx>
56 #include <Geom2d_BSplineCurve.hxx>
57 #include <Geom2d_CartesianPoint.hxx>
58 #include <Geom2d_Circle.hxx>
59 #include <Geom2d_Conic.hxx>
60 #include <Geom2d_Curve.hxx>
61 #include <Geom2d_Direction.hxx>
62 #include <Geom2d_Ellipse.hxx>
63 #include <Geom2d_Hyperbola.hxx>
64 #include <Geom2d_Line.hxx>
65 #include <Geom2d_Parabola.hxx>
66 #include <Geom2d_TrimmedCurve.hxx>
67 #include <Geom2d_VectorWithMagnitude.hxx>
68 #include <Geom2dConvert.hxx>
70 #include <gp_Trsf.hxx>
71 #include <gp_Trsf2d.hxx>
73 #include <gp_Lin2d.hxx>
75 #include <ShapeAlgo.hxx>
76 #include <ShapeAlgo_AlgoContainer.hxx>
77 #include <ShapeAnalysis_Curve.hxx>
79 #include <StepGeom_Axis1Placement.hxx>
80 #include <StepGeom_Axis2Placement2d.hxx>
81 #include <StepGeom_Axis2Placement3d.hxx>
82 #include <StepGeom_BoundedCurve.hxx>
83 #include <StepGeom_BoundedSurface.hxx>
84 #include <StepGeom_BSplineCurve.hxx>
85 #include <StepGeom_CartesianPoint.hxx>
86 #include <StepGeom_Direction.hxx>
88 #include <Standard_ErrorHandler.hxx>
89 #include <Standard_Failure.hxx>
91 #include <StepGeom_BezierCurve.hxx>
92 #include <StepGeom_BezierSurface.hxx>
93 #include <StepGeom_BSplineSurface.hxx>
94 #include <StepGeom_BSplineCurveWithKnots.hxx>
95 #include <StepGeom_BSplineCurveWithKnotsAndRationalBSplineCurve.hxx>
96 #include <StepGeom_BSplineSurfaceWithKnots.hxx>
97 #include <StepGeom_BSplineSurfaceWithKnotsAndRationalBSplineSurface.hxx>
98 #include <StepGeom_Circle.hxx>
99 #include <StepGeom_Conic.hxx>
100 #include <StepGeom_ConicalSurface.hxx>
101 #include <StepGeom_Curve.hxx>
102 #include <StepGeom_CurveReplica.hxx>
103 #include <StepGeom_CylindricalSurface.hxx>
104 #include <StepGeom_ElementarySurface.hxx>
105 #include <StepGeom_Ellipse.hxx>
106 #include <StepGeom_Hyperbola.hxx>
107 #include <StepGeom_Line.hxx>
108 #include <StepGeom_OffsetCurve3d.hxx>
109 #include <StepGeom_OffsetSurface.hxx>
110 #include <StepGeom_Parabola.hxx>
111 #include <StepGeom_Plane.hxx>
112 #include <StepGeom_Polyline.hxx>
113 #include <StepGeom_QuasiUniformCurve.hxx>
114 #include <StepGeom_QuasiUniformCurveAndRationalBSplineCurve.hxx>
115 #include <StepGeom_QuasiUniformSurface.hxx>
116 #include <StepGeom_QuasiUniformSurfaceAndRationalBSplineSurface.hxx>
117 #include <StepGeom_RectangularTrimmedSurface.hxx>
118 #include <StepGeom_SphericalSurface.hxx>
119 #include <StepGeom_Surface.hxx>
120 #include <StepGeom_SurfaceCurve.hxx>
121 #include <StepGeom_SurfaceOfLinearExtrusion.hxx>
122 #include <StepGeom_SurfaceOfRevolution.hxx>
123 #include <StepGeom_SurfaceReplica.hxx>
124 #include <StepGeom_SweptSurface.hxx>
125 #include <StepGeom_ToroidalSurface.hxx>
126 #include <StepGeom_CartesianTransformationOperator2d.hxx>
127 #include <StepGeom_CartesianTransformationOperator3d.hxx>
128 #include <StepGeom_TrimmedCurve.hxx>
129 #include <StepGeom_UniformCurve.hxx>
130 #include <StepGeom_UniformCurveAndRationalBSplineCurve.hxx>
131 #include <StepGeom_UniformSurface.hxx>
132 #include <StepGeom_UniformSurfaceAndRationalBSplineSurface.hxx>
133 #include <StepGeom_Vector.hxx>
135 #include <TopoDS.hxx>
136 #include <TopoDS_Face.hxx>
138 #include <StepData_GlobalFactors.hxx>
140 //=============================================================================
141 // Creation d' un Ax1Placement de Geom a partir d' un axis1_placement de Step
142 //=============================================================================
144 Handle(Geom_Axis1Placement) StepToGeom::MakeAxis1Placement (const Handle(StepGeom_Axis1Placement)& SA)
146 Handle(Geom_CartesianPoint) P = MakeCartesianPoint (SA->Location());
149 // sln 22.10.2001. CTS23496: If problems with creation of axis direction occur default direction is used
153 Handle(Geom_Direction) D1 = MakeDirection (SA->Axis());
157 return new Geom_Axis1Placement(P->Pnt(),D);
162 //=============================================================================
163 // Creation d' un Axis2Placement de Geom a partir d' un axis2_placement_3d de Step
164 //=============================================================================
166 Handle(Geom_Axis2Placement) StepToGeom::MakeAxis2Placement (const Handle(StepGeom_Axis2Placement3d)& SA)
168 Handle(Geom_CartesianPoint) P = MakeCartesianPoint (SA->Location());
171 const gp_Pnt Pgp = P->Pnt();
173 // sln 22.10.2001. CTS23496: If problems with creation of direction occur default direction is used (MakeLine(...) function)
174 gp_Dir Ngp(0.,0.,1.);
177 Handle(Geom_Direction) D = MakeDirection (SA->Axis());
183 Standard_Boolean isDefaultDirectionUsed = Standard_True;
184 if (SA->HasRefDirection())
186 Handle(Geom_Direction) D = MakeDirection (SA->RefDirection());
189 const gp_Dir Vxgp = D->Dir();
190 if (!Ngp.IsParallel(Vxgp,Precision::Angular()))
192 gpAx2 = gp_Ax2(Pgp, Ngp, Vxgp);
193 isDefaultDirectionUsed = Standard_False;
197 if(isDefaultDirectionUsed)
198 gpAx2 = gp_Ax2(Pgp, Ngp);
200 return new Geom_Axis2Placement(gpAx2);
205 //=============================================================================
206 // Creation d' un AxisPlacement de Geom2d a partir d' un axis2_placement_3d de Step
207 //=============================================================================
209 Handle(Geom2d_AxisPlacement) StepToGeom::MakeAxisPlacement (const Handle(StepGeom_Axis2Placement2d)& SA)
211 Handle(Geom2d_CartesianPoint) P = MakeCartesianPoint2d (SA->Location());
214 // sln 23.10.2001. CTS23496: If problems with creation of direction occur default direction is used
215 gp_Dir2d Vxgp(1.,0.);
216 if (SA->HasRefDirection()) {
217 Handle(Geom2d_Direction) Vx = MakeDirection2d (SA->RefDirection());
222 return new Geom2d_AxisPlacement(P->Pnt2d(),Vxgp);
227 //=============================================================================
228 // Creation d' une BoundedCurve de Geom a partir d' une BoundedCurve de Step
229 //=============================================================================
231 Handle(Geom_BoundedCurve) StepToGeom::MakeBoundedCurve (const Handle(StepGeom_BoundedCurve)& SC)
233 if (SC->IsKind(STANDARD_TYPE(StepGeom_BSplineCurveWithKnotsAndRationalBSplineCurve)))
235 return MakeBSplineCurve (Handle(StepGeom_BSplineCurveWithKnotsAndRationalBSplineCurve)::DownCast(SC));
237 if (SC->IsKind(STANDARD_TYPE(StepGeom_BSplineCurveWithKnots)))
239 return MakeBSplineCurve (Handle(StepGeom_BSplineCurveWithKnots)::DownCast(SC));
241 if (SC->IsKind(STANDARD_TYPE(StepGeom_TrimmedCurve)))
243 return MakeTrimmedCurve (Handle(StepGeom_TrimmedCurve)::DownCast(SC));
246 // STEP BezierCurve, UniformCurve and QuasiUniformCurve are transformed into
247 // STEP BSplineCurve before being mapped onto CAS.CADE/SF
248 if (SC->IsKind(STANDARD_TYPE(StepGeom_BezierCurve)))
250 const Handle(StepGeom_BezierCurve) BzC = Handle(StepGeom_BezierCurve)::DownCast(SC);
251 Standard_Integer aDegree = BzC->Degree();
252 if (aDegree < 1 || aDegree > Geom_BSplineCurve::MaxDegree())
254 const Handle(StepGeom_BSplineCurveWithKnots) BSPL = new StepGeom_BSplineCurveWithKnots;
255 BSPL->SetDegree(aDegree);
256 BSPL->SetControlPointsList(BzC->ControlPointsList());
257 BSPL->SetCurveForm(BzC->CurveForm());
258 BSPL->SetClosedCurve(BzC->ClosedCurve());
259 BSPL->SetSelfIntersect(BzC->SelfIntersect());
260 // Compute Knots and KnotsMultiplicity
261 const Handle(TColStd_HArray1OfInteger) Kmult = new TColStd_HArray1OfInteger(1,2);
262 const Handle(TColStd_HArray1OfReal) Knots = new TColStd_HArray1OfReal(1,2);
263 Kmult->SetValue(1, BzC->Degree() + 1);
264 Kmult->SetValue(2, BzC->Degree() + 1);
265 Knots->SetValue(1, 0.);
266 Knots->SetValue(2, 1.);
267 BSPL->SetKnotMultiplicities(Kmult);
268 BSPL->SetKnots(Knots);
270 return MakeBSplineCurve (BSPL);
273 if (SC->IsKind(STANDARD_TYPE(StepGeom_UniformCurve)))
275 const Handle(StepGeom_UniformCurve) UC = Handle(StepGeom_UniformCurve)::DownCast(SC);
276 Standard_Integer aDegree = UC->Degree();
277 if (aDegree < 1 || aDegree > Geom_BSplineCurve::MaxDegree())
279 const Handle(StepGeom_BSplineCurveWithKnots) BSPL = new StepGeom_BSplineCurveWithKnots;
280 BSPL->SetDegree(aDegree);
281 BSPL->SetControlPointsList(UC->ControlPointsList());
282 BSPL->SetCurveForm(UC->CurveForm());
283 BSPL->SetClosedCurve(UC->ClosedCurve());
284 BSPL->SetSelfIntersect(UC->SelfIntersect());
286 // Compute Knots and KnotsMultiplicity
287 const Standard_Integer nbK = BSPL->NbControlPointsList() + BSPL->Degree() + 1;
288 const Handle(TColStd_HArray1OfInteger) Kmult = new TColStd_HArray1OfInteger(1,nbK);
289 const Handle(TColStd_HArray1OfReal) Knots = new TColStd_HArray1OfReal(1,nbK);
290 for (Standard_Integer iUC = 1 ; iUC <= nbK ; iUC ++) {
291 Kmult->SetValue(iUC, 1);
292 Knots->SetValue(iUC, iUC - 1.);
294 BSPL->SetKnotMultiplicities(Kmult);
295 BSPL->SetKnots(Knots);
297 return MakeBSplineCurve (BSPL);
300 if (SC->IsKind(STANDARD_TYPE(StepGeom_QuasiUniformCurve)))
302 const Handle(StepGeom_QuasiUniformCurve) QUC =
303 Handle(StepGeom_QuasiUniformCurve)::DownCast(SC);
304 Standard_Integer aDegree = QUC->Degree();
305 if (aDegree < 1 || aDegree > Geom_BSplineCurve::MaxDegree())
307 const Handle(StepGeom_BSplineCurveWithKnots) BSPL = new StepGeom_BSplineCurveWithKnots;
308 BSPL->SetDegree(aDegree);
309 BSPL->SetControlPointsList(QUC->ControlPointsList());
310 BSPL->SetCurveForm(QUC->CurveForm());
311 BSPL->SetClosedCurve(QUC->ClosedCurve());
312 BSPL->SetSelfIntersect(QUC->SelfIntersect());
314 // Compute Knots and KnotsMultiplicity
315 const Standard_Integer nbK = BSPL->NbControlPointsList() - BSPL->Degree() + 1;
316 const Handle(TColStd_HArray1OfInteger) Kmult = new TColStd_HArray1OfInteger(1,nbK);
317 const Handle(TColStd_HArray1OfReal) Knots = new TColStd_HArray1OfReal(1,nbK);
318 for (Standard_Integer iQUC = 1 ; iQUC <= nbK ; iQUC ++) {
319 Kmult->SetValue(iQUC, 1);
320 Knots->SetValue(iQUC, iQUC - 1.);
322 Kmult->SetValue(1, BSPL->Degree() + 1);
323 Kmult->SetValue(nbK, BSPL->Degree() + 1);
324 BSPL->SetKnotMultiplicities(Kmult);
325 BSPL->SetKnots(Knots);
327 return MakeBSplineCurve (BSPL);
330 if (SC->IsKind(STANDARD_TYPE(StepGeom_UniformCurveAndRationalBSplineCurve)))
332 const Handle(StepGeom_UniformCurveAndRationalBSplineCurve) RUC =
333 Handle(StepGeom_UniformCurveAndRationalBSplineCurve)::DownCast(SC);
334 Standard_Integer aDegree = RUC->Degree();
335 if (aDegree < 1 || aDegree > Geom_BSplineCurve::MaxDegree())
337 const Handle(StepGeom_BSplineCurveWithKnotsAndRationalBSplineCurve) RBSPL =
338 new StepGeom_BSplineCurveWithKnotsAndRationalBSplineCurve;
340 // Compute Knots and KnotsMultiplicity
341 const Standard_Integer nbK = RUC->NbControlPointsList() + aDegree + 1;
342 const Handle(TColStd_HArray1OfInteger) Kmult = new TColStd_HArray1OfInteger(1,nbK);
343 const Handle(TColStd_HArray1OfReal) Knots = new TColStd_HArray1OfReal(1,nbK);
344 for (Standard_Integer iUC = 1 ; iUC <= nbK ; iUC ++) {
345 Kmult->SetValue(iUC, 1);
346 Knots->SetValue(iUC, iUC - 1.);
349 // Initialize the BSplineCurveWithKnotsAndRationalBSplineCurve
350 RBSPL->Init(RUC->Name(), aDegree, RUC->ControlPointsList(), RUC->CurveForm(),
351 RUC->ClosedCurve(), RUC->SelfIntersect(), Kmult, Knots, StepGeom_ktUnspecified,
354 return MakeBSplineCurve (RBSPL);
357 if (SC->IsKind(STANDARD_TYPE(StepGeom_QuasiUniformCurveAndRationalBSplineCurve)))
359 const Handle(StepGeom_QuasiUniformCurveAndRationalBSplineCurve) RQUC =
360 Handle(StepGeom_QuasiUniformCurveAndRationalBSplineCurve)::DownCast(SC);
361 Standard_Integer aDegree = RQUC->Degree();
362 if (aDegree < 1 || aDegree > Geom_BSplineCurve::MaxDegree())
364 const Handle(StepGeom_BSplineCurveWithKnotsAndRationalBSplineCurve) RBSPL =
365 new StepGeom_BSplineCurveWithKnotsAndRationalBSplineCurve;
367 // Compute Knots and KnotsMultiplicity
368 const Standard_Integer nbK = RQUC->NbControlPointsList() - aDegree + 1;
369 const Handle(TColStd_HArray1OfInteger) Kmult = new TColStd_HArray1OfInteger(1,nbK);
370 const Handle(TColStd_HArray1OfReal) Knots = new TColStd_HArray1OfReal(1,nbK);
371 for (Standard_Integer iRQUC = 1 ; iRQUC <= nbK ; iRQUC ++) {
372 Kmult->SetValue(iRQUC, 1);
373 Knots->SetValue(iRQUC, iRQUC - 1.);
375 Kmult->SetValue(1, aDegree + 1);
376 Kmult->SetValue(nbK, aDegree + 1);
377 // Initialize the BSplineCurveWithKnotsAndRationalBSplineCurve
378 RBSPL->Init(RQUC->Name(), aDegree, RQUC->ControlPointsList(), RQUC->CurveForm(),
379 RQUC->ClosedCurve(), RQUC->SelfIntersect(), Kmult, Knots, StepGeom_ktUnspecified,
380 RQUC->WeightsData());
382 return MakeBSplineCurve (RBSPL);
385 if (SC->IsKind(STANDARD_TYPE(StepGeom_Polyline)))
386 { //:n6 abv 15 Feb 99
387 return MakePolyline (Handle(StepGeom_Polyline)::DownCast (SC));
393 //=============================================================================
394 // Creation d' une BoundedCurve de Geom a partir d' une BoundedCurve de Step
395 //=============================================================================
397 Handle(Geom2d_BoundedCurve) StepToGeom::MakeBoundedCurve2d (const Handle(StepGeom_BoundedCurve)& SC)
399 if (SC->IsKind(STANDARD_TYPE(StepGeom_BSplineCurveWithKnotsAndRationalBSplineCurve)))
401 return MakeBSplineCurve2d (Handle(StepGeom_BSplineCurveWithKnotsAndRationalBSplineCurve)::DownCast(SC));
403 if (SC->IsKind(STANDARD_TYPE(StepGeom_BSplineCurveWithKnots)))
405 return MakeBSplineCurve2d (Handle(StepGeom_BSplineCurveWithKnots)::DownCast(SC));
407 if (SC->IsKind(STANDARD_TYPE(StepGeom_TrimmedCurve)))
409 return MakeTrimmedCurve2d (Handle(StepGeom_TrimmedCurve)::DownCast(SC));
411 if (SC->IsKind(STANDARD_TYPE(StepGeom_Polyline)))
412 { //:n6 abv 15 Feb 99
413 return MakePolyline2d (Handle(StepGeom_Polyline)::DownCast(SC));
415 return Handle(Geom2d_BoundedCurve)();
418 //=============================================================================
419 // Creation d' une BoundedSurface de Geom a partir d' une BoundedSurface de Step
420 //=============================================================================
422 Handle(Geom_BoundedSurface) StepToGeom::MakeBoundedSurface (const Handle(StepGeom_BoundedSurface)& SS)
424 if (SS->IsKind(STANDARD_TYPE(StepGeom_BSplineSurfaceWithKnotsAndRationalBSplineSurface)))
426 return MakeBSplineSurface (Handle(StepGeom_BSplineSurfaceWithKnotsAndRationalBSplineSurface)::DownCast(SS));
428 if (SS->IsKind(STANDARD_TYPE(StepGeom_BSplineSurfaceWithKnots)))
430 return MakeBSplineSurface (Handle(StepGeom_BSplineSurfaceWithKnots)::DownCast(SS));
432 if (SS->IsKind(STANDARD_TYPE(StepGeom_RectangularTrimmedSurface)))
434 return MakeRectangularTrimmedSurface (Handle(StepGeom_RectangularTrimmedSurface)::DownCast(SS));
437 // STEP BezierSurface, UniformSurface and QuasiUniformSurface are transformed
438 // into STEP BSplineSurface before being mapped onto CAS.CADE/SF
439 if (SS->IsKind(STANDARD_TYPE(StepGeom_BezierSurface))) {
440 const Handle(StepGeom_BezierSurface) BzS = Handle(StepGeom_BezierSurface)::DownCast(SS);
441 const Handle(StepGeom_BSplineSurfaceWithKnots) BSPL = new StepGeom_BSplineSurfaceWithKnots;
442 BSPL->SetUDegree(BzS->UDegree());
443 BSPL->SetVDegree(BzS->VDegree());
444 BSPL->SetControlPointsList(BzS->ControlPointsList());
445 BSPL->SetSurfaceForm(BzS->SurfaceForm());
446 BSPL->SetUClosed(BzS->UClosed());
447 BSPL->SetVClosed(BzS->VClosed());
448 BSPL->SetSelfIntersect(BzS->SelfIntersect());
450 // Compute Knots and KnotsMultiplicity
451 const Handle(TColStd_HArray1OfInteger) UKmult = new TColStd_HArray1OfInteger(1,2);
452 const Handle(TColStd_HArray1OfInteger) VKmult = new TColStd_HArray1OfInteger(1,2);
453 const Handle(TColStd_HArray1OfReal) UKnots = new TColStd_HArray1OfReal(1,2);
454 const Handle(TColStd_HArray1OfReal) VKnots = new TColStd_HArray1OfReal(1,2);
455 UKmult->SetValue(1, BzS->UDegree() + 1);
456 UKmult->SetValue(2, BzS->UDegree() + 1);
457 VKmult->SetValue(1, BzS->VDegree() + 1);
458 VKmult->SetValue(2, BzS->VDegree() + 1);
459 UKnots->SetValue(1, 0.);
460 UKnots->SetValue(2, 1.);
461 VKnots->SetValue(1, 0.);
462 VKnots->SetValue(2, 1.);
463 BSPL->SetUMultiplicities(UKmult);
464 BSPL->SetVMultiplicities(VKmult);
465 BSPL->SetUKnots(UKnots);
466 BSPL->SetVKnots(VKnots);
468 return MakeBSplineSurface (BSPL);
471 if (SS->IsKind(STANDARD_TYPE(StepGeom_UniformSurface)))
473 const Handle(StepGeom_UniformSurface) US = Handle(StepGeom_UniformSurface)::DownCast(SS);
474 const Handle(StepGeom_BSplineSurfaceWithKnots) BSPL = new StepGeom_BSplineSurfaceWithKnots;
475 BSPL->SetUDegree(US->UDegree());
476 BSPL->SetVDegree(US->VDegree());
477 BSPL->SetControlPointsList(US->ControlPointsList());
478 BSPL->SetSurfaceForm(US->SurfaceForm());
479 BSPL->SetUClosed(US->UClosed());
480 BSPL->SetVClosed(US->VClosed());
481 BSPL->SetSelfIntersect(US->SelfIntersect());
483 // Compute Knots and KnotsMultiplicity for U Direction
484 const Standard_Integer nbKU = BSPL->NbControlPointsListI() + BSPL->UDegree() + 1;
485 const Handle(TColStd_HArray1OfInteger) UKmult = new TColStd_HArray1OfInteger(1,nbKU);
486 const Handle(TColStd_HArray1OfReal) UKnots = new TColStd_HArray1OfReal(1,nbKU);
487 for (Standard_Integer iU = 1 ; iU <= nbKU ; iU ++) {
488 UKmult->SetValue(iU, 1);
489 UKnots->SetValue(iU, iU - 1.);
491 BSPL->SetUMultiplicities(UKmult);
492 BSPL->SetUKnots(UKnots);
494 // Compute Knots and KnotsMultiplicity for V Direction
495 const Standard_Integer nbKV = BSPL->NbControlPointsListJ() + BSPL->VDegree() + 1;
496 const Handle(TColStd_HArray1OfInteger) VKmult = new TColStd_HArray1OfInteger(1,nbKV);
497 const Handle(TColStd_HArray1OfReal) VKnots = new TColStd_HArray1OfReal(1,nbKV);
498 for (Standard_Integer iV = 1 ; iV <= nbKV ; iV ++) {
499 VKmult->SetValue(iV, 1);
500 VKnots->SetValue(iV, iV - 1.);
502 BSPL->SetVMultiplicities(VKmult);
503 BSPL->SetVKnots(VKnots);
505 return MakeBSplineSurface (BSPL);
508 if (SS->IsKind(STANDARD_TYPE(StepGeom_QuasiUniformSurface)))
510 const Handle(StepGeom_QuasiUniformSurface) QUS =
511 Handle(StepGeom_QuasiUniformSurface)::DownCast(SS);
512 const Handle(StepGeom_BSplineSurfaceWithKnots) BSPL = new StepGeom_BSplineSurfaceWithKnots;
513 BSPL->SetUDegree(QUS->UDegree());
514 BSPL->SetVDegree(QUS->VDegree());
515 BSPL->SetControlPointsList(QUS->ControlPointsList());
516 BSPL->SetSurfaceForm(QUS->SurfaceForm());
517 BSPL->SetUClosed(QUS->UClosed());
518 BSPL->SetVClosed(QUS->VClosed());
519 BSPL->SetSelfIntersect(QUS->SelfIntersect());
521 // Compute Knots and KnotsMultiplicity for U Direction
522 const Standard_Integer nbKU = BSPL->NbControlPointsListI() - BSPL->UDegree() + 1;
523 const Handle(TColStd_HArray1OfInteger) UKmult = new TColStd_HArray1OfInteger(1,nbKU);
524 const Handle(TColStd_HArray1OfReal) UKnots = new TColStd_HArray1OfReal(1,nbKU);
525 for (Standard_Integer iU = 1 ; iU <= nbKU ; iU ++) {
526 UKmult->SetValue(iU, 1);
527 UKnots->SetValue(iU, iU - 1.);
529 UKmult->SetValue(1, BSPL->UDegree() + 1);
530 UKmult->SetValue(nbKU, BSPL->UDegree() + 1);
531 BSPL->SetUMultiplicities(UKmult);
532 BSPL->SetUKnots(UKnots);
534 // Compute Knots and KnotsMultiplicity for V Direction
535 const Standard_Integer nbKV = BSPL->NbControlPointsListJ() - BSPL->VDegree() + 1;
536 const Handle(TColStd_HArray1OfInteger) VKmult = new TColStd_HArray1OfInteger(1,nbKV);
537 const Handle(TColStd_HArray1OfReal) VKnots = new TColStd_HArray1OfReal(1,nbKV);
538 for (Standard_Integer iV = 1 ; iV <= nbKV ; iV ++) {
539 VKmult->SetValue(iV, 1);
540 VKnots->SetValue(iV, iV - 1.);
542 VKmult->SetValue(1, BSPL->VDegree() + 1);
543 VKmult->SetValue(nbKV, BSPL->VDegree() + 1);
544 BSPL->SetVMultiplicities(VKmult);
545 BSPL->SetVKnots(VKnots);
547 return MakeBSplineSurface (BSPL);
550 if (SS->IsKind(STANDARD_TYPE(StepGeom_UniformSurfaceAndRationalBSplineSurface)))
552 const Handle(StepGeom_UniformSurfaceAndRationalBSplineSurface) RUS =
553 Handle(StepGeom_UniformSurfaceAndRationalBSplineSurface)::DownCast(SS);
554 const Handle(StepGeom_BSplineSurfaceWithKnotsAndRationalBSplineSurface) RBSPL =
555 new StepGeom_BSplineSurfaceWithKnotsAndRationalBSplineSurface;
557 // Compute Knots and KnotsMultiplicity for U Direction
558 const Standard_Integer nbKU = RUS->NbControlPointsListI() + RUS->UDegree() + 1;
559 const Handle(TColStd_HArray1OfInteger) UKmult = new TColStd_HArray1OfInteger(1,nbKU);
560 const Handle(TColStd_HArray1OfReal) UKnots = new TColStd_HArray1OfReal(1,nbKU);
561 for (Standard_Integer iU = 1 ; iU <= nbKU ; iU ++) {
562 UKmult->SetValue(iU, 1);
563 UKnots->SetValue(iU, iU - 1.);
566 // Compute Knots and KnotsMultiplicity for V Direction
567 const Standard_Integer nbKV = RUS->NbControlPointsListJ() + RUS->VDegree() + 1;
568 const Handle(TColStd_HArray1OfInteger) VKmult = new TColStd_HArray1OfInteger(1,nbKV);
569 const Handle(TColStd_HArray1OfReal) VKnots = new TColStd_HArray1OfReal(1,nbKV);
570 for (Standard_Integer iV = 1 ; iV <= nbKV ; iV ++) {
571 VKmult->SetValue(iV, 1);
572 VKnots->SetValue(iV, iV - 1.);
575 // Initialize the BSplineSurfaceWithKnotsAndRationalBSplineSurface
576 RBSPL->Init(RUS->Name(), RUS->UDegree(), RUS->VDegree(),
577 RUS->ControlPointsList(), RUS->SurfaceForm(),
578 RUS->UClosed(), RUS->VClosed(), RUS->SelfIntersect(),
579 UKmult, VKmult, UKnots, VKnots, StepGeom_ktUnspecified,
582 return MakeBSplineSurface (RBSPL);
585 if (SS->IsKind(STANDARD_TYPE(StepGeom_QuasiUniformSurfaceAndRationalBSplineSurface)))
587 const Handle(StepGeom_QuasiUniformSurfaceAndRationalBSplineSurface) RQUS =
588 Handle(StepGeom_QuasiUniformSurfaceAndRationalBSplineSurface)::DownCast(SS);
589 const Handle(StepGeom_BSplineSurfaceWithKnotsAndRationalBSplineSurface) RBSPL =
590 new StepGeom_BSplineSurfaceWithKnotsAndRationalBSplineSurface;
592 // Compute Knots and KnotsMultiplicity for U Direction
593 const Standard_Integer nbKU = RQUS->NbControlPointsListI() - RQUS->UDegree() + 1;
594 const Handle(TColStd_HArray1OfInteger) UKmult = new TColStd_HArray1OfInteger(1,nbKU);
595 const Handle(TColStd_HArray1OfReal) UKnots = new TColStd_HArray1OfReal(1,nbKU);
596 for (Standard_Integer iU = 1 ; iU <= nbKU ; iU ++) {
597 UKmult->SetValue(iU, 1);
598 UKnots->SetValue(iU, iU - 1.);
600 UKmult->SetValue(1, RQUS->UDegree() + 1);
601 UKmult->SetValue(nbKU, RQUS->UDegree() + 1);
603 // Compute Knots and KnotsMultiplicity for V Direction
604 const Standard_Integer nbKV = RQUS->NbControlPointsListJ() - RQUS->VDegree() + 1;
605 const Handle(TColStd_HArray1OfInteger) VKmult = new TColStd_HArray1OfInteger(1,nbKV);
606 const Handle(TColStd_HArray1OfReal) VKnots = new TColStd_HArray1OfReal(1,nbKV);
607 for (Standard_Integer iV = 1 ; iV <= nbKV ; iV ++) {
608 VKmult->SetValue(iV, 1);
609 VKnots->SetValue(iV, iV - 1.);
611 VKmult->SetValue(1, RQUS->VDegree() + 1);
612 VKmult->SetValue(nbKV, RQUS->VDegree() + 1);
614 // Initialize the BSplineSurfaceWithKnotsAndRationalBSplineSurface
615 RBSPL->Init(RQUS->Name(), RQUS->UDegree(), RQUS->VDegree(), RQUS->ControlPointsList(),
616 RQUS->SurfaceForm(), RQUS->UClosed(), RQUS->VClosed(),
617 RQUS->SelfIntersect(), UKmult, VKmult, UKnots, VKnots, StepGeom_ktUnspecified,
618 RQUS->WeightsData());
619 return MakeBSplineSurface (RBSPL);
625 //=============================================================================
626 // Template function for use in MakeBSplineCurve / MakeBSplineCurve2d
627 //=============================================================================
632 class TCartesianPoint,
636 Handle(TBSplineCurve) MakeBSplineCurveCommon
638 const Handle(StepGeom_BSplineCurve)& theStepGeom_BSplineCurve,
639 TGpPnt(TCartesianPoint::* thePntGetterFunction)() const,
640 Handle(TCartesianPoint) (*thePointMakerFunction)(const Handle(StepGeom_CartesianPoint)&)
643 Handle(StepGeom_BSplineCurveWithKnots) aBSplineCurveWithKnots;
644 Handle(StepGeom_BSplineCurveWithKnotsAndRationalBSplineCurve) aBSplineCurveWithKnotsAndRationalBSplineCurve;
646 if (theStepGeom_BSplineCurve->IsKind(STANDARD_TYPE(StepGeom_BSplineCurveWithKnotsAndRationalBSplineCurve)))
648 aBSplineCurveWithKnotsAndRationalBSplineCurve =
649 Handle(StepGeom_BSplineCurveWithKnotsAndRationalBSplineCurve)::DownCast(theStepGeom_BSplineCurve);
650 aBSplineCurveWithKnots = aBSplineCurveWithKnotsAndRationalBSplineCurve->BSplineCurveWithKnots();
653 aBSplineCurveWithKnots = Handle(StepGeom_BSplineCurveWithKnots)::DownCast(theStepGeom_BSplineCurve);
655 const Standard_Integer aDegree = aBSplineCurveWithKnots->Degree();
656 const Standard_Integer NbPoles = aBSplineCurveWithKnots->NbControlPointsList();
657 const Standard_Integer NbKnots = aBSplineCurveWithKnots->NbKnotMultiplicities();
659 const Handle(TColStd_HArray1OfInteger)& aKnotMultiplicities = aBSplineCurveWithKnots->KnotMultiplicities();
660 const Handle(TColStd_HArray1OfReal)& aKnots = aBSplineCurveWithKnots->Knots();
662 // Count number of unique knots
663 Standard_Integer NbUniqueKnots = 0;
664 Standard_Real lastKnot = RealFirst();
665 for (Standard_Integer i = 1; i <= NbKnots; ++i)
667 if (aKnots->Value(i) - lastKnot > Epsilon(Abs(lastKnot)))
670 lastKnot = aKnots->Value(i);
673 if (NbUniqueKnots <= 1)
677 TColStd_Array1OfReal aUniqueKnots(1, NbUniqueKnots);
678 TColStd_Array1OfInteger aUniqueKnotMultiplicities(1, NbUniqueKnots);
679 lastKnot = aKnots->Value(1);
680 aUniqueKnots.SetValue(1, aKnots->Value(1));
681 aUniqueKnotMultiplicities.SetValue(1, aKnotMultiplicities->Value(1));
682 Standard_Integer aKnotPosition = 1;
683 for (Standard_Integer i = 2; i <= NbKnots; i++)
685 if (aKnots->Value(i) - lastKnot > Epsilon(Abs(lastKnot)))
688 aUniqueKnots.SetValue(aKnotPosition, aKnots->Value(i));
689 aUniqueKnotMultiplicities.SetValue(aKnotPosition, aKnotMultiplicities->Value(i));
690 lastKnot = aKnots->Value(i);
694 // Knot not unique, increase multiplicity
695 Standard_Integer aCurrentMultiplicity = aUniqueKnotMultiplicities.Value(aKnotPosition);
696 aUniqueKnotMultiplicities.SetValue(aKnotPosition, aCurrentMultiplicity + aKnotMultiplicities->Value(i));
700 Standard_Integer aFirstMuultypisityDifference = 0;
701 Standard_Integer aLastMuultypisityDifference = 0;
702 for (Standard_Integer i = 1; i <= NbUniqueKnots; ++i)
704 Standard_Integer aCurrentVal = aUniqueKnotMultiplicities.Value(i);
705 if (aCurrentVal > aDegree + 1)
708 aFirstMuultypisityDifference = aCurrentVal - aDegree - 1;
709 if (i == NbUniqueKnots)
710 aLastMuultypisityDifference = aCurrentVal - aDegree - 1;
712 std::cout << "\nWrong multiplicity " << aCurrentVal << " on " << i
713 << " knot!" << "\nChanged to " << aDegree + 1 << std::endl;
715 aCurrentVal = aDegree + 1;
717 aUniqueKnotMultiplicities.SetValue(i, aCurrentVal);
720 const Handle(StepGeom_HArray1OfCartesianPoint)& aControlPointsList = aBSplineCurveWithKnots->ControlPointsList();
721 Standard_Integer aSummaryMuultypisityDifference = aFirstMuultypisityDifference + aLastMuultypisityDifference;
722 Standard_Integer NbUniquePoles = NbPoles - aSummaryMuultypisityDifference;
723 if (NbUniquePoles <= 0)
727 TPntArray Poles(1, NbPoles - aSummaryMuultypisityDifference);
729 for (Standard_Integer i = 1 + aFirstMuultypisityDifference; i <= NbPoles - aLastMuultypisityDifference; ++i)
731 Handle(TCartesianPoint) aPoint = (*thePointMakerFunction)(aControlPointsList->Value(i));
732 if (!aPoint.IsNull())
734 TCartesianPoint* pPoint = aPoint.get();
735 TGpPnt aGpPnt = (pPoint->*thePntGetterFunction)();
736 Poles.SetValue(i - aFirstMuultypisityDifference, aGpPnt);
744 // --- Does the Curve descriptor LOOKS like a periodic descriptor ? ---
745 Standard_Integer aSummaryMuultypisity = 0;
746 for (Standard_Integer i = 1; i <= NbUniqueKnots; i++)
748 aSummaryMuultypisity += aUniqueKnotMultiplicities.Value(i);
751 Standard_Boolean shouldBePeriodic;
752 if (aSummaryMuultypisity == (NbPoles + aDegree + 1))
754 shouldBePeriodic = Standard_False;
756 else if ((aUniqueKnotMultiplicities.Value(1) == aUniqueKnotMultiplicities.Value(NbUniqueKnots)) &&
757 ((aSummaryMuultypisity - aUniqueKnotMultiplicities.Value(1)) == NbPoles))
759 shouldBePeriodic = Standard_True;
763 // --- What is that ??? ---
764 shouldBePeriodic = Standard_False;
767 Handle(TBSplineCurve) aBSplineCurve;
768 if (theStepGeom_BSplineCurve->IsKind(STANDARD_TYPE(StepGeom_BSplineCurveWithKnotsAndRationalBSplineCurve)))
770 const Handle(TColStd_HArray1OfReal)& aWeights = aBSplineCurveWithKnotsAndRationalBSplineCurve->WeightsData();
771 TColStd_Array1OfReal aUniqueWeights(1, NbPoles - aSummaryMuultypisityDifference);
772 for (Standard_Integer i = 1 + aFirstMuultypisityDifference; i <= NbPoles - aLastMuultypisityDifference; ++i)
773 aUniqueWeights.SetValue(i - aFirstMuultypisityDifference, aWeights->Value(i));
774 aBSplineCurve = new TBSplineCurve(Poles, aUniqueWeights, aUniqueKnots, aUniqueKnotMultiplicities, aDegree, shouldBePeriodic);
778 aBSplineCurve = new TBSplineCurve(Poles, aUniqueKnots, aUniqueKnotMultiplicities, aDegree, shouldBePeriodic);
781 // abv 04.07.00 CAX-IF TRJ4: trj4_k1_top-md-203.stp #716 (face #581):
782 // force periodicity on closed curves
783 if (theStepGeom_BSplineCurve->ClosedCurve() && aBSplineCurve->Degree() > 1 && aBSplineCurve->IsClosed())
785 aBSplineCurve->SetPeriodic();
787 return aBSplineCurve;
790 //=============================================================================
791 // Creation d' une BSplineCurve de Geom a partir d' une BSplineCurve de Step
792 //=============================================================================
794 Handle(Geom_BSplineCurve) StepToGeom::MakeBSplineCurve (const Handle(StepGeom_BSplineCurve)& theStepGeom_BSplineCurve)
796 return MakeBSplineCurveCommon<TColgp_Array1OfPnt, Geom_CartesianPoint, gp_Pnt, Geom_BSplineCurve>
797 (theStepGeom_BSplineCurve, &Geom_CartesianPoint::Pnt, &MakeCartesianPoint);
800 //=============================================================================
801 // Creation d' une BSplineCurve de Geom2d a partir d' une
802 // BSplineCurveWithKnotsAndRationalBSplineCurve de Step
803 //=============================================================================
805 Handle(Geom2d_BSplineCurve) StepToGeom::MakeBSplineCurve2d (const Handle(StepGeom_BSplineCurve)& theStepGeom_BSplineCurve)
807 return MakeBSplineCurveCommon<TColgp_Array1OfPnt2d, Geom2d_CartesianPoint, gp_Pnt2d, Geom2d_BSplineCurve>
808 (theStepGeom_BSplineCurve, &Geom2d_CartesianPoint::Pnt2d, &MakeCartesianPoint2d);
811 //=============================================================================
812 // Creation d' une BSplineSurface de Geom a partir d' une
813 // BSplineSurface de Step
814 //=============================================================================
816 Handle(Geom_BSplineSurface) StepToGeom::MakeBSplineSurface (const Handle(StepGeom_BSplineSurface)& SS)
818 Standard_Integer i, j;
819 Handle(StepGeom_BSplineSurfaceWithKnots) BS;
820 Handle(StepGeom_BSplineSurfaceWithKnotsAndRationalBSplineSurface) BSR;
823 IsKind(STANDARD_TYPE(StepGeom_BSplineSurfaceWithKnotsAndRationalBSplineSurface))) {
825 Handle(StepGeom_BSplineSurfaceWithKnotsAndRationalBSplineSurface)
827 BS = BSR->BSplineSurfaceWithKnots();
830 BS = Handle(StepGeom_BSplineSurfaceWithKnots)::DownCast(SS);
832 const Standard_Integer UDeg = BS->UDegree();
833 const Standard_Integer VDeg = BS->VDegree();
834 const Standard_Integer NUPoles = BS->NbControlPointsListI();
835 const Standard_Integer NVPoles = BS->NbControlPointsListJ();
836 const Handle(StepGeom_HArray2OfCartesianPoint)& aControlPointsList = BS->ControlPointsList();
837 TColgp_Array2OfPnt Poles(1,NUPoles,1,NVPoles);
838 for (i=1; i<=NUPoles; i++) {
839 for (j=1; j<=NVPoles; j++) {
840 Handle(Geom_CartesianPoint) P = MakeCartesianPoint (aControlPointsList->Value(i,j));
842 Poles.SetValue(i,j,P->Pnt());
847 const Standard_Integer NUKnots = BS->NbUMultiplicities();
848 const Handle(TColStd_HArray1OfInteger)& aUMultiplicities = BS->UMultiplicities();
849 const Handle(TColStd_HArray1OfReal)& aUKnots = BS->UKnots();
851 // count number of unique uknots
852 Standard_Real lastKnot = RealFirst();
853 Standard_Integer NUKnotsUnique = 0;
854 for (i=1; i<=NUKnots; i++) {
855 if (aUKnots->Value(i) - lastKnot > Epsilon (Abs(lastKnot))) {
857 lastKnot = aUKnots->Value(i);
861 // set umultiplicities and uknots
862 TColStd_Array1OfInteger UMult(1,NUKnotsUnique);
863 TColStd_Array1OfReal KUn(1,NUKnotsUnique);
864 Standard_Integer pos = 1;
865 lastKnot = aUKnots->Value(1);
866 KUn.SetValue(1, aUKnots->Value(1));
867 UMult.SetValue(1, aUMultiplicities->Value(1));
868 for (i=2; i<=NUKnots; i++) {
869 if (aUKnots->Value(i) - lastKnot > Epsilon (Abs(lastKnot))) {
871 KUn.SetValue(pos, aUKnots->Value(i));
872 UMult.SetValue(pos, aUMultiplicities->Value(i));
873 lastKnot = aUKnots->Value(i);
876 // Knot not unique, increase multiplicity
877 Standard_Integer curMult = UMult.Value(pos);
878 UMult.SetValue(pos, curMult + aUMultiplicities->Value(i));
881 const Standard_Integer NVKnots = BS->NbVMultiplicities();
882 const Handle(TColStd_HArray1OfInteger)& aVMultiplicities = BS->VMultiplicities();
883 const Handle(TColStd_HArray1OfReal)& aVKnots = BS->VKnots();
885 // count number of unique vknots
886 lastKnot = RealFirst();
887 Standard_Integer NVKnotsUnique = 0;
888 for (i=1; i<=NVKnots; i++) {
889 if (aVKnots->Value(i) - lastKnot > Epsilon (Abs(lastKnot))) {
891 lastKnot = aVKnots->Value(i);
895 // set vmultiplicities and vknots
896 TColStd_Array1OfInteger VMult(1,NVKnotsUnique);
897 TColStd_Array1OfReal KVn(1,NVKnotsUnique);
899 lastKnot = aVKnots->Value(1);
900 KVn.SetValue(1, aVKnots->Value(1));
901 VMult.SetValue(1, aVMultiplicities->Value(1));
902 for (i=2; i<=NVKnots; i++) {
903 if (aVKnots->Value(i) - lastKnot > Epsilon (Abs(lastKnot))) {
905 KVn.SetValue(pos, aVKnots->Value(i));
906 VMult.SetValue(pos, aVMultiplicities->Value(i));
907 lastKnot = aVKnots->Value(i);
910 // Knot not unique, increase multiplicity
911 Standard_Integer curMult = VMult.Value(pos);
912 VMult.SetValue(pos, curMult + aVMultiplicities->Value(i));
916 // --- Does the Surface Descriptor LOOKS like a U and/or V Periodic ---
917 // --- Descriptor ? ---
919 // --- U Periodic ? ---
921 Standard_Integer SumMult = 0;
922 for (i=1; i<=NUKnotsUnique; i++) {
923 SumMult += UMult.Value(i);
926 Standard_Boolean shouldBeUPeriodic = Standard_False;
927 if (SumMult == (NUPoles + UDeg + 1)) {
928 //shouldBeUPeriodic = Standard_False;
930 else if ((UMult.Value(1) ==
931 UMult.Value(NUKnotsUnique)) &&
932 ((SumMult - UMult.Value(1))== NUPoles)) {
933 shouldBeUPeriodic = Standard_True;
936 // --- V Periodic ? ---
939 for (i=1; i<=NVKnotsUnique; i++) {
940 SumMult += VMult.Value(i);
943 Standard_Boolean shouldBeVPeriodic = Standard_False;
944 if (SumMult == (NVPoles + VDeg + 1)) {
945 //shouldBeVPeriodic = Standard_False;
947 else if ((VMult.Value(1) ==
948 VMult.Value(NVKnotsUnique)) &&
949 ((SumMult - VMult.Value(1)) == NVPoles)) {
950 shouldBeVPeriodic = Standard_True;
953 Handle(Geom_BSplineSurface) CS;
954 if (SS->IsKind(STANDARD_TYPE(StepGeom_BSplineSurfaceWithKnotsAndRationalBSplineSurface))) {
955 const Handle(TColStd_HArray2OfReal)& aWeight = BSR->WeightsData();
956 TColStd_Array2OfReal W(1,NUPoles,1,NVPoles);
957 for (i=1; i<=NUPoles; i++) {
958 for (j=1; j<=NVPoles; j++) {
959 W.SetValue(i,j,aWeight->Value(i,j));
962 CS = new Geom_BSplineSurface(Poles, W, KUn, KVn, UMult,
968 CS = new Geom_BSplineSurface(Poles, KUn, KVn, UMult,
975 //=============================================================================
976 // Creation d' un CartesianPoint de Geom a partir d' un CartesianPoint de Step
977 //=============================================================================
979 Handle(Geom_CartesianPoint) StepToGeom::MakeCartesianPoint (const Handle(StepGeom_CartesianPoint)& SP)
981 if (SP->NbCoordinates() == 3)
983 const Standard_Real LF = StepData_GlobalFactors::Intance().LengthFactor();
984 const Standard_Real X = SP->CoordinatesValue(1) * LF;
985 const Standard_Real Y = SP->CoordinatesValue(2) * LF;
986 const Standard_Real Z = SP->CoordinatesValue(3) * LF;
987 return new Geom_CartesianPoint(X, Y, Z);
992 //=============================================================================
993 // Creation d' un CartesianPoint de Geom2d a partir d' un CartesianPoint de
995 //=============================================================================
997 Handle(Geom2d_CartesianPoint) StepToGeom::MakeCartesianPoint2d (const Handle(StepGeom_CartesianPoint)& SP)
999 if (SP->NbCoordinates() == 2)
1001 const Standard_Real X = SP->CoordinatesValue(1);
1002 const Standard_Real Y = SP->CoordinatesValue(2);
1003 return new Geom2d_CartesianPoint(X, Y);
1008 //=============================================================================
1009 // Creation d' un Circle de Geom a partir d' un Circle de Step
1010 //=============================================================================
1012 Handle(Geom_Circle) StepToGeom::MakeCircle (const Handle(StepGeom_Circle)& SC)
1014 const StepGeom_Axis2Placement AxisSelect = SC->Position();
1015 if (AxisSelect.CaseNum(AxisSelect.Value()) == 2)
1017 Handle(Geom_Axis2Placement) A =
1018 MakeAxis2Placement (Handle(StepGeom_Axis2Placement3d)::DownCast(AxisSelect.Value()));
1021 return new Geom_Circle(A->Ax2(),SC->Radius() * StepData_GlobalFactors::Intance().LengthFactor());
1027 //=============================================================================
1028 // Creation d' un Circle de Geom2d a partir d' un Circle de Step
1029 //=============================================================================
1031 Handle(Geom2d_Circle) StepToGeom::MakeCircle2d (const Handle(StepGeom_Circle)& SC)
1033 const StepGeom_Axis2Placement AxisSelect = SC->Position();
1034 if (AxisSelect.CaseNum(AxisSelect.Value()) == 1) {
1035 Handle(Geom2d_AxisPlacement) A1 =
1036 MakeAxisPlacement (Handle(StepGeom_Axis2Placement2d)::DownCast(AxisSelect.Value()));
1039 return new Geom2d_Circle (A1->Ax2d(), SC->Radius());
1045 //=============================================================================
1046 // Creation d' une Conic de Geom a partir d' une Conic de Step
1047 //=============================================================================
1049 Handle(Geom_Conic) StepToGeom::MakeConic (const Handle(StepGeom_Conic)& SC)
1051 if (SC->IsKind(STANDARD_TYPE(StepGeom_Circle))) {
1052 return MakeCircle (Handle(StepGeom_Circle)::DownCast(SC));
1054 if (SC->IsKind(STANDARD_TYPE(StepGeom_Ellipse))) {
1055 return MakeEllipse (Handle(StepGeom_Ellipse)::DownCast(SC));
1057 if (SC->IsKind(STANDARD_TYPE(StepGeom_Hyperbola))) {
1058 return MakeHyperbola (Handle(StepGeom_Hyperbola)::DownCast(SC));
1060 if (SC->IsKind(STANDARD_TYPE(StepGeom_Parabola))) {
1061 return MakeParabola (Handle(StepGeom_Parabola)::DownCast(SC));
1063 // Attention : Other conic shall be implemented !
1067 //=============================================================================
1068 // Creation d' une Conic de Geom2d a partir d' une Conic de Step
1069 //=============================================================================
1071 Handle(Geom2d_Conic) StepToGeom::MakeConic2d (const Handle(StepGeom_Conic)& SC)
1073 if (SC->IsKind(STANDARD_TYPE(StepGeom_Circle))) {
1074 return MakeCircle2d (Handle(StepGeom_Circle)::DownCast(SC));
1076 if (SC->IsKind(STANDARD_TYPE(StepGeom_Ellipse))) {
1077 return MakeEllipse2d (Handle(StepGeom_Ellipse)::DownCast(SC));
1079 if (SC->IsKind(STANDARD_TYPE(StepGeom_Hyperbola))) {
1080 return MakeHyperbola2d (Handle(StepGeom_Hyperbola)::DownCast(SC));
1082 if (SC->IsKind(STANDARD_TYPE(StepGeom_Parabola))) {
1083 return MakeParabola2d (Handle(StepGeom_Parabola)::DownCast(SC));
1085 // Attention : Other conic shall be implemented !
1086 return Handle(Geom2d_Conic)();
1089 //=============================================================================
1090 // Creation d' une ConicalSurface de Geom a partir d' une ConicalSurface de
1092 //=============================================================================
1094 Handle(Geom_ConicalSurface) StepToGeom::MakeConicalSurface (const Handle(StepGeom_ConicalSurface)& SS)
1096 Handle(Geom_Axis2Placement) A = MakeAxis2Placement (SS->Position());
1099 const Standard_Real R = SS->Radius() * StepData_GlobalFactors::Intance().LengthFactor();
1100 const Standard_Real Ang = SS->SemiAngle() * StepData_GlobalFactors::Intance().PlaneAngleFactor();
1101 //#2(K3-3) rln 12/02/98 ProSTEP ct_turbine-A.stp entity #518, #3571 (gp::Resolution() is too little)
1102 return new Geom_ConicalSurface(A->Ax2(), Max(Ang, Precision::Angular()), R);
1107 //=============================================================================
1108 // Creation d' une Curve de Geom a partir d' une Curve de Step
1109 //=============================================================================
1111 Handle(Geom_Curve) StepToGeom::MakeCurve (const Handle(StepGeom_Curve)& SC)
1114 return Handle(Geom_Curve)();
1116 if (SC->IsKind(STANDARD_TYPE(StepGeom_Line))) {
1117 return MakeLine (Handle(StepGeom_Line)::DownCast(SC));
1119 if (SC->IsKind(STANDARD_TYPE(StepGeom_TrimmedCurve))) {
1120 return MakeTrimmedCurve (Handle(StepGeom_TrimmedCurve)::DownCast(SC));
1122 if (SC->IsKind(STANDARD_TYPE(StepGeom_Conic))) {
1123 return MakeConic (Handle(StepGeom_Conic)::DownCast(SC));
1125 if (SC->IsKind(STANDARD_TYPE(StepGeom_BoundedCurve))) {
1126 return MakeBoundedCurve (Handle(StepGeom_BoundedCurve)::DownCast(SC));
1128 if (SC->IsKind(STANDARD_TYPE(StepGeom_CurveReplica))) { //:n7 abv 16 Feb 99
1129 const Handle(StepGeom_CurveReplica) CR = Handle(StepGeom_CurveReplica)::DownCast(SC);
1130 const Handle(StepGeom_Curve) PC = CR->ParentCurve();
1131 const Handle(StepGeom_CartesianTransformationOperator3d) T =
1132 Handle(StepGeom_CartesianTransformationOperator3d)::DownCast(CR->Transformation());
1133 // protect against cyclic references and wrong type of cartop
1134 if ( !T.IsNull() && PC != SC )
1136 Handle(Geom_Curve) C1 = MakeCurve (PC);
1140 if (MakeTransformation3d(T,T1))
1142 C1->Transform ( T1 );
1148 else if (SC->IsKind(STANDARD_TYPE(StepGeom_OffsetCurve3d))) { //:o2 abv 17 Feb 99
1149 const Handle(StepGeom_OffsetCurve3d) OC = Handle(StepGeom_OffsetCurve3d)::DownCast(SC);
1150 const Handle(StepGeom_Curve) BC = OC->BasisCurve();
1151 if ( BC != SC ) { // protect against loop
1152 Handle(Geom_Curve) C1 = MakeCurve (BC);
1155 Handle(Geom_Direction) RD = MakeDirection(OC->RefDirection());
1158 return new Geom_OffsetCurve ( C1, -OC->Distance(), RD->Dir() );
1163 else if (SC->IsKind(STANDARD_TYPE(StepGeom_SurfaceCurve))) { //:o5 abv 17 Feb 99
1164 const Handle(StepGeom_SurfaceCurve) SurfC = Handle(StepGeom_SurfaceCurve)::DownCast(SC);
1165 return MakeCurve (SurfC->Curve3d());
1170 //=============================================================================
1171 // Creation d' une Curve de Geom2d a partir d' une Curve de Step
1172 //=============================================================================
1174 Handle(Geom2d_Curve) StepToGeom::MakeCurve2d (const Handle(StepGeom_Curve)& SC)
1176 if (SC->IsKind(STANDARD_TYPE(StepGeom_Line))) {
1177 return MakeLine2d (Handle(StepGeom_Line)::DownCast(SC));
1179 if (SC->IsKind(STANDARD_TYPE(StepGeom_Conic))) {
1180 return MakeConic2d (Handle(StepGeom_Conic)::DownCast(SC));
1182 if (SC->IsKind(STANDARD_TYPE(StepGeom_BoundedCurve))) {
1183 return MakeBoundedCurve2d (Handle(StepGeom_BoundedCurve)::DownCast(SC));
1185 if (SC->IsKind(STANDARD_TYPE(StepGeom_CurveReplica))) { //:n7 abv 16 Feb 99
1186 const Handle(StepGeom_CurveReplica) CR = Handle(StepGeom_CurveReplica)::DownCast(SC);
1187 const Handle(StepGeom_Curve) PC = CR->ParentCurve();
1188 const Handle(StepGeom_CartesianTransformationOperator2d) T =
1189 Handle(StepGeom_CartesianTransformationOperator2d)::DownCast(CR->Transformation());
1190 // protect against cyclic references and wrong type of cartop
1191 if ( !T.IsNull() && PC != SC )
1193 Handle(Geom2d_Curve) C1 = MakeCurve2d (PC);
1197 if (MakeTransformation2d(T,T1))
1199 C1->Transform ( T1 );
1208 //=============================================================================
1209 // Creation d' une CylindricalSurface de Geom a partir d' une
1210 // CylindricalSurface de Step
1211 //=============================================================================
1213 Handle(Geom_CylindricalSurface) StepToGeom::MakeCylindricalSurface (const Handle(StepGeom_CylindricalSurface)& SS)
1215 Handle(Geom_Axis2Placement) A = MakeAxis2Placement(SS->Position());
1218 return new Geom_CylindricalSurface(A->Ax2(), SS->Radius() * StepData_GlobalFactors::Intance().LengthFactor());
1223 //=============================================================================
1224 // Creation d' un Direction de Geom a partir d' un Direction de Step
1225 //=============================================================================
1227 Handle(Geom_Direction) StepToGeom::MakeDirection (const Handle(StepGeom_Direction)& SD)
1229 if (SD->NbDirectionRatios() >= 3)
1231 const Standard_Real X = SD->DirectionRatiosValue(1);
1232 const Standard_Real Y = SD->DirectionRatiosValue(2);
1233 const Standard_Real Z = SD->DirectionRatiosValue(3);
1234 //5.08.2021. Unstable test bugs xde bug24759: Y is very large value - FPE in SquareModulus
1235 if (Precision::IsInfinite(X) || Precision::IsInfinite(Y) || Precision::IsInfinite(Z))
1239 // sln 22.10.2001. CTS23496: Direction is not created if it has null magnitude
1240 if (gp_XYZ(X, Y, Z).SquareModulus() > gp::Resolution()*gp::Resolution())
1242 return new Geom_Direction(X, Y, Z);
1248 //=============================================================================
1249 // Creation d' un Direction de Geom2d a partir d' un Direction de Step
1250 //=============================================================================
1252 Handle(Geom2d_Direction) StepToGeom::MakeDirection2d (const Handle(StepGeom_Direction)& SD)
1254 if (SD->NbDirectionRatios() >= 2)
1256 const Standard_Real X = SD->DirectionRatiosValue(1);
1257 const Standard_Real Y = SD->DirectionRatiosValue(2);
1258 // sln 23.10.2001. CTS23496: Direction is not created if it has null magnitude
1259 if(gp_XY(X,Y).SquareModulus() > gp::Resolution()*gp::Resolution())
1261 return new Geom2d_Direction(X, Y);
1267 //=============================================================================
1268 // Creation d' une ElementarySurface de Geom a partir d' une
1269 // ElementarySurface de Step
1270 //=============================================================================
1272 Handle(Geom_ElementarySurface) StepToGeom::MakeElementarySurface (const Handle(StepGeom_ElementarySurface)& SS)
1274 if (SS->IsKind(STANDARD_TYPE(StepGeom_Plane))) {
1275 return MakePlane (Handle(StepGeom_Plane)::DownCast(SS));
1277 if (SS->IsKind(STANDARD_TYPE(StepGeom_CylindricalSurface))) {
1278 return MakeCylindricalSurface (Handle(StepGeom_CylindricalSurface)::DownCast(SS));
1280 if (SS->IsKind(STANDARD_TYPE(StepGeom_ConicalSurface))) {
1281 return MakeConicalSurface (Handle(StepGeom_ConicalSurface)::DownCast(SS));
1283 if (SS->IsKind(STANDARD_TYPE(StepGeom_SphericalSurface))) {
1284 return MakeSphericalSurface (Handle(StepGeom_SphericalSurface)::DownCast(SS));
1286 if (SS->IsKind(STANDARD_TYPE(StepGeom_ToroidalSurface))) {
1287 return MakeToroidalSurface (Handle(StepGeom_ToroidalSurface)::DownCast(SS));
1292 //=============================================================================
1293 // Creation d' un Ellipse de Geom a partir d' un Ellipse de Step
1294 //=============================================================================
1296 Handle(Geom_Ellipse) StepToGeom::MakeEllipse (const Handle(StepGeom_Ellipse)& SC)
1298 const StepGeom_Axis2Placement AxisSelect = SC->Position();
1299 if (AxisSelect.CaseNum(AxisSelect.Value()) == 2) {
1300 Handle(Geom_Axis2Placement) A1 = MakeAxis2Placement (Handle(StepGeom_Axis2Placement3d)::DownCast(AxisSelect.Value()));
1303 gp_Ax2 A( A1->Ax2() );
1304 const Standard_Real LF = StepData_GlobalFactors::Intance().LengthFactor();
1305 const Standard_Real majorR = SC->SemiAxis1() * LF;
1306 const Standard_Real minorR = SC->SemiAxis2() * LF;
1307 if ( majorR - minorR >= 0. ) { //:o9 abv 19 Feb 99
1308 return new Geom_Ellipse(A, majorR, minorR);
1312 A.SetXDirection ( A.XDirection() ^ A.Direction() );
1313 return new Geom_Ellipse(A, minorR, majorR);
1320 //=============================================================================
1321 // Creation d' un Ellipse de Geom2d a partir d' un Ellipse de Step
1322 //=============================================================================
1324 Handle(Geom2d_Ellipse) StepToGeom::MakeEllipse2d (const Handle(StepGeom_Ellipse)& SC)
1326 const StepGeom_Axis2Placement AxisSelect = SC->Position();
1327 if (AxisSelect.CaseNum(AxisSelect.Value()) == 1) {
1328 Handle(Geom2d_AxisPlacement) A1 = MakeAxisPlacement (Handle(StepGeom_Axis2Placement2d)::DownCast(AxisSelect.Value()));
1331 gp_Ax22d A( A1->Ax2d() );
1332 const Standard_Real majorR = SC->SemiAxis1();
1333 const Standard_Real minorR = SC->SemiAxis2();
1334 if ( majorR - minorR >= 0. ) { //:o9 abv 19 Feb 99: bm4_id_punch_b.stp #678: protection
1335 return new Geom2d_Ellipse(A, majorR, minorR);
1338 const gp_Dir2d X = A.XDirection();
1339 A.SetXDirection ( gp_Dir2d ( X.X(), -X.Y() ) );
1340 return new Geom2d_Ellipse(A, minorR, majorR);
1347 //=============================================================================
1348 // Creation d' un Hyperbola de Geom a partir d' un Hyperbola de Step
1349 //=============================================================================
1351 Handle(Geom_Hyperbola) StepToGeom::MakeHyperbola (const Handle(StepGeom_Hyperbola)& SC)
1353 const StepGeom_Axis2Placement AxisSelect = SC->Position();
1354 if (AxisSelect.CaseNum(AxisSelect.Value()) == 2)
1356 Handle(Geom_Axis2Placement) A1 = MakeAxis2Placement (Handle(StepGeom_Axis2Placement3d)::DownCast(AxisSelect.Value()));
1359 const gp_Ax2 A( A1->Ax2() );
1360 const Standard_Real LF = StepData_GlobalFactors::Intance().LengthFactor();
1361 return new Geom_Hyperbola(A, SC->SemiAxis() * LF, SC->SemiImagAxis() * LF);
1367 //=============================================================================
1368 // Creation d' un Hyperbola de Geom2d a partir d' un Hyperbola de Step
1369 //=============================================================================
1371 Handle(Geom2d_Hyperbola) StepToGeom::MakeHyperbola2d (const Handle(StepGeom_Hyperbola)& SC)
1373 const StepGeom_Axis2Placement AxisSelect = SC->Position();
1374 if (AxisSelect.CaseNum(AxisSelect.Value()) == 1)
1376 Handle(Geom2d_AxisPlacement) A1 = MakeAxisPlacement (Handle(StepGeom_Axis2Placement2d)::DownCast(AxisSelect.Value()));
1379 const gp_Ax22d A( A1->Ax2d() );
1380 return new Geom2d_Hyperbola(A, SC->SemiAxis(), SC->SemiImagAxis());
1386 //=============================================================================
1387 // Creation d' une Line de Geom a partir d' une Line de Step
1388 //=============================================================================
1390 Handle(Geom_Line) StepToGeom::MakeLine (const Handle(StepGeom_Line)& SC)
1392 Handle(Geom_CartesianPoint) P = MakeCartesianPoint(SC->Pnt());
1395 // sln 22.10.2001. CTS23496: Line is not created if direction have not been successfully created
1396 Handle(Geom_VectorWithMagnitude) D = MakeVectorWithMagnitude (SC->Dir());
1399 if( D->Vec().SquareMagnitude() < Precision::Confusion() * Precision::Confusion())
1401 const gp_Dir V(D->Vec());
1402 return new Geom_Line(P->Pnt(), V);
1408 //=============================================================================
1409 // Creation d' une Line de Geom2d a partir d' une Line de Step
1410 //=============================================================================
1412 Handle(Geom2d_Line) StepToGeom::MakeLine2d (const Handle(StepGeom_Line)& SC)
1414 Handle(Geom2d_CartesianPoint) P = MakeCartesianPoint2d(SC->Pnt());
1417 // sln 23.10.2001. CTS23496: Line is not created if direction have not been successfully created
1418 Handle(Geom2d_VectorWithMagnitude) D = MakeVectorWithMagnitude2d (SC->Dir());
1421 const gp_Dir2d D1(D->Vec2d());
1422 return new Geom2d_Line(P->Pnt2d(), D1);
1428 //=============================================================================
1429 // Creation d' un Parabola de Geom a partir d' un Parabola de Step
1430 //=============================================================================
1432 Handle(Geom_Parabola) StepToGeom::MakeParabola (const Handle(StepGeom_Parabola)& SC)
1434 const StepGeom_Axis2Placement AxisSelect = SC->Position();
1435 if (AxisSelect.CaseNum(AxisSelect.Value()) == 2)
1437 Handle(Geom_Axis2Placement) A = MakeAxis2Placement (Handle(StepGeom_Axis2Placement3d)::DownCast(AxisSelect.Value()));
1440 return new Geom_Parabola(A->Ax2(), SC->FocalDist() * StepData_GlobalFactors::Intance().LengthFactor());
1446 //=============================================================================
1447 // Creation d' un Parabola de Geom2d a partir d' un Parabola de Step
1448 //=============================================================================
1450 Handle(Geom2d_Parabola) StepToGeom::MakeParabola2d (const Handle(StepGeom_Parabola)& SC)
1452 const StepGeom_Axis2Placement AxisSelect = SC->Position();
1453 if (AxisSelect.CaseNum(AxisSelect.Value()) == 1) {
1454 Handle(Geom2d_AxisPlacement) A1 = MakeAxisPlacement (Handle(StepGeom_Axis2Placement2d)::DownCast(AxisSelect.Value()));
1457 const gp_Ax22d A( A1->Ax2d() );
1458 return new Geom2d_Parabola(A, SC->FocalDist());
1464 //=============================================================================
1465 // Creation d' un Plane de Geom a partir d' un plane de Step
1466 //=============================================================================
1468 Handle(Geom_Plane) StepToGeom::MakePlane (const Handle(StepGeom_Plane)& SP)
1470 Handle(Geom_Axis2Placement) A = MakeAxis2Placement (SP->Position());
1473 return new Geom_Plane(A->Ax2());
1478 //=======================================================================
1479 //function : MakePolyline
1481 //=======================================================================
1483 Handle(Geom_BSplineCurve) StepToGeom::MakePolyline (const Handle(StepGeom_Polyline)& SPL)
1486 return Handle(Geom_BSplineCurve)();
1488 const Standard_Integer nbp = SPL->NbPoints();
1491 TColgp_Array1OfPnt Poles ( 1, nbp );
1492 TColStd_Array1OfReal Knots ( 1, nbp );
1493 TColStd_Array1OfInteger Mults ( 1, nbp );
1495 for ( Standard_Integer i=1; i <= nbp; i++ )
1497 Handle(Geom_CartesianPoint) P = MakeCartesianPoint (SPL->PointsValue(i));
1499 Poles.SetValue ( i, P->Pnt() );
1502 Knots.SetValue ( i, Standard_Real(i-1) );
1503 Mults.SetValue ( i, 1 );
1505 Mults.SetValue ( 1, 2 );
1506 Mults.SetValue ( nbp, 2 );
1508 return new Geom_BSplineCurve ( Poles, Knots, Mults, 1 );
1513 //=======================================================================
1514 //function : MakePolyline2d
1516 //=======================================================================
1518 Handle(Geom2d_BSplineCurve) StepToGeom::MakePolyline2d (const Handle(StepGeom_Polyline)& SPL)
1521 return Handle(Geom2d_BSplineCurve)();
1523 const Standard_Integer nbp = SPL->NbPoints();
1526 TColgp_Array1OfPnt2d Poles ( 1, nbp );
1527 TColStd_Array1OfReal Knots ( 1, nbp );
1528 TColStd_Array1OfInteger Mults ( 1, nbp );
1530 for ( Standard_Integer i=1; i <= nbp; i++ )
1532 Handle(Geom2d_CartesianPoint) P = MakeCartesianPoint2d (SPL->PointsValue(i));
1534 Poles.SetValue ( i, P->Pnt2d() );
1537 Knots.SetValue ( i, Standard_Real(i-1) );
1538 Mults.SetValue ( i, 1 );
1540 Mults.SetValue ( 1, 2 );
1541 Mults.SetValue ( nbp, 2 );
1543 return new Geom2d_BSplineCurve ( Poles, Knots, Mults, 1 );
1548 //=============================================================================
1549 // Creation d' une RectangularTrimmedSurface de Geom a partir d' une
1550 // RectangularTrimmedSurface de Step
1551 //=============================================================================
1553 Handle(Geom_RectangularTrimmedSurface) StepToGeom::MakeRectangularTrimmedSurface (const Handle(StepGeom_RectangularTrimmedSurface)& SS)
1555 Handle(Geom_Surface) theBasis = MakeSurface (SS->BasisSurface());
1556 if (! theBasis.IsNull())
1558 // -----------------------------------------
1559 // Modification of the Trimming Parameters ?
1560 // -----------------------------------------
1562 Standard_Real uFact = 1.;
1563 Standard_Real vFact = 1.;
1564 const Standard_Real LengthFact = StepData_GlobalFactors::Intance().LengthFactor();
1565 const Standard_Real AngleFact = StepData_GlobalFactors::Intance().PlaneAngleFactor(); // abv 30.06.00 trj4_k1_geo-tc-214.stp #1477: PI/180.;
1567 if (theBasis->IsKind(STANDARD_TYPE(Geom_SphericalSurface)) ||
1568 theBasis->IsKind(STANDARD_TYPE(Geom_ToroidalSurface))) {
1569 uFact = vFact = AngleFact;
1571 else if (theBasis->IsKind(STANDARD_TYPE(Geom_CylindricalSurface))) {
1575 else if ( theBasis->IsKind(STANDARD_TYPE(Geom_SurfaceOfRevolution))) {
1578 else if (theBasis->IsKind(STANDARD_TYPE(Geom_ConicalSurface))) {
1579 const Handle(Geom_ConicalSurface) conicS = Handle(Geom_ConicalSurface)::DownCast(theBasis);
1581 vFact = LengthFact / Cos(conicS->SemiAngle());
1583 else if (theBasis->IsKind(STANDARD_TYPE(Geom_Plane))) {
1584 uFact = vFact = LengthFact;
1587 const Standard_Real U1 = SS->U1() * uFact;
1588 const Standard_Real U2 = SS->U2() * uFact;
1589 const Standard_Real V1 = SS->V1() * vFact;
1590 const Standard_Real V2 = SS->V2() * vFact;
1592 return new Geom_RectangularTrimmedSurface(theBasis, U1, U2, V1, V2, SS->Usense(), SS->Vsense());
1597 //=============================================================================
1598 // Creation d' une SphericalSurface de Geom a partir d' une
1599 // SphericalSurface de Step
1600 //=============================================================================
1602 Handle(Geom_SphericalSurface) StepToGeom::MakeSphericalSurface (const Handle(StepGeom_SphericalSurface)& SS)
1604 Handle(Geom_Axis2Placement) A = MakeAxis2Placement (SS->Position());
1607 return new Geom_SphericalSurface(A->Ax2(), SS->Radius() * StepData_GlobalFactors::Intance().LengthFactor());
1612 //=============================================================================
1613 // Creation d' une Surface de Geom a partir d' une Surface de Step
1614 //=============================================================================
1616 Handle(Geom_Surface) StepToGeom::MakeSurface (const Handle(StepGeom_Surface)& SS)
1618 // sln 01.10.2001 BUC61003. If entry shell is NULL do nothing
1620 return Handle(Geom_Surface)();
1625 if (SS->IsKind(STANDARD_TYPE(StepGeom_BoundedSurface))) {
1626 return MakeBoundedSurface (Handle(StepGeom_BoundedSurface)::DownCast(SS));
1628 if (SS->IsKind(STANDARD_TYPE(StepGeom_ElementarySurface))) {
1629 const Handle(StepGeom_ElementarySurface) S1 = Handle(StepGeom_ElementarySurface)::DownCast(SS);
1630 if(S1->Position().IsNull())
1631 return Handle(Geom_Surface)();
1633 return MakeElementarySurface (S1);
1635 if (SS->IsKind(STANDARD_TYPE(StepGeom_SweptSurface))) {
1636 return MakeSweptSurface (Handle(StepGeom_SweptSurface)::DownCast(SS));
1638 if (SS->IsKind(STANDARD_TYPE(StepGeom_OffsetSurface))) { //:d4 abv 12 Mar 98
1639 const Handle(StepGeom_OffsetSurface) OS = Handle(StepGeom_OffsetSurface)::DownCast(SS);
1641 Handle(Geom_Surface) aBasisSurface = MakeSurface (OS->BasisSurface());
1642 if (! aBasisSurface.IsNull())
1644 // sln 03.10.01. BUC61003. creation of offset surface is corrected
1645 const Standard_Real anOffset = OS->Distance() * StepData_GlobalFactors::Intance().LengthFactor();
1646 if (aBasisSurface->Continuity() == GeomAbs_C0)
1648 const BRepBuilderAPI_MakeFace aBFace(aBasisSurface, Precision::Confusion());
1649 if (aBFace.IsDone())
1651 const TopoDS_Shape aResult = ShapeAlgo::AlgoContainer()->C0ShapeToC1Shape(aBFace.Face(), Abs(anOffset));
1652 if (aResult.ShapeType() == TopAbs_FACE)
1654 aBasisSurface = BRep_Tool::Surface(TopoDS::Face(aResult));
1658 if(aBasisSurface->Continuity() != GeomAbs_C0)
1660 return new Geom_OffsetSurface ( aBasisSurface, anOffset );
1664 else if (SS->IsKind(STANDARD_TYPE(StepGeom_SurfaceReplica))) { //:n7 abv 16 Feb 99
1665 const Handle(StepGeom_SurfaceReplica) SR = Handle(StepGeom_SurfaceReplica)::DownCast(SS);
1666 const Handle(StepGeom_Surface) PS = SR->ParentSurface();
1667 const Handle(StepGeom_CartesianTransformationOperator3d) T = SR->Transformation();
1668 // protect against cyclic references and wrong type of cartop
1669 if ( !T.IsNull() && PS != SS ) {
1670 Handle(Geom_Surface) S1 = MakeSurface (PS);
1674 if (MakeTransformation3d(T,T1))
1676 S1->Transform ( T1 );
1683 catch(Standard_Failure const& anException) {
1687 std::cout<<"Warning: MakeSurface: Exception:";
1688 anException.Print(std::cout); std::cout << std::endl;
1695 //=============================================================================
1696 // Creation d' une SurfaceOfLinearExtrusion de Geom a partir d' une
1697 // SurfaceOfLinearExtrusion de Step
1698 //=============================================================================
1700 Handle(Geom_SurfaceOfLinearExtrusion) StepToGeom::MakeSurfaceOfLinearExtrusion (const Handle(StepGeom_SurfaceOfLinearExtrusion)& SS)
1702 Handle(Geom_Curve) C = MakeCurve (SS->SweptCurve());
1705 // sln 23.10.2001. CTS23496: Surface is not created if extrusion axis have not been successfully created
1706 Handle(Geom_VectorWithMagnitude) V = MakeVectorWithMagnitude (SS->ExtrusionAxis());
1709 const gp_Dir D(V->Vec());
1710 Handle(Geom_Line) aLine = Handle(Geom_Line)::DownCast(C);
1711 if (!aLine.IsNull() && aLine->Lin().Direction().IsParallel(D, Precision::Angular()))
1712 return Handle(Geom_SurfaceOfLinearExtrusion)();
1713 return new Geom_SurfaceOfLinearExtrusion(C,D);
1719 //=============================================================================
1720 // Creation d' une SurfaceOfRevolution de Geom a partir d' une
1721 // SurfaceOfRevolution de Step
1722 //=============================================================================
1724 Handle(Geom_SurfaceOfRevolution) StepToGeom::MakeSurfaceOfRevolution (const Handle(StepGeom_SurfaceOfRevolution)& SS)
1726 Handle(Geom_Curve) C = MakeCurve (SS->SweptCurve());
1729 Handle(Geom_Axis1Placement) A1 = MakeAxis1Placement (SS->AxisPosition());
1732 const gp_Ax1 A( A1->Ax1() );
1733 //skl for OCC952 (one bad case revolution of circle)
1734 if ( C->IsKind(STANDARD_TYPE(Geom_Circle)) || C->IsKind(STANDARD_TYPE(Geom_Ellipse)) )
1736 const Handle(Geom_Conic) conic = Handle(Geom_Conic)::DownCast(C);
1737 const gp_Pnt pc = conic->Location();
1738 const gp_Lin rl (A);
1739 if (rl.Distance(pc) < Precision::Confusion()) { //pc lies on A2
1740 const gp_Dir dirline = A.Direction();
1741 const gp_Dir norm = conic->Axis().Direction();
1742 const gp_Dir xAxis = conic->XAxis().Direction();
1743 //checking A2 lies on plane of circle
1744 if( dirline.IsNormal(norm,Precision::Angular()) && (dirline.IsParallel(xAxis,Precision::Angular()) || C->IsKind(STANDARD_TYPE(Geom_Circle)))) {
1745 //change parametrization for trimming
1746 gp_Ax2 axnew(pc,norm,dirline.Reversed());
1747 conic->SetPosition(axnew);
1748 C = new Geom_TrimmedCurve(conic, 0., M_PI);
1752 return new Geom_SurfaceOfRevolution(C, A);
1758 //=============================================================================
1759 // Creation d' une SweptSurface de prostep a partir d' une
1760 // SweptSurface de Geom
1761 //=============================================================================
1763 Handle(Geom_SweptSurface) StepToGeom::MakeSweptSurface (const Handle(StepGeom_SweptSurface)& SS)
1765 if (SS->IsKind(STANDARD_TYPE(StepGeom_SurfaceOfLinearExtrusion))) {
1766 return MakeSurfaceOfLinearExtrusion (Handle(StepGeom_SurfaceOfLinearExtrusion)::DownCast(SS));
1768 if (SS->IsKind(STANDARD_TYPE(StepGeom_SurfaceOfRevolution))) {
1769 return MakeSurfaceOfRevolution (Handle(StepGeom_SurfaceOfRevolution)::DownCast(SS));
1771 return Handle(Geom_SweptSurface)();
1774 //=============================================================================
1775 // Creation d' une ToroidalSurface de Geom a partir d' une
1776 // ToroidalSurface de Step
1777 //=============================================================================
1779 Handle(Geom_ToroidalSurface) StepToGeom::MakeToroidalSurface (const Handle(StepGeom_ToroidalSurface)& SS)
1781 Handle(Geom_Axis2Placement) A = MakeAxis2Placement (SS->Position());
1784 const Standard_Real LF = StepData_GlobalFactors::Intance().LengthFactor();
1785 return new Geom_ToroidalSurface(A->Ax2(), Abs(SS->MajorRadius() * LF), Abs(SS->MinorRadius() * LF));
1790 //=======================================================================
1791 //function : MakeTransformation2d
1793 //=======================================================================
1794 Standard_Boolean StepToGeom::MakeTransformation2d (const Handle(StepGeom_CartesianTransformationOperator2d)& SCTO, gp_Trsf2d& CT)
1796 // NB : on ne s interesse ici qu au deplacement rigide
1797 Handle(Geom2d_CartesianPoint) CP = MakeCartesianPoint2d (SCTO->LocalOrigin());
1801 // sln 23.10.2001. CTS23496: If problems with creation of direction occur default direction is used
1802 const Handle(StepGeom_Direction) A = SCTO->Axis1();
1805 Handle(Geom2d_Direction) D = MakeDirection2d (A);
1809 const gp_Ax2d result(CP->Pnt2d(),D1);
1810 CT.SetTransformation(result);
1812 return Standard_True;
1814 return Standard_False;
1817 //=======================================================================
1818 //function : MakeTransformation3d
1820 //=======================================================================
1822 Standard_Boolean StepToGeom::MakeTransformation3d (const Handle(StepGeom_CartesianTransformationOperator3d)& SCTO, gp_Trsf& CT)
1824 Handle(Geom_CartesianPoint) CP = MakeCartesianPoint (SCTO->LocalOrigin());
1827 const gp_Pnt Pgp = CP->Pnt();
1829 // sln 23.10.2001. CTS23496: If problems with creation of direction occur default direction is used
1830 gp_Dir D1(1.,0.,0.);
1831 const Handle(StepGeom_Direction) A1 = SCTO->Axis1();
1833 Handle(Geom_Direction) D = MakeDirection (A1);
1838 gp_Dir D2(0.,1.,0.);
1839 const Handle(StepGeom_Direction) A2 = SCTO->Axis2();
1841 Handle(Geom_Direction) D = MakeDirection (A2);
1846 Standard_Boolean isDefaultDirectionUsed = Standard_True;
1848 const Handle(StepGeom_Direction) A3 = SCTO->Axis3();
1850 Handle(Geom_Direction) D = MakeDirection (A3);
1854 isDefaultDirectionUsed = Standard_False;
1857 if(isDefaultDirectionUsed)
1858 D3 = D1.Crossed(D2);
1860 const gp_Ax3 result(Pgp,D3,D1);
1861 CT.SetTransformation(result);
1862 CT = CT.Inverted(); //:n8 abv 16 Feb 99: tr8_as2_db.stp: reverse for accordance with LV tool
1863 return Standard_True;
1865 return Standard_False;
1868 // ----------------------------------------------------------------
1870 // ----------------------------------------------------------------
1871 //:o6 abv 18 Feb 99: parameter Factor added
1872 //:p3 abv 23 Feb 99: parameter Shift added
1873 static Standard_Boolean ExtractParameter
1874 (const Handle(Geom_Curve) & aGeomCurve,
1875 const Handle(StepGeom_HArray1OfTrimmingSelect) & TS,
1876 const Standard_Integer nbSel,
1877 const Standard_Integer MasterRep,
1878 const Standard_Real Factor,
1879 const Standard_Real Shift,
1880 Standard_Real & aParam)
1882 Handle(StepGeom_CartesianPoint) aPoint;
1884 //:S4136 Standard_Real precBrep = BRepAPI::Precision();
1885 for ( i = 1 ; i <= nbSel ; i++) {
1886 StepGeom_TrimmingSelect theSel = TS->Value(i);
1887 if (MasterRep == 2 && theSel.CaseMember() > 0) {
1888 aParam = Shift + Factor * theSel.ParameterValue();
1889 return Standard_True;
1891 else if (MasterRep == 1 && theSel.CaseNumber() > 0) {
1892 aPoint = theSel.CartesianPoint();
1893 Handle(Geom_CartesianPoint) theGeomPnt = StepToGeom::MakeCartesianPoint (aPoint);
1894 gp_Pnt thegpPnt = theGeomPnt->Pnt();
1896 //:S4136: use advanced algorithm
1897 ShapeAnalysis_Curve sac;
1899 sac.Project ( aGeomCurve, thegpPnt, Precision::Confusion(), p, aParam );
1901 //Trim == natural boundary ?
1902 if(aGeomCurve->IsKind(STANDARD_TYPE(Geom_BoundedCurve))) {
1903 Standard_Real frstPar = aGeomCurve->FirstParameter();
1904 Standard_Real lstPar = aGeomCurve->LastParameter();
1905 gp_Pnt frstPnt = aGeomCurve->Value(frstPar);
1906 gp_Pnt lstPnt = aGeomCurve->Value(lstPar);
1907 if(frstPnt.IsEqual(thegpPnt,precBrep)) {
1909 return Standard_True;
1911 if(lstPnt.IsEqual(thegpPnt,precBrep)) {
1913 return Standard_True;
1916 // Project Point On Curve
1917 GeomAPI_ProjectPointOnCurve PPOC(thegpPnt, aGeomCurve);
1918 if (PPOC.NbPoints() == 0) {
1919 return Standard_False;
1921 aParam = PPOC.LowerDistanceParameter();
1923 return Standard_True;
1926 // if the MasterRepresentation is unspecified:
1927 // if a ParameterValue exists, it is preferred
1929 for ( i = 1 ; i <= nbSel ; i++) {
1930 StepGeom_TrimmingSelect theSel = TS->Value(i);
1931 if (theSel.CaseMember() > 0) {
1932 aParam = Shift + Factor * theSel.ParameterValue();
1934 return Standard_True;
1937 // if no ParameterValue exists, it is created from the CartesianPointValue
1939 for ( i = 1 ; i <= nbSel ; i++) {
1940 StepGeom_TrimmingSelect theSel = TS->Value(i);
1941 if (theSel.CaseNumber() > 0) {
1942 aPoint = theSel.CartesianPoint();
1943 Handle(Geom_CartesianPoint) theGeomPnt = StepToGeom::MakeCartesianPoint (aPoint);
1944 gp_Pnt thegpPnt = theGeomPnt->Pnt();
1945 // Project Point On Curve
1946 ShapeAnalysis_Curve sac;
1948 sac.Project ( aGeomCurve, thegpPnt, Precision::Confusion(), p, aParam );
1950 GeomAPI_ProjectPointOnCurve PPOC(thegpPnt, aGeomCurve);
1951 if (PPOC.NbPoints() == 0) {
1952 return Standard_False;
1954 aParam = PPOC.LowerDistanceParameter();
1956 return Standard_True;
1959 return Standard_False; // I suppose
1963 //=============================================================================
1964 // Creation d' une Trimmed Curve de Geom a partir d' une Trimmed Curve de Step
1965 //=============================================================================
1967 Handle(Geom_TrimmedCurve) StepToGeom::MakeTrimmedCurve (const Handle(StepGeom_TrimmedCurve)& SC)
1969 const Handle(StepGeom_Curve) theSTEPCurve = SC->BasisCurve();
1970 Handle(Geom_Curve) theCurve = MakeCurve (theSTEPCurve);
1971 if (theCurve.IsNull())
1972 return Handle(Geom_TrimmedCurve)();
1974 const Handle(StepGeom_HArray1OfTrimmingSelect)& theTrimSel1 = SC->Trim1();
1975 const Handle(StepGeom_HArray1OfTrimmingSelect)& theTrimSel2 = SC->Trim2();
1976 const Standard_Integer nbSel1 = SC->NbTrim1();
1977 const Standard_Integer nbSel2 = SC->NbTrim2();
1979 Standard_Integer MasterRep;
1980 switch (SC->MasterRepresentation())
1982 case StepGeom_tpCartesian: MasterRep = 1; break;
1983 case StepGeom_tpParameter: MasterRep = 2; break;
1984 default: MasterRep = 0;
1987 //gka 18.02.04 analysis for case when MasterRep = .Unspecified
1988 //and parameters are specified as CARTESIAN_POINT
1989 Standard_Boolean isPoint = Standard_False;
1990 if(MasterRep == 0 || (MasterRep == 2 && nbSel1 >1 && nbSel2 > 1)) {
1991 Standard_Integer ii;
1992 for(ii = 1; ii <= nbSel1; ii++)
1994 if (!(theTrimSel1->Value(ii).CartesianPoint().IsNull()))
1996 for(ii = 1; ii <= nbSel2; ii++)
1998 if (!(theTrimSel2->Value(ii).CartesianPoint().IsNull()))
2000 isPoint = Standard_True;
2009 //:o6 abv 18 Feb 99: computation of factor moved
2010 Standard_Real fact = 1., shift = 0.;
2011 if (theSTEPCurve->IsKind(STANDARD_TYPE(StepGeom_Line))) {
2012 const Handle(StepGeom_Line) theLine =
2013 Handle(StepGeom_Line)::DownCast(theSTEPCurve);
2014 fact = theLine->Dir()->Magnitude() * StepData_GlobalFactors::Intance().LengthFactor();
2016 else if (theSTEPCurve->IsKind(STANDARD_TYPE(StepGeom_Circle)) ||
2017 theSTEPCurve->IsKind(STANDARD_TYPE(StepGeom_Ellipse))) {
2018 // if (trim1 > 2.1*M_PI || trim2 > 2.1*M_PI) fact = M_PI / 180.;
2019 fact = StepData_GlobalFactors::Intance().PlaneAngleFactor();
2020 //:p3 abv 23 Feb 99: shift on pi/2 on ellipse with R1 < R2
2021 const Handle(StepGeom_Ellipse) ellipse = Handle(StepGeom_Ellipse)::DownCast(theSTEPCurve);
2022 if ( !ellipse.IsNull() && ellipse->SemiAxis1() - ellipse->SemiAxis2() < 0. )
2025 // skl 04.02.2002 for OCC133: we can not make TrimmedCurve if
2026 // there is no X-direction in StepGeom_Axis2Placement3d
2027 const Handle(StepGeom_Conic) conic = Handle(StepGeom_Conic)::DownCast(theSTEPCurve);
2028 // CKY 6-FEB-2004 for Airbus-MedialAxis :
2029 // this restriction does not apply for trimming by POINTS
2030 if(!conic.IsNull() && MasterRep != 1) {
2031 const StepGeom_Axis2Placement a2p = conic->Position();
2032 if(a2p.CaseNum(a2p.Value())==2) {
2033 if( !a2p.Axis2Placement3d()->HasRefDirection() ) {
2034 ////gka 18.02.04 analysis for case when MasterRep = .Unspecified
2035 //and parameters are specified as CARTESIAN_POINT
2036 if(isPoint /*&& !MasterRep*/)
2039 if ( SC->SenseAgreement() )
2040 return new Geom_TrimmedCurve(theCurve, 0., 2.*M_PI, Standard_True);
2042 return new Geom_TrimmedCurve(theCurve, 2.*M_PI, 0., Standard_False);
2049 Standard_Real trim1 = 0.;
2050 Standard_Real trim2 = 0.;
2051 Handle(StepGeom_CartesianPoint) TrimCP1, TrimCP2;
2052 const Standard_Boolean FoundParam1 = ExtractParameter(theCurve, theTrimSel1, nbSel1, MasterRep, fact, shift, trim1);
2053 const Standard_Boolean FoundParam2 = ExtractParameter(theCurve, theTrimSel2, nbSel2, MasterRep, fact, shift, trim2);
2055 if (FoundParam1 && FoundParam2) {
2056 const Standard_Real cf = theCurve->FirstParameter();
2057 const Standard_Real cl = theCurve->LastParameter();
2058 //: abv 09.04.99: S4136: bm2_ug_t4-B.stp #70610: protect against OutOfRange
2059 if ( !theCurve->IsPeriodic() ) {
2060 if ( trim1 < cf ) trim1 = cf;
2061 else if ( trim1 > cl ) trim1 = cl;
2062 if ( trim2 < cf ) trim2 = cf;
2063 else if ( trim2 > cl ) trim2 = cl;
2065 if (Abs(trim1 - trim2) < Precision::PConfusion()) {
2066 if (theCurve->IsPeriodic()) {
2067 ElCLib::AdjustPeriodic(cf,cl,Precision::PConfusion(),trim1,trim2);
2069 else if (theCurve->IsClosed()) {
2070 if (Abs(trim1 - cf) < Precision::PConfusion()) {
2081 // CKY 16-DEC-1997 : USA60035 le texte de Part42 parle de degres
2082 // mais des systemes ecrivent en radians. Exploiter UnitsMethods
2083 //:o6 trim1 = trim1 * fact;
2084 //:o6 trim2 = trim2 * fact;
2085 if ( SC->SenseAgreement() )
2086 return new Geom_TrimmedCurve(theCurve, trim1, trim2, Standard_True);
2087 else //:abv 29.09.00 PRO20362: reverse parameters in case of reversed curve
2088 return new Geom_TrimmedCurve(theCurve, trim2, trim1, Standard_False);
2093 //=============================================================================
2094 // Creation d'une Trimmed Curve de Geom2d a partir d' une Trimmed Curve de Step
2095 //=============================================================================
2096 // Shall be completed to treat trimming with points
2098 Handle(Geom2d_BSplineCurve) StepToGeom::MakeTrimmedCurve2d (const Handle(StepGeom_TrimmedCurve)& SC)
2100 const Handle(StepGeom_Curve) BasisCurve = SC->BasisCurve();
2101 Handle(Geom2d_Curve) theGeomBasis = MakeCurve2d (BasisCurve);
2102 if (theGeomBasis.IsNull())
2103 return Handle(Geom2d_BSplineCurve)();
2105 if (theGeomBasis->IsKind(STANDARD_TYPE(Geom2d_BSplineCurve))) {
2106 return Handle(Geom2d_BSplineCurve)::DownCast(theGeomBasis);
2109 const Handle(StepGeom_HArray1OfTrimmingSelect)& theTrimSel1 = SC->Trim1();
2110 const Handle(StepGeom_HArray1OfTrimmingSelect)& theTrimSel2 = SC->Trim2();
2111 const Standard_Integer nbSel1 = SC->NbTrim1();
2112 const Standard_Integer nbSel2 = SC->NbTrim2();
2113 if ((nbSel1 == 1) && (nbSel2 == 1) &&
2114 (theTrimSel1->Value(1).CaseMember() > 0) &&
2115 (theTrimSel2->Value(1).CaseMember() > 0))
2117 const Standard_Real u1 = theTrimSel1->Value(1).ParameterValue();
2118 const Standard_Real u2 = theTrimSel2->Value(1).ParameterValue();
2119 Standard_Real fact = 1., shift = 0.;
2121 if (BasisCurve->IsKind(STANDARD_TYPE(StepGeom_Line))) {
2122 const Handle(StepGeom_Line) theLine = Handle(StepGeom_Line)::DownCast(BasisCurve);
2123 fact = theLine->Dir()->Magnitude();
2125 else if (BasisCurve->IsKind(STANDARD_TYPE(StepGeom_Circle)) ||
2126 BasisCurve->IsKind(STANDARD_TYPE(StepGeom_Ellipse))) {
2127 // if (u1 > 2.1*M_PI || u2 > 2.1*M_PI) fact = M_PI / 180.;
2128 fact = StepData_GlobalFactors::Intance().PlaneAngleFactor();
2129 //:p3 abv 23 Feb 99: shift on pi/2 on ellipse with R1 < R2
2130 const Handle(StepGeom_Ellipse) ellipse = Handle(StepGeom_Ellipse)::DownCast(BasisCurve);
2131 if ( !ellipse.IsNull() && ellipse->SemiAxis1() - ellipse->SemiAxis2() < 0. )
2134 else if (BasisCurve->IsKind(STANDARD_TYPE(StepGeom_Parabola)) ||
2135 BasisCurve->IsKind(STANDARD_TYPE(StepGeom_Hyperbola))) {
2138 // CKY 16-DEC-1997 : USA60035 le texte de Part42 parle de degres
2139 // mais des systemes ecrivent en radians. Exploiter UnitsMethods
2141 const Standard_Real newU1 = shift + u1 * fact;
2142 const Standard_Real newU2 = shift + u2 * fact;
2144 const Handle(Geom2d_TrimmedCurve) theTrimmed =
2145 new Geom2d_TrimmedCurve(theGeomBasis, newU1, newU2, SC->SenseAgreement());
2146 return Geom2dConvert::CurveToBSplineCurve(theTrimmed);
2151 //=============================================================================
2152 // Creation d' un VectorWithMagnitude de Geom a partir d' un Vector de Step
2153 //=============================================================================
2155 Handle(Geom_VectorWithMagnitude) StepToGeom::MakeVectorWithMagnitude (const Handle(StepGeom_Vector)& SV)
2157 // sln 22.10.2001. CTS23496: Vector is not created if direction have not been successfully created
2158 Handle(Geom_Direction) D = MakeDirection (SV->Orientation());
2161 const gp_Vec V(D->Dir().XYZ() * SV->Magnitude() * StepData_GlobalFactors::Intance().LengthFactor());
2162 return new Geom_VectorWithMagnitude(V);
2167 //=============================================================================
2168 // Creation d' un VectorWithMagnitude de Geom2d a partir d' un Vector de Step
2169 //=============================================================================
2171 Handle(Geom2d_VectorWithMagnitude) StepToGeom::MakeVectorWithMagnitude2d (const Handle(StepGeom_Vector)& SV)
2173 // sln 23.10.2001. CTS23496: Vector is not created if direction have not been successfully created (MakeVectorWithMagnitude2d(...) function)
2174 Handle(Geom2d_Direction) D = MakeDirection2d (SV->Orientation());
2177 const gp_Vec2d V(D->Dir2d().XY() * SV->Magnitude());
2178 return new Geom2d_VectorWithMagnitude(V);