1 // Created on: 1993-03-24
3 // Copyright (c) 1993-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
6 // This file is part of Open CASCADE Technology software library.
8 // This library is free software; you can redistribute it and/or modify it under
9 // the terms of the GNU Lesser General Public License version 2.1 as published
10 // by the Free Software Foundation, with special exception defined in the file
11 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12 // distribution for complete text of the license and disclaimer of any warranty.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
17 #include <Geom2d_Line.ixx>
19 #include <Precision.hxx>
22 #include <Standard_RangeError.hxx>
25 typedef Geom2d_Line Line;
26 typedef Handle(Geom2d_Line) Handle(Line);
28 typedef gp_Dir2d Dir2d;
29 typedef gp_Pnt2d Pnt2d;
30 typedef gp_Vec2d Vec2d;
31 typedef gp_Trsf2d Trsf2d;
38 //=======================================================================
41 //=======================================================================
43 Handle(Geom2d_Geometry) Geom2d_Line::Copy() const
51 //=======================================================================
52 //function : Geom2d_Line
54 //=======================================================================
56 Geom2d_Line::Geom2d_Line (const Ax2d& A) : pos (A) { }
58 //=======================================================================
59 //function : Geom2d_Line
61 //=======================================================================
63 Geom2d_Line::Geom2d_Line (const gp_Lin2d& L) : pos (L.Position()) { }
65 //=======================================================================
66 //function : Geom2d_Line
68 //=======================================================================
70 Geom2d_Line::Geom2d_Line (const Pnt2d& P, const Dir2d& V) : pos (P, V) { }
72 //=======================================================================
73 //function : SetDirection
75 //=======================================================================
77 void Geom2d_Line::SetDirection (const Dir2d& V) { pos.SetDirection (V); }
79 //=======================================================================
80 //function : Direction
82 //=======================================================================
84 const gp_Dir2d& Geom2d_Line::Direction () const { return pos.Direction (); }
86 //=======================================================================
89 //=======================================================================
91 void Geom2d_Line::SetLin2d (const gp_Lin2d& L) { pos = L.Position(); }
93 //=======================================================================
94 //function : SetLocation
96 //=======================================================================
98 void Geom2d_Line::SetLocation (const Pnt2d& P) { pos.SetLocation (P); }
100 //=======================================================================
101 //function : Location
103 //=======================================================================
105 const gp_Pnt2d& Geom2d_Line::Location () const { return pos.Location (); }
107 //=======================================================================
108 //function : SetPosition
110 //=======================================================================
112 void Geom2d_Line::SetPosition (const Ax2d& A) { pos = A; }
114 //=======================================================================
115 //function : Position
117 //=======================================================================
119 const gp_Ax2d& Geom2d_Line::Position () const { return pos; }
121 //=======================================================================
124 //=======================================================================
126 gp_Lin2d Geom2d_Line::Lin2d () const { return gp_Lin2d (pos); }
128 //=======================================================================
131 //=======================================================================
133 void Geom2d_Line::Reverse () { pos.Reverse(); }
135 //=======================================================================
136 //function : ReversedParameter
138 //=======================================================================
140 Standard_Real Geom2d_Line::ReversedParameter( const Standard_Real U) const { return (-U); }
142 //=======================================================================
143 //function : FirstParameter
145 //=======================================================================
147 Standard_Real Geom2d_Line::FirstParameter () const
148 { return -Precision::Infinite(); }
150 //=======================================================================
151 //function : LastParameter
153 //=======================================================================
155 Standard_Real Geom2d_Line::LastParameter () const
156 { return Precision::Infinite(); }
158 //=======================================================================
159 //function : IsClosed
161 //=======================================================================
163 Standard_Boolean Geom2d_Line::IsClosed () const { return Standard_False; }
165 //=======================================================================
166 //function : IsPeriodic
168 //=======================================================================
170 Standard_Boolean Geom2d_Line::IsPeriodic () const { return Standard_False; }
172 //=======================================================================
173 //function : Continuity
175 //=======================================================================
177 GeomAbs_Shape Geom2d_Line::Continuity () const { return GeomAbs_CN; }
179 //=======================================================================
182 //=======================================================================
184 Standard_Boolean Geom2d_Line::IsCN (const Standard_Integer ) const { return Standard_True; }
186 //=======================================================================
189 //=======================================================================
191 void Geom2d_Line::D0 (const Standard_Real U, Pnt2d& P) const
193 P = ElCLib::LineValue (U, pos);
196 //=======================================================================
199 //=======================================================================
201 void Geom2d_Line::D1 (const Standard_Real U, Pnt2d& P, Vec2d& V1) const
203 ElCLib::LineD1 (U, pos, P, V1);
206 //=======================================================================
209 //=======================================================================
211 void Geom2d_Line::D2 (const Standard_Real U,
213 Vec2d& V1, Vec2d& V2) const
215 ElCLib::LineD1 (U, pos, P, V1);
216 V2.SetCoord (0.0, 0.0);
219 //=======================================================================
222 //=======================================================================
224 void Geom2d_Line::D3 (const Standard_Real U,
226 Vec2d& V1, Vec2d& V2, Vec2d& V3) const
228 ElCLib::LineD1 (U, pos, P, V1);
229 V2.SetCoord (0.0, 0.0);
230 V3.SetCoord (0.0, 0.0);
234 //=======================================================================
237 //=======================================================================
239 Vec2d Geom2d_Line::DN
240 (const Standard_Real ,
241 const Standard_Integer N ) const
243 Standard_RangeError_Raise_if (N <= 0, " ");
245 return Vec2d (pos.Direction ());
247 return Vec2d (0.0, 0.0);
251 //=======================================================================
252 //function : Transform
254 //=======================================================================
256 void Geom2d_Line::Transform (const Trsf2d& T) { pos.Transform (T); }
258 //=======================================================================
259 //function : TransformedParameter
261 //=======================================================================
263 Standard_Real Geom2d_Line::TransformedParameter(const Standard_Real U,
264 const gp_Trsf2d& T) const
266 if (Precision::IsInfinite(U)) return U;
267 return U * Abs(T.ScaleFactor());
270 //=======================================================================
271 //function : ParametricTransformation
273 //=======================================================================
275 Standard_Real Geom2d_Line::ParametricTransformation(const gp_Trsf2d& T) const
277 return Abs(T.ScaleFactor());
281 //=======================================================================
282 //function : Distance
284 //=======================================================================
286 Standard_Real Geom2d_Line::Distance (const gp_Pnt2d& P) const {
289 return L.Distance (P);