1 // Created on: 1995-05-03
2 // Created by: Bruno DUMORTIER
3 // Copyright (c) 1995-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 <Adaptor3d_Curve.hxx>
19 #include <Adaptor3d_HCurve.hxx>
20 #include <Adaptor3d_HSurface.hxx>
21 #include <Adaptor3d_Surface.hxx>
22 #include <Geom_BezierCurve.hxx>
23 #include <Geom_BezierSurface.hxx>
24 #include <Geom_BSplineCurve.hxx>
25 #include <Geom_BSplineSurface.hxx>
26 #include <Geom_Circle.hxx>
27 #include <Geom_ConicalSurface.hxx>
28 #include <Geom_Curve.hxx>
29 #include <Geom_CylindricalSurface.hxx>
30 #include <Geom_Ellipse.hxx>
31 #include <Geom_Hyperbola.hxx>
32 #include <Geom_Line.hxx>
33 #include <Geom_OffsetSurface.hxx>
34 #include <Geom_Parabola.hxx>
35 #include <Geom_Plane.hxx>
36 #include <Geom_RectangularTrimmedSurface.hxx>
37 #include <Geom_SphericalSurface.hxx>
38 #include <Geom_Surface.hxx>
39 #include <Geom_SurfaceOfLinearExtrusion.hxx>
40 #include <Geom_SurfaceOfRevolution.hxx>
41 #include <Geom_ToroidalSurface.hxx>
42 #include <Geom_TrimmedCurve.hxx>
43 #include <GeomAdaptor.hxx>
45 //=======================================================================
46 //function : MakeCurve
48 //=======================================================================
49 Handle(Geom_Curve) GeomAdaptor::MakeCurve (const Adaptor3d_Curve& HC)
56 C = new Geom_Line(HC.Line());
60 C = new Geom_Circle(HC.Circle());
64 C = new Geom_Ellipse(HC.Ellipse());
67 case GeomAbs_Parabola:
68 C = new Geom_Parabola(HC.Parabola());
71 case GeomAbs_Hyperbola:
72 C = new Geom_Hyperbola(HC.Hyperbola());
75 case GeomAbs_BezierCurve:
76 C = Handle(Geom_BezierCurve)::DownCast(HC.Bezier()->Copy());
79 case GeomAbs_BSplineCurve:
80 C = Handle(Geom_BSplineCurve)::DownCast(HC.BSpline()->Copy());
83 case GeomAbs_OtherCurve:
84 Standard_DomainError::Raise("GeomAdaptor::MakeCurve : OtherCurve");
88 // trim the curve if necassary.
90 (HC.FirstParameter() != C->FirstParameter())) ||
91 (HC.LastParameter() != C->LastParameter())) {
93 C = new Geom_TrimmedCurve(C,HC.FirstParameter(),HC.LastParameter());
100 //=======================================================================
101 //function : MakeSurface
103 //=======================================================================
105 Handle(Geom_Surface) GeomAdaptor::MakeSurface(const Adaptor3d_Surface& HS)
107 Handle(Geom_Surface) S;
109 switch ( HS.GetType())
112 S = new Geom_Plane(HS.Plane());
115 case GeomAbs_Cylinder:
116 S = new Geom_CylindricalSurface(HS.Cylinder());
120 S = new Geom_ConicalSurface(HS.Cone());
124 S = new Geom_SphericalSurface(HS.Sphere());
128 S = new Geom_ToroidalSurface(HS.Torus());
131 case GeomAbs_BezierSurface:
132 S = Handle(Geom_BezierSurface)::DownCast(HS.Bezier()->Copy());
135 case GeomAbs_BSplineSurface:
136 S = Handle(Geom_BSplineSurface)::DownCast(HS.BSpline()->Copy());
139 case GeomAbs_SurfaceOfRevolution:
140 S = new Geom_SurfaceOfRevolution
141 (GeomAdaptor::MakeCurve(HS.BasisCurve()->Curve()),HS.AxeOfRevolution());
144 case GeomAbs_SurfaceOfExtrusion:
145 S = new Geom_SurfaceOfLinearExtrusion
146 (GeomAdaptor::MakeCurve(HS.BasisCurve()->Curve()),HS.Direction());
149 case GeomAbs_OffsetSurface:
150 S = new Geom_OffsetSurface(GeomAdaptor::MakeSurface(HS.BasisSurface()->Surface()),
154 case GeomAbs_OtherSurface:
155 Standard_DomainError::Raise("GeomAdaptor::MakeSurface : OtherSurface");
162 // trim the surface if necassary.
163 Standard_Real U1, U2, V1, V2;
164 S->Bounds(U1, U2, V1, V2);
165 if ((HS.FirstUParameter() != U1 ) ||
166 (HS.LastUParameter () != U2 ) ||
167 (HS.FirstVParameter() != V1 ) ||
168 (HS.LastVParameter () != V2 ) ) {
170 S = new Geom_RectangularTrimmedSurface
171 (S,HS.FirstUParameter(),HS.LastUParameter(),
172 HS.FirstVParameter(),HS.LastVParameter());