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