0024023: Revamp the OCCT Handle -- general
[occt.git] / src / Geom / Geom_Line.cxx
1 // Created on: 1993-03-10
2 // Created by: JCV
3 // Copyright (c) 1993-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
5 //
6 // This file is part of Open CASCADE Technology software library.
7 //
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.
13 //
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
16
17 #include <Geom_Line.ixx>
18
19 #include <Precision.hxx>
20 #include <gp_XYZ.hxx>
21 #include <ElCLib.hxx>
22 #include <Standard_RangeError.hxx>
23
24
25
26 //=======================================================================
27 //function : Copy
28 //purpose  : 
29 //=======================================================================
30
31 Handle(Geom_Geometry) Geom_Line::Copy() const {
32
33    Handle(Geom_Line) L;
34    L = new Geom_Line (pos);
35    return L;
36 }
37
38 //=======================================================================
39 //function : Geom_Line
40 //purpose  : 
41 //=======================================================================
42
43 Geom_Line::Geom_Line (const gp_Ax1& A) : pos (A) { }
44
45 //=======================================================================
46 //function : Geom_Line
47 //purpose  : 
48 //=======================================================================
49
50 Geom_Line::Geom_Line (const gp_Lin& L) : pos (L.Position()) { }
51
52 //=======================================================================
53 //function : Geom_Line
54 //purpose  : 
55 //=======================================================================
56
57 Geom_Line::Geom_Line (const gp_Pnt& P, const gp_Dir& V) : pos (P, V) { }
58
59 //=======================================================================
60 //function : Reverse
61 //purpose  : 
62 //=======================================================================
63
64 void Geom_Line::Reverse () { pos.Reverse(); }
65
66 //=======================================================================
67 //function : ReversedParameter
68 //purpose  : 
69 //=======================================================================
70
71 Standard_Real Geom_Line::ReversedParameter( const Standard_Real U) const 
72 { return (-U);}
73
74 //=======================================================================
75 //function : SetDirection
76 //purpose  : 
77 //=======================================================================
78
79 void Geom_Line::SetDirection (const gp_Dir& V) { pos.SetDirection (V); }
80
81 //=======================================================================
82 //function : SetLin
83 //purpose  : 
84 //=======================================================================
85
86 void Geom_Line::SetLin (const gp_Lin& L) { pos = L.Position(); }
87
88 //=======================================================================
89 //function : SetLocation
90 //purpose  : 
91 //=======================================================================
92
93 void Geom_Line::SetLocation (const gp_Pnt& P) { pos.SetLocation (P); }
94
95 //=======================================================================
96 //function : SetPosition
97 //purpose  : 
98 //=======================================================================
99
100 void Geom_Line::SetPosition (const gp_Ax1& A1) { pos = A1; }
101
102 //=======================================================================
103 //function : Position
104 //purpose  : 
105 //=======================================================================
106
107 const gp_Ax1& Geom_Line::Position () const { return pos; }
108
109 //=======================================================================
110 //function : IsClosed
111 //purpose  : 
112 //=======================================================================
113
114 Standard_Boolean Geom_Line::IsClosed () const { return Standard_False; }
115
116 //=======================================================================
117 //function : IsPeriodic
118 //purpose  : 
119 //=======================================================================
120
121 Standard_Boolean Geom_Line::IsPeriodic () const { return Standard_False;  }
122
123 //=======================================================================
124 //function : Continuity
125 //purpose  : 
126 //=======================================================================
127
128 GeomAbs_Shape Geom_Line::Continuity () const { return GeomAbs_CN; }
129
130 //=======================================================================
131 //function : FirstParameter
132 //purpose  : 
133 //=======================================================================
134
135 Standard_Real Geom_Line::FirstParameter () const 
136 { return -Precision::Infinite(); }
137
138 //=======================================================================
139 //function : LastParameter
140 //purpose  : 
141 //=======================================================================
142
143 Standard_Real Geom_Line::LastParameter () const 
144 { return Precision::Infinite(); }
145
146 //=======================================================================
147 //function : Lin
148 //purpose  : 
149 //=======================================================================
150
151 gp_Lin Geom_Line::Lin () const { return gp_Lin (pos); }
152
153
154 //=======================================================================
155 //function : IsCN
156 //purpose  : 
157 //=======================================================================
158
159 Standard_Boolean Geom_Line::IsCN (const Standard_Integer ) const 
160 { return Standard_True; }
161
162 //=======================================================================
163 //function : Transform
164 //purpose  : 
165 //=======================================================================
166
167 void Geom_Line::Transform (const gp_Trsf& T) { pos.Transform (T); }
168
169 //=======================================================================
170 //function : D0
171 //purpose  : 
172 //=======================================================================
173
174 void Geom_Line::D0 (const Standard_Real U, gp_Pnt& P) const  
175
176   P = ElCLib::LineValue (U, pos);
177 }
178
179 //=======================================================================
180 //function : D1
181 //purpose  : 
182 //=======================================================================
183
184 void Geom_Line::D1 (const Standard_Real U, gp_Pnt& P, gp_Vec& V1) const {
185  
186   ElCLib::LineD1 (U, pos, P, V1);
187 }
188
189 //=======================================================================
190 //function : D2
191 //purpose  : 
192 //=======================================================================
193
194 void Geom_Line::D2 (const Standard_Real U, gp_Pnt& P, gp_Vec& V1, gp_Vec& V2) const {
195
196   ElCLib::LineD1 (U, pos, P, V1);
197   V2.SetCoord (0.0, 0.0, 0.0);
198 }
199
200 //=======================================================================
201 //function : D3
202 //purpose  : 
203 //=======================================================================
204
205 void Geom_Line::D3 (const Standard_Real U, gp_Pnt& P, gp_Vec& V1, gp_Vec& V2, gp_Vec& V3) const{
206
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);
210 }
211
212 //=======================================================================
213 //function : DN
214 //purpose  : 
215 //=======================================================================
216
217 gp_Vec Geom_Line::DN (const Standard_Real , const Standard_Integer N) const {
218
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);
222 }
223
224 //=======================================================================
225 //function : TransformedParameter
226 //purpose  : 
227 //=======================================================================
228
229 Standard_Real Geom_Line::TransformedParameter(const Standard_Real U,
230                                               const gp_Trsf& T) const
231 {
232   if (Precision::IsInfinite(U)) return U;
233   return U * Abs(T.ScaleFactor());
234 }
235
236
237 //=======================================================================
238 //function : TransformedParameter
239 //purpose  : 
240 //=======================================================================
241
242 Standard_Real Geom_Line::ParametricTransformation(const gp_Trsf& T) const
243 {
244   return Abs(T.ScaleFactor());
245 }
246
247