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()
28 : myUfirst(0.0), myUlast (0.0)
32 //=======================================================================
33 //function : Adaptor_Line2d
35 //=======================================================================
37 Adaptor2d_Line2d::Adaptor2d_Line2d(const gp_Pnt2d& P,
39 const Standard_Real UFirst,
40 const Standard_Real ULast)
41 : myUfirst(UFirst), myUlast(ULast), myAx2d(P,D)
45 //=======================================================================
48 //=======================================================================
50 void Adaptor2d_Line2d::Load(const gp_Lin2d& L)
52 myAx2d = L.Position();
53 myUfirst = -Precision::Infinite();
54 myUlast = Precision::Infinite();
57 //=======================================================================
60 //=======================================================================
62 void Adaptor2d_Line2d::Load(const gp_Lin2d& L, const Standard_Real Fi, const Standard_Real La)
64 myAx2d = L.Position();
69 //=======================================================================
70 //function : FirstParameter
72 //=======================================================================
74 Standard_Real Adaptor2d_Line2d::FirstParameter() const
79 //=======================================================================
80 //function : LastParameter
82 //=======================================================================
84 Standard_Real Adaptor2d_Line2d::LastParameter() const
89 //=======================================================================
90 //function : Continuity
92 //=======================================================================
94 GeomAbs_Shape Adaptor2d_Line2d::Continuity() const
99 //=======================================================================
100 //function : NbIntervals
102 //=======================================================================
104 //Standard_Integer Adaptor2d_Line2d::NbIntervals(const GeomAbs_Shape S) const
105 Standard_Integer Adaptor2d_Line2d::NbIntervals(const GeomAbs_Shape ) const
110 //=======================================================================
111 //function : Interval
113 //=======================================================================
115 void Adaptor2d_Line2d::Intervals(TColStd_Array1OfReal& T,
116 // const GeomAbs_Shape S) const
117 const GeomAbs_Shape ) const
119 T(T.Lower()) = myUfirst;
120 T(T.Lower()+1) = myUlast;
123 //=======================================================================
126 //=======================================================================
128 Handle(Adaptor2d_HCurve2d) Adaptor2d_Line2d::Trim
129 (const Standard_Real First,
130 const Standard_Real Last,
131 const Standard_Real) const
133 Handle(Adaptor2d_HLine2d) HL = new Adaptor2d_HLine2d();
134 HL->ChangeCurve2d().Load(gp_Lin2d(myAx2d),First,Last);
138 //=======================================================================
139 //function : IsClosed
141 //=======================================================================
143 Standard_Boolean Adaptor2d_Line2d::IsClosed() const
145 return Standard_False;
148 //=======================================================================
149 //function : IsPeriodic
151 //=======================================================================
153 Standard_Boolean Adaptor2d_Line2d::IsPeriodic() const
155 return Standard_False;
158 //=======================================================================
161 //=======================================================================
163 Standard_Real Adaptor2d_Line2d::Period() const
165 Standard_NoSuchObject::Raise();
169 //=======================================================================
172 //=======================================================================
174 gp_Pnt2d Adaptor2d_Line2d::Value(const Standard_Real X) const
176 return ElCLib::LineValue(X,myAx2d);
179 //=======================================================================
182 //=======================================================================
184 void Adaptor2d_Line2d::D0(const Standard_Real X, gp_Pnt2d& P) const
186 P = ElCLib::LineValue(X,myAx2d);
189 //=======================================================================
192 //=======================================================================
194 void Adaptor2d_Line2d::D1(const Standard_Real X, gp_Pnt2d& P, gp_Vec2d& V) const
196 ElCLib::LineD1(X,myAx2d,P,V);
199 //=======================================================================
202 //=======================================================================
204 void Adaptor2d_Line2d::D2(const Standard_Real X, gp_Pnt2d& P, gp_Vec2d& V1, gp_Vec2d& V2) const
206 ElCLib::LineD1(X,myAx2d,P,V1);
210 //=======================================================================
213 //=======================================================================
215 void Adaptor2d_Line2d::D3(const Standard_Real X, gp_Pnt2d& P, gp_Vec2d& V1, gp_Vec2d& V2, gp_Vec2d& V3) const
217 ElCLib::LineD1(X,myAx2d,P,V1);
222 //=======================================================================
225 //=======================================================================
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
230 if (N<=0) {Standard_OutOfRange::Raise();}
232 return myAx2d.Direction();
234 return gp_Vec2d(0.,0.);
237 //=======================================================================
238 //function : Resolution
240 //=======================================================================
242 Standard_Real Adaptor2d_Line2d::Resolution(const Standard_Real R3d) const
244 return R3d; // nul !!!!
247 //=======================================================================
250 //=======================================================================
252 GeomAbs_CurveType Adaptor2d_Line2d::GetType() const
257 //=======================================================================
260 //=======================================================================
262 gp_Lin2d Adaptor2d_Line2d::Line() const
264 return gp_Lin2d(myAx2d);
267 //=======================================================================
270 //=======================================================================
272 gp_Circ2d Adaptor2d_Line2d::Circle() const
274 Standard_NoSuchObject::Raise();
278 //=======================================================================
281 //=======================================================================
283 gp_Elips2d Adaptor2d_Line2d::Ellipse() const
285 Standard_NoSuchObject::Raise();
289 //=======================================================================
290 //function : Hyperbola
292 //=======================================================================
294 gp_Hypr2d Adaptor2d_Line2d::Hyperbola() const
296 Standard_NoSuchObject::Raise();
300 //=======================================================================
301 //function : Parabola
303 //=======================================================================
305 gp_Parab2d Adaptor2d_Line2d::Parabola() const
307 Standard_NoSuchObject::Raise();
311 //=======================================================================
314 //=======================================================================
316 Standard_Integer Adaptor2d_Line2d::Degree() const
318 Standard_NoSuchObject::Raise();
321 //=======================================================================
322 //function : IsRational
324 //=======================================================================
326 Standard_Boolean Adaptor2d_Line2d::IsRational() const
328 Standard_NoSuchObject::Raise();
331 //=======================================================================
334 //=======================================================================
336 Standard_Integer Adaptor2d_Line2d::NbPoles() const
338 Standard_NoSuchObject::Raise();
341 //=======================================================================
344 //=======================================================================
346 Standard_Integer Adaptor2d_Line2d::NbKnots() const
348 Standard_NoSuchObject::Raise();
351 //=======================================================================
354 //=======================================================================
356 Handle(Geom2d_BezierCurve) Adaptor2d_Line2d::Bezier() const
358 Standard_NoSuchObject::Raise();
359 Handle(Geom2d_BezierCurve) nul;
363 //=======================================================================
366 //=======================================================================
368 Handle(Geom2d_BSplineCurve) Adaptor2d_Line2d::BSpline() const
370 Standard_NoSuchObject::Raise();
371 Handle(Geom2d_BSplineCurve) nul;