b311480e |
1 | // Created on: 1993-08-24 |
2 | // Created by: Bruno DUMORTIER |
3 | // Copyright (c) 1993-1999 Matra Datavision |
973c2be1 |
4 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
b311480e |
5 | // |
973c2be1 |
6 | // This file is part of Open CASCADE Technology software library. |
b311480e |
7 | // |
d5f74e42 |
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 |
973c2be1 |
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. |
b311480e |
13 | // |
973c2be1 |
14 | // Alternatively, this file may be used under the terms of Open CASCADE |
15 | // commercial license or contractual agreement. |
7fd59977 |
16 | |
42cf5bc1 |
17 | |
18 | #include <ElSLib.hxx> |
19 | #include <gp_Circ.hxx> |
20 | #include <gp_Circ2d.hxx> |
21 | #include <gp_Cone.hxx> |
22 | #include <gp_Cylinder.hxx> |
23 | #include <gp_Elips.hxx> |
24 | #include <gp_Elips2d.hxx> |
25 | #include <gp_Hypr.hxx> |
26 | #include <gp_Hypr2d.hxx> |
27 | #include <gp_Lin.hxx> |
28 | #include <gp_Lin2d.hxx> |
29 | #include <gp_Parab.hxx> |
30 | #include <gp_Parab2d.hxx> |
31 | #include <gp_Pln.hxx> |
32 | #include <gp_Pnt.hxx> |
33 | #include <gp_Pnt2d.hxx> |
34 | #include <gp_Sphere.hxx> |
35 | #include <gp_Torus.hxx> |
36 | #include <ProjLib.hxx> |
7fd59977 |
37 | #include <ProjLib_Cone.hxx> |
42cf5bc1 |
38 | #include <ProjLib_Cylinder.hxx> |
39 | #include <ProjLib_Plane.hxx> |
7fd59977 |
40 | #include <ProjLib_Sphere.hxx> |
41 | #include <ProjLib_Torus.hxx> |
f48cb55d |
42 | #include <ProjLib_ProjectedCurve.hxx> |
43 | #include <Geom2d_Line.hxx> |
44 | #include <Geom2d_Circle.hxx> |
45 | #include <Geom2d_Ellipse.hxx> |
46 | #include <Geom2d_Parabola.hxx> |
47 | #include <Geom2d_Hyperbola.hxx> |
48 | #include <Geom2d_BSplineCurve.hxx> |
49 | #include <Geom2d_BezierCurve.hxx> |
50 | #include <Standard_NotImplemented.hxx> |
7fd59977 |
51 | |
7fd59977 |
52 | //======================================================================= |
53 | //function : Project |
54 | //purpose : |
55 | //======================================================================= |
7fd59977 |
56 | gp_Pnt2d ProjLib::Project(const gp_Pln& Pl, const gp_Pnt& P) |
57 | { |
58 | Standard_Real U, V; |
59 | ElSLib::Parameters(Pl, P, U, V); |
60 | return gp_Pnt2d(U,V); |
61 | } |
62 | |
63 | |
64 | //======================================================================= |
65 | //function : Project |
66 | //purpose : |
67 | //======================================================================= |
68 | |
69 | gp_Lin2d ProjLib::Project(const gp_Pln& Pl, const gp_Lin& L) |
70 | { |
71 | ProjLib_Plane Proj( Pl, L); |
72 | return Proj.Line(); |
73 | } |
74 | |
75 | |
76 | //======================================================================= |
77 | //function : Project |
78 | //purpose : |
79 | //======================================================================= |
80 | |
81 | gp_Circ2d ProjLib::Project(const gp_Pln& Pl, const gp_Circ& C) |
82 | { |
83 | ProjLib_Plane Proj( Pl, C); |
84 | return Proj.Circle(); |
85 | } |
86 | |
87 | |
88 | //======================================================================= |
89 | //function : Project |
90 | //purpose : |
91 | //======================================================================= |
92 | |
93 | gp_Elips2d ProjLib::Project(const gp_Pln& Pl, const gp_Elips& E) |
94 | { |
95 | ProjLib_Plane Proj( Pl, E); |
96 | return Proj.Ellipse(); |
97 | } |
98 | |
99 | |
100 | //======================================================================= |
101 | //function : Project |
102 | //purpose : |
103 | //======================================================================= |
104 | |
105 | gp_Parab2d ProjLib::Project(const gp_Pln& Pl, const gp_Parab& P) |
106 | { |
107 | ProjLib_Plane Proj( Pl, P); |
108 | return Proj.Parabola(); |
109 | } |
110 | |
111 | |
112 | //======================================================================= |
113 | //function : Project |
114 | //purpose : |
115 | //======================================================================= |
116 | |
117 | gp_Hypr2d ProjLib::Project(const gp_Pln& Pl, const gp_Hypr& H) |
118 | { |
119 | ProjLib_Plane Proj( Pl, H); |
120 | return Proj.Hyperbola(); |
121 | } |
122 | |
123 | |
124 | //======================================================================= |
125 | //function : Project |
126 | //purpose : |
127 | //======================================================================= |
128 | |
129 | gp_Pnt2d ProjLib::Project(const gp_Cylinder& Cy, const gp_Pnt& P) |
130 | { |
131 | Standard_Real U, V; |
132 | ElSLib::Parameters(Cy, P, U, V); |
133 | return gp_Pnt2d(U,V); |
134 | } |
135 | |
136 | |
137 | //======================================================================= |
138 | //function : Project |
139 | //purpose : |
140 | //======================================================================= |
141 | |
142 | gp_Lin2d ProjLib::Project(const gp_Cylinder& Cy, const gp_Lin& L) |
143 | { |
144 | ProjLib_Cylinder Proj( Cy, L); |
145 | return Proj.Line(); |
146 | } |
147 | |
148 | |
149 | //======================================================================= |
150 | //function : Project |
151 | //purpose : |
152 | //======================================================================= |
153 | |
154 | gp_Lin2d ProjLib::Project(const gp_Cylinder& Cy, const gp_Circ& Ci) |
155 | { |
156 | ProjLib_Cylinder Proj( Cy, Ci); |
157 | return Proj.Line(); |
158 | } |
159 | |
160 | |
161 | //======================================================================= |
162 | //function : Project |
163 | //purpose : |
164 | //======================================================================= |
165 | |
166 | gp_Pnt2d ProjLib::Project(const gp_Cone& Co, const gp_Pnt& P) |
167 | { |
168 | Standard_Real U, V; |
169 | ElSLib::Parameters(Co, P, U, V); |
170 | return gp_Pnt2d(U,V); |
171 | } |
172 | |
173 | |
174 | //======================================================================= |
175 | //function : Project |
176 | //purpose : |
177 | //======================================================================= |
178 | |
179 | gp_Lin2d ProjLib::Project(const gp_Cone& Co, const gp_Lin& L) |
180 | { |
181 | ProjLib_Cone Proj( Co, L); |
182 | return Proj.Line(); |
183 | } |
184 | |
185 | |
186 | //======================================================================= |
187 | //function : Project |
188 | //purpose : |
189 | //======================================================================= |
190 | |
191 | gp_Lin2d ProjLib::Project(const gp_Cone& Co, const gp_Circ& Ci) |
192 | { |
193 | ProjLib_Cone Proj( Co, Ci); |
194 | return Proj.Line(); |
195 | } |
196 | |
197 | |
198 | //======================================================================= |
199 | //function : Project |
200 | //purpose : |
201 | //======================================================================= |
202 | |
203 | gp_Pnt2d ProjLib::Project(const gp_Sphere& Sp, const gp_Pnt& P) |
204 | { |
205 | Standard_Real U, V; |
206 | ElSLib::Parameters(Sp, P, U, V); |
207 | return gp_Pnt2d(U,V); |
208 | } |
209 | |
210 | |
211 | //======================================================================= |
212 | //function : Project |
213 | //purpose : |
214 | //======================================================================= |
215 | |
216 | gp_Lin2d ProjLib::Project(const gp_Sphere& Sp, const gp_Circ& Ci) |
217 | { |
218 | ProjLib_Sphere Proj( Sp, Ci); |
219 | return Proj.Line(); |
220 | } |
221 | |
222 | |
223 | //======================================================================= |
224 | //function : Project |
225 | //purpose : |
226 | //======================================================================= |
227 | |
228 | gp_Pnt2d ProjLib::Project(const gp_Torus& To, const gp_Pnt& P) |
229 | { |
230 | Standard_Real U, V; |
231 | ElSLib::Parameters(To, P, U, V); |
232 | return gp_Pnt2d(U,V); |
233 | } |
234 | |
235 | |
236 | //======================================================================= |
237 | //function : Project |
238 | //purpose : |
239 | //======================================================================= |
240 | |
241 | gp_Lin2d ProjLib::Project(const gp_Torus& To, const gp_Circ& Ci) |
242 | { |
243 | ProjLib_Torus Proj( To, Ci); |
244 | return Proj.Line(); |
245 | } |
f48cb55d |
246 | |
247 | //======================================================================= |
248 | //function : MakePCurveOfType |
249 | //purpose : |
250 | //======================================================================= |
251 | void ProjLib::MakePCurveOfType |
252 | (const ProjLib_ProjectedCurve& PC, |
253 | Handle(Geom2d_Curve)& C2D) |
254 | { |
255 | |
256 | switch (PC.GetType()) { |
257 | |
258 | case GeomAbs_Line : |
259 | C2D = new Geom2d_Line(PC.Line()); |
260 | break; |
261 | case GeomAbs_Circle : |
262 | C2D = new Geom2d_Circle(PC.Circle()); |
263 | break; |
264 | case GeomAbs_Ellipse : |
265 | C2D = new Geom2d_Ellipse(PC.Ellipse()); |
266 | break; |
267 | case GeomAbs_Parabola : |
268 | C2D = new Geom2d_Parabola(PC.Parabola()); |
269 | break; |
270 | case GeomAbs_Hyperbola : |
271 | C2D = new Geom2d_Hyperbola(PC.Hyperbola()); |
272 | break; |
273 | case GeomAbs_BSplineCurve : |
274 | C2D = PC.BSpline(); |
275 | break; |
276 | case GeomAbs_BezierCurve : |
277 | case GeomAbs_OtherCurve : |
278 | default : |
279 | Standard_NotImplemented::Raise |
280 | ("ProjLib::MakePCurveOfType"); |
281 | break; |
282 | } |
283 | } |