1 // Created on: 1993-03-10
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.
19 #include <Geom_Geometry.hxx>
20 #include <Geom_Line.hxx>
25 #include <gp_Trsf.hxx>
28 #include <Precision.hxx>
29 #include <Standard_RangeError.hxx>
30 #include <Standard_Type.hxx>
32 IMPLEMENT_STANDARD_RTTIEXT(Geom_Line,Geom_Curve)
34 //=======================================================================
37 //=======================================================================
38 Handle(Geom_Geometry) Geom_Line::Copy() const {
41 L = new Geom_Line (pos);
45 //=======================================================================
46 //function : Geom_Line
48 //=======================================================================
50 Geom_Line::Geom_Line (const gp_Ax1& A) : pos (A) { }
52 //=======================================================================
53 //function : Geom_Line
55 //=======================================================================
57 Geom_Line::Geom_Line (const gp_Lin& L) : pos (L.Position()) { }
59 //=======================================================================
60 //function : Geom_Line
62 //=======================================================================
64 Geom_Line::Geom_Line (const gp_Pnt& P, const gp_Dir& V) : pos (P, V) { }
66 //=======================================================================
69 //=======================================================================
71 void Geom_Line::Reverse () { pos.Reverse(); }
73 //=======================================================================
74 //function : ReversedParameter
76 //=======================================================================
78 Standard_Real Geom_Line::ReversedParameter( const Standard_Real U) const
81 //=======================================================================
82 //function : SetDirection
84 //=======================================================================
86 void Geom_Line::SetDirection (const gp_Dir& V) { pos.SetDirection (V); }
88 //=======================================================================
91 //=======================================================================
93 void Geom_Line::SetLin (const gp_Lin& L) { pos = L.Position(); }
95 //=======================================================================
96 //function : SetLocation
98 //=======================================================================
100 void Geom_Line::SetLocation (const gp_Pnt& P) { pos.SetLocation (P); }
102 //=======================================================================
103 //function : SetPosition
105 //=======================================================================
107 void Geom_Line::SetPosition (const gp_Ax1& A1) { pos = A1; }
109 //=======================================================================
110 //function : Position
112 //=======================================================================
114 const gp_Ax1& Geom_Line::Position () const { return pos; }
116 //=======================================================================
117 //function : IsClosed
119 //=======================================================================
121 Standard_Boolean Geom_Line::IsClosed () const { return Standard_False; }
123 //=======================================================================
124 //function : IsPeriodic
126 //=======================================================================
128 Standard_Boolean Geom_Line::IsPeriodic () const { return Standard_False; }
130 //=======================================================================
131 //function : Continuity
133 //=======================================================================
135 GeomAbs_Shape Geom_Line::Continuity () const { return GeomAbs_CN; }
137 //=======================================================================
138 //function : FirstParameter
140 //=======================================================================
142 Standard_Real Geom_Line::FirstParameter () const
143 { return -Precision::Infinite(); }
145 //=======================================================================
146 //function : LastParameter
148 //=======================================================================
150 Standard_Real Geom_Line::LastParameter () const
151 { return Precision::Infinite(); }
153 //=======================================================================
156 //=======================================================================
158 gp_Lin Geom_Line::Lin () const { return gp_Lin (pos); }
161 //=======================================================================
164 //=======================================================================
166 Standard_Boolean Geom_Line::IsCN (const Standard_Integer ) const
167 { return Standard_True; }
169 //=======================================================================
170 //function : Transform
172 //=======================================================================
174 void Geom_Line::Transform (const gp_Trsf& T) { pos.Transform (T); }
176 //=======================================================================
179 //=======================================================================
181 void Geom_Line::D0 (const Standard_Real U, gp_Pnt& P) const
183 P = ElCLib::LineValue (U, pos);
186 //=======================================================================
189 //=======================================================================
191 void Geom_Line::D1 (const Standard_Real U, gp_Pnt& P, gp_Vec& V1) const {
193 ElCLib::LineD1 (U, pos, P, V1);
196 //=======================================================================
199 //=======================================================================
201 void Geom_Line::D2 (const Standard_Real U, gp_Pnt& P, gp_Vec& V1, gp_Vec& V2) const {
203 ElCLib::LineD1 (U, pos, P, V1);
204 V2.SetCoord (0.0, 0.0, 0.0);
207 //=======================================================================
210 //=======================================================================
212 void Geom_Line::D3 (const Standard_Real U, gp_Pnt& P, gp_Vec& V1, gp_Vec& V2, gp_Vec& V3) const{
214 ElCLib::LineD1 (U, pos, P, V1);
215 V2.SetCoord (0.0, 0.0, 0.0);
216 V3.SetCoord (0.0, 0.0, 0.0);
219 //=======================================================================
222 //=======================================================================
224 gp_Vec Geom_Line::DN (const Standard_Real , const Standard_Integer N) const {
226 Standard_RangeError_Raise_if (N <= 0, " ");
227 if (N == 1) return gp_Vec (pos.Direction ());
228 else return gp_Vec (0.0, 0.0, 0.0);
231 //=======================================================================
232 //function : TransformedParameter
234 //=======================================================================
236 Standard_Real Geom_Line::TransformedParameter(const Standard_Real U,
237 const gp_Trsf& T) const
239 if (Precision::IsInfinite(U)) return U;
240 return U * Abs(T.ScaleFactor());
244 //=======================================================================
245 //function : TransformedParameter
247 //=======================================================================
249 Standard_Real Geom_Line::ParametricTransformation(const gp_Trsf& T) const
251 return Abs(T.ScaleFactor());