0031642: Visualization - crash in Graphic3d_Structure::SetVisual() on redisplaying...
[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
15 #include <Geom2d_Parabola.hxx>
16 #include <Geom_Parabola.hxx>
17 #include <GeomToStep_MakeAxis2Placement2d.hxx>
18 #include <GeomToStep_MakeAxis2Placement3d.hxx>
19 #include <GeomToStep_MakeParabola.hxx>
20 #include <gp_Parab.hxx>
21 #include <gp_Parab2d.hxx>
22 #include <StdFail_NotDone.hxx>
23 #include <StepGeom_Axis2Placement2d.hxx>
24 #include <StepGeom_Axis2Placement3d.hxx>
25 #include <StepGeom_Parabola.hxx>
26 #include <TCollection_HAsciiString.hxx>
27 #include <UnitsMethods.hxx>
28
29 //=============================================================================
30 // Creation d'une Parabola de prostep a partir d'une Parabola de
31 // Geom2d
32 //=============================================================================
33 GeomToStep_MakeParabola::GeomToStep_MakeParabola(const Handle(Geom2d_Parabola)& C)
34 {
35   gp_Parab2d gpPar;
36   gpPar = C->Parab2d();
37
38   Handle(StepGeom_Parabola) PStep = new StepGeom_Parabola;
39   StepGeom_Axis2Placement            Ax2;
40   Handle(StepGeom_Axis2Placement2d)  Ax2Step;
41   Standard_Real                   focal;
42   
43   GeomToStep_MakeAxis2Placement2d MkAxis2(gpPar.Axis());
44   Ax2Step = MkAxis2.Value();
45   focal = gpPar.Focal();
46   Ax2.SetValue(Ax2Step);
47   Handle(TCollection_HAsciiString) name = new TCollection_HAsciiString("");
48   PStep->Init(name, Ax2, focal);
49   theParabola = PStep;
50   done = Standard_True;
51 }
52
53 //=============================================================================
54 // Creation d'une Parabola de prostep a partir d'une Parabola de
55 // Geom
56 //=============================================================================
57
58  GeomToStep_MakeParabola::GeomToStep_MakeParabola(const Handle(Geom_Parabola)& C)
59 {
60   gp_Parab gpPar;
61   gpPar = C->Parab();
62
63   Handle(StepGeom_Parabola) PStep = new StepGeom_Parabola;
64   StepGeom_Axis2Placement            Ax2;
65   Handle(StepGeom_Axis2Placement3d)  Ax2Step;
66   Standard_Real                   focal;
67   
68   GeomToStep_MakeAxis2Placement3d MkAxis2(gpPar.Position());
69   Ax2Step = MkAxis2.Value();
70   focal = gpPar.Focal();
71   Ax2.SetValue(Ax2Step);
72   Handle(TCollection_HAsciiString) name = new TCollection_HAsciiString("");
73   PStep->Init(name, Ax2, focal / UnitsMethods::LengthFactor());
74   theParabola = PStep;
75   done = Standard_True;
76 }
77
78 //=============================================================================
79 // return the result
80 //=============================================================================
81
82 const Handle(StepGeom_Parabola)& GeomToStep_MakeParabola::Value() const 
83 {
84   StdFail_NotDone_Raise_if (!done, "GeomToStep_MakeParabola::Value() - no result");
85   return theParabola;
86 }
87