1 // Created on: 1994-09-01
2 // Created by: Frederic MAUPAS
3 // Copyright (c) 1994-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 //:o9 abv 19.02.99: bm4_id_punch_b.stp #678: treatment of minR > maxR
18 // NOTE: parametrisation of resulting ellipse shifted on pi/2
20 #include <Geom2d_AxisPlacement.hxx>
21 #include <Geom2d_Ellipse.hxx>
23 #include <gp_Ax22d.hxx>
24 #include <StepGeom_Axis2Placement2d.hxx>
25 #include <StepGeom_Ellipse.hxx>
26 #include <StepToGeom_MakeAxisPlacement.hxx>
27 #include <StepToGeom_MakeEllipse2d.hxx>
29 //=============================================================================
30 // Creation d' un Ellipse de Geom2d a partir d' un Ellipse de Step
31 //=============================================================================
32 Standard_Boolean StepToGeom_MakeEllipse2d::Convert
33 (const Handle(StepGeom_Ellipse)& SC,
34 Handle(Geom2d_Ellipse)& CC)
36 const StepGeom_Axis2Placement AxisSelect = SC->Position();
37 if (AxisSelect.CaseNum(AxisSelect.Value()) == 1) {
38 Handle(Geom2d_AxisPlacement) A1;
39 if (StepToGeom_MakeAxisPlacement::Convert
40 (Handle(StepGeom_Axis2Placement2d)::DownCast(AxisSelect.Value()),A1))
42 gp_Ax22d A( A1->Ax2d() );
43 const Standard_Real majorR = SC->SemiAxis1();
44 const Standard_Real minorR = SC->SemiAxis2();
45 if ( majorR - minorR >= 0. ) { //:o9 abv 19 Feb 99: bm4_id_punch_b.stp #678: protection
46 CC = new Geom2d_Ellipse(A, majorR, minorR);
49 const gp_Dir2d X = A.XDirection();
50 A.SetXDirection ( gp_Dir2d ( X.X(), -X.Y() ) );
51 CC = new Geom2d_Ellipse(A, minorR, majorR);
56 return Standard_False;