Integration of OCCT 6.5.0 from SVN
[occt.git] / src / GeomAdaptor / GeomAdaptor.cxx
CommitLineData
7fd59977 1// File: GeomAdaptor.cxx
2// Created: Wed May 3 17:48:12 1995
3// Author: Bruno DUMORTIER
4// Copyright: OPEN CASCADE 1995
5
6#include <GeomAdaptor.ixx>
7
8#include <Geom_Line.hxx>
9#include <Geom_Circle.hxx>
10#include <Geom_Ellipse.hxx>
11#include <Geom_Parabola.hxx>
12#include <Geom_Hyperbola.hxx>
13#include <Geom_BezierCurve.hxx>
14#include <Geom_BSplineCurve.hxx>
15#include <Geom_TrimmedCurve.hxx>
16
17#include <Geom_Plane.hxx>
18#include <Geom_CylindricalSurface.hxx>
19#include <Geom_ConicalSurface.hxx>
20#include <Geom_SphericalSurface.hxx>
21#include <Geom_ToroidalSurface.hxx>
22#include <Geom_BezierSurface.hxx>
23#include <Geom_BSplineSurface.hxx>
24#include <Geom_SurfaceOfRevolution.hxx>
25#include <Geom_SurfaceOfLinearExtrusion.hxx>
26#include <Geom_RectangularTrimmedSurface.hxx>
27#include <Geom_OffsetSurface.hxx>
28
29#include <Adaptor3d_HCurve.hxx>
30#include <Adaptor3d_HSurface.hxx>
31
32//=======================================================================
33//function : MakeCurve
34//purpose :
35//=======================================================================
36
37Handle(Geom_Curve) GeomAdaptor::MakeCurve (const Adaptor3d_Curve& HC)
38{
39 Handle(Geom_Curve) C;
40
41 switch (HC.GetType())
42 {
43 case GeomAbs_Line:
44 C = new Geom_Line(HC.Line());
45 break;
46
47 case GeomAbs_Circle:
48 C = new Geom_Circle(HC.Circle());
49 break;
50
51 case GeomAbs_Ellipse:
52 C = new Geom_Ellipse(HC.Ellipse());
53 break;
54
55 case GeomAbs_Parabola:
56 C = new Geom_Parabola(HC.Parabola());
57 break;
58
59 case GeomAbs_Hyperbola:
60 C = new Geom_Hyperbola(HC.Hyperbola());
61 break;
62
63 case GeomAbs_BezierCurve:
64 C = Handle(Geom_BezierCurve)::DownCast(HC.Bezier()->Copy());
65 break;
66
67 case GeomAbs_BSplineCurve:
68 C = Handle(Geom_BSplineCurve)::DownCast(HC.BSpline()->Copy());
69 break;
70
71 case GeomAbs_OtherCurve:
72 Standard_DomainError::Raise("GeomAdaptor::MakeCurve : OtherCurve");
73
74 }
75
76 // trim the curve if necassary.
77 if (! C.IsNull() &&
78 (HC.FirstParameter() != C->FirstParameter()) ||
79 (HC.LastParameter() != C->LastParameter())) {
80
81 C = new Geom_TrimmedCurve(C,HC.FirstParameter(),HC.LastParameter());
82 }
83
84 return C;
85}
86
87
88//=======================================================================
89//function : MakeSurface
90//purpose :
91//=======================================================================
92
93Handle(Geom_Surface) GeomAdaptor::MakeSurface(const Adaptor3d_Surface& HS)
94{
95 Handle(Geom_Surface) S;
96
97 switch ( HS.GetType())
98 {
99 case GeomAbs_Plane:
100 S = new Geom_Plane(HS.Plane());
101 break;
102
103 case GeomAbs_Cylinder:
104 S = new Geom_CylindricalSurface(HS.Cylinder());
105 break;
106
107 case GeomAbs_Cone:
108 S = new Geom_ConicalSurface(HS.Cone());
109 break;
110
111 case GeomAbs_Sphere:
112 S = new Geom_SphericalSurface(HS.Sphere());
113 break;
114
115 case GeomAbs_Torus:
116 S = new Geom_ToroidalSurface(HS.Torus());
117 break;
118
119 case GeomAbs_BezierSurface:
120 S = Handle(Geom_BezierSurface)::DownCast(HS.Bezier()->Copy());
121 break;
122
123 case GeomAbs_BSplineSurface:
124 S = Handle(Geom_BSplineSurface)::DownCast(HS.BSpline()->Copy());
125 break;
126
127 case GeomAbs_SurfaceOfRevolution:
128 S = new Geom_SurfaceOfRevolution
129 (GeomAdaptor::MakeCurve(HS.BasisCurve()->Curve()),HS.AxeOfRevolution());
130 break;
131
132 case GeomAbs_SurfaceOfExtrusion:
133 S = new Geom_SurfaceOfLinearExtrusion
134 (GeomAdaptor::MakeCurve(HS.BasisCurve()->Curve()),HS.Direction());
135 break;
136
137 case GeomAbs_OffsetSurface:
138 S = new Geom_OffsetSurface(GeomAdaptor::MakeSurface(HS.BasisSurface()->Surface()),
139 HS.OffsetValue());
140 break;
141
142 case GeomAbs_OtherSurface:
143 Standard_DomainError::Raise("GeomAdaptor::MakeSurface : OtherSurface");
144 break;
145 }
146
147 if ( S.IsNull() )
148 return S;
149
150 // trim the surface if necassary.
151 Standard_Real U1, U2, V1, V2;
152 S->Bounds(U1, U2, V1, V2);
153 if ((HS.FirstUParameter() != U1 ) ||
154 (HS.LastUParameter () != U2 ) ||
155 (HS.FirstVParameter() != V1 ) ||
156 (HS.LastVParameter () != V2 ) ) {
157
158 S = new Geom_RectangularTrimmedSurface
159 (S,HS.FirstUParameter(),HS.LastUParameter(),
160 HS.FirstVParameter(),HS.LastVParameter());
161 }
162
163 return S;
164}