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