0024023: Revamp the OCCT Handle -- general
[occt.git] / src / GeomToStep / GeomToStep_MakeHyperbola.cxx
CommitLineData
973c2be1 1// Copyright (c) 1999-2014 OPEN CASCADE SAS
b311480e 2//
973c2be1 3// This file is part of Open CASCADE Technology software library.
b311480e 4//
d5f74e42 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
973c2be1 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.
b311480e 10//
973c2be1 11// Alternatively, this file may be used under the terms of Open CASCADE
12// commercial license or contractual agreement.
b311480e 13
7fd59977 14#include <GeomToStep_MakeHyperbola.ixx>
15
16#include <StepGeom_Hyperbola.hxx>
c04c30b3 17#include <StepGeom_Axis2Placement2d.hxx>
18#include <StepGeom_Axis2Placement3d.hxx>
7fd59977 19#include <gp_Hypr.hxx>
20#include <gp_Hypr2d.hxx>
21#include <Geom_Hyperbola.hxx>
22#include <GeomToStep_MakeAxis2Placement2d.hxx>
23#include <GeomToStep_MakeAxis2Placement3d.hxx>
24#include <StdFail_NotDone.hxx>
25#include <TCollection_HAsciiString.hxx>
26#include <UnitsMethods.hxx>
27
28
29//=============================================================================
30// Creation d'une hyperbola de prostep a partir d'une hyperbola de
31// Geom2d
32//=============================================================================
33
b311480e 34GeomToStep_MakeHyperbola::GeomToStep_MakeHyperbola(const Handle(Geom2d_Hyperbola)& C)
7fd59977 35{
36 gp_Hypr2d gpHyp;
37 gpHyp = C->Hypr2d();
38
39 Handle(StepGeom_Hyperbola) HStep = new StepGeom_Hyperbola;
40 StepGeom_Axis2Placement Ax2;
41 Handle(StepGeom_Axis2Placement2d) Ax2Step;
42 Standard_Real majorR, minorR;
43
44 GeomToStep_MakeAxis2Placement2d MkAxis2(gpHyp.Axis());
45 Ax2Step = MkAxis2.Value();
46 majorR = gpHyp.MajorRadius();
47 minorR = gpHyp.MinorRadius();
48 Ax2.SetValue(Ax2Step);
49 Handle(TCollection_HAsciiString) name = new TCollection_HAsciiString("");
50 HStep->Init(name, Ax2,majorR,minorR);
51 theHyperbola = HStep;
52 done = Standard_True;
53}
54
55//=============================================================================
56// Creation d'une hyperbola de prostep a partir d'une hyperbola de
57// Geom
58//=============================================================================
59
60 GeomToStep_MakeHyperbola::GeomToStep_MakeHyperbola(const Handle(Geom_Hyperbola)& C)
61{
62 gp_Hypr gpHyp;
63 gpHyp = C->Hypr();
64
65 Handle(StepGeom_Hyperbola) HStep = new StepGeom_Hyperbola;
66 StepGeom_Axis2Placement Ax2;
67 Handle(StepGeom_Axis2Placement3d) Ax2Step;
68 Standard_Real majorR, minorR;
69
70 GeomToStep_MakeAxis2Placement3d MkAxis2(gpHyp.Position());
71 Ax2Step = MkAxis2.Value();
72 majorR = gpHyp.MajorRadius();
73 minorR = gpHyp.MinorRadius();
74 Ax2.SetValue(Ax2Step);
75 Handle(TCollection_HAsciiString) name = new TCollection_HAsciiString("");
76 Standard_Real fact = UnitsMethods::LengthFactor();
77 HStep->Init(name, Ax2,majorR/fact,minorR/fact);
78 theHyperbola = HStep;
79 done = Standard_True;
80}
81
82//=============================================================================
83// return the result
84//=============================================================================
85
86const Handle(StepGeom_Hyperbola)& GeomToStep_MakeHyperbola::Value() const
87{
11bf7051 88 StdFail_NotDone_Raise_if(!done, "");
7fd59977 89 return theHyperbola;
90}
91