0024023: Revamp the OCCT Handle -- general
[occt.git] / src / GeomToStep / GeomToStep_MakeConic.cxx
1 // Created on: 1993-06-21
2 // Created by: Martine LANGLOIS
3 // Copyright (c) 1993-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_MakeConic.ixx>
18 #include <StdFail_NotDone.hxx>
19 #include <StepGeom_Circle.hxx>
20 #include <StepGeom_Ellipse.hxx>
21 #include <StepGeom_Hyperbola.hxx>
22 #include <StepGeom_Parabola.hxx>
23 #include <GeomToStep_MakeConic.hxx>
24 #include <Geom_Circle.hxx>
25 #include <Geom_Ellipse.hxx>
26 #include <Geom_Hyperbola.hxx>
27 #include <Geom_Parabola.hxx>
28 #include <Geom2d_Circle.hxx>
29 #include <Geom2d_Ellipse.hxx>
30 #include <Geom2d_Hyperbola.hxx>
31 #include <Geom2d_Parabola.hxx>
32 #include <GeomToStep_MakeCircle.hxx>
33 #include <GeomToStep_MakeEllipse.hxx>
34 #include <GeomToStep_MakeHyperbola.hxx>
35 #include <GeomToStep_MakeParabola.hxx>
36
37 //=============================================================================
38 // Creation d' une Conic de prostep a partir d' une Conic de Geom
39 //=============================================================================
40
41 GeomToStep_MakeConic::GeomToStep_MakeConic ( const Handle(Geom_Conic)& C)
42 {
43   done = Standard_True;
44   if (C->IsKind(STANDARD_TYPE(Geom_Circle))) {
45     Handle(Geom_Circle) Cer = Handle(Geom_Circle)::DownCast(C);
46     GeomToStep_MakeCircle MkCircle(Cer);
47     theConic = MkCircle.Value();
48   }
49   else if (C->IsKind(STANDARD_TYPE(Geom_Ellipse))) {
50     Handle(Geom_Ellipse) Ell = Handle(Geom_Ellipse)::DownCast(C);
51     GeomToStep_MakeEllipse MkEllipse(Ell);
52     theConic = MkEllipse.Value();
53   }
54   else if (C->IsKind(STANDARD_TYPE(Geom_Hyperbola))) {
55     Handle(Geom_Hyperbola) Hyp = Handle(Geom_Hyperbola)::DownCast(C);
56     GeomToStep_MakeHyperbola MkHyperbola(Hyp);
57     theConic = MkHyperbola.Value();
58   }
59   else if (C->IsKind(STANDARD_TYPE(Geom_Parabola))) {
60     Handle(Geom_Parabola) Par = Handle(Geom_Parabola)::DownCast(C);
61     GeomToStep_MakeParabola MkParabola(Par);
62     theConic = MkParabola.Value();
63   }
64   else {
65 #ifdef OCCT_DEBUG
66     cout << "3D Curve Type   : " << C->DynamicType() << endl;
67 #endif
68     done = Standard_False;
69   }
70 }        
71
72 //=============================================================================
73 // Creation d' une Conic2d de prostep a partir d' une Conic de Geom2d
74 //=============================================================================
75
76 GeomToStep_MakeConic::GeomToStep_MakeConic ( const Handle(Geom2d_Conic)& C)
77 {
78   done = Standard_True;
79   if (C->IsKind(STANDARD_TYPE(Geom2d_Circle))) {
80     Handle(Geom2d_Circle) Cer = Handle(Geom2d_Circle)::DownCast(C);
81     GeomToStep_MakeCircle MkCircle(Cer);
82     theConic = MkCircle.Value();
83   }
84   else if (C->IsKind(STANDARD_TYPE(Geom2d_Ellipse))) {
85     Handle(Geom2d_Ellipse) Ell = Handle(Geom2d_Ellipse)::DownCast(C);
86     GeomToStep_MakeEllipse MkEllipse(Ell);
87     theConic = MkEllipse.Value();
88   }
89   else if (C->IsKind(STANDARD_TYPE(Geom2d_Hyperbola))) {
90     Handle(Geom2d_Hyperbola) Hyp = Handle(Geom2d_Hyperbola)::DownCast(C);
91     GeomToStep_MakeHyperbola MkHyperbola(Hyp);
92     theConic = MkHyperbola.Value();
93   }
94   else if (C->IsKind(STANDARD_TYPE(Geom2d_Parabola))) {
95     Handle(Geom2d_Parabola) Par = Handle(Geom2d_Parabola)::DownCast(C);
96     GeomToStep_MakeParabola MkParabola(Par);
97     theConic = MkParabola.Value();
98   }
99   else {
100     // Attention : Other 2d conics shall be implemented ...
101     //             To be performed later !
102 #ifdef OCCT_DEBUG
103     cout << "2D conic not yet implemented" << endl;
104 #endif
105     done = Standard_False;
106   }
107 }        
108
109 //=============================================================================
110 // renvoi des valeurs
111 //=============================================================================
112
113 const Handle(StepGeom_Conic) &
114       GeomToStep_MakeConic::Value() const
115 {
116   StdFail_NotDone_Raise_if(!done, "");
117   return theConic;
118 }