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
6 // This file is part of Open CASCADE Technology software library.
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.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
18 #include <Adaptor2d_Curve2d.hxx>
19 #include <Geom2dAdaptor_Curve.hxx>
20 #include <Geom2d_BezierCurve.hxx>
21 #include <Geom2d_BSplineCurve.hxx>
22 #include <Geom2d_Circle.hxx>
23 #include <Geom2d_Curve.hxx>
24 #include <Geom2d_Ellipse.hxx>
25 #include <Geom2d_Hyperbola.hxx>
26 #include <Geom2d_Line.hxx>
27 #include <Geom2d_Parabola.hxx>
28 #include <Geom2d_TrimmedCurve.hxx>
29 #include <Geom2dAdaptor.hxx>
30 #include <gp_Circ2d.hxx>
31 #include <gp_Elips2d.hxx>
32 #include <gp_Hypr2d.hxx>
33 #include <gp_Lin2d.hxx>
34 #include <gp_Parab2d.hxx>
36 //=======================================================================
37 //function : MakeCurve
39 //=======================================================================
40 Handle(Geom2d_Curve) Geom2dAdaptor::MakeCurve
41 (const Adaptor2d_Curve2d& HC)
43 Handle(Geom2d_Curve) C2D;
44 switch (HC.GetType()) {
48 Handle(Geom2d_Line) GL = new Geom2d_Line(HC.Line());
55 Handle(Geom2d_Circle) GL = new Geom2d_Circle(HC.Circle());
62 Handle(Geom2d_Ellipse) GL = new Geom2d_Ellipse(HC.Ellipse());
67 case GeomAbs_Parabola:
69 Handle(Geom2d_Parabola) GL = new Geom2d_Parabola(HC.Parabola());
74 case GeomAbs_Hyperbola:
76 Handle(Geom2d_Hyperbola) GL = new Geom2d_Hyperbola(HC.Hyperbola());
81 case GeomAbs_BezierCurve:
87 case GeomAbs_BSplineCurve:
93 case GeomAbs_OffsetCurve:
95 const Geom2dAdaptor_Curve* pGAC = dynamic_cast<const Geom2dAdaptor_Curve*>(&HC);
102 Standard_DomainError::Raise("Geom2dAdaptor::MakeCurve, Not Geom2dAdaptor_Curve");
108 throw Standard_DomainError("Geom2dAdaptor::MakeCurve, OtherCurve");
112 // trim the curve if necassary.
113 if (! C2D.IsNull() &&
114 ((HC.FirstParameter() != C2D->FirstParameter()) ||
115 (HC.LastParameter() != C2D->LastParameter()))) {
117 if (C2D->IsPeriodic() ||
118 (HC.FirstParameter() >= C2D->FirstParameter() &&
119 HC.LastParameter() <= C2D->LastParameter()))
121 C2D = new Geom2d_TrimmedCurve
122 (C2D, HC.FirstParameter(), HC.LastParameter());
126 Standard_Real tf = Max(HC.FirstParameter(), C2D->FirstParameter());
127 Standard_Real tl = Min(HC.LastParameter(), C2D->LastParameter());
128 C2D = new Geom2d_TrimmedCurve(C2D, tf, tl);