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 //=======================================================================
59 //=======================================================================
61 void Adaptor2d_Line2d::Load(const gp_Lin2d& L)
63 myAx2d = L.Position();
64 myUfirst = -Precision::Infinite();
65 myUlast = Precision::Infinite();
68 //=======================================================================
71 //=======================================================================
73 void Adaptor2d_Line2d::Load(const gp_Lin2d& L, const Standard_Real Fi, const Standard_Real La)
75 myAx2d = L.Position();
80 //=======================================================================
81 //function : FirstParameter
83 //=======================================================================
85 Standard_Real Adaptor2d_Line2d::FirstParameter() const
90 //=======================================================================
91 //function : LastParameter
93 //=======================================================================
95 Standard_Real Adaptor2d_Line2d::LastParameter() const
100 //=======================================================================
101 //function : Continuity
103 //=======================================================================
105 GeomAbs_Shape Adaptor2d_Line2d::Continuity() const
110 //=======================================================================
111 //function : NbIntervals
113 //=======================================================================
115 //Standard_Integer Adaptor2d_Line2d::NbIntervals(const GeomAbs_Shape S) const
116 Standard_Integer Adaptor2d_Line2d::NbIntervals(const GeomAbs_Shape ) const
121 //=======================================================================
122 //function : Interval
124 //=======================================================================
126 void Adaptor2d_Line2d::Intervals(TColStd_Array1OfReal& T,
127 // const GeomAbs_Shape S) const
128 const GeomAbs_Shape ) const
130 T(T.Lower()) = myUfirst;
131 T(T.Lower()+1) = myUlast;
134 //=======================================================================
137 //=======================================================================
139 Handle(Adaptor2d_Curve2d) Adaptor2d_Line2d::Trim
140 (const Standard_Real First,
141 const Standard_Real Last,
142 const Standard_Real) const
144 Handle(Adaptor2d_Line2d) HL = new Adaptor2d_Line2d();
145 HL->Load(gp_Lin2d(myAx2d),First,Last);
149 //=======================================================================
150 //function : IsClosed
152 //=======================================================================
154 Standard_Boolean Adaptor2d_Line2d::IsClosed() const
156 return Standard_False;
159 //=======================================================================
160 //function : IsPeriodic
162 //=======================================================================
164 Standard_Boolean Adaptor2d_Line2d::IsPeriodic() const
166 return Standard_False;
169 //=======================================================================
172 //=======================================================================
174 Standard_Real Adaptor2d_Line2d::Period() const
176 throw Standard_NoSuchObject();
179 //=======================================================================
182 //=======================================================================
184 gp_Pnt2d Adaptor2d_Line2d::Value(const Standard_Real X) const
186 return ElCLib::LineValue(X,myAx2d);
189 //=======================================================================
192 //=======================================================================
194 void Adaptor2d_Line2d::D0(const Standard_Real X, gp_Pnt2d& P) const
196 P = ElCLib::LineValue(X,myAx2d);
199 //=======================================================================
202 //=======================================================================
204 void Adaptor2d_Line2d::D1(const Standard_Real X, gp_Pnt2d& P, gp_Vec2d& V) const
206 ElCLib::LineD1(X,myAx2d,P,V);
209 //=======================================================================
212 //=======================================================================
214 void Adaptor2d_Line2d::D2(const Standard_Real X, gp_Pnt2d& P, gp_Vec2d& V1, gp_Vec2d& V2) const
216 ElCLib::LineD1(X,myAx2d,P,V1);
220 //=======================================================================
223 //=======================================================================
225 void Adaptor2d_Line2d::D3(const Standard_Real X, gp_Pnt2d& P, gp_Vec2d& V1, gp_Vec2d& V2, gp_Vec2d& V3) const
227 ElCLib::LineD1(X,myAx2d,P,V1);
232 //=======================================================================
235 //=======================================================================
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
240 if (N<=0) {throw Standard_OutOfRange();}
242 return myAx2d.Direction();
244 return gp_Vec2d(0.,0.);
247 //=======================================================================
248 //function : Resolution
250 //=======================================================================
252 Standard_Real Adaptor2d_Line2d::Resolution(const Standard_Real R3d) const
254 return R3d; // nul !!!!
257 //=======================================================================
260 //=======================================================================
262 GeomAbs_CurveType Adaptor2d_Line2d::GetType() const
267 //=======================================================================
270 //=======================================================================
272 gp_Lin2d Adaptor2d_Line2d::Line() const
274 return gp_Lin2d(myAx2d);
277 //=======================================================================
280 //=======================================================================
282 gp_Circ2d Adaptor2d_Line2d::Circle() const
284 throw Standard_NoSuchObject();
287 //=======================================================================
290 //=======================================================================
292 gp_Elips2d Adaptor2d_Line2d::Ellipse() const
294 throw Standard_NoSuchObject();
297 //=======================================================================
298 //function : Hyperbola
300 //=======================================================================
302 gp_Hypr2d Adaptor2d_Line2d::Hyperbola() const
304 throw Standard_NoSuchObject();
307 //=======================================================================
308 //function : Parabola
310 //=======================================================================
312 gp_Parab2d Adaptor2d_Line2d::Parabola() const
314 throw Standard_NoSuchObject();
317 //=======================================================================
320 //=======================================================================
322 Standard_Integer Adaptor2d_Line2d::Degree() const
324 throw Standard_NoSuchObject();
326 //=======================================================================
327 //function : IsRational
329 //=======================================================================
331 Standard_Boolean Adaptor2d_Line2d::IsRational() const
333 throw Standard_NoSuchObject();
335 //=======================================================================
338 //=======================================================================
340 Standard_Integer Adaptor2d_Line2d::NbPoles() const
342 throw Standard_NoSuchObject();
344 //=======================================================================
347 //=======================================================================
349 Standard_Integer Adaptor2d_Line2d::NbKnots() const
351 throw Standard_NoSuchObject();
353 //=======================================================================
356 //=======================================================================
358 Handle(Geom2d_BezierCurve) Adaptor2d_Line2d::Bezier() const
360 throw Standard_NoSuchObject();
363 //=======================================================================
366 //=======================================================================
368 Handle(Geom2d_BSplineCurve) Adaptor2d_Line2d::BSpline() const
370 throw Standard_NoSuchObject();