b311480e |
1 | // Copyright (c) 1999-2012 OPEN CASCADE SAS |
2 | // |
3 | // The content of this file is subject to the Open CASCADE Technology Public |
4 | // License Version 6.5 (the "License"). You may not use the content of this file |
5 | // except in compliance with the License. Please obtain a copy of the License |
6 | // at http://www.opencascade.org and read it completely before using this file. |
7 | // |
8 | // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its |
9 | // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. |
10 | // |
11 | // The Original Code and all software distributed under the License is |
12 | // distributed on an "AS IS" basis, without warranty of any kind, and the |
13 | // Initial Developer hereby disclaims all such warranties, including without |
14 | // limitation, any warranties of merchantability, fitness for a particular |
15 | // purpose or non-infringement. Please see the License for the specific terms |
16 | // and conditions governing the rights and limitations under the License. |
17 | |
7fd59977 |
18 | #include <Adaptor2d_Line2d.ixx> |
19 | |
20 | #include <Precision.hxx> |
21 | #include <ElCLib.hxx> |
22 | #include <Standard_OutOfRange.hxx> |
23 | #include <Standard_NoSuchObject.hxx> |
24 | #include <Adaptor2d_HLine2d.hxx> |
25 | |
26 | //======================================================================= |
27 | //function : Adaptor2d_Line2d |
28 | //purpose : |
29 | //======================================================================= |
30 | |
b311480e |
31 | Adaptor2d_Line2d::Adaptor2d_Line2d() |
7fd59977 |
32 | { |
33 | } |
34 | |
35 | //======================================================================= |
36 | //function : Adaptor_Line2d |
37 | //purpose : |
38 | //======================================================================= |
39 | |
40 | Adaptor2d_Line2d::Adaptor2d_Line2d(const gp_Pnt2d& P, const gp_Dir2d& D, |
41 | const Standard_Real UFirst, |
42 | const Standard_Real ULast): |
43 | myUfirst(UFirst),myUlast(ULast),myAx2d(P,D) |
44 | { |
45 | } |
46 | |
47 | //======================================================================= |
48 | //function : Load |
49 | //purpose : |
50 | //======================================================================= |
51 | |
52 | void Adaptor2d_Line2d::Load(const gp_Lin2d& L) |
53 | { |
54 | myAx2d = L.Position(); |
55 | myUfirst = -Precision::Infinite(); |
56 | myUlast = Precision::Infinite(); |
57 | } |
58 | |
59 | //======================================================================= |
60 | //function : Load |
61 | //purpose : |
62 | //======================================================================= |
63 | |
64 | void Adaptor2d_Line2d::Load(const gp_Lin2d& L, const Standard_Real Fi, const Standard_Real La) |
65 | { |
66 | myAx2d = L.Position(); |
67 | myUfirst = Fi; |
68 | myUlast = La; |
69 | } |
70 | |
71 | //======================================================================= |
72 | //function : FirstParameter |
73 | //purpose : |
74 | //======================================================================= |
75 | |
76 | Standard_Real Adaptor2d_Line2d::FirstParameter() const |
77 | { |
78 | return myUfirst; |
79 | } |
80 | |
81 | //======================================================================= |
82 | //function : LastParameter |
83 | //purpose : |
84 | //======================================================================= |
85 | |
86 | Standard_Real Adaptor2d_Line2d::LastParameter() const |
87 | { |
88 | return myUlast; |
89 | } |
90 | |
91 | //======================================================================= |
92 | //function : Continuity |
93 | //purpose : |
94 | //======================================================================= |
95 | |
96 | GeomAbs_Shape Adaptor2d_Line2d::Continuity() const |
97 | { |
98 | return GeomAbs_CN; |
99 | } |
100 | |
101 | //======================================================================= |
102 | //function : NbIntervals |
103 | //purpose : |
104 | //======================================================================= |
105 | |
106 | //Standard_Integer Adaptor2d_Line2d::NbIntervals(const GeomAbs_Shape S) const |
107 | Standard_Integer Adaptor2d_Line2d::NbIntervals(const GeomAbs_Shape ) const |
108 | { |
109 | return 1; |
110 | } |
111 | |
112 | //======================================================================= |
113 | //function : Interval |
114 | //purpose : |
115 | //======================================================================= |
116 | |
117 | void Adaptor2d_Line2d::Intervals(TColStd_Array1OfReal& T, |
118 | // const GeomAbs_Shape S) const |
119 | const GeomAbs_Shape ) const |
120 | { |
121 | T(T.Lower()) = myUfirst; |
122 | T(T.Lower()+1) = myUlast; |
123 | } |
124 | |
125 | //======================================================================= |
126 | //function : Trim |
127 | //purpose : |
128 | //======================================================================= |
129 | |
130 | Handle(Adaptor2d_HCurve2d) Adaptor2d_Line2d::Trim |
131 | (const Standard_Real First, |
132 | const Standard_Real Last, |
133 | const Standard_Real) const |
134 | { |
135 | Handle(Adaptor2d_HLine2d) HL = new Adaptor2d_HLine2d(); |
136 | HL->ChangeCurve2d().Load(gp_Lin2d(myAx2d),First,Last); |
137 | return HL; |
138 | } |
139 | |
140 | //======================================================================= |
141 | //function : IsClosed |
142 | //purpose : |
143 | //======================================================================= |
144 | |
145 | Standard_Boolean Adaptor2d_Line2d::IsClosed() const |
146 | { |
147 | return Standard_False; |
148 | } |
149 | |
150 | //======================================================================= |
151 | //function : IsPeriodic |
152 | //purpose : |
153 | //======================================================================= |
154 | |
155 | Standard_Boolean Adaptor2d_Line2d::IsPeriodic() const |
156 | { |
157 | return Standard_False; |
158 | } |
159 | |
160 | //======================================================================= |
161 | //function : Period |
162 | //purpose : |
163 | //======================================================================= |
164 | |
165 | Standard_Real Adaptor2d_Line2d::Period() const |
166 | { |
167 | Standard_NoSuchObject::Raise(); |
168 | return 0; |
169 | } |
170 | |
171 | //======================================================================= |
172 | //function : Value |
173 | //purpose : |
174 | //======================================================================= |
175 | |
176 | gp_Pnt2d Adaptor2d_Line2d::Value(const Standard_Real X) const |
177 | { |
178 | return ElCLib::LineValue(X,myAx2d); |
179 | } |
180 | |
181 | //======================================================================= |
182 | //function : D0 |
183 | //purpose : |
184 | //======================================================================= |
185 | |
186 | void Adaptor2d_Line2d::D0(const Standard_Real X, gp_Pnt2d& P) const |
187 | { |
188 | P = ElCLib::LineValue(X,myAx2d); |
189 | } |
190 | |
191 | //======================================================================= |
192 | //function : D1 |
193 | //purpose : |
194 | //======================================================================= |
195 | |
196 | void Adaptor2d_Line2d::D1(const Standard_Real X, gp_Pnt2d& P, gp_Vec2d& V) const |
197 | { |
198 | ElCLib::LineD1(X,myAx2d,P,V); |
199 | } |
200 | |
201 | //======================================================================= |
202 | //function : D2 |
203 | //purpose : |
204 | //======================================================================= |
205 | |
206 | void Adaptor2d_Line2d::D2(const Standard_Real X, gp_Pnt2d& P, gp_Vec2d& V1, gp_Vec2d& V2) const |
207 | { |
208 | ElCLib::LineD1(X,myAx2d,P,V1); |
209 | V2.SetCoord(0.,0.); |
210 | } |
211 | |
212 | //======================================================================= |
213 | //function : D3 |
214 | //purpose : |
215 | //======================================================================= |
216 | |
217 | void Adaptor2d_Line2d::D3(const Standard_Real X, gp_Pnt2d& P, gp_Vec2d& V1, gp_Vec2d& V2, gp_Vec2d& V3) const |
218 | { |
219 | ElCLib::LineD1(X,myAx2d,P,V1); |
220 | V2.SetCoord(0.,0.); |
221 | V3.SetCoord(0.,0.); |
222 | } |
223 | |
224 | //======================================================================= |
225 | //function : DN |
226 | //purpose : |
227 | //======================================================================= |
228 | |
229 | //gp_Vec2d Adaptor2d_Line2d::DN(const Standard_Real U, const Standard_Integer N) const |
230 | gp_Vec2d Adaptor2d_Line2d::DN(const Standard_Real , const Standard_Integer N) const |
231 | { |
232 | if (N<=0) {Standard_OutOfRange::Raise();} |
233 | if (N==1) { |
234 | return myAx2d.Direction(); |
235 | } |
236 | return gp_Vec2d(0.,0.); |
237 | } |
238 | |
239 | //======================================================================= |
240 | //function : Resolution |
241 | //purpose : |
242 | //======================================================================= |
243 | |
244 | Standard_Real Adaptor2d_Line2d::Resolution(const Standard_Real R3d) const |
245 | { |
246 | return R3d; // nul !!!! |
247 | } |
248 | |
249 | //======================================================================= |
250 | //function : GetType |
251 | //purpose : |
252 | //======================================================================= |
253 | |
254 | GeomAbs_CurveType Adaptor2d_Line2d::GetType() const |
255 | { |
256 | return GeomAbs_Line; |
257 | } |
258 | |
259 | //======================================================================= |
260 | //function : Line |
261 | //purpose : |
262 | //======================================================================= |
263 | |
264 | gp_Lin2d Adaptor2d_Line2d::Line() const |
265 | { |
266 | return gp_Lin2d(myAx2d); |
267 | } |
268 | |
269 | //======================================================================= |
270 | //function : Circle |
271 | //purpose : |
272 | //======================================================================= |
273 | |
274 | gp_Circ2d Adaptor2d_Line2d::Circle() const |
275 | { |
276 | Standard_NoSuchObject::Raise(); |
277 | return gp_Circ2d(); |
278 | } |
279 | |
280 | //======================================================================= |
281 | //function : Ellipse |
282 | //purpose : |
283 | //======================================================================= |
284 | |
285 | gp_Elips2d Adaptor2d_Line2d::Ellipse() const |
286 | { |
287 | Standard_NoSuchObject::Raise(); |
288 | return gp_Elips2d(); |
289 | } |
290 | |
291 | //======================================================================= |
292 | //function : Hyperbola |
293 | //purpose : |
294 | //======================================================================= |
295 | |
296 | gp_Hypr2d Adaptor2d_Line2d::Hyperbola() const |
297 | { |
298 | Standard_NoSuchObject::Raise(); |
299 | return gp_Hypr2d(); |
300 | } |
301 | |
302 | //======================================================================= |
303 | //function : Parabola |
304 | //purpose : |
305 | //======================================================================= |
306 | |
307 | gp_Parab2d Adaptor2d_Line2d::Parabola() const |
308 | { |
309 | Standard_NoSuchObject::Raise(); |
310 | return gp_Parab2d(); |
311 | } |
312 | |
313 | //======================================================================= |
314 | //function : Degree |
315 | //purpose : |
316 | //======================================================================= |
317 | |
318 | Standard_Integer Adaptor2d_Line2d::Degree() const |
319 | { |
320 | Standard_NoSuchObject::Raise(); |
321 | return 0 ; |
322 | } |
323 | //======================================================================= |
324 | //function : IsRational |
325 | //purpose : |
326 | //======================================================================= |
327 | |
328 | Standard_Boolean Adaptor2d_Line2d::IsRational() const |
329 | { |
330 | Standard_NoSuchObject::Raise(); |
331 | return 0 ; |
332 | } |
333 | //======================================================================= |
334 | //function : NbPoles |
335 | //purpose : |
336 | //======================================================================= |
337 | |
338 | Standard_Integer Adaptor2d_Line2d::NbPoles() const |
339 | { |
340 | Standard_NoSuchObject::Raise(); |
341 | return 0 ; |
342 | } |
343 | //======================================================================= |
344 | //function : NbKnots |
345 | //purpose : |
346 | //======================================================================= |
347 | |
348 | Standard_Integer Adaptor2d_Line2d::NbKnots() const |
349 | { |
350 | Standard_NoSuchObject::Raise(); |
351 | return 0 ; |
352 | } |
353 | //======================================================================= |
354 | //function : Bezier |
355 | //purpose : |
356 | //======================================================================= |
357 | |
358 | Handle(Geom2d_BezierCurve) Adaptor2d_Line2d::Bezier() const |
359 | { |
360 | Standard_NoSuchObject::Raise(); |
361 | Handle(Geom2d_BezierCurve) nul; |
362 | return nul; |
363 | } |
364 | |
365 | //======================================================================= |
366 | //function : BSpline |
367 | //purpose : |
368 | //======================================================================= |
369 | |
370 | Handle(Geom2d_BSplineCurve) Adaptor2d_Line2d::BSpline() const |
371 | { |
372 | Standard_NoSuchObject::Raise(); |
373 | Handle(Geom2d_BSplineCurve) nul; |
374 | return nul; |
375 | } |
376 | |