0d91ace93f040b5df5d29a872e350381b5380cea
[occt.git] / src / GeomToStep / GeomToStep_MakeParabola.cxx
1 // Copyright (c) 1999-2014 OPEN CASCADE SAS
2 //
3 // This file is part of Open CASCADE Technology software library.
4 //
5 // This library is free software; you can redistribute it and/or modify it under
6 // the terms of the GNU Lesser General Public License version 2.1 as published
7 // by the Free Software Foundation, with special exception defined in the file
8 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
9 // distribution for complete text of the license and disclaimer of any warranty.
10 //
11 // Alternatively, this file may be used under the terms of Open CASCADE
12 // commercial license or contractual agreement.
13
14 #include <GeomToStep_MakeParabola.ixx>
15
16 #include <StepGeom_Parabola.hxx>
17 #include <gp_Parab.hxx>
18 #include <gp_Parab2d.hxx>
19 #include <Geom_Parabola.hxx>
20 #include <GeomToStep_MakeAxis2Placement2d.hxx>
21 #include <GeomToStep_MakeAxis2Placement3d.hxx>
22 #include <StdFail_NotDone.hxx>
23 #include <TCollection_HAsciiString.hxx>
24 #include <UnitsMethods.hxx>
25
26
27 //=============================================================================
28 // Creation d'une Parabola de prostep a partir d'une Parabola de
29 // Geom2d
30 //=============================================================================
31
32 GeomToStep_MakeParabola::GeomToStep_MakeParabola(const Handle(Geom2d_Parabola)& C)
33 {
34   gp_Parab2d gpPar;
35   gpPar = C->Parab2d();
36
37   Handle(StepGeom_Parabola) PStep = new StepGeom_Parabola;
38   StepGeom_Axis2Placement            Ax2;
39   Handle(StepGeom_Axis2Placement2d)  Ax2Step;
40   Standard_Real                   focal;
41   
42   GeomToStep_MakeAxis2Placement2d MkAxis2(gpPar.Axis());
43   Ax2Step = MkAxis2.Value();
44   focal = gpPar.Focal();
45   Ax2.SetValue(Ax2Step);
46   Handle(TCollection_HAsciiString) name = new TCollection_HAsciiString("");
47   PStep->Init(name, Ax2, focal);
48   theParabola = PStep;
49   done = Standard_True;
50 }
51
52 //=============================================================================
53 // Creation d'une Parabola de prostep a partir d'une Parabola de
54 // Geom
55 //=============================================================================
56
57  GeomToStep_MakeParabola::GeomToStep_MakeParabola(const Handle(Geom_Parabola)& C)
58 {
59   gp_Parab gpPar;
60   gpPar = C->Parab();
61
62   Handle(StepGeom_Parabola) PStep = new StepGeom_Parabola;
63   StepGeom_Axis2Placement            Ax2;
64   Handle(StepGeom_Axis2Placement3d)  Ax2Step;
65   Standard_Real                   focal;
66   
67   GeomToStep_MakeAxis2Placement3d MkAxis2(gpPar.Position());
68   Ax2Step = MkAxis2.Value();
69   focal = gpPar.Focal();
70   Ax2.SetValue(Ax2Step);
71   Handle(TCollection_HAsciiString) name = new TCollection_HAsciiString("");
72   PStep->Init(name, Ax2, focal / UnitsMethods::LengthFactor());
73   theParabola = PStep;
74   done = Standard_True;
75 }
76
77 //=============================================================================
78 // return the result
79 //=============================================================================
80
81 const Handle(StepGeom_Parabola)& GeomToStep_MakeParabola::Value() const 
82 {
83   StdFail_NotDone_Raise_if(!done, "");
84   return theParabola;
85 }
86