b311480e |
1 | // Created on: 1993-03-24 |
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 <Geom2d_Geometry.hxx> |
20 | #include <Geom2d_Line.hxx> |
21 | #include <gp_Ax2d.hxx> |
22 | #include <gp_Dir2d.hxx> |
23 | #include <gp_Lin2d.hxx> |
24 | #include <gp_Pnt2d.hxx> |
25 | #include <gp_Trsf2d.hxx> |
26 | #include <gp_Vec2d.hxx> |
7fd59977 |
27 | #include <gp_XY.hxx> |
42cf5bc1 |
28 | #include <Precision.hxx> |
7fd59977 |
29 | #include <Standard_RangeError.hxx> |
42cf5bc1 |
30 | #include <Standard_Type.hxx> |
7fd59977 |
31 | |
7fd59977 |
32 | typedef Geom2d_Line Line; |
7fd59977 |
33 | typedef gp_Ax2d Ax2d; |
34 | typedef gp_Dir2d Dir2d; |
35 | typedef gp_Pnt2d Pnt2d; |
36 | typedef gp_Vec2d Vec2d; |
37 | typedef gp_Trsf2d Trsf2d; |
38 | typedef gp_XY XY; |
39 | |
7fd59977 |
40 | //======================================================================= |
41 | //function : Copy |
42 | //purpose : |
43 | //======================================================================= |
44 | |
45 | Handle(Geom2d_Geometry) Geom2d_Line::Copy() const |
46 | { |
c04c30b3 |
47 | Handle(Geom2d_Line) L; |
7fd59977 |
48 | L = new Line (pos); |
49 | return L; |
50 | } |
51 | |
52 | |
53 | //======================================================================= |
54 | //function : Geom2d_Line |
55 | //purpose : |
56 | //======================================================================= |
57 | |
58 | Geom2d_Line::Geom2d_Line (const Ax2d& A) : pos (A) { } |
59 | |
60 | //======================================================================= |
61 | //function : Geom2d_Line |
62 | //purpose : |
63 | //======================================================================= |
64 | |
65 | Geom2d_Line::Geom2d_Line (const gp_Lin2d& L) : pos (L.Position()) { } |
66 | |
67 | //======================================================================= |
68 | //function : Geom2d_Line |
69 | //purpose : |
70 | //======================================================================= |
71 | |
72 | Geom2d_Line::Geom2d_Line (const Pnt2d& P, const Dir2d& V) : pos (P, V) { } |
73 | |
74 | //======================================================================= |
75 | //function : SetDirection |
76 | //purpose : |
77 | //======================================================================= |
78 | |
79 | void Geom2d_Line::SetDirection (const Dir2d& V) { pos.SetDirection (V); } |
80 | |
81 | //======================================================================= |
82 | //function : Direction |
83 | //purpose : |
84 | //======================================================================= |
85 | |
86 | const gp_Dir2d& Geom2d_Line::Direction () const { return pos.Direction (); } |
87 | |
88 | //======================================================================= |
89 | //function : SetLin2d |
90 | //purpose : |
91 | //======================================================================= |
92 | |
93 | void Geom2d_Line::SetLin2d (const gp_Lin2d& L) { pos = L.Position(); } |
94 | |
95 | //======================================================================= |
96 | //function : SetLocation |
97 | //purpose : |
98 | //======================================================================= |
99 | |
100 | void Geom2d_Line::SetLocation (const Pnt2d& P) { pos.SetLocation (P); } |
101 | |
102 | //======================================================================= |
103 | //function : Location |
104 | //purpose : |
105 | //======================================================================= |
106 | |
107 | const gp_Pnt2d& Geom2d_Line::Location () const { return pos.Location (); } |
108 | |
109 | //======================================================================= |
110 | //function : SetPosition |
111 | //purpose : |
112 | //======================================================================= |
113 | |
114 | void Geom2d_Line::SetPosition (const Ax2d& A) { pos = A; } |
115 | |
116 | //======================================================================= |
117 | //function : Position |
118 | //purpose : |
119 | //======================================================================= |
120 | |
121 | const gp_Ax2d& Geom2d_Line::Position () const { return pos; } |
122 | |
123 | //======================================================================= |
124 | //function : Lin2d |
125 | //purpose : |
126 | //======================================================================= |
127 | |
128 | gp_Lin2d Geom2d_Line::Lin2d () const { return gp_Lin2d (pos); } |
129 | |
130 | //======================================================================= |
131 | //function : Reverse |
132 | //purpose : |
133 | //======================================================================= |
134 | |
135 | void Geom2d_Line::Reverse () { pos.Reverse(); } |
136 | |
137 | //======================================================================= |
138 | //function : ReversedParameter |
139 | //purpose : |
140 | //======================================================================= |
141 | |
142 | Standard_Real Geom2d_Line::ReversedParameter( const Standard_Real U) const { return (-U); } |
143 | |
144 | //======================================================================= |
145 | //function : FirstParameter |
146 | //purpose : |
147 | //======================================================================= |
148 | |
149 | Standard_Real Geom2d_Line::FirstParameter () const |
150 | { return -Precision::Infinite(); } |
151 | |
152 | //======================================================================= |
153 | //function : LastParameter |
154 | //purpose : |
155 | //======================================================================= |
156 | |
157 | Standard_Real Geom2d_Line::LastParameter () const |
158 | { return Precision::Infinite(); } |
159 | |
160 | //======================================================================= |
161 | //function : IsClosed |
162 | //purpose : |
163 | //======================================================================= |
164 | |
165 | Standard_Boolean Geom2d_Line::IsClosed () const { return Standard_False; } |
166 | |
167 | //======================================================================= |
168 | //function : IsPeriodic |
169 | //purpose : |
170 | //======================================================================= |
171 | |
172 | Standard_Boolean Geom2d_Line::IsPeriodic () const { return Standard_False; } |
173 | |
174 | //======================================================================= |
175 | //function : Continuity |
176 | //purpose : |
177 | //======================================================================= |
178 | |
179 | GeomAbs_Shape Geom2d_Line::Continuity () const { return GeomAbs_CN; } |
180 | |
181 | //======================================================================= |
182 | //function : IsCN |
183 | //purpose : |
184 | //======================================================================= |
185 | |
186 | Standard_Boolean Geom2d_Line::IsCN (const Standard_Integer ) const { return Standard_True; } |
187 | |
188 | //======================================================================= |
189 | //function : D0 |
190 | //purpose : |
191 | //======================================================================= |
192 | |
193 | void Geom2d_Line::D0 (const Standard_Real U, Pnt2d& P) const |
194 | { |
195 | P = ElCLib::LineValue (U, pos); |
196 | } |
197 | |
198 | //======================================================================= |
199 | //function : D1 |
200 | //purpose : |
201 | //======================================================================= |
202 | |
203 | void Geom2d_Line::D1 (const Standard_Real U, Pnt2d& P, Vec2d& V1) const |
204 | { |
205 | ElCLib::LineD1 (U, pos, P, V1); |
206 | } |
207 | |
208 | //======================================================================= |
209 | //function : D2 |
210 | //purpose : |
211 | //======================================================================= |
212 | |
213 | void Geom2d_Line::D2 (const Standard_Real U, |
214 | Pnt2d& P, |
215 | Vec2d& V1, Vec2d& V2) const |
216 | { |
217 | ElCLib::LineD1 (U, pos, P, V1); |
218 | V2.SetCoord (0.0, 0.0); |
219 | } |
220 | |
221 | //======================================================================= |
222 | //function : D3 |
223 | //purpose : |
224 | //======================================================================= |
225 | |
226 | void Geom2d_Line::D3 (const Standard_Real U, |
227 | Pnt2d& P, |
228 | Vec2d& V1, Vec2d& V2, Vec2d& V3) const |
229 | { |
230 | ElCLib::LineD1 (U, pos, P, V1); |
231 | V2.SetCoord (0.0, 0.0); |
232 | V3.SetCoord (0.0, 0.0); |
233 | } |
234 | |
235 | |
236 | //======================================================================= |
237 | //function : DN |
238 | //purpose : |
239 | //======================================================================= |
240 | |
241 | Vec2d Geom2d_Line::DN |
242 | (const Standard_Real , |
243 | const Standard_Integer N ) const |
244 | { |
245 | Standard_RangeError_Raise_if (N <= 0, " "); |
246 | if (N == 1) |
247 | return Vec2d (pos.Direction ()); |
248 | else |
249 | return Vec2d (0.0, 0.0); |
250 | } |
251 | |
252 | |
253 | //======================================================================= |
254 | //function : Transform |
255 | //purpose : |
256 | //======================================================================= |
257 | |
258 | void Geom2d_Line::Transform (const Trsf2d& T) { pos.Transform (T); } |
259 | |
260 | //======================================================================= |
261 | //function : TransformedParameter |
262 | //purpose : |
263 | //======================================================================= |
264 | |
265 | Standard_Real Geom2d_Line::TransformedParameter(const Standard_Real U, |
266 | const gp_Trsf2d& T) const |
267 | { |
268 | if (Precision::IsInfinite(U)) return U; |
269 | return U * Abs(T.ScaleFactor()); |
270 | } |
271 | |
272 | //======================================================================= |
273 | //function : ParametricTransformation |
274 | //purpose : |
275 | //======================================================================= |
276 | |
277 | Standard_Real Geom2d_Line::ParametricTransformation(const gp_Trsf2d& T) const |
278 | { |
279 | return Abs(T.ScaleFactor()); |
280 | } |
281 | |
282 | |
283 | //======================================================================= |
284 | //function : Distance |
285 | //purpose : |
286 | //======================================================================= |
287 | |
288 | Standard_Real Geom2d_Line::Distance (const gp_Pnt2d& P) const { |
289 | |
290 | gp_Lin2d L (pos); |
291 | return L.Distance (P); |
292 | } |
293 | |