1 // Copyright (c) 1999-2012 OPEN CASCADE SAS
3 // The content of this file is subject to the Open CASCADE Technology Public
4 // License Version 6.5 (the "License"). You may not use the content of this file
5 // except in compliance with the License. Please obtain a copy of the License
6 // at http://www.opencascade.org and read it completely before using this file.
8 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
9 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
11 // The Original Code and all software distributed under the License is
12 // distributed on an "AS IS" basis, without warranty of any kind, and the
13 // Initial Developer hereby disclaims all such warranties, including without
14 // limitation, any warranties of merchantability, fitness for a particular
15 // purpose or non-infringement. Please see the License for the specific terms
16 // and conditions governing the rights and limitations under the License.
18 #include <Adaptor2d_Line2d.ixx>
20 #include <Precision.hxx>
22 #include <Standard_OutOfRange.hxx>
23 #include <Standard_NoSuchObject.hxx>
24 #include <Adaptor2d_HLine2d.hxx>
26 //=======================================================================
27 //function : Adaptor2d_Line2d
29 //=======================================================================
31 Adaptor2d_Line2d::Adaptor2d_Line2d()
35 //=======================================================================
36 //function : Adaptor_Line2d
38 //=======================================================================
40 Adaptor2d_Line2d::Adaptor2d_Line2d(const gp_Pnt2d& P, const gp_Dir2d& D,
41 const Standard_Real UFirst,
42 const Standard_Real ULast):
43 myUfirst(UFirst),myUlast(ULast),myAx2d(P,D)
47 //=======================================================================
50 //=======================================================================
52 void Adaptor2d_Line2d::Load(const gp_Lin2d& L)
54 myAx2d = L.Position();
55 myUfirst = -Precision::Infinite();
56 myUlast = Precision::Infinite();
59 //=======================================================================
62 //=======================================================================
64 void Adaptor2d_Line2d::Load(const gp_Lin2d& L, const Standard_Real Fi, const Standard_Real La)
66 myAx2d = L.Position();
71 //=======================================================================
72 //function : FirstParameter
74 //=======================================================================
76 Standard_Real Adaptor2d_Line2d::FirstParameter() const
81 //=======================================================================
82 //function : LastParameter
84 //=======================================================================
86 Standard_Real Adaptor2d_Line2d::LastParameter() const
91 //=======================================================================
92 //function : Continuity
94 //=======================================================================
96 GeomAbs_Shape Adaptor2d_Line2d::Continuity() const
101 //=======================================================================
102 //function : NbIntervals
104 //=======================================================================
106 //Standard_Integer Adaptor2d_Line2d::NbIntervals(const GeomAbs_Shape S) const
107 Standard_Integer Adaptor2d_Line2d::NbIntervals(const GeomAbs_Shape ) const
112 //=======================================================================
113 //function : Interval
115 //=======================================================================
117 void Adaptor2d_Line2d::Intervals(TColStd_Array1OfReal& T,
118 // const GeomAbs_Shape S) const
119 const GeomAbs_Shape ) const
121 T(T.Lower()) = myUfirst;
122 T(T.Lower()+1) = myUlast;
125 //=======================================================================
128 //=======================================================================
130 Handle(Adaptor2d_HCurve2d) Adaptor2d_Line2d::Trim
131 (const Standard_Real First,
132 const Standard_Real Last,
133 const Standard_Real) const
135 Handle(Adaptor2d_HLine2d) HL = new Adaptor2d_HLine2d();
136 HL->ChangeCurve2d().Load(gp_Lin2d(myAx2d),First,Last);
140 //=======================================================================
141 //function : IsClosed
143 //=======================================================================
145 Standard_Boolean Adaptor2d_Line2d::IsClosed() const
147 return Standard_False;
150 //=======================================================================
151 //function : IsPeriodic
153 //=======================================================================
155 Standard_Boolean Adaptor2d_Line2d::IsPeriodic() const
157 return Standard_False;
160 //=======================================================================
163 //=======================================================================
165 Standard_Real Adaptor2d_Line2d::Period() const
167 Standard_NoSuchObject::Raise();
171 //=======================================================================
174 //=======================================================================
176 gp_Pnt2d Adaptor2d_Line2d::Value(const Standard_Real X) const
178 return ElCLib::LineValue(X,myAx2d);
181 //=======================================================================
184 //=======================================================================
186 void Adaptor2d_Line2d::D0(const Standard_Real X, gp_Pnt2d& P) const
188 P = ElCLib::LineValue(X,myAx2d);
191 //=======================================================================
194 //=======================================================================
196 void Adaptor2d_Line2d::D1(const Standard_Real X, gp_Pnt2d& P, gp_Vec2d& V) const
198 ElCLib::LineD1(X,myAx2d,P,V);
201 //=======================================================================
204 //=======================================================================
206 void Adaptor2d_Line2d::D2(const Standard_Real X, gp_Pnt2d& P, gp_Vec2d& V1, gp_Vec2d& V2) const
208 ElCLib::LineD1(X,myAx2d,P,V1);
212 //=======================================================================
215 //=======================================================================
217 void Adaptor2d_Line2d::D3(const Standard_Real X, gp_Pnt2d& P, gp_Vec2d& V1, gp_Vec2d& V2, gp_Vec2d& V3) const
219 ElCLib::LineD1(X,myAx2d,P,V1);
224 //=======================================================================
227 //=======================================================================
229 //gp_Vec2d Adaptor2d_Line2d::DN(const Standard_Real U, const Standard_Integer N) const
230 gp_Vec2d Adaptor2d_Line2d::DN(const Standard_Real , const Standard_Integer N) const
232 if (N<=0) {Standard_OutOfRange::Raise();}
234 return myAx2d.Direction();
236 return gp_Vec2d(0.,0.);
239 //=======================================================================
240 //function : Resolution
242 //=======================================================================
244 Standard_Real Adaptor2d_Line2d::Resolution(const Standard_Real R3d) const
246 return R3d; // nul !!!!
249 //=======================================================================
252 //=======================================================================
254 GeomAbs_CurveType Adaptor2d_Line2d::GetType() const
259 //=======================================================================
262 //=======================================================================
264 gp_Lin2d Adaptor2d_Line2d::Line() const
266 return gp_Lin2d(myAx2d);
269 //=======================================================================
272 //=======================================================================
274 gp_Circ2d Adaptor2d_Line2d::Circle() const
276 Standard_NoSuchObject::Raise();
280 //=======================================================================
283 //=======================================================================
285 gp_Elips2d Adaptor2d_Line2d::Ellipse() const
287 Standard_NoSuchObject::Raise();
291 //=======================================================================
292 //function : Hyperbola
294 //=======================================================================
296 gp_Hypr2d Adaptor2d_Line2d::Hyperbola() const
298 Standard_NoSuchObject::Raise();
302 //=======================================================================
303 //function : Parabola
305 //=======================================================================
307 gp_Parab2d Adaptor2d_Line2d::Parabola() const
309 Standard_NoSuchObject::Raise();
313 //=======================================================================
316 //=======================================================================
318 Standard_Integer Adaptor2d_Line2d::Degree() const
320 Standard_NoSuchObject::Raise();
323 //=======================================================================
324 //function : IsRational
326 //=======================================================================
328 Standard_Boolean Adaptor2d_Line2d::IsRational() const
330 Standard_NoSuchObject::Raise();
333 //=======================================================================
336 //=======================================================================
338 Standard_Integer Adaptor2d_Line2d::NbPoles() const
340 Standard_NoSuchObject::Raise();
343 //=======================================================================
346 //=======================================================================
348 Standard_Integer Adaptor2d_Line2d::NbKnots() const
350 Standard_NoSuchObject::Raise();
353 //=======================================================================
356 //=======================================================================
358 Handle(Geom2d_BezierCurve) Adaptor2d_Line2d::Bezier() const
360 Standard_NoSuchObject::Raise();
361 Handle(Geom2d_BezierCurve) nul;
365 //=======================================================================
368 //=======================================================================
370 Handle(Geom2d_BSplineCurve) Adaptor2d_Line2d::BSpline() const
372 Standard_NoSuchObject::Raise();
373 Handle(Geom2d_BSplineCurve) nul;