0025621: CAST analysis - Avoid constructors not supplying an initial value for all...
[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 : myUfirst(0.0), myUlast (0.0)
29 {
30 }
31
32 //=======================================================================
33 //function : Adaptor_Line2d
34 //purpose  : 
35 //=======================================================================
36
37  Adaptor2d_Line2d::Adaptor2d_Line2d(const gp_Pnt2d&     P,
38                                     const gp_Dir2d&     D,
39                                     const Standard_Real UFirst,
40                                     const Standard_Real ULast)
41 : myUfirst(UFirst), myUlast(ULast), myAx2d(P,D)
42 {
43 }
44
45 //=======================================================================
46 //function : Load
47 //purpose  : 
48 //=======================================================================
49
50 void Adaptor2d_Line2d::Load(const gp_Lin2d& L)
51 {
52   myAx2d   =  L.Position();
53   myUfirst = -Precision::Infinite();
54   myUlast  =  Precision::Infinite();
55 }
56
57 //=======================================================================
58 //function : Load
59 //purpose  : 
60 //=======================================================================
61
62 void Adaptor2d_Line2d::Load(const gp_Lin2d& L, const Standard_Real Fi, const Standard_Real La)
63 {
64   myAx2d   =  L.Position();
65   myUfirst =  Fi;
66   myUlast  =  La;
67 }
68
69 //=======================================================================
70 //function : FirstParameter
71 //purpose  : 
72 //=======================================================================
73
74 Standard_Real Adaptor2d_Line2d::FirstParameter() const 
75 {
76   return myUfirst;
77 }
78
79 //=======================================================================
80 //function : LastParameter
81 //purpose  : 
82 //=======================================================================
83
84 Standard_Real Adaptor2d_Line2d::LastParameter() const 
85 {
86   return myUlast;
87 }
88
89 //=======================================================================
90 //function : Continuity
91 //purpose  : 
92 //=======================================================================
93
94 GeomAbs_Shape Adaptor2d_Line2d::Continuity() const 
95 {
96   return GeomAbs_CN;
97 }
98
99 //=======================================================================
100 //function : NbIntervals
101 //purpose  : 
102 //=======================================================================
103
104 //Standard_Integer Adaptor2d_Line2d::NbIntervals(const GeomAbs_Shape S) const 
105 Standard_Integer Adaptor2d_Line2d::NbIntervals(const GeomAbs_Shape ) const 
106 {
107   return 1;
108 }
109
110 //=======================================================================
111 //function : Interval
112 //purpose  : 
113 //=======================================================================
114
115 void Adaptor2d_Line2d::Intervals(TColStd_Array1OfReal& T,
116 //                             const GeomAbs_Shape S) const 
117                                const GeomAbs_Shape ) const 
118 {
119   T(T.Lower())   = myUfirst;
120   T(T.Lower()+1) = myUlast;
121 }
122
123 //=======================================================================
124 //function : Trim
125 //purpose  : 
126 //=======================================================================
127
128 Handle(Adaptor2d_HCurve2d) Adaptor2d_Line2d::Trim
129 (const Standard_Real First,
130  const Standard_Real Last,
131  const Standard_Real) const 
132 {
133   Handle(Adaptor2d_HLine2d) HL = new Adaptor2d_HLine2d();
134   HL->ChangeCurve2d().Load(gp_Lin2d(myAx2d),First,Last);
135   return HL;
136 }
137
138 //=======================================================================
139 //function : IsClosed
140 //purpose  : 
141 //=======================================================================
142
143 Standard_Boolean Adaptor2d_Line2d::IsClosed() const 
144 {
145   return Standard_False;
146 }
147
148 //=======================================================================
149 //function : IsPeriodic
150 //purpose  : 
151 //=======================================================================
152
153 Standard_Boolean Adaptor2d_Line2d::IsPeriodic() const 
154 {
155   return Standard_False;
156 }
157
158 //=======================================================================
159 //function : Period
160 //purpose  : 
161 //=======================================================================
162
163 Standard_Real Adaptor2d_Line2d::Period() const 
164 {
165   Standard_NoSuchObject::Raise();
166   return 0;
167 }
168
169 //=======================================================================
170 //function : Value
171 //purpose  : 
172 //=======================================================================
173
174 gp_Pnt2d Adaptor2d_Line2d::Value(const Standard_Real X) const 
175 {
176   return ElCLib::LineValue(X,myAx2d);
177 }
178
179 //=======================================================================
180 //function : D0
181 //purpose  : 
182 //=======================================================================
183
184 void Adaptor2d_Line2d::D0(const Standard_Real X, gp_Pnt2d& P) const 
185 {
186   P = ElCLib::LineValue(X,myAx2d);
187 }
188
189 //=======================================================================
190 //function : D1
191 //purpose  : 
192 //=======================================================================
193
194 void Adaptor2d_Line2d::D1(const Standard_Real X, gp_Pnt2d& P, gp_Vec2d& V) const 
195 {
196   ElCLib::LineD1(X,myAx2d,P,V);
197 }
198
199 //=======================================================================
200 //function : D2
201 //purpose  : 
202 //=======================================================================
203
204 void Adaptor2d_Line2d::D2(const Standard_Real X, gp_Pnt2d& P, gp_Vec2d& V1, gp_Vec2d& V2) const 
205 {
206   ElCLib::LineD1(X,myAx2d,P,V1);
207   V2.SetCoord(0.,0.);
208 }
209
210 //=======================================================================
211 //function : D3
212 //purpose  : 
213 //=======================================================================
214
215 void Adaptor2d_Line2d::D3(const Standard_Real X, gp_Pnt2d& P, gp_Vec2d& V1, gp_Vec2d& V2, gp_Vec2d& V3) const 
216 {
217   ElCLib::LineD1(X,myAx2d,P,V1);
218   V2.SetCoord(0.,0.);
219   V3.SetCoord(0.,0.);
220 }
221
222 //=======================================================================
223 //function : DN
224 //purpose  : 
225 //=======================================================================
226
227 //gp_Vec2d Adaptor2d_Line2d::DN(const Standard_Real U, const Standard_Integer N) const 
228 gp_Vec2d Adaptor2d_Line2d::DN(const Standard_Real , const Standard_Integer N) const 
229 {
230   if (N<=0) {Standard_OutOfRange::Raise();}
231   if (N==1) {
232     return myAx2d.Direction();
233   }
234   return gp_Vec2d(0.,0.);
235 }
236
237 //=======================================================================
238 //function : Resolution
239 //purpose  : 
240 //=======================================================================
241
242 Standard_Real Adaptor2d_Line2d::Resolution(const Standard_Real R3d) const 
243 {
244   return R3d; // nul !!!!
245 }
246
247 //=======================================================================
248 //function : GetType
249 //purpose  : 
250 //=======================================================================
251
252 GeomAbs_CurveType Adaptor2d_Line2d::GetType() const 
253 {
254   return GeomAbs_Line;
255 }
256
257 //=======================================================================
258 //function : Line
259 //purpose  : 
260 //=======================================================================
261
262 gp_Lin2d Adaptor2d_Line2d::Line() const 
263 {
264   return gp_Lin2d(myAx2d);
265 }
266
267 //=======================================================================
268 //function : Circle
269 //purpose  : 
270 //=======================================================================
271
272 gp_Circ2d Adaptor2d_Line2d::Circle() const 
273 {
274   Standard_NoSuchObject::Raise();
275   return gp_Circ2d();
276 }
277
278 //=======================================================================
279 //function : Ellipse
280 //purpose  : 
281 //=======================================================================
282
283 gp_Elips2d Adaptor2d_Line2d::Ellipse() const 
284 {
285   Standard_NoSuchObject::Raise();
286   return gp_Elips2d();
287 }
288
289 //=======================================================================
290 //function : Hyperbola
291 //purpose  : 
292 //=======================================================================
293
294 gp_Hypr2d Adaptor2d_Line2d::Hyperbola() const 
295 {
296   Standard_NoSuchObject::Raise();
297   return gp_Hypr2d();
298 }
299
300 //=======================================================================
301 //function : Parabola
302 //purpose  : 
303 //=======================================================================
304
305 gp_Parab2d Adaptor2d_Line2d::Parabola() const 
306 {
307   Standard_NoSuchObject::Raise();
308   return gp_Parab2d();
309 }
310
311 //=======================================================================
312 //function : Degree
313 //purpose  : 
314 //=======================================================================
315
316 Standard_Integer Adaptor2d_Line2d::Degree()  const 
317  {
318   Standard_NoSuchObject::Raise();
319   return 0 ;
320 }
321 //=======================================================================
322 //function : IsRational
323 //purpose  : 
324 //=======================================================================
325
326 Standard_Boolean Adaptor2d_Line2d::IsRational()  const 
327  {
328   Standard_NoSuchObject::Raise();
329   return 0 ;
330 }
331 //=======================================================================
332 //function : NbPoles
333 //purpose  : 
334 //=======================================================================
335
336 Standard_Integer Adaptor2d_Line2d::NbPoles()  const 
337  {
338   Standard_NoSuchObject::Raise();
339   return 0 ;
340 }
341 //=======================================================================
342 //function : NbKnots
343 //purpose  : 
344 //=======================================================================
345
346 Standard_Integer Adaptor2d_Line2d::NbKnots()  const 
347  {
348   Standard_NoSuchObject::Raise();
349   return 0 ;
350 }
351 //=======================================================================
352 //function : Bezier
353 //purpose  : 
354 //=======================================================================
355
356 Handle(Geom2d_BezierCurve) Adaptor2d_Line2d::Bezier() const 
357 {
358   Standard_NoSuchObject::Raise();
359   Handle(Geom2d_BezierCurve) nul;
360   return nul;
361 }
362
363 //=======================================================================
364 //function : BSpline
365 //purpose  : 
366 //=======================================================================
367
368 Handle(Geom2d_BSplineCurve) Adaptor2d_Line2d::BSpline() const 
369 {
370   Standard_NoSuchObject::Raise();
371   Handle(Geom2d_BSplineCurve) nul;
372   return nul;
373 }
374