1 // Copyright (c) 1999-2014 OPEN CASCADE SAS
3 // This file is part of Open CASCADE Technology software library.
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.
11 // Alternatively, this file may be used under the terms of Open CASCADE
12 // commercial license or contractual agreement.
14 #include <Adaptor2d_Line2d.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>
32 IMPLEMENT_STANDARD_RTTIEXT(Adaptor2d_Line2d, Adaptor2d_Curve2d)
34 //=======================================================================
35 //function : Adaptor2d_Line2d
37 //=======================================================================
38 Adaptor2d_Line2d::Adaptor2d_Line2d()
39 : myUfirst(0.0), myUlast (0.0)
43 //=======================================================================
44 //function : Adaptor_Line2d
46 //=======================================================================
48 Adaptor2d_Line2d::Adaptor2d_Line2d(const gp_Pnt2d& P,
50 const Standard_Real UFirst,
51 const Standard_Real ULast)
52 : myUfirst(UFirst), myUlast(ULast), myAx2d(P,D)
56 //=======================================================================
57 //function : ShallowCopy
59 //=======================================================================
61 Handle(Adaptor2d_Curve2d) Adaptor2d_Line2d::ShallowCopy() const
63 Handle(Adaptor2d_Line2d) aCopy = new Adaptor2d_Line2d();
65 aCopy->myUfirst = myUfirst;
66 aCopy->myUlast = myUlast;
67 aCopy->myAx2d = myAx2d;
72 //=======================================================================
75 //=======================================================================
77 void Adaptor2d_Line2d::Load(const gp_Lin2d& L)
79 myAx2d = L.Position();
80 myUfirst = -Precision::Infinite();
81 myUlast = Precision::Infinite();
84 //=======================================================================
87 //=======================================================================
89 void Adaptor2d_Line2d::Load(const gp_Lin2d& L, const Standard_Real Fi, const Standard_Real La)
91 myAx2d = L.Position();
96 //=======================================================================
97 //function : FirstParameter
99 //=======================================================================
101 Standard_Real Adaptor2d_Line2d::FirstParameter() const
106 //=======================================================================
107 //function : LastParameter
109 //=======================================================================
111 Standard_Real Adaptor2d_Line2d::LastParameter() const
116 //=======================================================================
117 //function : Continuity
119 //=======================================================================
121 GeomAbs_Shape Adaptor2d_Line2d::Continuity() const
126 //=======================================================================
127 //function : NbIntervals
129 //=======================================================================
131 //Standard_Integer Adaptor2d_Line2d::NbIntervals(const GeomAbs_Shape S) const
132 Standard_Integer Adaptor2d_Line2d::NbIntervals(const GeomAbs_Shape ) const
137 //=======================================================================
138 //function : Interval
140 //=======================================================================
142 void Adaptor2d_Line2d::Intervals(TColStd_Array1OfReal& T,
143 // const GeomAbs_Shape S) const
144 const GeomAbs_Shape ) const
146 T(T.Lower()) = myUfirst;
147 T(T.Lower()+1) = myUlast;
150 //=======================================================================
153 //=======================================================================
155 Handle(Adaptor2d_Curve2d) Adaptor2d_Line2d::Trim
156 (const Standard_Real First,
157 const Standard_Real Last,
158 const Standard_Real) const
160 Handle(Adaptor2d_Line2d) HL = new Adaptor2d_Line2d();
161 HL->Load(gp_Lin2d(myAx2d),First,Last);
165 //=======================================================================
166 //function : IsClosed
168 //=======================================================================
170 Standard_Boolean Adaptor2d_Line2d::IsClosed() const
172 return Standard_False;
175 //=======================================================================
176 //function : IsPeriodic
178 //=======================================================================
180 Standard_Boolean Adaptor2d_Line2d::IsPeriodic() const
182 return Standard_False;
185 //=======================================================================
188 //=======================================================================
190 Standard_Real Adaptor2d_Line2d::Period() const
192 throw Standard_NoSuchObject();
195 //=======================================================================
198 //=======================================================================
200 gp_Pnt2d Adaptor2d_Line2d::Value(const Standard_Real X) const
202 return ElCLib::LineValue(X,myAx2d);
205 //=======================================================================
208 //=======================================================================
210 void Adaptor2d_Line2d::D0(const Standard_Real X, gp_Pnt2d& P) const
212 P = ElCLib::LineValue(X,myAx2d);
215 //=======================================================================
218 //=======================================================================
220 void Adaptor2d_Line2d::D1(const Standard_Real X, gp_Pnt2d& P, gp_Vec2d& V) const
222 ElCLib::LineD1(X,myAx2d,P,V);
225 //=======================================================================
228 //=======================================================================
230 void Adaptor2d_Line2d::D2(const Standard_Real X, gp_Pnt2d& P, gp_Vec2d& V1, gp_Vec2d& V2) const
232 ElCLib::LineD1(X,myAx2d,P,V1);
236 //=======================================================================
239 //=======================================================================
241 void Adaptor2d_Line2d::D3(const Standard_Real X, gp_Pnt2d& P, gp_Vec2d& V1, gp_Vec2d& V2, gp_Vec2d& V3) const
243 ElCLib::LineD1(X,myAx2d,P,V1);
248 //=======================================================================
251 //=======================================================================
253 //gp_Vec2d Adaptor2d_Line2d::DN(const Standard_Real U, const Standard_Integer N) const
254 gp_Vec2d Adaptor2d_Line2d::DN(const Standard_Real , const Standard_Integer N) const
256 if (N<=0) {throw Standard_OutOfRange();}
258 return myAx2d.Direction();
260 return gp_Vec2d(0.,0.);
263 //=======================================================================
264 //function : Resolution
266 //=======================================================================
268 Standard_Real Adaptor2d_Line2d::Resolution(const Standard_Real R3d) const
270 return R3d; // nul !!!!
273 //=======================================================================
276 //=======================================================================
278 GeomAbs_CurveType Adaptor2d_Line2d::GetType() const
283 //=======================================================================
286 //=======================================================================
288 gp_Lin2d Adaptor2d_Line2d::Line() const
290 return gp_Lin2d(myAx2d);
293 //=======================================================================
296 //=======================================================================
298 gp_Circ2d Adaptor2d_Line2d::Circle() const
300 throw Standard_NoSuchObject();
303 //=======================================================================
306 //=======================================================================
308 gp_Elips2d Adaptor2d_Line2d::Ellipse() const
310 throw Standard_NoSuchObject();
313 //=======================================================================
314 //function : Hyperbola
316 //=======================================================================
318 gp_Hypr2d Adaptor2d_Line2d::Hyperbola() const
320 throw Standard_NoSuchObject();
323 //=======================================================================
324 //function : Parabola
326 //=======================================================================
328 gp_Parab2d Adaptor2d_Line2d::Parabola() const
330 throw Standard_NoSuchObject();
333 //=======================================================================
336 //=======================================================================
338 Standard_Integer Adaptor2d_Line2d::Degree() const
340 throw Standard_NoSuchObject();
342 //=======================================================================
343 //function : IsRational
345 //=======================================================================
347 Standard_Boolean Adaptor2d_Line2d::IsRational() const
349 throw Standard_NoSuchObject();
351 //=======================================================================
354 //=======================================================================
356 Standard_Integer Adaptor2d_Line2d::NbPoles() const
358 throw Standard_NoSuchObject();
360 //=======================================================================
363 //=======================================================================
365 Standard_Integer Adaptor2d_Line2d::NbKnots() const
367 throw Standard_NoSuchObject();
369 //=======================================================================
372 //=======================================================================
374 Handle(Geom2d_BezierCurve) Adaptor2d_Line2d::Bezier() const
376 throw Standard_NoSuchObject();
379 //=======================================================================
382 //=======================================================================
384 Handle(Geom2d_BSplineCurve) Adaptor2d_Line2d::BSpline() const
386 throw Standard_NoSuchObject();