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.
17 #include <Geom_Line.ixx>
19 #include <Precision.hxx>
22 #include <Standard_RangeError.hxx>
26 //=======================================================================
29 //=======================================================================
31 Handle(Geom_Geometry) Geom_Line::Copy() const {
34 L = new Geom_Line (pos);
38 //=======================================================================
39 //function : Geom_Line
41 //=======================================================================
43 Geom_Line::Geom_Line (const gp_Ax1& A) : pos (A) { }
45 //=======================================================================
46 //function : Geom_Line
48 //=======================================================================
50 Geom_Line::Geom_Line (const gp_Lin& L) : pos (L.Position()) { }
52 //=======================================================================
53 //function : Geom_Line
55 //=======================================================================
57 Geom_Line::Geom_Line (const gp_Pnt& P, const gp_Dir& V) : pos (P, V) { }
59 //=======================================================================
62 //=======================================================================
64 void Geom_Line::Reverse () { pos.Reverse(); }
66 //=======================================================================
67 //function : ReversedParameter
69 //=======================================================================
71 Standard_Real Geom_Line::ReversedParameter( const Standard_Real U) const
74 //=======================================================================
75 //function : SetDirection
77 //=======================================================================
79 void Geom_Line::SetDirection (const gp_Dir& V) { pos.SetDirection (V); }
81 //=======================================================================
84 //=======================================================================
86 void Geom_Line::SetLin (const gp_Lin& L) { pos = L.Position(); }
88 //=======================================================================
89 //function : SetLocation
91 //=======================================================================
93 void Geom_Line::SetLocation (const gp_Pnt& P) { pos.SetLocation (P); }
95 //=======================================================================
96 //function : SetPosition
98 //=======================================================================
100 void Geom_Line::SetPosition (const gp_Ax1& A1) { pos = A1; }
102 //=======================================================================
103 //function : Position
105 //=======================================================================
107 const gp_Ax1& Geom_Line::Position () const { return pos; }
109 //=======================================================================
110 //function : IsClosed
112 //=======================================================================
114 Standard_Boolean Geom_Line::IsClosed () const { return Standard_False; }
116 //=======================================================================
117 //function : IsPeriodic
119 //=======================================================================
121 Standard_Boolean Geom_Line::IsPeriodic () const { return Standard_False; }
123 //=======================================================================
124 //function : Continuity
126 //=======================================================================
128 GeomAbs_Shape Geom_Line::Continuity () const { return GeomAbs_CN; }
130 //=======================================================================
131 //function : FirstParameter
133 //=======================================================================
135 Standard_Real Geom_Line::FirstParameter () const
136 { return -Precision::Infinite(); }
138 //=======================================================================
139 //function : LastParameter
141 //=======================================================================
143 Standard_Real Geom_Line::LastParameter () const
144 { return Precision::Infinite(); }
146 //=======================================================================
149 //=======================================================================
151 gp_Lin Geom_Line::Lin () const { return gp_Lin (pos); }
154 //=======================================================================
157 //=======================================================================
159 Standard_Boolean Geom_Line::IsCN (const Standard_Integer ) const
160 { return Standard_True; }
162 //=======================================================================
163 //function : Transform
165 //=======================================================================
167 void Geom_Line::Transform (const gp_Trsf& T) { pos.Transform (T); }
169 //=======================================================================
172 //=======================================================================
174 void Geom_Line::D0 (const Standard_Real U, gp_Pnt& P) const
176 P = ElCLib::LineValue (U, pos);
179 //=======================================================================
182 //=======================================================================
184 void Geom_Line::D1 (const Standard_Real U, gp_Pnt& P, gp_Vec& V1) const {
186 ElCLib::LineD1 (U, pos, P, V1);
189 //=======================================================================
192 //=======================================================================
194 void Geom_Line::D2 (const Standard_Real U, gp_Pnt& P, gp_Vec& V1, gp_Vec& V2) const {
196 ElCLib::LineD1 (U, pos, P, V1);
197 V2.SetCoord (0.0, 0.0, 0.0);
200 //=======================================================================
203 //=======================================================================
205 void Geom_Line::D3 (const Standard_Real U, gp_Pnt& P, gp_Vec& V1, gp_Vec& V2, gp_Vec& V3) const{
207 ElCLib::LineD1 (U, pos, P, V1);
208 V2.SetCoord (0.0, 0.0, 0.0);
209 V3.SetCoord (0.0, 0.0, 0.0);
212 //=======================================================================
215 //=======================================================================
217 gp_Vec Geom_Line::DN (const Standard_Real , const Standard_Integer N) const {
219 Standard_RangeError_Raise_if (N <= 0, " ");
220 if (N == 1) return gp_Vec (pos.Direction ());
221 else return gp_Vec (0.0, 0.0, 0.0);
224 //=======================================================================
225 //function : TransformedParameter
227 //=======================================================================
229 Standard_Real Geom_Line::TransformedParameter(const Standard_Real U,
230 const gp_Trsf& T) const
232 if (Precision::IsInfinite(U)) return U;
233 return U * Abs(T.ScaleFactor());
237 //=======================================================================
238 //function : TransformedParameter
240 //=======================================================================
242 Standard_Real Geom_Line::ParametricTransformation(const gp_Trsf& T) const
244 return Abs(T.ScaleFactor());