b311480e |
1 | // Created on: 1994-07-06 |
2 | // Created by: Laurent PAINNOT |
3 | // Copyright (c) 1994-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 | // |
973c2be1 |
8 | // This library is free software; you can redistribute it and / or modify it |
9 | // under the terms of the GNU Lesser General Public 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. |
b311480e |
13 | // |
973c2be1 |
14 | // Alternatively, this file may be used under the terms of Open CASCADE |
15 | // commercial license or contractual agreement. |
7fd59977 |
16 | |
17 | #include Extrema_ECC2d_hxx |
18 | #include <Extrema_ExtElC2d.hxx> |
19 | #include <StdFail_NotDone.hxx> |
20 | #include <Extrema_ExtElC.hxx> |
21 | #include <ElCLib.hxx> |
22 | #include <Standard_Failure.hxx> |
23 | #include <GeomAbs_CurveType.hxx> |
24 | #include <Geom2d_Curve.hxx> |
25 | #include <Geom2d_TrimmedCurve.hxx> |
26 | #include <Geom2d_Ellipse.hxx> |
27 | #include <Geom2d_Circle.hxx> |
28 | #include <Geom2d_Line.hxx> |
29 | #include <Geom2d_Parabola.hxx> |
30 | #include <Geom2d_Hyperbola.hxx> |
31 | #include <Extrema_POnCurv2d.hxx> |
32 | #include <Extrema_SequenceOfPOnCurv2d.hxx> |
33 | #include <Standard_NotImplemented.hxx> |
34 | #include <Precision.hxx> |
35 | |
36 | |
32ca7a51 |
37 | //======================================================================= |
38 | //function : IsParallelDot |
39 | //purpose : This function returns True if angle between <theV1> and |
40 | //<theV2> vectors or between <theV1> and <-theV2> vectors is less than |
41 | //AngTol. |
42 | //======================================================================= |
43 | static Standard_Boolean IsParallelDot( gp_Vec2d theV1, |
44 | gp_Vec2d theV2, |
45 | Standard_Real AngTol) |
46 | { |
47 | return Abs(theV1.Dot(theV2)) >= |
48 | theV1.Magnitude()*theV2.Magnitude()*cos(AngTol); |
49 | } |
50 | |
7fd59977 |
51 | Extrema_GExtCC2d::Extrema_GExtCC2d() {} |
52 | |
53 | |
54 | Extrema_GExtCC2d::Extrema_GExtCC2d(const Curve1& C1, |
55 | const Curve2& C2, |
56 | const Standard_Real TolC1, |
57 | const Standard_Real TolC2) |
58 | { |
59 | Initialize(C2, Tool2::FirstParameter(C2), Tool2::LastParameter(C2), TolC1, TolC2); |
60 | Perform(C1, Tool1::FirstParameter(C1), Tool1::LastParameter(C1)); |
61 | } |
62 | |
63 | Extrema_GExtCC2d::Extrema_GExtCC2d(const Curve1& C1, |
64 | const Curve2& C2, |
65 | const Standard_Real U1, |
66 | const Standard_Real U2, |
67 | const Standard_Real V1, |
68 | const Standard_Real V2, |
69 | const Standard_Real TolC1, |
70 | const Standard_Real TolC2) |
71 | { |
72 | Initialize(C2, V1, V2, TolC1, TolC2); |
73 | Perform(C1, U1, U2); |
74 | } |
75 | |
76 | |
77 | |
78 | void Extrema_GExtCC2d::Initialize(const Curve2& C2, |
79 | const Standard_Real V1, |
80 | const Standard_Real V2, |
81 | const Standard_Real TolC1, |
82 | const Standard_Real TolC2) |
83 | { |
84 | myC = (Standard_Address)&C2; |
85 | myv1 = V1; |
86 | myv2 = V2; |
87 | mytolc1 = TolC1; |
88 | mytolc2 = TolC2; |
89 | } |
90 | |
91 | |
92 | |
93 | void Extrema_GExtCC2d::Perform (const Curve1& C1, |
94 | const Standard_Real U1, |
95 | const Standard_Real U2) |
96 | { |
97 | mypoints.Clear(); |
98 | mySqDist.Clear(); |
99 | Standard_Integer NbU = 32, NbV = 32; |
100 | GeomAbs_CurveType type1 = Tool1::GetType(C1), type2 = Tool2::GetType(*((Curve2*)myC)); |
101 | Standard_Real U11, U12, U21, U22, Tol = Min(mytolc1, mytolc2); |
102 | // Extrema_POnCurv2d P1, P2; |
103 | mynbext = 0; |
104 | inverse = Standard_False; |
105 | myIsPar = Standard_False; |
106 | |
107 | U11 = U1; |
108 | U12 = U2; |
109 | U21 = myv1; |
110 | U22 = myv2; |
111 | P1f = Tool1::Value(C1, U11); |
112 | P1l = Tool1::Value(C1, U12); |
113 | P2f = Tool2::Value(*((Curve2*)myC), U21); |
114 | P2l = Tool2::Value(*((Curve2*)myC), U22); |
115 | |
116 | |
117 | switch(type1) { |
118 | // |
119 | // La premiere courbe est un cercle: |
120 | // |
121 | case GeomAbs_Circle: { |
122 | |
123 | switch(type2) { |
124 | case GeomAbs_Circle: { |
125 | Extrema_ExtElC2d Xtrem(Tool1::Circle(C1), Tool2::Circle(*((Curve2*)myC))); |
c6541a0c |
126 | Results(Xtrem, U11, U12, U21, U22, 2*M_PI, 2*M_PI); |
7fd59977 |
127 | } |
128 | break; |
129 | case GeomAbs_Ellipse: { |
130 | Extrema_ExtElC2d Xtrem(Tool1::Circle(C1), Tool2::Ellipse(*((Curve2*)myC))); |
c6541a0c |
131 | Results(Xtrem, U11, U12, U21, U22, 2*M_PI, 2*M_PI ); |
7fd59977 |
132 | } |
133 | break; |
134 | case GeomAbs_Parabola: { |
135 | Extrema_ExtElC2d Xtrem(Tool1::Circle(C1), Tool2::Parabola(*((Curve2*)myC))); |
c6541a0c |
136 | Results(Xtrem, U11, U12, U21, U22, 2*M_PI, 0.); |
7fd59977 |
137 | } |
138 | break; |
139 | case GeomAbs_Hyperbola: { |
140 | Extrema_ExtElC2d Xtrem(Tool1::Circle(C1), Tool2::Hyperbola(*((Curve2*)myC))); |
c6541a0c |
141 | Results(Xtrem, U11, U12, U21, U22, 2*M_PI, 0. ); |
7fd59977 |
142 | } |
143 | break; |
144 | case GeomAbs_BezierCurve: |
145 | case GeomAbs_OtherCurve: |
146 | case GeomAbs_BSplineCurve: { |
147 | Extrema_ECC2d Xtrem(C1, *((Curve2*)myC), |
148 | NbU, NbV, mytolc1, mytolc2); |
149 | Standard_Real Period2 = 0.; |
150 | if (Tool2::IsPeriodic(*((Curve2*)myC))) Period2 = Tool2::Period(*((Curve2*)myC)); |
c6541a0c |
151 | Results(Xtrem, C1, U11, U12, U21, U22, 2*M_PI,Period2); |
7fd59977 |
152 | } |
153 | break; |
154 | case GeomAbs_Line: { |
155 | inverse = Standard_True; |
156 | Extrema_ExtElC2d Xtrem(Tool2::Line(*((Curve2*)myC)), Tool1::Circle(C1), Tol); |
c6541a0c |
157 | Results(Xtrem, U11, U12, U21, U22, 2*M_PI, 0.); |
7fd59977 |
158 | } |
159 | break; |
160 | }; // switch(type2) |
161 | } |
162 | break; |
163 | |
164 | // |
165 | // La premiere courbe est une ellipse: |
166 | // |
167 | case GeomAbs_Ellipse: { |
168 | |
169 | switch(type2) { |
170 | case GeomAbs_Circle: { |
171 | inverse = Standard_True; |
172 | Extrema_ExtElC2d Xtrem(Tool2::Circle(*((Curve2*)myC)), Tool1::Ellipse(C1)); |
c6541a0c |
173 | Results(Xtrem, U11, U12, U21, U22, 2*M_PI, 2*M_PI); |
7fd59977 |
174 | } |
175 | break; |
176 | case GeomAbs_Ellipse: { |
177 | //Extrema_ExtElC2d Xtrem(Tool1::Ellipse(C1), Tool2::Ellipse(*((Curve2*)myC))); |
178 | Extrema_ECC2d Xtrem(C1, *((Curve2*)myC), |
179 | NbU, NbV, mytolc1, mytolc2); |
c6541a0c |
180 | Results(Xtrem, C1, U11, U12, U21, U22,2*M_PI, 2*M_PI); |
7fd59977 |
181 | } |
182 | break; |
183 | case GeomAbs_Parabola: { |
184 | //Extrema_ExtElC2d Xtrem(Tool1::Ellipse(C1), Tool2::Parabola(*((Curve2*)myC))); |
185 | Extrema_ECC2d Xtrem(C1, *((Curve2*)myC), |
186 | NbU, NbV, mytolc1, mytolc2); |
c6541a0c |
187 | Results(Xtrem, C1, U11, U12, U21, U22, 2*M_PI, 0.); |
7fd59977 |
188 | } |
189 | break; |
190 | case GeomAbs_Hyperbola: { |
191 | //Extrema_ExtElC2d Xtrem(Tool1::Ellipse(C1), Tool2::Hyperbola(*((Curve2*)myC))); |
192 | Extrema_ECC2d Xtrem(C1, *((Curve2*)myC), |
193 | NbU, NbV, mytolc1, mytolc2); |
c6541a0c |
194 | Results(Xtrem, C1, U11, U12, U21, U22, 2*M_PI, 0.); |
7fd59977 |
195 | } |
196 | break; |
197 | case GeomAbs_BezierCurve: |
198 | case GeomAbs_OtherCurve: |
199 | case GeomAbs_BSplineCurve: { |
200 | Extrema_ECC2d Xtrem(C1, *((Curve2*)myC), |
201 | NbU, NbV, mytolc1, mytolc2); |
202 | Standard_Real Period2 = 0.; |
203 | if (Tool2::IsPeriodic(*((Curve2*)myC))) Period2 = Tool2::Period(*((Curve2*)myC)); |
c6541a0c |
204 | Results(Xtrem, C1, U11, U12, U21, U22, 2*M_PI,Period2); |
7fd59977 |
205 | } |
206 | break; |
207 | case GeomAbs_Line: { |
208 | inverse = Standard_True; |
209 | Extrema_ExtElC2d Xtrem(Tool2::Line(*((Curve2*)myC)), Tool1::Ellipse(C1)); |
c6541a0c |
210 | Results(Xtrem, U11, U12, U21, U22, 2*M_PI, 0.); |
7fd59977 |
211 | } |
212 | break; |
213 | }; // switch(type2) |
214 | } |
215 | break; |
216 | |
217 | // |
218 | // La premiere courbe est une parabole: |
219 | // |
220 | case GeomAbs_Parabola: { |
221 | |
222 | switch(type2) { |
223 | case GeomAbs_Circle: { |
224 | inverse = Standard_True; |
225 | Extrema_ExtElC2d Xtrem(Tool2::Circle(*((Curve2*)myC)), Tool1::Parabola(C1)); |
c6541a0c |
226 | Results(Xtrem, U11, U12, U21, U22, 0., 2*M_PI); |
7fd59977 |
227 | } |
228 | break; |
229 | case GeomAbs_Ellipse: { |
230 | //inverse = Standard_True; |
231 | //Extrema_ExtElC2d Xtrem(Tool2::Ellipse(*((Curve2*)myC)), Tool1::Parabola(C1)); |
232 | Extrema_ECC2d Xtrem(C1, *((Curve2*)myC), |
233 | NbU, NbV, mytolc1, mytolc2); |
c6541a0c |
234 | Results(Xtrem, C1, U11, U12, U21, U22, 0., 2*M_PI); |
7fd59977 |
235 | } |
236 | break; |
237 | case GeomAbs_Parabola: { |
238 | //Extrema_ExtElC2d Xtrem(Tool1::Parabola(C1), Tool2::Parabola(*((Curve2*)myC))); |
239 | Extrema_ECC2d Xtrem(C1, *((Curve2*)myC), |
240 | NbU, NbV, mytolc1, mytolc2); |
241 | Results(Xtrem, C1, U11, U12, U21, U22, 0., 0.); |
242 | } |
243 | break; |
244 | case GeomAbs_Hyperbola: { |
245 | //inverse = Standard_True; |
246 | //Extrema_ExtElC2d Xtrem(Tool2::Hyperbola(*((Curve2*)myC)), Tool1::Parabola(C1)); |
247 | Extrema_ECC2d Xtrem(C1, *((Curve2*)myC), |
248 | NbU, NbV, mytolc1, mytolc2); |
249 | Results(Xtrem, C1, U11, U12, U21, U22, 0., 0.); |
250 | } |
251 | break; |
252 | case GeomAbs_BezierCurve: |
253 | case GeomAbs_OtherCurve: |
254 | case GeomAbs_BSplineCurve: { |
255 | Extrema_ECC2d Xtrem(C1, *((Curve2*)myC), |
256 | NbU, NbV, mytolc1, mytolc2); |
257 | Standard_Real Period2 = 0.; |
258 | if (Tool2::IsPeriodic(*((Curve2*)myC))) Period2 = Tool2::Period(*((Curve2*)myC)); |
259 | Results(Xtrem, C1, U11, U12, U21, U22, 0., Period2); |
260 | } |
261 | break; |
262 | case GeomAbs_Line: { |
263 | inverse = Standard_True; |
264 | Extrema_ExtElC2d Xtrem(Tool2::Line(*((Curve2*)myC)), Tool1::Parabola(C1)); |
265 | Results(Xtrem, U11, U12, U21, U22, 0., 0.); |
266 | } |
267 | break; |
268 | }; // switch(type2) |
269 | } |
270 | break; |
271 | |
272 | // |
273 | // La premiere courbe est une hyperbole: |
274 | // |
275 | case GeomAbs_Hyperbola: { |
276 | |
277 | switch(type2) { |
278 | case GeomAbs_Circle: { |
279 | inverse = Standard_True; |
280 | Extrema_ExtElC2d Xtrem(Tool2::Circle(*((Curve2*)myC)), Tool1::Hyperbola(C1)); |
c6541a0c |
281 | Results(Xtrem, U11, U12, U21, U22, 0., 2*M_PI); |
7fd59977 |
282 | } |
283 | break; |
284 | case GeomAbs_Ellipse: { |
285 | //inverse = Standard_True; |
286 | //Extrema_ExtElC2d Xtrem(Tool2::Ellipse(*((Curve2*)myC)), Tool1::Hyperbola(C1)); |
287 | Extrema_ECC2d Xtrem(C1, *((Curve2*)myC), |
288 | NbU, NbV, mytolc1, mytolc2); |
c6541a0c |
289 | Results(Xtrem, C1, U11, U12, U21, U22, 0., 2*M_PI ); |
7fd59977 |
290 | } |
291 | break; |
292 | case GeomAbs_Parabola: { |
293 | //Extrema_ExtElC2d Xtrem(Tool1::Hyperbola(C1), Tool2::Parabola(*((Curve2*)myC))); |
294 | Extrema_ECC2d Xtrem(C1, *((Curve2*)myC), |
295 | NbU, NbV, mytolc1, mytolc2); |
296 | Results(Xtrem, C1, U11, U12, U21, U22, 0., 0.); |
297 | } |
298 | break; |
299 | case GeomAbs_Hyperbola: { |
300 | //Extrema_ExtElC2d Xtrem(Tool1::Hyperbola(C1), Tool2::Hyperbola(*((Curve2*)myC))); |
301 | Extrema_ECC2d Xtrem(C1, *((Curve2*)myC), |
302 | NbU, NbV, mytolc1, mytolc2); |
303 | Results(Xtrem, C1, U11, U12, U21, U22, 0., 0.); |
304 | } |
305 | break; |
306 | case GeomAbs_OtherCurve: |
307 | case GeomAbs_BezierCurve: |
308 | case GeomAbs_BSplineCurve: { |
309 | Extrema_ECC2d Xtrem(C1, *((Curve2*)myC) |
310 | , NbU, NbV, mytolc1, mytolc2); |
311 | Standard_Real Period2 = 0.; |
312 | if (Tool2::IsPeriodic(*((Curve2*)myC))) Period2 = Tool2::Period(*((Curve2*)myC)); |
313 | Results(Xtrem, C1, U11, U12, U21, U22, 0., Period2); |
314 | } |
315 | break; |
316 | case GeomAbs_Line: { |
317 | inverse = Standard_True; |
318 | Extrema_ExtElC2d Xtrem(Tool2::Line(*((Curve2*)myC)), Tool1::Hyperbola(C1)); |
319 | Results(Xtrem, U11, U12, U21, U22, 0., 0.); |
320 | } |
321 | break; |
322 | }; // switch(type2) |
323 | } |
324 | break; |
325 | |
326 | // |
327 | // La premiere courbe est une BezierCurve ou une BSplineCurve: |
328 | // |
329 | case GeomAbs_BezierCurve: |
330 | case GeomAbs_OtherCurve: |
331 | case GeomAbs_BSplineCurve: { |
332 | Extrema_ECC2d Xtrem(C1, *((Curve2*)myC), |
333 | NbU, NbV, mytolc1, mytolc2); |
334 | Standard_Real Period1 = 0.; |
335 | if (Tool1::IsPeriodic(C1)) Period1 = Tool1::Period(C1); |
336 | Standard_Real Period2 = 0.; |
337 | if (Tool2::IsPeriodic(*((Curve2*)myC))) Period2 = Tool2::Period(*((Curve2*)myC)); |
338 | Results(Xtrem, C1, U11, U12, U21, U22, Period1, Period2); |
339 | } |
340 | break; |
341 | |
342 | // |
343 | // La premiere courbe est une Line: |
344 | // |
345 | case GeomAbs_Line: { |
346 | |
347 | switch(type2) { |
348 | case GeomAbs_Circle: { |
349 | Extrema_ExtElC2d Xtrem(Tool1::Line(C1), Tool2::Circle(*((Curve2*)myC)), Tol); |
c6541a0c |
350 | Results(Xtrem, U11, U12, U21, U22, 0., 2*M_PI); |
7fd59977 |
351 | } |
352 | break; |
353 | case GeomAbs_Ellipse: { |
354 | Extrema_ExtElC2d Xtrem(Tool1::Line(C1), Tool2::Ellipse(*((Curve2*)myC))); |
c6541a0c |
355 | Results(Xtrem, U11, U12, U21, U22, 0., 2*M_PI); |
7fd59977 |
356 | } |
357 | break; |
358 | case GeomAbs_Parabola: { |
359 | Extrema_ExtElC2d Xtrem(Tool1::Line(C1), Tool2::Parabola(*((Curve2*)myC))); |
360 | Results(Xtrem, U11, U12, U21, U22, 0., 0.); |
361 | } |
362 | break; |
363 | case GeomAbs_Hyperbola: { |
364 | Extrema_ExtElC2d Xtrem(Tool1::Line(C1), Tool2::Hyperbola(*((Curve2*)myC))); |
365 | Results(Xtrem, U11, U12, U21, U22, 0., 0.); |
366 | } |
367 | break; |
368 | case GeomAbs_BezierCurve: |
369 | case GeomAbs_OtherCurve: |
370 | case GeomAbs_BSplineCurve: { |
371 | Extrema_ECC2d Xtrem(C1, *((Curve2*)myC), |
372 | NbU, NbV, mytolc1, mytolc2); |
373 | Standard_Real Period2 = 0.; |
374 | if (Tool2::IsPeriodic(*((Curve2*)myC))) Period2 = Tool2::Period(*((Curve2*)myC)); |
375 | Results(Xtrem, C1, U11, U12, U21, U22, 0., Period2); |
376 | } |
377 | break; |
378 | case GeomAbs_Line: { |
379 | Extrema_ExtElC2d Xtrem(Tool1::Line(C1), Tool2::Line(*((Curve2*)myC)), Tol); |
380 | Results(Xtrem, U11, U12, U21, U22, 0., 0.); |
381 | } |
382 | break; |
383 | }; // switch(type2) |
384 | } |
385 | break; |
386 | |
387 | }; |
388 | |
389 | } |
390 | |
391 | |
392 | Standard_Boolean Extrema_GExtCC2d::IsDone() const |
393 | { |
394 | return myDone; |
395 | } |
396 | |
397 | |
398 | Standard_Real Extrema_GExtCC2d::SquareDistance(const Standard_Integer N) const |
399 | { |
400 | if(!myDone) StdFail_NotDone::Raise(); |
401 | if ((N <= 0) || (N > mynbext)) Standard_OutOfRange::Raise(); |
402 | return mySqDist.Value(N); |
403 | } |
404 | |
405 | |
406 | Standard_Integer Extrema_GExtCC2d::NbExt() const |
407 | { |
408 | if(!myDone) StdFail_NotDone::Raise(); |
409 | return mynbext; |
410 | } |
411 | |
412 | |
413 | void Extrema_GExtCC2d::Points(const Standard_Integer N, |
414 | Extrema_POnCurv2d& P1, |
415 | Extrema_POnCurv2d& P2) const |
416 | { |
417 | if(!myDone) StdFail_NotDone::Raise(); |
418 | if ((N <= 0) || (N > mynbext)) Standard_OutOfRange::Raise(); |
419 | P1 = mypoints.Value(2*N-1); |
420 | P2 = mypoints.Value(2*N); |
421 | } |
422 | |
423 | |
424 | |
425 | void Extrema_GExtCC2d::TrimmedSquareDistances(Standard_Real& dist11, |
426 | Standard_Real& dist12, |
427 | Standard_Real& dist21, |
428 | Standard_Real& dist22, |
429 | gp_Pnt2d& P11, |
430 | gp_Pnt2d& P12, |
431 | gp_Pnt2d& P21, |
432 | gp_Pnt2d& P22) const |
433 | { |
434 | dist11 = mydist11; |
435 | dist12 = mydist12; |
436 | dist21 = mydist21; |
437 | dist22 = mydist22; |
438 | P11 = P1f; |
439 | P12 = P1l; |
440 | P21 = P2f; |
441 | P22 = P2l; |
442 | } |
443 | |
444 | |
445 | |
446 | void Extrema_GExtCC2d::Results(const Extrema_ExtElC2d& AlgExt, |
447 | const Standard_Real Ut11, |
448 | const Standard_Real Ut12, |
449 | const Standard_Real Ut21, |
450 | const Standard_Real Ut22, |
451 | const Standard_Real Period1, |
452 | const Standard_Real Period2) |
453 | { |
454 | Standard_Integer i, NbExt; |
455 | Standard_Real Val, U, U2; |
456 | Extrema_POnCurv2d P1, P2; |
457 | |
458 | myDone = AlgExt.IsDone(); |
459 | myIsPar = AlgExt.IsParallel(); |
460 | if (myDone) { |
461 | if (!myIsPar) { |
462 | NbExt = AlgExt.NbExt(); |
463 | for (i = 1; i <= NbExt; i++) { |
464 | // Verification de la validite des parametres pour le cas trimme: |
465 | AlgExt.Points(i, P1, P2); |
466 | if (!inverse) { |
467 | U = P1.Parameter(); |
468 | if (Period1 != 0.0) U = ElCLib::InPeriod(U,Ut11,Ut11+Period1); |
469 | U2 = P2.Parameter(); |
470 | if (Period2 != 0.0) U2 = ElCLib::InPeriod(U2,Ut21,Ut21+Period2); |
471 | } |
472 | else { |
473 | U2 = P1.Parameter(); |
474 | if (Period2 != 0.0) U2 = ElCLib::InPeriod(U2,Ut21,Ut21+Period2); |
475 | U = P2.Parameter(); |
476 | if (Period1 != 0.0) U = ElCLib::InPeriod(U,Ut11,Ut11+Period1); |
477 | } |
478 | if ((U >= Ut11 - Precision::PConfusion()) && |
479 | (U <= Ut12 + Precision::PConfusion()) && |
480 | (U2 >= Ut21 - Precision::PConfusion()) && |
481 | (U2 <= Ut22 + Precision::PConfusion())) { |
482 | mynbext++; |
483 | Val = AlgExt.SquareDistance(i); |
484 | mySqDist.Append(Val); |
485 | if (!inverse) { |
486 | P1.SetValues(U, P1.Value()); |
487 | P2.SetValues(U2, P2.Value()); |
488 | mypoints.Append(P1); |
489 | mypoints.Append(P2); |
490 | } |
491 | else { |
492 | P1.SetValues(U2, P1.Value()); |
493 | P2.SetValues(U, P2.Value()); |
494 | mypoints.Append(P2); |
495 | mypoints.Append(P1); |
496 | } |
497 | } |
498 | } |
499 | } |
500 | |
501 | mydist11 = P1f.SquareDistance(P2f); |
502 | mydist12 = P1f.SquareDistance(P2l); |
503 | mydist21 = P1l.SquareDistance(P2f); |
504 | mydist22 = P1l.SquareDistance(P2l); |
505 | } |
506 | } |
507 | |
508 | |
509 | void Extrema_GExtCC2d::Results(const Extrema_ECC2d& AlgExt, |
510 | // modified by NIZHNY-EAP Wed Feb 23 14:51:24 2000 ___BEGIN___ |
511 | const Curve1& C1, |
512 | // modified by NIZHNY-EAP Wed Feb 23 14:51:26 2000 ___END___ |
513 | const Standard_Real Ut11, |
514 | const Standard_Real Ut12, |
515 | const Standard_Real Ut21, |
516 | const Standard_Real Ut22, |
517 | const Standard_Real Period1, |
518 | const Standard_Real Period2) |
519 | { |
520 | Standard_Integer i, NbExt; |
521 | Standard_Real Val, U, U2; |
522 | Extrema_POnCurv2d P1, P2; |
523 | |
524 | myDone = AlgExt.IsDone(); |
525 | if (myDone) { |
526 | if (!myIsPar) { |
527 | NbExt = AlgExt.NbExt(); |
528 | for (i = 1; i <= NbExt; i++) { |
529 | // Verification de la validite des parametres pour le cas trimme: |
530 | AlgExt.Points(i, P1, P2); |
531 | U = P1.Parameter(); |
532 | if (Period1 != 0.0) U = ElCLib::InPeriod(U,Ut11,Ut11+Period1); |
533 | U2 = P2.Parameter(); |
534 | if (Period2 != 0.0) U2 = ElCLib::InPeriod(U2,Ut21,Ut21+Period2); |
535 | |
536 | if ((U >= Ut11 - Precision::PConfusion()) && |
537 | (U <= Ut12 + Precision::PConfusion()) && |
538 | (U2 >= Ut21 - Precision::PConfusion()) && |
539 | (U2 <= Ut22 + Precision::PConfusion())) { |
540 | // modified by NIZHNY-EAP Thu Jan 27 16:40:55 2000 ___BEGIN___ |
541 | // to be sure that it's a real extrema |
542 | gp_Pnt2d p; |
543 | gp_Vec2d v1, v2; |
544 | Tool1::D1(C1,U,p, v1); |
545 | Tool2::D1(*((Curve2*)myC),U2,p, v2); |
32ca7a51 |
546 | if (IsParallelDot(v1, v2, Precision::Angular())) |
547 | { |
7fd59977 |
548 | mynbext++; |
549 | Val = AlgExt.SquareDistance(i); |
550 | P1.SetValues(U, P1.Value()); |
551 | P2.SetValues(U2, P2.Value()); |
552 | mySqDist.Append(Val); |
553 | mypoints.Append(P1); |
554 | mypoints.Append(P2); |
32ca7a51 |
555 | } |
7fd59977 |
556 | // modified by NIZHNY-EAP Thu Jan 27 16:41:00 2000 ___END___ |
557 | } |
558 | } |
559 | } |
560 | |
561 | mydist11 = P1f.SquareDistance(P2f); |
562 | mydist12 = P1f.SquareDistance(P2l); |
563 | mydist21 = P1l.SquareDistance(P2f); |
564 | mydist22 = P1l.SquareDistance(P2l); |
565 | } |
566 | } |
567 | |
568 | |
569 | Standard_Boolean Extrema_GExtCC2d::IsParallel() const |
570 | { |
571 | if (!myDone) StdFail_NotDone::Raise(); |
572 | return myIsPar; |
573 | } |