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.
15 #include <Adaptor2d_HCurve2d.hxx>
16 #include <Adaptor2d_HLine2d.hxx>
17 #include <Adaptor2d_Line2d.hxx>
19 #include <Geom2d_BezierCurve.hxx>
20 #include <Geom2d_BSplineCurve.hxx>
21 #include <gp_Circ2d.hxx>
22 #include <gp_Dir2d.hxx>
23 #include <gp_Elips2d.hxx>
24 #include <gp_Hypr2d.hxx>
25 #include <gp_Lin2d.hxx>
26 #include <gp_Parab2d.hxx>
27 #include <gp_Pnt2d.hxx>
28 #include <gp_Vec2d.hxx>
29 #include <Precision.hxx>
30 #include <Standard_DomainError.hxx>
31 #include <Standard_NoSuchObject.hxx>
32 #include <Standard_OutOfRange.hxx>
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_HCurve2d) Adaptor2d_Line2d::Trim
140 (const Standard_Real First,
141 const Standard_Real Last,
142 const Standard_Real) const
144 Handle(Adaptor2d_HLine2d) HL = new Adaptor2d_HLine2d();
145 HL->ChangeCurve2d().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 Standard_NoSuchObject::Raise();
180 //=======================================================================
183 //=======================================================================
185 gp_Pnt2d Adaptor2d_Line2d::Value(const Standard_Real X) const
187 return ElCLib::LineValue(X,myAx2d);
190 //=======================================================================
193 //=======================================================================
195 void Adaptor2d_Line2d::D0(const Standard_Real X, gp_Pnt2d& P) const
197 P = ElCLib::LineValue(X,myAx2d);
200 //=======================================================================
203 //=======================================================================
205 void Adaptor2d_Line2d::D1(const Standard_Real X, gp_Pnt2d& P, gp_Vec2d& V) const
207 ElCLib::LineD1(X,myAx2d,P,V);
210 //=======================================================================
213 //=======================================================================
215 void Adaptor2d_Line2d::D2(const Standard_Real X, gp_Pnt2d& P, gp_Vec2d& V1, gp_Vec2d& V2) const
217 ElCLib::LineD1(X,myAx2d,P,V1);
221 //=======================================================================
224 //=======================================================================
226 void Adaptor2d_Line2d::D3(const Standard_Real X, gp_Pnt2d& P, gp_Vec2d& V1, gp_Vec2d& V2, gp_Vec2d& V3) const
228 ElCLib::LineD1(X,myAx2d,P,V1);
233 //=======================================================================
236 //=======================================================================
238 //gp_Vec2d Adaptor2d_Line2d::DN(const Standard_Real U, const Standard_Integer N) const
239 gp_Vec2d Adaptor2d_Line2d::DN(const Standard_Real , const Standard_Integer N) const
241 if (N<=0) {Standard_OutOfRange::Raise();}
243 return myAx2d.Direction();
245 return gp_Vec2d(0.,0.);
248 //=======================================================================
249 //function : Resolution
251 //=======================================================================
253 Standard_Real Adaptor2d_Line2d::Resolution(const Standard_Real R3d) const
255 return R3d; // nul !!!!
258 //=======================================================================
261 //=======================================================================
263 GeomAbs_CurveType Adaptor2d_Line2d::GetType() const
268 //=======================================================================
271 //=======================================================================
273 gp_Lin2d Adaptor2d_Line2d::Line() const
275 return gp_Lin2d(myAx2d);
278 //=======================================================================
281 //=======================================================================
283 gp_Circ2d Adaptor2d_Line2d::Circle() const
285 Standard_NoSuchObject::Raise();
289 //=======================================================================
292 //=======================================================================
294 gp_Elips2d Adaptor2d_Line2d::Ellipse() const
296 Standard_NoSuchObject::Raise();
300 //=======================================================================
301 //function : Hyperbola
303 //=======================================================================
305 gp_Hypr2d Adaptor2d_Line2d::Hyperbola() const
307 Standard_NoSuchObject::Raise();
311 //=======================================================================
312 //function : Parabola
314 //=======================================================================
316 gp_Parab2d Adaptor2d_Line2d::Parabola() const
318 Standard_NoSuchObject::Raise();
322 //=======================================================================
325 //=======================================================================
327 Standard_Integer Adaptor2d_Line2d::Degree() const
329 Standard_NoSuchObject::Raise();
332 //=======================================================================
333 //function : IsRational
335 //=======================================================================
337 Standard_Boolean Adaptor2d_Line2d::IsRational() const
339 Standard_NoSuchObject::Raise();
342 //=======================================================================
345 //=======================================================================
347 Standard_Integer Adaptor2d_Line2d::NbPoles() const
349 Standard_NoSuchObject::Raise();
352 //=======================================================================
355 //=======================================================================
357 Standard_Integer Adaptor2d_Line2d::NbKnots() const
359 Standard_NoSuchObject::Raise();
362 //=======================================================================
365 //=======================================================================
367 Handle(Geom2d_BezierCurve) Adaptor2d_Line2d::Bezier() const
369 Standard_NoSuchObject::Raise();
370 Handle(Geom2d_BezierCurve) nul;
374 //=======================================================================
377 //=======================================================================
379 Handle(Geom2d_BSplineCurve) Adaptor2d_Line2d::BSpline() const
381 Standard_NoSuchObject::Raise();
382 Handle(Geom2d_BSplineCurve) nul;