0024510: Remove unused local variables
[occt.git] / src / IntCurve / IntCurve_IntConicConic.cxx
CommitLineData
b311480e 1// Created on: 1992-04-27
2// Created by: Laurent BUCHARD
3// Copyright (c) 1992-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.
b311480e 16
7fd59977 17// Modified: OFV Thu Nov 6 17:03:52 2003
18
19
20#include <IntCurve_IntConicConic.ixx>
21#include <IntCurve_IntConicConic_1.hxx>
22#include <IntCurve_IConicTool.hxx>
23#include <IntCurve_PConic.hxx>
24#include <IntRes2d_Domain.hxx>
25#include <gp.hxx>
26#include <Precision.hxx>
27#include <Standard_ConstructionError.hxx>
28
29#include <IntAna2d_AnaIntersection.hxx>
30#include <IntAna2d_IntPoint.hxx>
31#include <IntAna2d_Conic.hxx>
32#include <ElCLib.hxx>
33
34//=======================================================================
35// Perform() for
36// Line - Parabola
37// Line - Elipse
38// Line - Hyperbola
39// Circle - Parabola
40// Circle - Elipse
41// Circle - Hyperbola
42// Parabola - Parabola
43// Elipse - Parabola
44// Parabola - Hyperbola
45// Elipse - Elipse
46// Elipse - Hyperbola
47// Hyperbola - Hyperbola
48//=======================================================================
49
50static const Standard_Real PARAM_MAX_ON_PARABOLA = 100000000.0;
51static const Standard_Real PARAM_MAX_ON_HYPERBOLA = 10000.0;
52static const Standard_Real TOL_EXACT_INTER = 1.e-7;
53
54static inline Standard_Boolean BOUNDED_DOMAIN(const IntRes2d_Domain& domain)
55{
56 return (domain.HasFirstPoint() && domain.HasLastPoint());
57}
58
59static Standard_Boolean SET_BOUNDED_DOMAIN(const IntRes2d_Domain domain,
60 Standard_Real& binf,
61 Standard_Real& tolinf,
62 gp_Pnt2d& Pntinf,
63 Standard_Real& bsup,
64 Standard_Real& tolsup,
65 gp_Pnt2d& Pntsup)
66{
67 if(domain.HasFirstPoint()) {
68 if(binf<domain.FirstParameter()) {
69 Pntinf = domain.FirstPoint();
70 binf = domain.FirstParameter();
71 tolinf = domain.FirstTolerance();
72 }
73 }
74 if(domain.HasLastPoint()) {
75 if(bsup>domain.FirstParameter()) {
76 Pntsup = domain.LastPoint();
77 bsup = domain.LastParameter();
78 tolsup = domain.LastTolerance();
79 }
80 }
81 Standard_Boolean result = (bsup <= binf) ? Standard_False : Standard_True;
82// if(bsup<=binf) return(Standard_False);
83// return(Standard_True);
84 return result;
85}
86
87void SetBinfBsupFromIntAna2d(const IntAna2d_AnaIntersection& theIntAna2d,
88 Standard_Real& binf,
89 gp_Pnt2d& pntinf,
90 Standard_Real& bsup,gp_Pnt2d& pntsup,
91 const gp_Hypr2d& H,
92 const Standard_Real maxtol,
93 const Standard_Real LIMITE);
94
95void SetBinfBsupFromIntAna2d(const IntAna2d_AnaIntersection &theIntAna2d,
96 Standard_Real& binf,gp_Pnt2d& pntinf,
97 Standard_Real& bsup,gp_Pnt2d& pntsup,
98 const gp_Parab2d& PR,
99 const Standard_Real maxtol,
100 const Standard_Real LIMITE);
101
102//=======================================================================
103//function : Perform
104//purpose : Line - Parabola
105//=======================================================================
106void IntCurve_IntConicConic::Perform(const gp_Lin2d& L,
107 const IntRes2d_Domain& DL,
108 const gp_Parab2d& P,
109 const IntRes2d_Domain& DP,
110 const Standard_Real TolConf,
111 const Standard_Real Tol)
112{
113
114 this->ResetFields();
115 IntCurve_IConicTool ITool(L);
116 IntCurve_PConic PCurve(P);
117
118 PCurve.SetAccuracy(20);
119 Inter.SetReversedParameters(ReversedParameters());
120
121 Standard_Real binf = Precision::Infinite();
122 Standard_Real bsup = -Precision::Infinite();
123 Standard_Real maxtol = (Tol > TolConf) ? Tol : TolConf;
124 if( maxtol< 1.e-7 ) maxtol = 1.e-7;
125 Standard_Boolean wasSet = Standard_False;
126
127 gp_Pnt2d Pntinf,Pntsup;
128 IntAna2d_AnaIntersection theIntAna2d;
129
130 maxtol*=100.0;
131// if(maxtol<0.000001) maxtol = 0.000001;
132
133 gp_Vec2d Offset(maxtol*L.Direction().Y(),maxtol*L.Direction().X());
134 gp_Lin2d Lp(L.Translated(Offset));
135 theIntAna2d.Perform(P,Lp);
136 SetBinfBsupFromIntAna2d(theIntAna2d,binf,Pntinf,bsup,Pntsup,P,maxtol,PARAM_MAX_ON_PARABOLA);
137
138 Offset.Reverse();
139 gp_Lin2d Lm(L.Translated(Offset));
140 theIntAna2d.Perform(P,Lm);
141 SetBinfBsupFromIntAna2d(theIntAna2d,binf,Pntinf,bsup,Pntsup,P,maxtol,PARAM_MAX_ON_PARABOLA);
142
143 if(binf<=bsup) {
144 if(!BOUNDED_DOMAIN(DP)) {
145 Standard_Real tolinf = 0.0;
146 Standard_Real tolsup = 0.0;
147 if(SET_BOUNDED_DOMAIN(DP,binf,tolinf,Pntinf,bsup,tolsup,Pntsup)) {
148 IntRes2d_Domain DPModif(Pntinf,binf,tolinf,Pntsup,bsup,tolsup);
149 Inter.Perform(ITool,DL,PCurve,DPModif,TolConf,Tol);
150 }
151 else {
152 done = Standard_True; return;
153 }
154 }
155 else {
156 Standard_Real ft=0.0,lt=0.0;
157 if(binf< DP.FirstParameter()) {
158 binf = DP.FirstParameter();
159 Pntinf = DP.FirstPoint();
160 ft = DP.FirstTolerance();
161 if(bsup < DP.FirstParameter()) {
162 done=Standard_True; return;
163 }
164 }
165 if(bsup> DP.LastParameter()) {
166 bsup = DP.LastParameter();
167 Pntsup = DP.LastPoint();
168 lt = DP.LastTolerance();
169 if(binf>DP.LastParameter()) {
170 done=Standard_True; return;
171 }
172 }
173 IntRes2d_Domain DPModif(Pntinf,binf,ft,Pntsup,bsup,lt);
174// Inter.Perform(ITool,DL,PCurve,DPModif,TolConf,Tol);
175 Inter.Perform(ITool,DL,PCurve,DPModif,TOL_EXACT_INTER,TOL_EXACT_INTER);
176 this->SetValues(Inter);
177 wasSet = Standard_True;
178 if( this->IsDone() && this->NbPoints() == 0 ) {
179 this->ResetFields();
180 Inter.Perform(ITool,DL,PCurve,DPModif,TolConf,Tol);
181 wasSet = Standard_False;
182 }
183 }
184 if( !wasSet ) this->SetValues(Inter);
185 }
186 else {
187 done = Standard_True;
188 }
189}
190
191//=======================================================================
192//function : Perform
193//purpose : Line - Elipse
194//=======================================================================
195void IntCurve_IntConicConic::Perform(const gp_Lin2d& L,
196 const IntRes2d_Domain& DL,
197 const gp_Elips2d& E,
198 const IntRes2d_Domain& DE,
199 const Standard_Real TolConf,
200 const Standard_Real Tol)
201{
202
203 this->ResetFields();
204 IntCurve_IConicTool ITool(L);
205 IntCurve_PConic PCurve(E);
206 PCurve.SetAccuracy(20);
207
208 Inter.SetReversedParameters(ReversedParameters());
209 if(! DE.IsClosed()) {
210 IntRes2d_Domain D(DE);
c6541a0c 211 D.SetEquivalentParameters(DE.FirstParameter(),DE.FirstParameter()+M_PI+M_PI);
7fd59977 212 Inter.Perform(ITool,DL,PCurve,D,TolConf,Tol);
213 }
214 else {
215 Inter.Perform(ITool,DL,PCurve,DE,TolConf,Tol);
216 }
217 this->SetValues(Inter);
218}
219
220//=======================================================================
221//function : Perform
222//purpose : Line - Hyperbola
223//=======================================================================
224void IntCurve_IntConicConic::Perform(const gp_Lin2d& L,
225 const IntRes2d_Domain& DL,
226 const gp_Hypr2d& H,
227 const IntRes2d_Domain& DH,
228 const Standard_Real TolConf,
229 const Standard_Real Tol)
230{
231 this->ResetFields();
232 IntCurve_IConicTool ITool(L);
233 IntCurve_PConic PCurve(H);
234 PCurve.SetAccuracy(20);
235
236
237 Inter.SetReversedParameters(ReversedParameters());
238
239 Standard_Real binf = Precision::Infinite(),bsup = -Precision::Infinite(),maxtol;
240 gp_Pnt2d Pntinf,Pntsup;
241 if(Tol > TolConf) maxtol = Tol; else maxtol = TolConf;
242 maxtol*=100.0;
243 if(maxtol<0.000001) maxtol = 0.000001;
244 gp_Vec2d Offset(maxtol*H.XAxis().Direction().X(),
245 maxtol*H.XAxis().Direction().Y());
246 gp_Hypr2d Hp(H.Translated(Offset));
247 IntAna2d_AnaIntersection theIntAna2d;
248 theIntAna2d.Perform(Hp,L);
249 SetBinfBsupFromIntAna2d(theIntAna2d,binf,Pntinf,bsup,Pntsup,H,maxtol,PARAM_MAX_ON_HYPERBOLA);
250 Offset.Reverse();
251 gp_Hypr2d Hm(H.Translated(Offset));
252 theIntAna2d.Perform(Hm,L);
253 SetBinfBsupFromIntAna2d(theIntAna2d,binf,Pntinf,bsup,Pntsup,H,maxtol,PARAM_MAX_ON_HYPERBOLA);
254 if(binf<=bsup) {
255 if(!BOUNDED_DOMAIN(DH)) {
256 Standard_Real tolinf = 0.0;
257 Standard_Real tolsup = 0.0;
258 if(SET_BOUNDED_DOMAIN(DH,binf,tolinf,Pntinf,bsup,tolsup,Pntsup)) {
259 IntRes2d_Domain DHModif(Pntinf,binf,tolinf,Pntsup,bsup,tolsup);
260 Inter.Perform(ITool,DL,PCurve,DHModif,TolConf,Tol);
261 }
262 else {
263 done = Standard_True; return;
264 }
265 }
266 else {
267 Standard_Real ft=0.0,lt=0.0;
268 if(binf< DH.FirstParameter()) {
269 binf = DH.FirstParameter();
270 Pntinf = DH.FirstPoint();
271 ft = DH.FirstTolerance();
272 if(bsup < DH.FirstParameter()) {
273 done=Standard_True; return;
274 }
275 }
276 if(bsup> DH.LastParameter()) {
277 bsup = DH.LastParameter();
278 Pntsup = DH.LastPoint();
279 lt = DH.LastTolerance();
280 if(binf>DH.LastParameter()) {
281 done=Standard_True; return;
282 }
283 }
284 IntRes2d_Domain DHModif(Pntinf,binf,ft,Pntsup,bsup,lt);
285 Inter.Perform(ITool,DL,PCurve,DHModif,TolConf,Tol);
286 }
287 this->SetValues(Inter);
288 }
289 else {
290 done = Standard_True;
291 }
292}
293
294//=======================================================================
295//function : Perform
296//purpose : Circle - Parabola
297//=======================================================================
298void IntCurve_IntConicConic::Perform(const gp_Circ2d& C,
299 const IntRes2d_Domain& DC,
300 const gp_Parab2d& P,
301 const IntRes2d_Domain& DP,
302 const Standard_Real TolConf,
303 const Standard_Real Tol)
304{
305 this->ResetFields();
306 IntCurve_IConicTool ITool(C);
307 IntCurve_PConic PCurve(P);
308 PCurve.SetAccuracy(20);
309 Inter.SetReversedParameters(ReversedParameters());
310
311 IntRes2d_Domain D(DC);
312 if(! DC.IsClosed()) {
c6541a0c 313 D.SetEquivalentParameters(DC.FirstParameter(),DC.FirstParameter()+M_PI+M_PI);
7fd59977 314 }
315
316 Standard_Real binf = Precision::Infinite(),bsup = -Precision::Infinite(),maxtol;
317 gp_Pnt2d Pntinf,Pntsup;
318 maxtol = C.Radius() / 10.0;
319 gp_Circ2d Cp(C);
320 Cp.SetRadius(C.Radius()+maxtol);
321 IntAna2d_AnaIntersection theIntAna2d;
322 theIntAna2d.Perform(P,Cp);
323 SetBinfBsupFromIntAna2d(theIntAna2d,binf,Pntinf,bsup,Pntsup,P,maxtol,PARAM_MAX_ON_PARABOLA);
324 if(C.Radius() > maxtol) {
325 Cp.SetRadius(C.Radius() - maxtol);
326 theIntAna2d.Perform(P,Cp);
327 SetBinfBsupFromIntAna2d(theIntAna2d,binf,Pntinf,bsup,Pntsup,P,maxtol,PARAM_MAX_ON_PARABOLA);
328 }
329 if(binf<=bsup) {
330 if(!BOUNDED_DOMAIN(DP)) {
331 Standard_Real tolinf = 0.0;
332 Standard_Real tolsup = 0.0;
333 if(SET_BOUNDED_DOMAIN(DP,binf,tolinf,Pntinf,bsup,tolsup,Pntsup)) {
334 IntRes2d_Domain DPModif(Pntinf,binf,tolinf,Pntsup,bsup,tolsup);
335 Inter.Perform(ITool,D,PCurve,DPModif,TolConf,Tol);
336 }
337 else {
338 done = Standard_True; return;
339 }
340 }
341 else {
342 Standard_Real ft=0.0,lt=0.0;
343 if(binf< DP.FirstParameter()) {
344 binf = DP.FirstParameter();
345 Pntinf = DP.FirstPoint();
346 ft = DP.FirstTolerance();
347 if(bsup < DP.FirstParameter()) {
348 done=Standard_True; return;
349 }
350 }
351 if(bsup> DP.LastParameter()) {
352 bsup = DP.LastParameter();
353 Pntsup = DP.LastPoint();
354 lt = DP.LastTolerance();
355 if(binf>DP.LastParameter()) {
356 done=Standard_True; return;
357 }
358 }
359 IntRes2d_Domain DPModif(Pntinf,binf,ft,Pntsup,bsup,lt);
360 Inter.Perform(ITool,D,PCurve,DPModif,TolConf,Tol);
361 }
362 this->SetValues(Inter);
363 }
364 else {
365 done = Standard_True;
366 }
367}
368
369//=======================================================================
370//function : Perform
371//purpose : Circle - Elipse
372//=======================================================================
373void IntCurve_IntConicConic::Perform(const gp_Circ2d& C,
374 const IntRes2d_Domain& DC,
375 const gp_Elips2d& E,
376 const IntRes2d_Domain& DE,
377 const Standard_Real TolConf,
378 const Standard_Real Tol)
379{
380 this->ResetFields();
381 IntCurve_IConicTool ITool(C);
382 IntCurve_PConic PCurve(E);
383 PCurve.SetAccuracy(20);
384
385 Inter.SetReversedParameters(ReversedParameters());
386
387 if(! DC.IsClosed()) {
388 IntRes2d_Domain D1(DC);
c6541a0c 389 D1.SetEquivalentParameters(DC.FirstParameter(),DC.FirstParameter()+M_PI+M_PI);
7fd59977 390 if(! DE.IsClosed()) {
391 IntRes2d_Domain D2(DE);
c6541a0c 392 D2.SetEquivalentParameters(DE.FirstParameter(),DE.FirstParameter()+M_PI+M_PI);
7fd59977 393 Inter.Perform(ITool,D1,PCurve,D2,TolConf,Tol);
394 }
395 else {
396 Inter.Perform(ITool,D1,PCurve,DE,TolConf,Tol);
397 }
398 }
399 else {
400 if(! DE.IsClosed()) {
401 IntRes2d_Domain D2(DE);
c6541a0c 402 D2.SetEquivalentParameters(DE.FirstParameter(),DE.FirstParameter()+M_PI+M_PI);
7fd59977 403 Inter.Perform(ITool,DC,PCurve,D2,TolConf,Tol);
404 }
405 else {
406 Inter.Perform(ITool,DC,PCurve,DE,TolConf,Tol);
407 }
408 }
409 this->SetValues(Inter);
410}
411
412//=======================================================================
413//function : Perform
414//purpose : Circle - Hyperbola
415//=======================================================================
416void IntCurve_IntConicConic::Perform(const gp_Circ2d& C,
417 const IntRes2d_Domain& DC,
418 const gp_Hypr2d& H,
419 const IntRes2d_Domain& DH,
420 const Standard_Real TolConf,
421 const Standard_Real Tol)
422{
423 this->ResetFields();
424 IntCurve_IConicTool ITool(C);
425 IntCurve_PConic PCurve(H);
426 PCurve.SetAccuracy(20);
427 Inter.SetReversedParameters(ReversedParameters());
428 IntRes2d_Domain D(DC);
429
430 if(! DC.IsClosed()) {
c6541a0c 431 D.SetEquivalentParameters(DC.FirstParameter(),DC.FirstParameter()+M_PI+M_PI);
7fd59977 432 }
433 Standard_Real binf = Precision::Infinite(),bsup = -Precision::Infinite(),maxtol;
434 gp_Pnt2d Pntinf,Pntsup;
435 maxtol = C.Radius() / 10.0;
436 gp_Vec2d Offset(maxtol*H.XAxis().Direction().X(),
437 maxtol*H.XAxis().Direction().Y());
438 gp_Hypr2d Hp(H.Translated(Offset));
439 IntAna2d_AnaIntersection theIntAna2d;
440 theIntAna2d.Perform(Hp,C);
441 SetBinfBsupFromIntAna2d(theIntAna2d,binf,Pntinf,bsup,Pntsup,H,maxtol,PARAM_MAX_ON_HYPERBOLA);
442 Offset.Reverse();
443 gp_Hypr2d Hm(H.Translated(Offset));
444 theIntAna2d.Perform(Hm,C);
445 SetBinfBsupFromIntAna2d(theIntAna2d,binf,Pntinf,bsup,Pntsup,H,maxtol,PARAM_MAX_ON_HYPERBOLA);
446 if(binf<=bsup) {
447 if(!BOUNDED_DOMAIN(DH)) {
448 Standard_Real tolinf = 0.0;
449 Standard_Real tolsup = 0.0;
450 if(SET_BOUNDED_DOMAIN(DH,binf,tolinf,Pntinf,bsup,tolsup,Pntsup)) {
451 IntRes2d_Domain DHModif(Pntinf,binf,tolinf,Pntsup,bsup,tolsup);
452 Inter.Perform(ITool,D,PCurve,DHModif,TolConf,Tol);
453 }
454 else {
455 done = Standard_True; return;
456 }
457 }
458 else {
459 Standard_Real ft=0.0,lt=0.0;
460 if(binf< DH.FirstParameter()) {
461 binf = DH.FirstParameter();
462 Pntinf = DH.FirstPoint();
463 ft = DH.FirstTolerance();
464 if(bsup < DH.FirstParameter()) {
465 done=Standard_True; return;
466 }
467 }
468 if(bsup> DH.LastParameter()) {
469 bsup = DH.LastParameter();
470 Pntsup = DH.LastPoint();
471 lt = DH.LastTolerance();
472 if(binf>DH.LastParameter()) {
473 done=Standard_True; return;
474 }
475 }
476 IntRes2d_Domain DHModif(Pntinf,binf,ft,Pntsup,bsup,lt);
477 Inter.Perform(ITool,D,PCurve,DHModif,TolConf,Tol);
478 }
479 this->SetValues(Inter);
480 }
481 else {
482 done = Standard_True;
483 }
484}
485
486//=======================================================================
487//function : Perform
488//purpose : Parabola - Parabola
489//=======================================================================
490void IntCurve_IntConicConic::Perform(const gp_Parab2d& P1,
491 const IntRes2d_Domain& DP1,
492 const gp_Parab2d& P2,
493 const IntRes2d_Domain& DP2,
494 const Standard_Real TolConf,
495 const Standard_Real Tol)
496{
497 this->ResetFields();
498 IntCurve_IConicTool ITool(P1);
499 IntCurve_PConic PCurve(P2);
500 PCurve.SetAccuracy(20);
501 Inter.SetReversedParameters(ReversedParameters());
502
503 Standard_Real binf = Precision::Infinite(),bsup = -Precision::Infinite(),maxtol;
504 gp_Pnt2d Pntinf,Pntsup;
505 if(Tol > TolConf) maxtol = Tol; else maxtol = TolConf;
506 maxtol*=100.0;
507 if(maxtol<0.000001) maxtol = 0.000001;
508 gp_Vec2d Offset(maxtol*P2.MirrorAxis().Direction().X(),
509 maxtol*P2.MirrorAxis().Direction().Y());
510 gp_Parab2d Pp(P2.Translated(Offset));
511 IntAna2d_AnaIntersection theIntAna2d;
512 theIntAna2d.Perform(Pp,P1);
513 SetBinfBsupFromIntAna2d(theIntAna2d,binf,Pntinf,bsup,Pntsup,P2,maxtol,PARAM_MAX_ON_PARABOLA);
514 Offset.Reverse();
515 gp_Parab2d Pm(P2.Translated(Offset));
516 theIntAna2d.Perform(Pm,P1);
517 SetBinfBsupFromIntAna2d(theIntAna2d,binf,Pntinf,bsup,Pntsup,P2,maxtol,PARAM_MAX_ON_PARABOLA);
518 if(binf<=bsup) {
519 if(!BOUNDED_DOMAIN(DP2)) {
520 Standard_Real tolinf = 0.0;
521 Standard_Real tolsup = 0.0;
522 if(SET_BOUNDED_DOMAIN(DP2,binf,tolinf,Pntinf,bsup,tolsup,Pntsup)) {
523 IntRes2d_Domain DPModif(Pntinf,binf,tolinf,Pntsup,bsup,tolsup);
524 Inter.Perform(ITool,DP1,PCurve,DPModif,TolConf,Tol);
525 }
526 else {
527 done = Standard_True; return;
528 }
529 }
530 else {
531 Standard_Real ft=0.0,lt=0.0;
532 if(binf< DP2.FirstParameter()) {
533 binf = DP2.FirstParameter();
534 Pntinf = DP2.FirstPoint();
535 ft = DP2.FirstTolerance();
536 if(bsup < DP2.FirstParameter()) {
537 done=Standard_True; return;
538 }
539 }
540 if(bsup> DP2.LastParameter()) {
541 bsup = DP2.LastParameter();
542 Pntsup = DP2.LastPoint();
543 lt = DP2.LastTolerance();
544 if(binf>DP2.LastParameter()) {
545 done=Standard_True; return;
546 }
547 }
548 IntRes2d_Domain DPModif(Pntinf,binf,ft,Pntsup,bsup,lt);
549 Inter.Perform(ITool,DP1,PCurve,DPModif,TolConf,Tol);
550 }
551 this->SetValues(Inter);
552 }
553 else {
554 done = Standard_True;
555 }
556}
557
558//=======================================================================
559//function : Perform
560//purpose : Elipse - Parabola
561//=======================================================================
562void IntCurve_IntConicConic::Perform(const gp_Elips2d& E,
563 const IntRes2d_Domain& DE,
564 const gp_Parab2d& P,
565 const IntRes2d_Domain& DP,
566 const Standard_Real TolConf,
567 const Standard_Real Tol)
568{
569 this->ResetFields();
570 IntCurve_IConicTool ITool(E);
571 IntCurve_PConic PCurve(P);
572 PCurve.SetAccuracy(20);
573 Inter.SetReversedParameters(ReversedParameters());
574
575 IntRes2d_Domain D(DE);
576 if(! DE.IsClosed()) {
c6541a0c 577 D.SetEquivalentParameters(DE.FirstParameter(),DE.FirstParameter()+M_PI+M_PI);
7fd59977 578 }
579
580 //-- cout<<" Parab Elips "<<endl;
581
582 Standard_Real binf = Precision::Infinite(),bsup = -Precision::Infinite(),maxtol;
583 gp_Pnt2d Pntinf,Pntsup;
584 if(Tol > TolConf) maxtol = Tol; else maxtol = TolConf;
585
586 maxtol = E.MinorRadius() / 10.0;
587 gp_Elips2d Ep(E);
588 Ep.SetMajorRadius(E.MajorRadius()+maxtol);
589 Ep.SetMinorRadius(E.MinorRadius()+maxtol);
590 IntAna2d_AnaIntersection theIntAna2d;
591 theIntAna2d.Perform(P,Ep);
592 SetBinfBsupFromIntAna2d(theIntAna2d,binf,Pntinf,bsup,Pntsup,P,maxtol,PARAM_MAX_ON_PARABOLA);
593 if(E.MinorRadius() > maxtol) {
594 Ep.SetMinorRadius(E.MinorRadius() - maxtol);
595 Ep.SetMajorRadius(E.MajorRadius() - maxtol);
596 theIntAna2d.Perform(P,Ep);
597 SetBinfBsupFromIntAna2d(theIntAna2d,binf,Pntinf,bsup,Pntsup,P,maxtol,PARAM_MAX_ON_PARABOLA);
598 }
599 //-- cout<<" binf,bsup "<<binf<<" "<<bsup<<endl;
600 if(binf<=bsup) {
601 if(!BOUNDED_DOMAIN(DP)) {
602 Standard_Real tolinf = 0.0;
603 Standard_Real tolsup = 0.0;
604 if(SET_BOUNDED_DOMAIN(DP,binf,tolinf,Pntinf,bsup,tolsup,Pntsup)) {
605 IntRes2d_Domain DPModif(Pntinf,binf,tolinf,Pntsup,bsup,tolsup);
606 Inter.Perform(ITool,D,PCurve,DPModif,TolConf,Tol);
607 }
608 else {
609 done = Standard_True; return;
610 }
611 }
612 else {
613 Standard_Real ft=0.0,lt=0.0;
614 if(binf< DP.FirstParameter()) {
615 binf = DP.FirstParameter();
616 Pntinf = DP.FirstPoint();
617 ft = DP.FirstTolerance();
618 if(bsup < DP.FirstParameter()) {
619 done=Standard_True; return;
620 }
621 }
622 if(bsup> DP.LastParameter()) {
623 bsup = DP.LastParameter();
624 Pntsup = DP.LastPoint();
625 lt = DP.LastTolerance();
626 if(binf>DP.LastParameter()) {
627 done=Standard_True; return;
628 }
629 }
630 //-- cout<<"BOUNDED binf,bsup "<<binf<<" "<<bsup<<endl;
631 //-- cout<<"Domain "<<DP.FirstParameter()<<" "<<DP.LastParameter()<<endl;
632 IntRes2d_Domain DPModif(Pntinf,binf,ft,Pntsup,bsup,lt);
633 Inter.Perform(ITool,D,PCurve,DPModif,TolConf,Tol);
634 }
635 this->SetValues(Inter);
636 }
637 else {
638 done = Standard_True;
639 }
640}
641
642//=======================================================================
643//function : Perform
644//purpose : Parabola - Hyperbola
645//=======================================================================
646void IntCurve_IntConicConic::Perform(const gp_Parab2d& P,
647 const IntRes2d_Domain& DP,
648 const gp_Hypr2d& H,
649 const IntRes2d_Domain& DH,
650 const Standard_Real TolConf,
651 const Standard_Real Tol)
652{
653 this->ResetFields();
654 IntCurve_IConicTool ITool(P);
655 IntCurve_PConic PCurve(H);
656 Inter.SetReversedParameters(ReversedParameters());
657
658 Standard_Real binf = Precision::Infinite(),bsup = -Precision::Infinite(),maxtol;
659 gp_Pnt2d Pntinf,Pntsup;
660 if(Tol > TolConf) maxtol = Tol; else maxtol = TolConf;
661 maxtol*=100.0;
662 if(maxtol<0.000001) maxtol = 0.000001;
663 gp_Vec2d Offset(maxtol*H.XAxis().Direction().X(),
664 maxtol*H.XAxis().Direction().Y());
665 gp_Hypr2d Hp(H.Translated(Offset));
666 IntAna2d_AnaIntersection theIntAna2d;
667 theIntAna2d.Perform(Hp,P);
668 SetBinfBsupFromIntAna2d(theIntAna2d,binf,Pntinf,bsup,Pntsup,H,maxtol,PARAM_MAX_ON_HYPERBOLA);
669 Offset.Reverse();
670 gp_Hypr2d Hm(H.Translated(Offset));
671 theIntAna2d.Perform(Hm,P);
672 SetBinfBsupFromIntAna2d(theIntAna2d,binf,Pntinf,bsup,Pntsup,H,maxtol,PARAM_MAX_ON_HYPERBOLA);
673 if(binf<=bsup) {
674 if(!BOUNDED_DOMAIN(DH)) {
675 Standard_Real tolinf = 0.0;
676 Standard_Real tolsup = 0.0;
677 if(SET_BOUNDED_DOMAIN(DH,binf,tolinf,Pntinf,bsup,tolsup,Pntsup)) {
678 IntRes2d_Domain DHModif(Pntinf,binf,tolinf,Pntsup,bsup,tolsup);
679 Inter.Perform(ITool,DP,PCurve,DHModif,TolConf,Tol);
680 }
681 else {
682 done = Standard_True; return;
683 }
684 }
685 else {
686 Standard_Real ft=0.0,lt=0.0;
687 if(binf< DH.FirstParameter()) {
688 binf = DH.FirstParameter();
689 Pntinf = DH.FirstPoint();
690 ft = DH.FirstTolerance();
691 if(bsup < DH.FirstParameter()) {
692 done=Standard_True; return;
693 }
694 }
695 if(bsup> DH.LastParameter()) {
696 bsup = DH.LastParameter();
697 Pntsup = DH.LastPoint();
698 lt = DH.LastTolerance();
699 if(binf>DH.LastParameter()) {
700 done=Standard_True; return;
701 }
702 }
703 IntRes2d_Domain DHModif(Pntinf,binf,ft,Pntsup,bsup,lt);
704 Inter.Perform(ITool,DP,PCurve,DHModif,TolConf,Tol);
705 }
706 this->SetValues(Inter);
707 }
708 else {
709 done = Standard_True;
710 }
711}
712
713//=======================================================================
714//function : Perform
715//purpose : Elipse - Elipse
716//=======================================================================
717
718void IntCurve_IntConicConic::Perform(const gp_Elips2d& E1,
719 const IntRes2d_Domain& DE1,
720 const gp_Elips2d& E2,
721 const IntRes2d_Domain& DE2,
722 const Standard_Real TolConf,
723 const Standard_Real Tol)
724{
725 this->ResetFields();
726 IntCurve_IConicTool ITool(E1);
727 IntCurve_PConic PCurve(E2);
728 PCurve.SetAccuracy(20);
729
730
731 Inter.SetReversedParameters(ReversedParameters());
732
733 if(! DE1.IsClosed()) {
734 IntRes2d_Domain D1(DE1);
c6541a0c 735 D1.SetEquivalentParameters(DE1.FirstParameter(),DE1.FirstParameter()+M_PI+M_PI);
7fd59977 736 if(! DE2.IsClosed()) {
737 IntRes2d_Domain D2(DE2);
c6541a0c 738 D2.SetEquivalentParameters(DE2.FirstParameter(),DE2.FirstParameter()+M_PI+M_PI);
7fd59977 739 Inter.Perform(ITool,D1,PCurve,D2,TolConf,Tol);
740 }
741 else {
742 Inter.Perform(ITool,D1,PCurve,DE2,TolConf,Tol);
743 }
744 }
745 else {
746 if(! DE2.IsClosed()) {
747 IntRes2d_Domain D2(DE2);
c6541a0c 748 D2.SetEquivalentParameters(DE2.FirstParameter(),DE2.FirstParameter()+M_PI+M_PI);
7fd59977 749 Inter.Perform(ITool,DE1,PCurve,D2,TolConf,Tol);
750 }
751 else {
752 Inter.Perform(ITool,DE1,PCurve,DE2,TolConf,Tol);
753 }
754 }
755 this->SetValues(Inter);
756}
757
758//=======================================================================
759//function : Perform
760//purpose : Elipse - Hyperbola
761//=======================================================================
762void IntCurve_IntConicConic::Perform(const gp_Elips2d& E,
763 const IntRes2d_Domain& DE,
764 const gp_Hypr2d& H,
765 const IntRes2d_Domain& DH,
766 const Standard_Real TolConf,
767 const Standard_Real Tol)
768{
769 this->ResetFields();
770 IntCurve_IConicTool ITool(E);
771 IntCurve_PConic PCurve(H);
772 PCurve.SetAccuracy(20);
773 Inter.SetReversedParameters(ReversedParameters());
774 IntRes2d_Domain DEModif(DE);
775
776 if(! DE.IsClosed()) {
c6541a0c 777 DEModif.SetEquivalentParameters(DE.FirstParameter(),DE.FirstParameter()+M_PI+M_PI);
7fd59977 778 }
779
780 Standard_Real binf = Precision::Infinite(),bsup = -Precision::Infinite(),maxtol;
781 gp_Pnt2d Pntinf,Pntsup;
782 maxtol = E.MinorRadius() / 10.0;
783 gp_Vec2d Offset(maxtol*H.XAxis().Direction().X(),
784 maxtol*H.XAxis().Direction().Y());
785 gp_Hypr2d Hp(H.Translated(Offset));
786 IntAna2d_AnaIntersection theIntAna2d;
787 theIntAna2d.Perform(Hp,E);
788 SetBinfBsupFromIntAna2d(theIntAna2d,binf,Pntinf,bsup,Pntsup,H,maxtol,PARAM_MAX_ON_HYPERBOLA);
789 Offset.Reverse();
790 gp_Hypr2d Hm(H.Translated(Offset));
791 theIntAna2d.Perform(Hm,E);
792 SetBinfBsupFromIntAna2d(theIntAna2d,binf,Pntinf,bsup,Pntsup,H,maxtol,PARAM_MAX_ON_HYPERBOLA);
793 if(binf<=bsup) {
794 if(!BOUNDED_DOMAIN(DH)) {
795 Standard_Real tolinf = 0.0;
796 Standard_Real tolsup = 0.0;
797 if(SET_BOUNDED_DOMAIN(DH,binf,tolinf,Pntinf,bsup,tolsup,Pntsup)) {
798 IntRes2d_Domain DHModif(Pntinf,binf,tolinf,Pntsup,bsup,tolsup);
799 Inter.Perform(ITool,DEModif,PCurve,DHModif,TolConf,Tol);
800 }
801 else {
802 done = Standard_True; return;
803 }
804 }
805 else {
806 Standard_Real ft=0.0,lt=0.0;
807 if(binf< DH.FirstParameter()) {
808 binf = DH.FirstParameter();
809 Pntinf = DH.FirstPoint();
810 ft = DH.FirstTolerance();
811 if(bsup < DH.FirstParameter()) {
812 done=Standard_True; return;
813 }
814 }
815 if(bsup> DH.LastParameter()) {
816 bsup = DH.LastParameter();
817 Pntsup = DH.LastPoint();
818 lt = DH.LastTolerance();
819 if(binf>DH.LastParameter()) {
820 done=Standard_True; return;
821 }
822 }
823 if(binf>=bsup) {
824 done = Standard_True; return;
825 }
826 IntRes2d_Domain DHModif(Pntinf,binf,ft,Pntsup,bsup,lt);
827 Inter.Perform(ITool,DEModif,PCurve,DHModif,TolConf,Tol);
828 }
829 this->SetValues(Inter);
830 }
831 else {
832 done = Standard_True;
833 }
834}
835
836//=======================================================================
837//function : Perform
838//purpose : Hyperbola - Hyperbola
839//=======================================================================
840
841void IntCurve_IntConicConic::Perform(const gp_Hypr2d& H1,
842 const IntRes2d_Domain& DH1,
843 const gp_Hypr2d& H2,
844 const IntRes2d_Domain& DH2,
845 const Standard_Real TolConf,
846 const Standard_Real Tol)
847{
848 this->ResetFields();
849 IntCurve_IConicTool ITool(H1);
850 IntCurve_PConic PCurve(H2);
851 PCurve.SetAccuracy(20);
852
853 Inter.SetReversedParameters(ReversedParameters());
854
855 Standard_Real binf = Precision::Infinite(),bsup = -Precision::Infinite(),maxtol;
856 gp_Pnt2d Pntinf,Pntsup;
857 if(Tol > TolConf) maxtol = Tol; else maxtol = TolConf;
858 maxtol*=100.0;
859 if(maxtol<0.000001) maxtol = 0.000001;
860 gp_Vec2d Offset(maxtol*H2.XAxis().Direction().X(),
861 maxtol*H2.XAxis().Direction().Y());
862 gp_Hypr2d Hp(H2.Translated(Offset));
863 IntAna2d_AnaIntersection theIntAna2d;
864 theIntAna2d.Perform(Hp,H1);
865 SetBinfBsupFromIntAna2d(theIntAna2d,binf,Pntinf,bsup,Pntsup,H2,maxtol,PARAM_MAX_ON_HYPERBOLA);
866 Offset.Reverse();
867 gp_Hypr2d Hm(H2.Translated(Offset));
868 theIntAna2d.Perform(Hm,H1);
869 SetBinfBsupFromIntAna2d(theIntAna2d,binf,Pntinf,bsup,Pntsup,H2,maxtol,PARAM_MAX_ON_HYPERBOLA);
870 if(binf<=bsup) {
871 if(!BOUNDED_DOMAIN(DH2)) {
872 Standard_Real tolinf = 0.0;
873 Standard_Real tolsup = 0.0;
874 if(SET_BOUNDED_DOMAIN(DH2,binf,tolinf,Pntinf,bsup,tolsup,Pntsup)) {
875 IntRes2d_Domain DHModif(Pntinf,binf,tolinf,Pntsup,bsup,tolsup);
876 Inter.Perform(ITool,DH1,PCurve,DHModif,TolConf,Tol);
877 }
878 else {
879 done = Standard_True; return;
880 }
881 }
882 else {
883 Standard_Real ft=0.0,lt=0.0;
884 if(binf< DH2.FirstParameter()) {
885 binf = DH2.FirstParameter();
886 Pntinf = DH2.FirstPoint();
887 ft = DH2.FirstTolerance();
888 }
889 if(bsup> DH2.LastParameter()) {
890 bsup = DH2.LastParameter();
891 Pntsup = DH2.LastPoint();
892 lt = DH2.LastTolerance();
893 }
894
895 //-- lbr le 22 sept 97
896 //-- binf=-5.6 bsup=-5.3 DH2=(5.6,5.7) -> binf=+5.6 bsup=-5.3
897 if(binf>=bsup) {
898 done = Standard_True; return;
899 }
900 IntRes2d_Domain DHModif(Pntinf,binf,ft,Pntsup,bsup,lt);
901 Inter.Perform(ITool,DH1,PCurve,DHModif,TolConf,Tol);
902 }
903 this->SetValues(Inter);
904 }
905 else {
906 done = Standard_True;
907 }
908}
909//----------------------------------------------------------------------
910
911
912void SetBinfBsupFromIntAna2d(const IntAna2d_AnaIntersection &theIntAna2d,
913 Standard_Real& binf,gp_Pnt2d& Pntinf,
914 Standard_Real& bsup,gp_Pnt2d& Pntsup,
915 const gp_Parab2d& PR,
916 const Standard_Real maxtol,
917 const Standard_Real LIMITE) {
918
919
920 if(theIntAna2d.IsDone()) {
921 if(!theIntAna2d.IsEmpty()) {
922 for(Standard_Integer p=1; p<=theIntAna2d.NbPoints(); p++) {
923 Standard_Real param = theIntAna2d.Point(p).ParamOnFirst();
924
925 if(Abs(param) < LIMITE) {
926 gp_Vec2d V;
927 gp_Pnt2d P;
928 ElCLib::D1(param,PR,P,V);
929 Standard_Real NormeD1 = V.Magnitude();
930 Standard_Real dparam = 100.0*maxtol/NormeD1;
931 if(dparam<1e-3) dparam = 1e-3;
932 param-=dparam;
933
934 if(param < binf) {
935 binf = param;
936 Pntinf=ElCLib::Value(param,PR);
937 }
938 param+=dparam+dparam;
939 if(param > bsup) {
940 bsup = param;
941 Pntsup=ElCLib::Value(param,PR);
942 }
943 }
944 }
945 }
946 }
947}
948void SetBinfBsupFromIntAna2d(const IntAna2d_AnaIntersection &theIntAna2d,
949 Standard_Real& binf,gp_Pnt2d& Pntinf,
950 Standard_Real& bsup,gp_Pnt2d& Pntsup,
951 const gp_Hypr2d& H,
952 const Standard_Real maxtol,
953 const Standard_Real LIMITE) {
954
955
956 if(theIntAna2d.IsDone()) {
957 if(!theIntAna2d.IsEmpty()) {
958 for(Standard_Integer p=1; p<=theIntAna2d.NbPoints(); p++) {
959 Standard_Real param = theIntAna2d.Point(p).ParamOnFirst();
960
961 if(Abs(param) < LIMITE) {
962 gp_Vec2d V;
963 gp_Pnt2d P;
964 ElCLib::D1(param,H,P,V);
965 Standard_Real NormeD1 = V.Magnitude();
966 Standard_Real dparam = 100.0*maxtol/NormeD1;
967 if(dparam<1e-3) dparam = 1e-3;
968 param-=dparam;
969
970 if(param < binf) {
971 binf = param;
972 Pntinf=ElCLib::Value(param,H);
973 }
974 param+=dparam+dparam;
975 if(param > bsup) {
976 bsup = param;
977 Pntsup=ElCLib::Value(param,H);
978 }
979 }
980 }
981 }
982 }
983}
984
985
986