b311480e |
1 | // Created on: 1993-03-24 |
2 | // Created by: JCV |
3 | // Copyright (c) 1993-1999 Matra Datavision |
4 | // Copyright (c) 1999-2012 OPEN CASCADE SAS |
5 | // |
6 | // The content of this file is subject to the Open CASCADE Technology Public |
7 | // License Version 6.5 (the "License"). You may not use the content of this file |
8 | // except in compliance with the License. Please obtain a copy of the License |
9 | // at http://www.opencascade.org and read it completely before using this file. |
10 | // |
11 | // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its |
12 | // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. |
13 | // |
14 | // The Original Code and all software distributed under the License is |
15 | // distributed on an "AS IS" basis, without warranty of any kind, and the |
16 | // Initial Developer hereby disclaims all such warranties, including without |
17 | // limitation, any warranties of merchantability, fitness for a particular |
18 | // purpose or non-infringement. Please see the License for the specific terms |
19 | // and conditions governing the rights and limitations under the License. |
20 | |
7fd59977 |
21 | |
7fd59977 |
22 | |
23 | |
24 | |
25 | #include <Geom2d_Line.ixx> |
26 | |
27 | #include <Precision.hxx> |
28 | #include <ElCLib.hxx> |
29 | #include <gp_XY.hxx> |
30 | #include <Standard_RangeError.hxx> |
31 | |
32 | |
33 | typedef Geom2d_Line Line; |
34 | typedef Handle(Geom2d_Line) Handle(Line); |
35 | typedef gp_Ax2d Ax2d; |
36 | typedef gp_Dir2d Dir2d; |
37 | typedef gp_Pnt2d Pnt2d; |
38 | typedef gp_Vec2d Vec2d; |
39 | typedef gp_Trsf2d Trsf2d; |
40 | typedef gp_XY XY; |
41 | |
42 | |
43 | |
44 | |
45 | |
46 | //======================================================================= |
47 | //function : Copy |
48 | //purpose : |
49 | //======================================================================= |
50 | |
51 | Handle(Geom2d_Geometry) Geom2d_Line::Copy() const |
52 | { |
53 | Handle(Line) L; |
54 | L = new Line (pos); |
55 | return L; |
56 | } |
57 | |
58 | |
59 | //======================================================================= |
60 | //function : Geom2d_Line |
61 | //purpose : |
62 | //======================================================================= |
63 | |
64 | Geom2d_Line::Geom2d_Line (const Ax2d& A) : pos (A) { } |
65 | |
66 | //======================================================================= |
67 | //function : Geom2d_Line |
68 | //purpose : |
69 | //======================================================================= |
70 | |
71 | Geom2d_Line::Geom2d_Line (const gp_Lin2d& L) : pos (L.Position()) { } |
72 | |
73 | //======================================================================= |
74 | //function : Geom2d_Line |
75 | //purpose : |
76 | //======================================================================= |
77 | |
78 | Geom2d_Line::Geom2d_Line (const Pnt2d& P, const Dir2d& V) : pos (P, V) { } |
79 | |
80 | //======================================================================= |
81 | //function : SetDirection |
82 | //purpose : |
83 | //======================================================================= |
84 | |
85 | void Geom2d_Line::SetDirection (const Dir2d& V) { pos.SetDirection (V); } |
86 | |
87 | //======================================================================= |
88 | //function : Direction |
89 | //purpose : |
90 | //======================================================================= |
91 | |
92 | const gp_Dir2d& Geom2d_Line::Direction () const { return pos.Direction (); } |
93 | |
94 | //======================================================================= |
95 | //function : SetLin2d |
96 | //purpose : |
97 | //======================================================================= |
98 | |
99 | void Geom2d_Line::SetLin2d (const gp_Lin2d& L) { pos = L.Position(); } |
100 | |
101 | //======================================================================= |
102 | //function : SetLocation |
103 | //purpose : |
104 | //======================================================================= |
105 | |
106 | void Geom2d_Line::SetLocation (const Pnt2d& P) { pos.SetLocation (P); } |
107 | |
108 | //======================================================================= |
109 | //function : Location |
110 | //purpose : |
111 | //======================================================================= |
112 | |
113 | const gp_Pnt2d& Geom2d_Line::Location () const { return pos.Location (); } |
114 | |
115 | //======================================================================= |
116 | //function : SetPosition |
117 | //purpose : |
118 | //======================================================================= |
119 | |
120 | void Geom2d_Line::SetPosition (const Ax2d& A) { pos = A; } |
121 | |
122 | //======================================================================= |
123 | //function : Position |
124 | //purpose : |
125 | //======================================================================= |
126 | |
127 | const gp_Ax2d& Geom2d_Line::Position () const { return pos; } |
128 | |
129 | //======================================================================= |
130 | //function : Lin2d |
131 | //purpose : |
132 | //======================================================================= |
133 | |
134 | gp_Lin2d Geom2d_Line::Lin2d () const { return gp_Lin2d (pos); } |
135 | |
136 | //======================================================================= |
137 | //function : Reverse |
138 | //purpose : |
139 | //======================================================================= |
140 | |
141 | void Geom2d_Line::Reverse () { pos.Reverse(); } |
142 | |
143 | //======================================================================= |
144 | //function : ReversedParameter |
145 | //purpose : |
146 | //======================================================================= |
147 | |
148 | Standard_Real Geom2d_Line::ReversedParameter( const Standard_Real U) const { return (-U); } |
149 | |
150 | //======================================================================= |
151 | //function : FirstParameter |
152 | //purpose : |
153 | //======================================================================= |
154 | |
155 | Standard_Real Geom2d_Line::FirstParameter () const |
156 | { return -Precision::Infinite(); } |
157 | |
158 | //======================================================================= |
159 | //function : LastParameter |
160 | //purpose : |
161 | //======================================================================= |
162 | |
163 | Standard_Real Geom2d_Line::LastParameter () const |
164 | { return Precision::Infinite(); } |
165 | |
166 | //======================================================================= |
167 | //function : IsClosed |
168 | //purpose : |
169 | //======================================================================= |
170 | |
171 | Standard_Boolean Geom2d_Line::IsClosed () const { return Standard_False; } |
172 | |
173 | //======================================================================= |
174 | //function : IsPeriodic |
175 | //purpose : |
176 | //======================================================================= |
177 | |
178 | Standard_Boolean Geom2d_Line::IsPeriodic () const { return Standard_False; } |
179 | |
180 | //======================================================================= |
181 | //function : Continuity |
182 | //purpose : |
183 | //======================================================================= |
184 | |
185 | GeomAbs_Shape Geom2d_Line::Continuity () const { return GeomAbs_CN; } |
186 | |
187 | //======================================================================= |
188 | //function : IsCN |
189 | //purpose : |
190 | //======================================================================= |
191 | |
192 | Standard_Boolean Geom2d_Line::IsCN (const Standard_Integer ) const { return Standard_True; } |
193 | |
194 | //======================================================================= |
195 | //function : D0 |
196 | //purpose : |
197 | //======================================================================= |
198 | |
199 | void Geom2d_Line::D0 (const Standard_Real U, Pnt2d& P) const |
200 | { |
201 | P = ElCLib::LineValue (U, pos); |
202 | } |
203 | |
204 | //======================================================================= |
205 | //function : D1 |
206 | //purpose : |
207 | //======================================================================= |
208 | |
209 | void Geom2d_Line::D1 (const Standard_Real U, Pnt2d& P, Vec2d& V1) const |
210 | { |
211 | ElCLib::LineD1 (U, pos, P, V1); |
212 | } |
213 | |
214 | //======================================================================= |
215 | //function : D2 |
216 | //purpose : |
217 | //======================================================================= |
218 | |
219 | void Geom2d_Line::D2 (const Standard_Real U, |
220 | Pnt2d& P, |
221 | Vec2d& V1, Vec2d& V2) const |
222 | { |
223 | ElCLib::LineD1 (U, pos, P, V1); |
224 | V2.SetCoord (0.0, 0.0); |
225 | } |
226 | |
227 | //======================================================================= |
228 | //function : D3 |
229 | //purpose : |
230 | //======================================================================= |
231 | |
232 | void Geom2d_Line::D3 (const Standard_Real U, |
233 | Pnt2d& P, |
234 | Vec2d& V1, Vec2d& V2, Vec2d& V3) const |
235 | { |
236 | ElCLib::LineD1 (U, pos, P, V1); |
237 | V2.SetCoord (0.0, 0.0); |
238 | V3.SetCoord (0.0, 0.0); |
239 | } |
240 | |
241 | |
242 | //======================================================================= |
243 | //function : DN |
244 | //purpose : |
245 | //======================================================================= |
246 | |
247 | Vec2d Geom2d_Line::DN |
248 | (const Standard_Real , |
249 | const Standard_Integer N ) const |
250 | { |
251 | Standard_RangeError_Raise_if (N <= 0, " "); |
252 | if (N == 1) |
253 | return Vec2d (pos.Direction ()); |
254 | else |
255 | return Vec2d (0.0, 0.0); |
256 | } |
257 | |
258 | |
259 | //======================================================================= |
260 | //function : Transform |
261 | //purpose : |
262 | //======================================================================= |
263 | |
264 | void Geom2d_Line::Transform (const Trsf2d& T) { pos.Transform (T); } |
265 | |
266 | //======================================================================= |
267 | //function : TransformedParameter |
268 | //purpose : |
269 | //======================================================================= |
270 | |
271 | Standard_Real Geom2d_Line::TransformedParameter(const Standard_Real U, |
272 | const gp_Trsf2d& T) const |
273 | { |
274 | if (Precision::IsInfinite(U)) return U; |
275 | return U * Abs(T.ScaleFactor()); |
276 | } |
277 | |
278 | //======================================================================= |
279 | //function : ParametricTransformation |
280 | //purpose : |
281 | //======================================================================= |
282 | |
283 | Standard_Real Geom2d_Line::ParametricTransformation(const gp_Trsf2d& T) const |
284 | { |
285 | return Abs(T.ScaleFactor()); |
286 | } |
287 | |
288 | |
289 | //======================================================================= |
290 | //function : Distance |
291 | //purpose : |
292 | //======================================================================= |
293 | |
294 | Standard_Real Geom2d_Line::Distance (const gp_Pnt2d& P) const { |
295 | |
296 | gp_Lin2d L (pos); |
297 | return L.Distance (P); |
298 | } |
299 | |