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.ixx>
16 #include <Precision.hxx>
18 #include <Standard_OutOfRange.hxx>
19 #include <Standard_NoSuchObject.hxx>
20 #include <Adaptor2d_HLine2d.hxx>
22 //=======================================================================
23 //function : Adaptor2d_Line2d
25 //=======================================================================
27 Adaptor2d_Line2d::Adaptor2d_Line2d()
31 //=======================================================================
32 //function : Adaptor_Line2d
34 //=======================================================================
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)
43 //=======================================================================
46 //=======================================================================
48 void Adaptor2d_Line2d::Load(const gp_Lin2d& L)
50 myAx2d = L.Position();
51 myUfirst = -Precision::Infinite();
52 myUlast = Precision::Infinite();
55 //=======================================================================
58 //=======================================================================
60 void Adaptor2d_Line2d::Load(const gp_Lin2d& L, const Standard_Real Fi, const Standard_Real La)
62 myAx2d = L.Position();
67 //=======================================================================
68 //function : FirstParameter
70 //=======================================================================
72 Standard_Real Adaptor2d_Line2d::FirstParameter() const
77 //=======================================================================
78 //function : LastParameter
80 //=======================================================================
82 Standard_Real Adaptor2d_Line2d::LastParameter() const
87 //=======================================================================
88 //function : Continuity
90 //=======================================================================
92 GeomAbs_Shape Adaptor2d_Line2d::Continuity() const
97 //=======================================================================
98 //function : NbIntervals
100 //=======================================================================
102 //Standard_Integer Adaptor2d_Line2d::NbIntervals(const GeomAbs_Shape S) const
103 Standard_Integer Adaptor2d_Line2d::NbIntervals(const GeomAbs_Shape ) const
108 //=======================================================================
109 //function : Interval
111 //=======================================================================
113 void Adaptor2d_Line2d::Intervals(TColStd_Array1OfReal& T,
114 // const GeomAbs_Shape S) const
115 const GeomAbs_Shape ) const
117 T(T.Lower()) = myUfirst;
118 T(T.Lower()+1) = myUlast;
121 //=======================================================================
124 //=======================================================================
126 Handle(Adaptor2d_HCurve2d) Adaptor2d_Line2d::Trim
127 (const Standard_Real First,
128 const Standard_Real Last,
129 const Standard_Real) const
131 Handle(Adaptor2d_HLine2d) HL = new Adaptor2d_HLine2d();
132 HL->ChangeCurve2d().Load(gp_Lin2d(myAx2d),First,Last);
136 //=======================================================================
137 //function : IsClosed
139 //=======================================================================
141 Standard_Boolean Adaptor2d_Line2d::IsClosed() const
143 return Standard_False;
146 //=======================================================================
147 //function : IsPeriodic
149 //=======================================================================
151 Standard_Boolean Adaptor2d_Line2d::IsPeriodic() const
153 return Standard_False;
156 //=======================================================================
159 //=======================================================================
161 Standard_Real Adaptor2d_Line2d::Period() const
163 Standard_NoSuchObject::Raise();
167 //=======================================================================
170 //=======================================================================
172 gp_Pnt2d Adaptor2d_Line2d::Value(const Standard_Real X) const
174 return ElCLib::LineValue(X,myAx2d);
177 //=======================================================================
180 //=======================================================================
182 void Adaptor2d_Line2d::D0(const Standard_Real X, gp_Pnt2d& P) const
184 P = ElCLib::LineValue(X,myAx2d);
187 //=======================================================================
190 //=======================================================================
192 void Adaptor2d_Line2d::D1(const Standard_Real X, gp_Pnt2d& P, gp_Vec2d& V) const
194 ElCLib::LineD1(X,myAx2d,P,V);
197 //=======================================================================
200 //=======================================================================
202 void Adaptor2d_Line2d::D2(const Standard_Real X, gp_Pnt2d& P, gp_Vec2d& V1, gp_Vec2d& V2) const
204 ElCLib::LineD1(X,myAx2d,P,V1);
208 //=======================================================================
211 //=======================================================================
213 void Adaptor2d_Line2d::D3(const Standard_Real X, gp_Pnt2d& P, gp_Vec2d& V1, gp_Vec2d& V2, gp_Vec2d& V3) const
215 ElCLib::LineD1(X,myAx2d,P,V1);
220 //=======================================================================
223 //=======================================================================
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
228 if (N<=0) {Standard_OutOfRange::Raise();}
230 return myAx2d.Direction();
232 return gp_Vec2d(0.,0.);
235 //=======================================================================
236 //function : Resolution
238 //=======================================================================
240 Standard_Real Adaptor2d_Line2d::Resolution(const Standard_Real R3d) const
242 return R3d; // nul !!!!
245 //=======================================================================
248 //=======================================================================
250 GeomAbs_CurveType Adaptor2d_Line2d::GetType() const
255 //=======================================================================
258 //=======================================================================
260 gp_Lin2d Adaptor2d_Line2d::Line() const
262 return gp_Lin2d(myAx2d);
265 //=======================================================================
268 //=======================================================================
270 gp_Circ2d Adaptor2d_Line2d::Circle() const
272 Standard_NoSuchObject::Raise();
276 //=======================================================================
279 //=======================================================================
281 gp_Elips2d Adaptor2d_Line2d::Ellipse() const
283 Standard_NoSuchObject::Raise();
287 //=======================================================================
288 //function : Hyperbola
290 //=======================================================================
292 gp_Hypr2d Adaptor2d_Line2d::Hyperbola() const
294 Standard_NoSuchObject::Raise();
298 //=======================================================================
299 //function : Parabola
301 //=======================================================================
303 gp_Parab2d Adaptor2d_Line2d::Parabola() const
305 Standard_NoSuchObject::Raise();
309 //=======================================================================
312 //=======================================================================
314 Standard_Integer Adaptor2d_Line2d::Degree() const
316 Standard_NoSuchObject::Raise();
319 //=======================================================================
320 //function : IsRational
322 //=======================================================================
324 Standard_Boolean Adaptor2d_Line2d::IsRational() const
326 Standard_NoSuchObject::Raise();
329 //=======================================================================
332 //=======================================================================
334 Standard_Integer Adaptor2d_Line2d::NbPoles() const
336 Standard_NoSuchObject::Raise();
339 //=======================================================================
342 //=======================================================================
344 Standard_Integer Adaptor2d_Line2d::NbKnots() const
346 Standard_NoSuchObject::Raise();
349 //=======================================================================
352 //=======================================================================
354 Handle(Geom2d_BezierCurve) Adaptor2d_Line2d::Bezier() const
356 Standard_NoSuchObject::Raise();
357 Handle(Geom2d_BezierCurve) nul;
361 //=======================================================================
364 //=======================================================================
366 Handle(Geom2d_BSplineCurve) Adaptor2d_Line2d::BSpline() const
368 Standard_NoSuchObject::Raise();
369 Handle(Geom2d_BSplineCurve) nul;