0022048: Visualization, AIS_InteractiveContext - single object selection should alway...
[occt.git] / src / Geom2dAdaptor / Geom2dAdaptor.cxx
1 // Created on: 1994-05-30
2 // Created by: Remi LEQUETTE
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
18 #include <Adaptor2d_Curve2d.hxx>
19 #include <Geom2d_BezierCurve.hxx>
20 #include <Geom2d_BSplineCurve.hxx>
21 #include <Geom2d_Circle.hxx>
22 #include <Geom2d_Curve.hxx>
23 #include <Geom2d_Ellipse.hxx>
24 #include <Geom2d_Hyperbola.hxx>
25 #include <Geom2d_Line.hxx>
26 #include <Geom2d_Parabola.hxx>
27 #include <Geom2d_TrimmedCurve.hxx>
28 #include <Geom2dAdaptor.hxx>
29 #include <gp_Circ2d.hxx>
30 #include <gp_Elips2d.hxx>
31 #include <gp_Hypr2d.hxx>
32 #include <gp_Lin2d.hxx>
33 #include <gp_Parab2d.hxx>
34
35 //=======================================================================
36 //function : MakeCurve
37 //purpose  : 
38 //=======================================================================
39 Handle(Geom2d_Curve) Geom2dAdaptor::MakeCurve
40        (const Adaptor2d_Curve2d& HC)
41 {
42   Handle(Geom2d_Curve) C2D;
43   switch (HC.GetType()) {
44
45   case GeomAbs_Line:
46     {
47       Handle(Geom2d_Line) GL = new Geom2d_Line(HC.Line());
48       C2D = GL;
49     }
50     break;
51     
52   case GeomAbs_Circle:
53     {
54       Handle(Geom2d_Circle) GL = new Geom2d_Circle(HC.Circle());
55       C2D = GL;
56     }
57     break;
58     
59   case GeomAbs_Ellipse:
60     {
61       Handle(Geom2d_Ellipse) GL = new Geom2d_Ellipse(HC.Ellipse());
62       C2D = GL;
63     }
64     break;
65     
66   case GeomAbs_Parabola:
67     {
68       Handle(Geom2d_Parabola) GL = new Geom2d_Parabola(HC.Parabola());
69       C2D = GL;
70     }
71     break;
72     
73   case GeomAbs_Hyperbola:
74     {
75       Handle(Geom2d_Hyperbola) GL = new Geom2d_Hyperbola(HC.Hyperbola());
76       C2D = GL;
77     }
78     break;
79
80   case GeomAbs_BezierCurve:
81     {
82       C2D = HC.Bezier();
83     }
84     break;
85
86   case GeomAbs_BSplineCurve:
87     {
88       C2D = HC.BSpline();
89     }
90     break;
91     
92   default:
93     throw Standard_DomainError("Geom2dAdaptor::MakeCurve, OtherCurve");
94
95   }
96
97   // trim the curve if necassary.
98   if (! C2D.IsNull() &&
99       ((HC.FirstParameter() != C2D->FirstParameter()) ||
100       (HC.LastParameter()  != C2D->LastParameter()))) {
101
102     C2D = new Geom2d_TrimmedCurve
103       (C2D,HC.FirstParameter(),HC.LastParameter());
104   }
105
106   return C2D;
107 }