0024023: Revamp the OCCT Handle -- general
[occt.git] / src / GeomToStep / GeomToStep_MakeEllipse.cxx
1 // Created on: 1994-09-02
2 // Created by: Frederic MAUPAS
3 // Copyright (c) 1994-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
5 //
6 // This file is part of Open CASCADE Technology software library.
7 //
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.
13 //
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
16
17 #include <GeomToStep_MakeEllipse.ixx>
18 #include <GeomToStep_MakeAxis2Placement3d.hxx>
19 #include <GeomToStep_MakeAxis2Placement2d.hxx>
20 #include <StdFail_NotDone.hxx>
21 #include <Geom_Ellipse.hxx>
22 #include <gp_Elips2d.hxx>
23 #include <StepGeom_Ellipse.hxx>
24 #include <StepGeom_Axis2Placement2d.hxx>
25 #include <StepGeom_Axis2Placement3d.hxx>
26 #include <TCollection_HAsciiString.hxx>
27 #include <UnitsMethods.hxx>
28
29 //=============================================================================
30 // Creation d'une ellipse de prostep a partir d'une ellipse 3d de gp
31 //=============================================================================
32
33 GeomToStep_MakeEllipse::GeomToStep_MakeEllipse( const gp_Elips& E)
34 {
35 #include <GeomToStep_MakeEllipse_gen.pxx>
36 }
37
38
39 //=============================================================================
40 // Creation d'une ellipse de prostep a partir d'une ellipse de
41 // Geom
42 //=============================================================================
43
44 GeomToStep_MakeEllipse::GeomToStep_MakeEllipse( const Handle(Geom_Ellipse)& Cer)
45 {
46   gp_Elips E;
47   E = Cer->Elips();
48 #include <GeomToStep_MakeEllipse_gen.pxx>
49 }
50
51
52 //=============================================================================
53 // Creation d'une ellipse 2d de prostep a partir d'une ellipse de
54 // Geom2d
55 //=============================================================================
56
57 GeomToStep_MakeEllipse::GeomToStep_MakeEllipse( const Handle(Geom2d_Ellipse)& Cer)
58 {
59   gp_Elips2d E2d;
60   E2d = Cer->Elips2d();
61
62   Handle(StepGeom_Ellipse) EStep = new StepGeom_Ellipse;
63   StepGeom_Axis2Placement Ax2;
64   Handle(StepGeom_Axis2Placement2d) Ax2Step;
65   Standard_Real majorR, minorR;
66   
67   GeomToStep_MakeAxis2Placement2d MkAxis2(E2d.Axis());
68   Ax2Step = MkAxis2.Value();
69   majorR = E2d.MajorRadius();
70   minorR = E2d.MinorRadius();
71   Ax2.SetValue(Ax2Step);
72   Handle(TCollection_HAsciiString) name = new TCollection_HAsciiString("");
73   EStep->Init(name, Ax2, majorR, minorR);
74   theEllipse = EStep;
75   done = Standard_True;
76
77 }
78
79 //=============================================================================
80 // renvoi des valeurs
81 //=============================================================================
82
83 const Handle(StepGeom_Ellipse) &
84       GeomToStep_MakeEllipse::Value() const
85 {
86   StdFail_NotDone_Raise_if(!done, "");
87   return theEllipse;
88 }