0031939: Coding - correction of spelling errors in comments [part 3]
[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
18 #include <ElCLib.hxx>
19 #include <Geom_Geometry.hxx>
20 #include <Geom_Line.hxx>
21 #include <gp_Ax1.hxx>
22 #include <gp_Dir.hxx>
23 #include <gp_Lin.hxx>
24 #include <gp_Pnt.hxx>
25 #include <gp_Trsf.hxx>
26 #include <gp_Vec.hxx>
27 #include <gp_XYZ.hxx>
28 #include <Precision.hxx>
29 #include <Standard_RangeError.hxx>
30 #include <Standard_Type.hxx>
31
32 IMPLEMENT_STANDARD_RTTIEXT(Geom_Line,Geom_Curve)
33
34 //=======================================================================
35 //function : Copy
36 //purpose  : 
37 //=======================================================================
38 Handle(Geom_Geometry) Geom_Line::Copy() const {
39
40    Handle(Geom_Line) L;
41    L = new Geom_Line (pos);
42    return L;
43 }
44
45 //=======================================================================
46 //function : Geom_Line
47 //purpose  : 
48 //=======================================================================
49
50 Geom_Line::Geom_Line (const gp_Ax1& A) : pos (A) { }
51
52 //=======================================================================
53 //function : Geom_Line
54 //purpose  : 
55 //=======================================================================
56
57 Geom_Line::Geom_Line (const gp_Lin& L) : pos (L.Position()) { }
58
59 //=======================================================================
60 //function : Geom_Line
61 //purpose  : 
62 //=======================================================================
63
64 Geom_Line::Geom_Line (const gp_Pnt& P, const gp_Dir& V) : pos (P, V) { }
65
66 //=======================================================================
67 //function : Reverse
68 //purpose  : 
69 //=======================================================================
70
71 void Geom_Line::Reverse () { pos.Reverse(); }
72
73 //=======================================================================
74 //function : ReversedParameter
75 //purpose  : 
76 //=======================================================================
77
78 Standard_Real Geom_Line::ReversedParameter( const Standard_Real U) const 
79 { return (-U);}
80
81 //=======================================================================
82 //function : SetDirection
83 //purpose  : 
84 //=======================================================================
85
86 void Geom_Line::SetDirection (const gp_Dir& V) { pos.SetDirection (V); }
87
88 //=======================================================================
89 //function : SetLin
90 //purpose  : 
91 //=======================================================================
92
93 void Geom_Line::SetLin (const gp_Lin& L) { pos = L.Position(); }
94
95 //=======================================================================
96 //function : SetLocation
97 //purpose  : 
98 //=======================================================================
99
100 void Geom_Line::SetLocation (const gp_Pnt& P) { pos.SetLocation (P); }
101
102 //=======================================================================
103 //function : SetPosition
104 //purpose  : 
105 //=======================================================================
106
107 void Geom_Line::SetPosition (const gp_Ax1& A1) { pos = A1; }
108
109 //=======================================================================
110 //function : Position
111 //purpose  : 
112 //=======================================================================
113
114 const gp_Ax1& Geom_Line::Position () const { return pos; }
115
116 //=======================================================================
117 //function : IsClosed
118 //purpose  : 
119 //=======================================================================
120
121 Standard_Boolean Geom_Line::IsClosed () const { return Standard_False; }
122
123 //=======================================================================
124 //function : IsPeriodic
125 //purpose  : 
126 //=======================================================================
127
128 Standard_Boolean Geom_Line::IsPeriodic () const { return Standard_False;  }
129
130 //=======================================================================
131 //function : Continuity
132 //purpose  : 
133 //=======================================================================
134
135 GeomAbs_Shape Geom_Line::Continuity () const { return GeomAbs_CN; }
136
137 //=======================================================================
138 //function : FirstParameter
139 //purpose  : 
140 //=======================================================================
141
142 Standard_Real Geom_Line::FirstParameter () const 
143 { return -Precision::Infinite(); }
144
145 //=======================================================================
146 //function : LastParameter
147 //purpose  : 
148 //=======================================================================
149
150 Standard_Real Geom_Line::LastParameter () const 
151 { return Precision::Infinite(); }
152
153 //=======================================================================
154 //function : Lin
155 //purpose  : 
156 //=======================================================================
157
158 gp_Lin Geom_Line::Lin () const { return gp_Lin (pos); }
159
160
161 //=======================================================================
162 //function : IsCN
163 //purpose  : 
164 //=======================================================================
165
166 Standard_Boolean Geom_Line::IsCN (const Standard_Integer ) const 
167 { return Standard_True; }
168
169 //=======================================================================
170 //function : Transform
171 //purpose  : 
172 //=======================================================================
173
174 void Geom_Line::Transform (const gp_Trsf& T) { pos.Transform (T); }
175
176 //=======================================================================
177 //function : D0
178 //purpose  : 
179 //=======================================================================
180
181 void Geom_Line::D0 (const Standard_Real U, gp_Pnt& P) const  
182
183   P = ElCLib::LineValue (U, pos);
184 }
185
186 //=======================================================================
187 //function : D1
188 //purpose  : 
189 //=======================================================================
190
191 void Geom_Line::D1 (const Standard_Real U, gp_Pnt& P, gp_Vec& V1) const {
192  
193   ElCLib::LineD1 (U, pos, P, V1);
194 }
195
196 //=======================================================================
197 //function : D2
198 //purpose  : 
199 //=======================================================================
200
201 void Geom_Line::D2 (const Standard_Real U, gp_Pnt& P, gp_Vec& V1, gp_Vec& V2) const {
202
203   ElCLib::LineD1 (U, pos, P, V1);
204   V2.SetCoord (0.0, 0.0, 0.0);
205 }
206
207 //=======================================================================
208 //function : D3
209 //purpose  : 
210 //=======================================================================
211
212 void Geom_Line::D3 (const Standard_Real U, gp_Pnt& P, gp_Vec& V1, gp_Vec& V2, gp_Vec& V3) const{
213
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);
217 }
218
219 //=======================================================================
220 //function : DN
221 //purpose  : 
222 //=======================================================================
223
224 gp_Vec Geom_Line::DN (const Standard_Real , const Standard_Integer N) const {
225
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);
229 }
230
231 //=======================================================================
232 //function : TransformedParameter
233 //purpose  : 
234 //=======================================================================
235
236 Standard_Real Geom_Line::TransformedParameter(const Standard_Real U,
237                                               const gp_Trsf& T) const
238 {
239   if (Precision::IsInfinite(U)) return U;
240   return U * Abs(T.ScaleFactor());
241 }
242
243
244 //=======================================================================
245 //function : TransformedParameter
246 //purpose  : 
247 //=======================================================================
248
249 Standard_Real Geom_Line::ParametricTransformation(const gp_Trsf& T) const
250 {
251   return Abs(T.ScaleFactor());
252 }
253
254 //=======================================================================
255 //function : DumpJson
256 //purpose  : 
257 //=======================================================================
258 void Geom_Line::DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth) const
259 {
260   OCCT_DUMP_TRANSIENT_CLASS_BEGIN (theOStream)
261   OCCT_DUMP_BASE_CLASS (theOStream, theDepth, Geom_Curve)
262
263   OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &pos)
264 }
265