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