0026586: Eliminate compile warnings obtained by building occt with vc14: declaration...
[occt.git] / src / IntCurve / IntCurve_IntConicConic_1.cxx
CommitLineData
b311480e 1// Created on: 1992-05-06
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//
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.
b311480e 16
7fd59977 17// a modifier le cas de 2 points confondus ( Insert a la place d'append ? )
18
42cf5bc1 19#include <ElCLib.hxx>
7fd59977 20#include <gp.hxx>
42cf5bc1 21#include <gp_Circ2d.hxx>
22#include <gp_Elips2d.hxx>
23#include <gp_Hypr2d.hxx>
24#include <gp_Lin2d.hxx>
25#include <gp_Parab2d.hxx>
26#include <gp_Pnt2d.hxx>
27#include <gp_Vec2d.hxx>
28#include <IntCurve_IConicTool.hxx>
29#include <IntCurve_IntConicConic.hxx>
30#include <IntCurve_IntConicConic_1.hxx>
7fd59977 31#include <IntCurve_IntConicConic_Tool.hxx>
42cf5bc1 32#include <IntCurve_PConic.hxx>
7fd59977 33#include <IntImpParGen.hxx>
42cf5bc1 34#include <IntRes2d_Domain.hxx>
7fd59977 35#include <IntRes2d_IntersectionPoint.hxx>
36#include <IntRes2d_IntersectionSegment.hxx>
c2b14317 37#include <IntRes2d_TypeTrans.hxx>
42cf5bc1 38#include <Precision.hxx>
39#include <Standard_ConstructionError.hxx>
7fd59977 40
41Standard_Boolean Affichage=Standard_False;
42Standard_Boolean AffichageGraph=Standard_True;
43
44//modified by NIZHNY-MKK Tue Feb 15 10:53:34 2000.BEGIN
45// #define TOLERANCE_ANGULAIRE 0.00000001
46#define TOLERANCE_ANGULAIRE 1.e-15 //the reason is at least to make an accordance between transition and position computation.
47//modified by NIZHNY-MKK Tue Feb 15 10:53:45 2000.END
48
c6541a0c 49const Standard_Real PIsur2 = 0.5*M_PI;
7fd59977 50
51//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
52IntRes2d_Position FindPositionLL(Standard_Real&,const IntRes2d_Domain&);
53const IntRes2d_IntersectionPoint SegmentToPoint( const IntRes2d_IntersectionPoint& Pa
54 ,const IntRes2d_Transition& T1a
55 ,const IntRes2d_Transition& T2a
56 ,const IntRes2d_IntersectionPoint& Pb
57 ,const IntRes2d_Transition& T1b
58 ,const IntRes2d_Transition& T2b);
59//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
60void ProjectOnC2AndIntersectWithC2Domain(const gp_Circ2d& Circle1
61 ,const gp_Circ2d& Circle2
62 ,PeriodicInterval& C1DomainAndRes
63 ,PeriodicInterval& DomainC2
64 ,PeriodicInterval* SolutionC1
65 ,PeriodicInterval* SolutionC2
66 ,Standard_Integer &NbSolTotal
67 ,const Standard_Boolean IdentCircles)
68{
69
70 if(C1DomainAndRes.IsNull()) return;
71 //-------------------------------------------------------------------------
72 //-- On cherche l intervalle correspondant sur C2
73 //-- Puis on intersecte l intervalle avec le domaine de C2
74 //-- Enfin, on cherche l intervalle correspondant sur C1
75 //--
76 Standard_Real C2inf =
77 ElCLib::CircleParameter(Circle2.Axis()
78 ,ElCLib::CircleValue(C1DomainAndRes.Binf
79 ,Circle1.Axis(),Circle1.Radius()));
80 Standard_Real C2sup =
81 ElCLib::CircleParameter(Circle2.Axis()
82 ,ElCLib::CircleValue(C1DomainAndRes.Bsup
83 ,Circle1.Axis(),Circle1.Radius()));
84
85 PeriodicInterval C2Inter(C2inf,C2sup);
86
87 if(!IdentCircles) {
c6541a0c 88 if(C2Inter.Length() > M_PI)
7fd59977 89 C2Inter.Complement();
90 }
91 else {
92 if(C2sup<=C2inf) C2sup+=PIpPI;
93 if(C2inf>=PIpPI) {
94 C2sup-=PIpPI;
95 C2inf-=PIpPI;
96 }
97 C2Inter.Binf=C2inf;
98 C2Inter.Bsup=C2sup; //--- Verifier la longueur de l'intervalle sur C2
99 C2Inter.Bsup=C2inf+C1DomainAndRes.Bsup-C1DomainAndRes.Binf;
100 }
101
102 PeriodicInterval C2InterAndDomain[2];
103
104 for(Standard_Integer i=0; i<2 ; i++) {
105 C2InterAndDomain[i]=(i==0)? DomainC2.FirstIntersection(C2Inter)
106 : DomainC2.SecondIntersection(C2Inter);
107
108 if(!C2InterAndDomain[i].IsNull()) {
109
110 Standard_Real C1inf =
111 ElCLib::CircleParameter(Circle1.Axis()
112 ,ElCLib::CircleValue(C2InterAndDomain[i].Binf
113 ,Circle2.Axis(),Circle2.Radius()));
114 Standard_Real C1sup =
115 ElCLib::CircleParameter(Circle1.Axis()
116 ,ElCLib::CircleValue(C2InterAndDomain[i].Bsup
117 ,Circle2.Axis(),Circle2.Radius()));
118
119 SolutionC1[NbSolTotal]=PeriodicInterval(C1inf,C1sup);
120 if(!IdentCircles) {
c6541a0c 121 if(SolutionC1[NbSolTotal].Length() > M_PI)
7fd59977 122 SolutionC1[NbSolTotal].Complement();
123 }
124 else {
125 if(SolutionC1[NbSolTotal].Bsup <= SolutionC1[NbSolTotal].Binf) {
126 SolutionC1[NbSolTotal].Bsup+=PIpPI;
127 }
128 if(SolutionC1[NbSolTotal].Binf>=PIpPI) {
129 SolutionC1[NbSolTotal].Binf-=PIpPI;
130 SolutionC1[NbSolTotal].Bsup-=PIpPI;
131 }
132 }
133 SolutionC2[NbSolTotal]=C2InterAndDomain[i];
134 NbSolTotal++;
135 }
136 }
137}
138//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
139//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
140void CircleCircleGeometricIntersection(const gp_Circ2d& C1
141 ,const gp_Circ2d& C2
142 ,const Standard_Real Tol
143 ,const Standard_Real TolTang
144 ,PeriodicInterval& C1_Res1
145 ,PeriodicInterval& C1_Res2
146 ,Standard_Integer& nbsol) {
147
148 Standard_Real C1_binf1,C1_binf2=0,C1_bsup1,C1_bsup2=0;
149 Standard_Real dO1O2=(C1.Location()).Distance(C2.Location());
150 Standard_Real R1=C1.Radius();
151 Standard_Real R2=C2.Radius();
152 Standard_Real AbsR1mR2=Abs(R1-R2);
153 //----------------------------------------------------------------
154 if(dO1O2 > (R1+R2+Tol)) {
155 if(dO1O2 > (R1+R2+TolTang)) {
156 nbsol=0;
157 return;
158 }
159 else {
160 C1_binf1 = 0.0;
161 C1_bsup1 = 0.0;
162 nbsol = 1;
163 }
164 }
165 //----------------------------------------------------------------
166 else if(dO1O2 <= Tol && AbsR1mR2<=Tol) {
167 nbsol=3;
168 return;
169 }
170 else {
171 //----------------------------------------------------------------
172 Standard_Real R1pR2=R1+R2;
173 Standard_Real R1pTol=R1+Tol;
174 Standard_Real R1mTol=R1-Tol;
175// Standard_Real R1R1=R1*R1;
176 Standard_Real R2R2=R2*R2;
177 Standard_Real R1pTolR1pTol=R1pTol*R1pTol;
178 Standard_Real R1mTolR1mTol=R1mTol*R1mTol;
179 Standard_Real dO1O2dO1O2=dO1O2*dO1O2;
180 Standard_Real dAlpha1;
181 //--------------------------------------------------------------- Cas
182 //-- C2 coupe le cercle C1+ (=C(x1,y1,R1+Tol))
183 //-- 1 seul segment donne par Inter C2 C1+
184 //--
185 if(dO1O2 > R1pR2-Tol) {
186 Standard_Real dx=(R1pTolR1pTol+dO1O2dO1O2-R2R2)/(dO1O2+dO1O2);
187 Standard_Real dy=(R1pTolR1pTol-dx*dx);
188 dy=(dy>=0.0)? Sqrt(dy) : 0.0;
189 dAlpha1=ATan2(dy,dx);
190
191 C1_binf1=-dAlpha1;
192 C1_bsup1=dAlpha1;
193 nbsol=1;
194 }
195 //--------------------------------------------------------------------
196 //-- 2 segments donnes par Inter C2 avec C1- C1 C1+
197 //-- Seul le signe de dx change si dO1O2 < Max(R1,R2)
198 //--
199 else if(dO1O2 > AbsR1mR2-Tol) { // -- +
200 //------------------- Intersection C2 C1+ --------------------------
201 Standard_Real dx=(R1pTolR1pTol+dO1O2dO1O2-R2R2)/(dO1O2+dO1O2);
202 Standard_Real dy=(R1pTolR1pTol-dx*dx);
203 dy=(dy>=0.0)? Sqrt(dy) : 0.0;
204
205 dAlpha1=ATan2(dy,dx);
206 C1_binf1=-dAlpha1; C1_bsup2=dAlpha1; //-- |...? ?...| Sur C1
207
208 //------------------ Intersection C2 C1- -------------------------
209 dx=(R1mTolR1mTol+dO1O2dO1O2-R2R2)/(dO1O2+dO1O2);
210 dy=(R1mTolR1mTol-dx*dx);
211 dy=(dy>=0.0)? Sqrt(dy) : 0.0;
212 dAlpha1=ATan2(dy,dx);
213
214 C1_binf2=dAlpha1; C1_bsup1=-dAlpha1; //-- |...x x...| Sur C1
215 nbsol=2;
216 //------------------------------
217 //-- Les 2 intervalles sont ils
218 //-- en fait un seul inter ?
219 //--
220 if(dy==0) { //-- Les 2 bornes internes sont identiques
221 C1_bsup1 = C1_bsup2;
222 nbsol = 1;
223 }
224 else {
225 if(C1_binf1>C1_bsup1) {
226 dAlpha1 = C1_binf1; C1_binf1 = C1_bsup1; C1_bsup1 = dAlpha1;
227 }
228 if(C1_binf2>C1_bsup2) {
229 dAlpha1 = C1_binf2; C1_binf2 = C1_bsup2; C1_bsup2 = dAlpha1;
230 }
231 if( ((C1_binf1<=C1_bsup2) && (C1_binf1>=C1_binf2))
232 || ((C1_bsup1<=C1_bsup2) && (C1_bsup1>=C1_binf2))) {
233 if(C1_binf1 > C1_binf2) C1_binf1 = C1_binf2;
234 if(C1_binf1 > C1_bsup2) C1_binf1 = C1_bsup2;
235 if(C1_bsup1 < C1_binf2) C1_bsup1 = C1_binf2;
236 if(C1_bsup1 < C1_bsup2) C1_bsup1 = C1_bsup2;
237 nbsol=1;
238 }
239 }
240 }
241 //--------------------------------------------------------------
7fd59977 242 else {
243 if((dO1O2 > AbsR1mR2-TolTang) && (AbsR1mR2-TolTang)>0.0) {
244 C1_binf1=0.0;
245 C1_bsup1=0.0;
246 nbsol = 1;
247 }
248 else {
249 nbsol=0; return ;
250 }
251 }
252 }
253
254 //-- cout<<" C1_binf1:"<<C1_binf1;
255 //-- cout<<" C1_bsup1:"<<C1_bsup1;
256 //-- cout<<" C1_binf2:"<<C1_binf2;
257 //-- cout<<" C1_bsup2:"<<C1_bsup2<<endl;
258 //----------------------------------------------------------------
259 //-- Mise en forme des resultats :
260 //-- Les calculs ont ete fait dans le repere x1,y1, (O1,O2)
261 //-- On se ramene au repere propre a C1
262
263 gp_Vec2d Axe1=C1.XAxis().Direction();
264 gp_Vec2d AxeO1O2=gp_Vec2d(C1.Location(),C2.Location());
265
266 Standard_Real dAngle1;
267 if(AxeO1O2.Magnitude() <= gp::Resolution())
268 dAngle1=Axe1.Angle(C2.XAxis().Direction());
269 else
270 dAngle1=Axe1.Angle(AxeO1O2);
271
272 if(C1.IsDirect() == Standard_False) {
273 dAngle1 = -dAngle1;
274 }
275
276
277 C1_binf1+=dAngle1; C1_bsup1+=dAngle1;
278
279 //-- par construction aucun des segments ne peut exceder PI
280 //-- (permet de ne pas gerer trop de cas differents)
281
282 C1_Res1.SetValues(C1_binf1,C1_bsup1);
c6541a0c 283 if(C1_Res1.Length() > M_PI) C1_Res1.Complement();
7fd59977 284
285 if(nbsol==2) {
286 C1_binf2+=dAngle1; C1_bsup2+=dAngle1;
287 C1_Res2.SetValues(C1_binf2,C1_bsup2);
c6541a0c 288 if(C1_Res2.Length() > M_PI) C1_Res2.Complement();
7fd59977 289 }
290 else {
291 C1_Res2.SetNull();
292 }
293}
294//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
295//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
296void ProjectOnLAndIntersectWithLDomain(const gp_Circ2d& Circle
297 ,const gp_Lin2d& Line
298 ,PeriodicInterval& CDomainAndRes
299 ,Interval& LDomain
300 ,PeriodicInterval* CircleSolution
301 ,Interval* LineSolution
302 ,Standard_Integer &NbSolTotal
303 ,const IntRes2d_Domain& RefLineDomain
304// ,const IntRes2d_Domain& )
305 ,const IntRes2d_Domain& )
306{
307
308
309 if(CDomainAndRes.IsNull()) return;
310 //-------------------------------------------------------------------------
311 //-- On cherche l intervalle correspondant sur C2
312 //-- Puis on intersecte l intervalle avec le domaine de C2
313 //-- Enfin, on cherche l intervalle correspondant sur C1
314 //--
315
316 Standard_Real Linf=ElCLib::Parameter(Line
317 ,ElCLib::CircleValue(CDomainAndRes.Binf
318 ,Circle.Axis()
319 ,Circle.Radius()));
320 Standard_Real Lsup=ElCLib::Parameter(Line
321 ,ElCLib::CircleValue(CDomainAndRes.Bsup
322 ,Circle.Axis()
323 ,Circle.Radius()));
324
325 Interval LInter(Linf,Lsup); //-- Necessairement Borne
326
327 Interval LInterAndDomain=LDomain.IntersectionWithBounded(LInter);
328
329 if(!LInterAndDomain.IsNull) {
330
331 Standard_Real DomLinf = (RefLineDomain.HasFirstPoint())? RefLineDomain.FirstParameter() : -Precision::Infinite();
332 Standard_Real DomLsup = (RefLineDomain.HasLastPoint())? RefLineDomain.LastParameter() : Precision::Infinite();
333
334 Linf = LInterAndDomain.Binf;
335 Lsup = LInterAndDomain.Bsup;
336
337 if(Linf<DomLinf) {
338 Linf = DomLinf;
339 }
340 if(Lsup<DomLinf) {
341 Lsup = DomLinf;
342 }
343
344 if(Linf>DomLsup) {
345 Linf = DomLsup;
346 }
347 if(Lsup>DomLsup) {
348 Lsup = DomLsup;
349 }
350
351 LInterAndDomain.Binf = Linf;
352 LInterAndDomain.Bsup = Lsup;
353
354#if 0
355 Standard_Real Cinf =
356 ElCLib::CircleParameter(Circle.Axis()
357 ,ElCLib::LineValue(LInterAndDomain.Binf,
358 Line.Position()));
359 Standard_Real Csup =
360 ElCLib::CircleParameter(Circle.Axis()
361 ,ElCLib::LineValue(LInterAndDomain.Bsup
362 ,Line.Position()));
363
364 if(Cinf<CDomainAndRes.Binf) Cinf = CDomainAndRes.Binf;
365 if(Csup>CDomainAndRes.Bsup) Csup = CDomainAndRes.Bsup;
366#else
367 Standard_Real Cinf=CDomainAndRes.Binf;
368 Standard_Real Csup=CDomainAndRes.Bsup;
369#endif
370 if(Cinf>=Csup) { Cinf = CDomainAndRes.Binf; Csup = CDomainAndRes.Bsup; }
371 CircleSolution[NbSolTotal]=PeriodicInterval(Cinf,Csup);
c6541a0c 372 if(CircleSolution[NbSolTotal].Length() > M_PI)
7fd59977 373 CircleSolution[NbSolTotal].Complement();
374
375 LineSolution[NbSolTotal]=LInterAndDomain;
376 NbSolTotal++;
377 }
378}
bd05fabf
S
379
380//=======================================================================
381//function : LineCircleGeometricIntersection
382//purpose :
7fd59977 383//~~ On cherche des segments d intersection dans le `tuyau`
384//~~ R+Tol R-Tol ( Tol est TolConf : Tolerance de confusion d arc)
385//~~ On Cherche un point d intersection a une distance TolTang du cercle.
bd05fabf
S
386//=======================================================================
387void LineCircleGeometricIntersection(const gp_Lin2d& Line,
388 const gp_Circ2d& Circle,
389 const Standard_Real Tol,
390 const Standard_Real TolTang,
391 PeriodicInterval& CInt1,
392 PeriodicInterval& CInt2,
393 Standard_Integer& nbsol)
394{
7fd59977 395
396
397 Standard_Real dO1O2=Line.Distance(Circle.Location());
398 Standard_Real R=Circle.Radius();
7fd59977 399 Standard_Real RmTol=R-Tol;
400 Standard_Real binf1,binf2=0,bsup1,bsup2=0;
401
402 //----------------------------------------------------------------
403 if(dO1O2 > (R+Tol)) { //-- pas d intersection avec le 'tuyau'
404 if(dO1O2 > (R+TolTang)) {
405 nbsol=0;
406 return;
407 }
408 else {
409 binf1=0.0;
410 bsup1=0.0;
411 nbsol=1;
412 }
413 }
414 else {
415 //----------------------------------------------------------------
bd05fabf 416 Standard_Boolean b2Sol;
7fd59977 417 Standard_Real dAlpha1;
418 //---------------------------------------------------------------
419 //-- Line coupe le cercle Circle+ (=C(x1,y1,R1+Tol))
bd05fabf
S
420 b2Sol=Standard_False;
421 if (R>dO1O2+TolTang) {
422 Standard_Real aX2, aTol2;
423 //
424 aTol2=Tol*Tol;
425 aX2=4.*(R*R-dO1O2*dO1O2);
426 if (aX2>aTol2) {
427 b2Sol=!b2Sol;
428 }
429 }
430 if(dO1O2 > RmTol && !b2Sol) {
431 //if(dO1O2 > RmTol) {
7fd59977 432 Standard_Real dx=dO1O2;
433 Standard_Real dy=0.0; //(RpTol*RpTol-dx*dx); //Patch !!!
434 dy=(dy>=0.0)? Sqrt(dy) : 0.0;
435 dAlpha1=ATan2(dy,dx);
436
437 binf1=-dAlpha1;
438 bsup1=dAlpha1;
439 nbsol=1;
440 }
441 //--------------------------------------------------------------------
442 //-- 2 segments donnes par Inter Line avec Circle- Circle+
443 //--
444 else {
445 //------------------- Intersection Line Circle+ --------------------------
446 Standard_Real dx=dO1O2;
447 Standard_Real dy=R*R-dx*dx; //(RpTol*RpTol-dx*dx); //Patch !!!
448 dy=(dy>=0.0)? Sqrt(dy) : 0.0;
449
450 dAlpha1=ATan2(dy,dx);
451 binf1=-dAlpha1; bsup2=dAlpha1; //-- |...? ?...| Sur C1
452
453 //------------------ Intersection Line Circle- -------------------------
454 dy=R*R-dx*dx; //(RmTol*RmTol-dx*dx); //Patch !!!
455 dy=(dy>=0.0)? Sqrt(dy) : 0.0;
456 dAlpha1=ATan2(dy,dx);
457
458 binf2=dAlpha1; bsup1=-dAlpha1; //-- |...x x...| Sur C1
459
460 if((dAlpha1*R)<(Max(Tol,TolTang))) {
461 bsup1 = bsup2;
462 nbsol = 1;
463 }
464 else {
465 nbsol=2;
466 }
467 }
468 }
469 //--------------------------------------------------------------
470 //-- Mise en forme des resultats :
471 //-- Les calculs ont ete fait dans le repere x1,y1, (O1,O2)
472 //-- On se ramene au repere propre a C1
473
474 Standard_Real dAngle1=(Circle.XAxis().Direction()).Angle(Line.Direction());
475
476#if 0
477 //---------------------------------------------
478 //-- Si le cercle est indirect alors l origine
479 //-- est vue en -dAngle1.
480 //--
481 if(Circle.IsDirect() == Standard_False) {
482 dAngle1 = -dAngle1;
483 }
484#endif
485
486
487 Standard_Real a,b,c,d;
488 Line.Coefficients(a,b,c);
489
490 d = a*Circle.Location().X() + b*Circle.Location().Y() + c;
491
492 if(d>0.0) dAngle1+= PIsur2;
493 else dAngle1-= PIsur2;
494
495
496 if(dAngle1<0.0) dAngle1+=PIpPI;
497 else if(dAngle1>PIpPI) dAngle1-=PIpPI;
498
499
500 binf1+=dAngle1; bsup1+=dAngle1;
501
502 //-- par construction aucun des segments ne peut exceder PI
503 //-- (permet de ne pas gerer trop de cas differents)
504
505 if(Circle.IsDirect() == Standard_False) {
506 Standard_Real t=binf1; binf1=bsup1; bsup1=t;
507 binf1 = -binf1;
508 bsup1 = -bsup1;
509 }
510
511
512 CInt1.SetValues(binf1,bsup1);
c6541a0c 513 if(CInt1.Length() > M_PI) CInt1.Complement();
7fd59977 514
515
516 if(nbsol==2) {
517 binf2+=dAngle1; bsup2+=dAngle1;
518
519 if(Circle.IsDirect() == Standard_False) {
520 Standard_Real t=binf2; binf2=bsup2; bsup2=t;
521 binf2 = -binf2;
522 bsup2 = -bsup2;
523 }
524
525 CInt2.SetValues(binf2,bsup2);
c6541a0c 526 if(CInt2.Length() > M_PI) CInt2.Complement();
7fd59977 527 }
528// Modified by Sergey KHROMOV - Thu Oct 26 17:51:05 2000 Begin
529 else {
530 if (CInt1.Bsup > PIpPI && CInt1.Binf < PIpPI) {
531 nbsol = 2;
532 binf2 = CInt1.Binf;
533 bsup2 = PIpPI;
534 binf1 = 0.;
535 CInt1.SetValues(binf1,CInt1.Bsup - PIpPI);
c6541a0c 536 if(CInt1.Length() > M_PI) CInt1.Complement();
7fd59977 537 CInt2.SetValues(binf2,bsup2);
c6541a0c 538 if(CInt2.Length() > M_PI) CInt2.Complement();
7fd59977 539 }
540 }
541// Modified by Sergey KHROMOV - Thu Oct 26 17:51:13 2000 End
542}
543//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
544//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
545void DomainIntersection(const IntRes2d_Domain& Domain
546 ,const Standard_Real U1inf
547 ,const Standard_Real U1sup
548 ,Standard_Real& Res1inf
549 ,Standard_Real& Res1sup
550 ,IntRes2d_Position& PosInf
551 ,IntRes2d_Position& PosSup) {
552
553 if(Domain.HasFirstPoint()) {
554 if(U1sup < (Domain.FirstParameter()-Domain.FirstTolerance())) {
ba5ab97f 555 Res1inf=1; Res1sup=-1;
556 return;
557 }
7fd59977 558 if(U1inf>(Domain.FirstParameter()+Domain.FirstTolerance())) {
ba5ab97f 559 Res1inf=U1inf;
560 PosInf=IntRes2d_Middle;
7fd59977 561 }
562 else {
563 Res1inf=Domain.FirstParameter();
564 PosInf=IntRes2d_Head;
565 }
566 }
567 else {
568 Res1inf=U1inf;
569 PosInf=IntRes2d_Middle;
570 }
571
572 if(Domain.HasLastPoint()) {
573 if(U1inf >(Domain.LastParameter()+Domain.LastTolerance())) {
574 Res1inf=1; Res1sup=-1;
575 return;
576 }
577 if(U1sup<(Domain.LastParameter()-Domain.LastTolerance())) {
ba5ab97f 578 Res1sup=U1sup;
579 PosSup=IntRes2d_Middle;
7fd59977 580 }
581 else {
582 Res1sup=Domain.LastParameter();
583 PosSup=IntRes2d_End;
584 }
585 }
586 else {
587 Res1sup=U1sup;
588 PosSup=IntRes2d_Middle;
589 }
590 //-- Si un des points est en bout ,
591 //-- on s assure que les parametres sont corrects
592 if(Res1inf>Res1sup) {
593 if(PosSup==IntRes2d_Middle) {
594 Res1sup=Res1inf;
595 }
596 else {
597 Res1inf=Res1sup;
598 }
599 }
600 //--- Traitement des cas ou une intersection vraie est dans la tolerance
601 //-- d un des bouts
c2b14317 602 /*if(PosInf==IntRes2d_Head) {
7fd59977 603 if(Res1sup <= (Res1inf+Domain.FirstTolerance())) {
604 Res1sup=Res1inf;
ba5ab97f 605 PosSup=IntRes2d_Head;
7fd59977 606 }
ba5ab97f 607}
7fd59977 608 if(PosSup==IntRes2d_End) {
609 if(Res1inf >= (Res1sup-Domain.LastTolerance())) {
610 Res1inf=Res1sup;
611 PosInf=IntRes2d_End;
612 }
c2b14317 613 }*/
7fd59977 614}
615//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
616//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
617void LineLineGeometricIntersection(const gp_Lin2d& L1
618 ,const gp_Lin2d& L2
619 ,const Standard_Real Tol
620 ,Standard_Real& U1
621 ,Standard_Real& U2
622 ,Standard_Real& SinDemiAngle
623 ,Standard_Integer& nbsol) {
624
625 Standard_Real U1x=L1.Direction().X();
626 Standard_Real U1y=L1.Direction().Y();
627 Standard_Real U2x=L2.Direction().X();
628 Standard_Real U2y=L2.Direction().Y();
629 Standard_Real Uo21x = L2.Location().X() - L1.Location().X();
630 Standard_Real Uo21y = L2.Location().Y() - L1.Location().Y();
631
632 Standard_Real D=U1y*U2x-U1x*U2y;
633
634//modified by NIZHNY-MKK Tue Feb 15 10:54:04 2000.BEGIN
635// if(Abs(D)<1e-15) { //-- Droites //
636 if(Abs(D) < TOLERANCE_ANGULAIRE) {
637//modified by NIZHNY-MKK Tue Feb 15 10:54:11 2000.END
638 D=U1y*Uo21x - U1x*Uo21y;
639 nbsol=(Abs(D)<=Tol)? 2 : 0;
640 }
641 else {
642 U1=(Uo21y * U2x - Uo21x * U2y)/D;
643 U2=(Uo21y * U1x - Uo21x * U1y)/D;
644
645 //------------------- Calcul du Sin du demi angle entre L1 et L2
646 //----
647 if(D<0.0) D=-D;
648 if(D>1.0) D=1.0; //-- Deja vu !
649 SinDemiAngle=Sin(0.5*ASin(D));
650 nbsol=1;
651 }
652}
653//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
654//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
655/*IntCurve_IntConicConic::IntCurve_IntConicConic(const gp_Lin2d& L1
656 ,const IntRes2d_Domain& D1
657 ,const gp_Lin2d& L2
658 ,const IntRes2d_Domain& D2
659 ,const Standard_Real TolConf
660 ,const Standard_Real Tol) {
661 Perform(L1,D1,L2,D2,TolConf,Tol);
662}
663
664
665IntCurve_IntConicConic::IntCurve_IntConicConic(const gp_Lin2d& L1
666 ,const IntRes2d_Domain& D1
667 ,const gp_Circ2d& C2
668 ,const IntRes2d_Domain& D2
669 ,const Standard_Real TolConf
670 ,const Standard_Real Tol) {
671
672 Perform(L1,D1,C2,D2,TolConf,Tol);
673}
674
675
676IntCurve_IntConicConic::IntCurve_IntConicConic(const gp_Circ2d& C1
677 ,const IntRes2d_Domain& D1
678 ,const gp_Circ2d& C2
679 ,const IntRes2d_Domain& D2
680 ,const Standard_Real TolConf
681 ,const Standard_Real Tol) {
682 SetReversedParameters(Standard_False);
683 Perform(C1,D1,C2,D2,TolConf,Tol);
684}*/ //amv OCC12547
685//----------------------------------------------------------------------
686void IntCurve_IntConicConic::Perform(const gp_Circ2d& Circle1
687 ,const IntRes2d_Domain& DomainCirc1
688 ,const gp_Circ2d& _Circle2
689 ,const IntRes2d_Domain& _DomainCirc2
690 ,const Standard_Real TolConf,const Standard_Real Tol) {
691
692
693//-- TRES TRES MAL FAIT A REPRENDRE UN JOUR .... (lbr Octobre 98)
694 gp_Circ2d Circle2=_Circle2;
695 IntRes2d_Domain DomainCirc2=_DomainCirc2;
696 Standard_Boolean IndirectCircles=Standard_False;
8696d65d 697 if(Circle1.IsDirect() != _Circle2.IsDirect())
698 {
7fd59977 699 IndirectCircles=Standard_True;
700 Circle2=_Circle2.Reversed();
701 DomainCirc2.SetValues(_DomainCirc2.LastPoint(),
8696d65d 702 PIpPI-_DomainCirc2.LastParameter(),
703 _DomainCirc2.LastTolerance(),
704 _DomainCirc2.FirstPoint(),
705 PIpPI-_DomainCirc2.FirstParameter(),
706 _DomainCirc2.FirstTolerance());
7fd59977 707 DomainCirc2.SetEquivalentParameters(0.0,PIpPI);
708 }
709
710 this->ResetFields();
711 Standard_Integer nbsol=0;
712 PeriodicInterval C1_Int1,C1_Int2;
713
714 //------- Intersection sans tenir compte du domaine ----> nbsol=0,1,2,3
715 CircleCircleGeometricIntersection(Circle1,Circle2,TolConf,Tol,C1_Int1,C1_Int2,nbsol);
716 done=Standard_True;
717
718 if(nbsol==0) { //-- Pas de solutions
719 return;
720 }
721
722 PeriodicInterval C1Domain(DomainCirc1);
723 //-- On se ramene entre 0 et 2PI
724 Standard_Real deltat = C1Domain.Bsup-C1Domain.Binf;
3062fdf9 725 if(deltat>=PIpPI)
726 {
727 // make deltat not including the upper limit
728 deltat=NextAfter(PIpPI, 0.);
729 }
7fd59977 730
8696d65d 731 while(C1Domain.Binf >= PIpPI)
732 C1Domain.Binf-=PIpPI;
733 while(C1Domain.Binf < 0.0)
734 C1Domain.Binf+=PIpPI;
735
7fd59977 736 C1Domain.Bsup=C1Domain.Binf+deltat;
737
738 PeriodicInterval C2Domain(DomainCirc2);
739 deltat = C2Domain.Bsup-C2Domain.Binf;
8696d65d 740 if(deltat>=PIpPI)
741 {
3062fdf9 742 deltat=NextAfter(PIpPI, 0.);
743 }
8696d65d 744
745 while(C2Domain.Binf >= PIpPI)
746 C2Domain.Binf-=PIpPI;
747 while(C2Domain.Binf < 0.0)
748 C2Domain.Binf+=PIpPI;
7fd59977 749
7fd59977 750 C2Domain.Bsup=C2Domain.Binf+deltat;
751
752 Standard_Boolean IdentCircles=Standard_False;
753
8696d65d 754 if(nbsol>2)
755 {
7fd59977 756 //-- Les 2 cercles sont confondus a Tol pres
757 C1_Int1.SetValues(0,PIpPI);
758 C1_Int2.SetNull();
759 //---------------------------------------------------------------
760 //-- Flag utilise pour specifier que les intervalles manipules
761 //-- peuvent etre de longueur superieure a pi.
762 //-- Pour des cercles non identiques, on a necessairement cette
763 //-- condition sur les resultats de l intersection geometrique
764 //-- ce qui permet de normaliser rapidement les intervalles.
765 //-- ex: -1 4 -> longueur > PI
766 //-- donc -1 4 devient 4 , 2*pi-1
767 //---------------------------------------------------------------
768 IdentCircles=Standard_True;
769 }
770
771 Standard_Integer NbSolTotal=0;
772 PeriodicInterval SolutionC1[4];
773 PeriodicInterval SolutionC2[4];
774
775 //----------------------------------------------------------------------
776 //----------- Traitement du premier intervalle Geometrique C1_Int1 ----
777 //----------------------------------------------------------------------
778 //-- NbSolTotal est incremente a chaque Intervalle solution.
779 //-- On stocke les intervalles dans les tableaux : SolutionC1(C2)
780 //-- Dimensionnes a 4 elements.
781 //-- des Exemples faciles donnent 3 Intersections
782 //-- des Problemes numeriques peuvent en donner 4 ??????
783 //--
784 PeriodicInterval C1DomainAndRes=C1Domain.FirstIntersection(C1_Int1);
785
786 ProjectOnC2AndIntersectWithC2Domain(Circle1,Circle2
787 ,C1DomainAndRes
788 ,C2Domain
789 ,SolutionC1,SolutionC2
790 ,NbSolTotal
791 ,IdentCircles);
792 //----------------------------------------------------------------------
793 //-- Seconde Intersection : Par exemple : 2*PI-1 2*PI+1
794 //-- Intersecte avec 0.5 2*PI-0.5
795 //-- Donne les intervalles : 0.5,1 et 2*PI-1,2*PI-0.5
796 //--
797 C1DomainAndRes=C1Domain.SecondIntersection(C1_Int1);
798
799 ProjectOnC2AndIntersectWithC2Domain(Circle1,Circle2
800 ,C1DomainAndRes
801 ,C2Domain
802 ,SolutionC1,SolutionC2
803 ,NbSolTotal
804 ,IdentCircles);
805
806 //----------------------------------------------------------------------
807 //----------- Traitement du second intervalle Geometrique C1_Int2 ----
808 //----------------------------------------------------------------------
8696d65d 809 if(nbsol==2)
810 {
7fd59977 811 C1DomainAndRes=C1Domain.FirstIntersection(C1_Int2);
812
813 ProjectOnC2AndIntersectWithC2Domain(Circle1,Circle2
814 ,C1DomainAndRes
815 ,C2Domain
816 ,SolutionC1,SolutionC2
817 ,NbSolTotal
818 ,IdentCircles);
819 //--------------------------------------------------------------------
820 C1DomainAndRes=C1Domain.SecondIntersection(C1_Int2);
821
822 ProjectOnC2AndIntersectWithC2Domain(Circle1,Circle2
823 ,C1DomainAndRes
824 ,C2Domain
825 ,SolutionC1,SolutionC2
826 ,NbSolTotal
827 ,IdentCircles);
828 }
829 //----------------------------------------------------------------------
830 //-- Calcul de toutes les transitions et Positions.
831 //--
832 //----------------------------------------------------------------------
833 //-- On determine si des intervalles sont reduit a des points
834 //-- ( Rayon * Intervalle.Length() < Tol )
835 //--
836 Standard_Real R1=Circle1.Radius();
837 Standard_Real R2=Circle2.Radius();
838 Standard_Real Tol2=Tol+Tol; //---- Pour eviter de toujours retourner
839 //des segments
840 Standard_Integer i ;
8696d65d 841 if(Tol < (1e-10))
842 Tol2 = 1e-10;
843
844 for( i=0; i<NbSolTotal ; i++)
845 {
846 if(((R1 * SolutionC1[i].Length()) <=Tol2) &&
847 ((R2 * SolutionC2[i].Length())<=Tol2))
848 {
7fd59977 849 Standard_Real t=(SolutionC1[i].Binf+SolutionC1[i].Bsup)*0.5;
850 SolutionC1[i].Binf=SolutionC1[i].Bsup=t;
8696d65d 851
7fd59977 852 t=(SolutionC2[i].Binf+SolutionC2[i].Bsup)*0.5;
853 SolutionC2[i].Binf=SolutionC2[i].Bsup=t;
854 }
855 }
856
857 //----------------------------------------------------------------------
858 //-- Traitement des intervalles (ou des points obtenus)
859 //--
860 gp_Ax22d Axis2C1=Circle1.Axis();
861 gp_Ax22d Axis2C2=Circle2.Axis();
862 gp_Pnt2d P1a,P1b,P2a,P2b;
863 gp_Vec2d Tan1,Tan2,Norm1,Norm2;
864 IntRes2d_Transition T1a,T1b,T2a,T2b;
865 IntRes2d_Position Pos1a,Pos1b,Pos2a,Pos2b;
866
8696d65d 867 Standard_Boolean Opposite =
868 ((Circle1.Location().SquareDistance(Circle2.Location())) > (R1*R1+R2*R2)) ?
869 Standard_True : Standard_False;
7fd59977 870
871 //if(Circle1.IsDirect()) { cout<<" C1 Direct"<<endl; } else { cout<<" C1 INDirect"<<endl; }
872 //if(Circle2.IsDirect()) { cout<<" C2 Direct"<<endl; } else { cout<<" C2 INDirect"<<endl; }
873
8696d65d 874 for(i=0; i<NbSolTotal; i++)
875 {
7fd59977 876 Standard_Real C2inf=(Opposite)? SolutionC2[i].Bsup : SolutionC2[i].Binf;
877 Standard_Real C2sup=(Opposite)? SolutionC2[i].Binf : SolutionC2[i].Bsup;
8696d65d 878 Standard_Real C1tinf = SolutionC1[i].Binf, C2tinf = C2inf;
879 Standard_Real C1inf=NormalizeOnCircleDomain(C1tinf,DomainCirc1);
880 C2inf=NormalizeOnCircleDomain(C2tinf,DomainCirc2);
7fd59977 881
8696d65d 882 Standard_Boolean isOutOfRange = Standard_False;
883 if(C1inf < DomainCirc1.FirstParameter())
884 {
885 if(C1tinf < DomainCirc1.FirstParameter())
886 {
887 C1inf = DomainCirc1.FirstParameter();
888 isOutOfRange = Standard_True;
889 }
890 else
891 {
892 C1inf = C1tinf;
893 }
894 }
7fd59977 895
8696d65d 896 if(C1inf > DomainCirc1.LastParameter())
897 {
898 if(C1tinf > DomainCirc1.LastParameter())
899 {
900 C1inf = DomainCirc1.LastParameter();
901 isOutOfRange = Standard_True;
902 }
903 else
904 {
905 C1inf = C1tinf;
906 }
907 }
908
909 if(C2inf < DomainCirc2.FirstParameter())
910 {
911 if(C2tinf < DomainCirc2.FirstParameter())
912 {
913 C2inf = DomainCirc2.FirstParameter();
914 isOutOfRange = Standard_True;
915 }
916 else
917 {
918 C2inf = C2tinf;
919 }
920 }
921
922 if(C2inf > DomainCirc2.LastParameter())
923 {
924 if(C2tinf > DomainCirc2.LastParameter())
925 {
926 C2inf = DomainCirc2.LastParameter();
927 isOutOfRange = Standard_True;
928 }
929 else
930 {
931 C2inf = C2tinf;
932 }
933 }
934
935 if(isOutOfRange)
936 {
937 gp_Pnt2d aP1, aP2;
938 gp_Vec2d aV11, aV12;
939 gp_Vec2d aV21, aV22;
940
941 ElCLib::CircleD2(C1inf,Axis2C1,R1,aP1,aV11,aV12);
942 ElCLib::CircleD2(C2inf,Axis2C2,R2,aP2,aV21,aV22);
943
944 if(aP1.SquareDistance(aP2) > Tol2*Tol2)
945 {//there are not any solutions in given parametric range.
946 continue;
947 }
948 }
949
950 if(IndirectCircles)
951 {
7fd59977 952 ElCLib::CircleD2(C1inf,Axis2C1,R1,P1a,Tan1,Norm1);
953 ElCLib::CircleD2(C2inf,Axis2C2,R2,P2a,Tan2,Norm2);
954 Tan2.Reverse();
955
956 IntImpParGen::DeterminePosition(Pos1a,DomainCirc1,P1a,C1inf);
957 IntImpParGen::DeterminePosition(Pos2a,_DomainCirc2,P2a,PIpPI-C2inf);
958 Determine_Transition_LC(Pos1a,Tan1,Norm1,T1a , Pos2a,Tan2,Norm2,T2a, Tol);
959
960
961 IntRes2d_IntersectionPoint NewPoint1(P1a,C1inf,PIpPI-C2inf,T1a,T2a,Standard_False);
962
8696d65d 963 if((SolutionC1[i].Length()>0.0 ) || (SolutionC2[i].Length() >0.0))
964 {
965 //-- On traite un intervalle non reduit a un point
966 Standard_Real C1sup=NormalizeOnCircleDomain(SolutionC1[i].Bsup,DomainCirc1);
967 if(C1sup<C1inf) C1sup+=PIpPI;
968 C2sup=NormalizeOnCircleDomain(C2sup,DomainCirc2);
969
970 ElCLib::CircleD2(C1sup,Axis2C1,R1,P1b,Tan1,Norm1);
971 ElCLib::CircleD2(C2sup,Axis2C2,R2,P2b,Tan2,Norm2);
972 Tan2.Reverse();
973
974 IntImpParGen::DeterminePosition(Pos1b,DomainCirc1,P1b,C1sup);
975 IntImpParGen::DeterminePosition(Pos2b,_DomainCirc2,P2b,PIpPI-C2sup);
976 Determine_Transition_LC(Pos1b,Tan1,Norm1,T1b , Pos2b,Tan2,Norm2,T2b, Tol);
977
978 //--------------------------------------------------
979
980 if(Opposite)
981 {
982 if(nbsol!=3)
983 {
984 if(C2inf<C2sup)
985 C2inf+=PIpPI;
986 }
987 }
988 else
989 {
990 if(nbsol!=3)
991 {
992 if(C2sup<C2inf) C2sup+=PIpPI;
993 }
994 }
995
996 IntRes2d_IntersectionPoint NewPoint2(P1b,C1sup,PIpPI-C2sup,T1b,T2b,Standard_False);
997 IntRes2d_IntersectionSegment NewSeg(NewPoint1,NewPoint2,
998 (Opposite==Standard_True)? Standard_False : Standard_True,
999 Standard_False);
1000 Append(NewSeg);
7fd59977 1001 }
8696d65d 1002 else
1003 {
1004 Append(NewPoint1);
7fd59977 1005 }
7fd59977 1006 }
8696d65d 1007 else
1008 {
7fd59977 1009 ElCLib::CircleD2(C1inf,Axis2C1,R1,P1a,Tan1,Norm1);
1010 ElCLib::CircleD2(C2inf,Axis2C2,R2,P2a,Tan2,Norm2);
1011
1012 IntImpParGen::DeterminePosition(Pos1a,DomainCirc1,P1a,C1inf);
1013 IntImpParGen::DeterminePosition(Pos2a,DomainCirc2,P2a,C2inf);
1014 Determine_Transition_LC(Pos1a,Tan1,Norm1,T1a , Pos2a,Tan2,Norm2,T2a, Tol);
1015
1016
1017 IntRes2d_IntersectionPoint NewPoint1(P1a,C1inf,C2inf,T1a,T2a,Standard_False);
1018
8696d65d 1019 if((SolutionC1[i].Length()>0.0 ) || (SolutionC2[i].Length() >0.0))
1020 {
1021 //-- On traite un intervalle non reduit a un point
1022 Standard_Real C1sup=NormalizeOnCircleDomain(SolutionC1[i].Bsup,DomainCirc1);
1023 if(C1sup<C1inf) C1sup+=PIpPI;
1024 C2sup=NormalizeOnCircleDomain(C2sup,DomainCirc2);
1025
1026 ElCLib::CircleD2(C1sup,Axis2C1,R1,P1b,Tan1,Norm1);
1027 ElCLib::CircleD2(C2sup,Axis2C2,R2,P2b,Tan2,Norm2);
1028
1029 IntImpParGen::DeterminePosition(Pos1b,DomainCirc1,P1b,C1sup);
1030 IntImpParGen::DeterminePosition(Pos2b,DomainCirc2,P2b,C2sup);
1031 Determine_Transition_LC(Pos1b,Tan1,Norm1,T1b , Pos2b,Tan2,Norm2,T2b, Tol);
1032
1033 //--------------------------------------------------
1034
1035 if(Opposite)
1036 {
8696d65d 1037 if(C2inf<C2sup)
1038 C2inf+=PIpPI;
8696d65d 1039 }
1040 else
1041 {
8696d65d 1042 if(C2sup<C2inf)
1043 C2sup+=PIpPI;
8696d65d 1044 }
1045
1046 IntRes2d_IntersectionPoint NewPoint2(P1b,C1sup,C2sup,T1b,T2b,Standard_False);
1047 IntRes2d_IntersectionSegment NewSeg(NewPoint1,NewPoint2,Opposite,Standard_False);
1048 Append(NewSeg);
7fd59977 1049 }
8696d65d 1050 else
1051 {
1052 Append(NewPoint1);
7fd59977 1053 }
1054 }
1055 }
1056}
1057//----------------------------------------------------------------------
1058IntRes2d_Position FindPositionLL(Standard_Real &Param
c2b14317
G
1059 ,const IntRes2d_Domain& Domain)
1060{
1061 Standard_Real aDPar = Precision::Infinite();
1062 IntRes2d_Position aPos = IntRes2d_Middle;
1063 Standard_Real aResPar = Param;
7fd59977 1064 if(Domain.HasFirstPoint()) {
c2b14317
G
1065 aDPar = Abs(Param-Domain.FirstParameter());
1066 if( aDPar <= Domain.FirstTolerance()) {
1067 aResPar=Domain.FirstParameter();
1068 aPos = IntRes2d_Head;
1069
7fd59977 1070 }
1071 }
1072 if(Domain.HasLastPoint()) {
c2b14317
G
1073 Standard_Real aD2 = Abs(Param-Domain.LastParameter());
1074 if( aD2 <= Domain.LastTolerance() && (aPos == IntRes2d_Middle || aD2 < aDPar ))
1075 {
1076 aResPar=Domain.LastParameter();
1077 aPos = IntRes2d_End;
7fd59977 1078 }
1079 }
c2b14317
G
1080 Param = aResPar;
1081 return aPos;
7fd59977 1082}
c2b14317
G
1083//--------------------------------------------------------------------
1084//gka 0022833
1085// Method to compute of point of intersection for case
1086//when specified domain less than specified tolerance for intersection
1087static inline void getDomainParametrs(const IntRes2d_Domain& theDomain,
1088 Standard_Real& theFirst,
1089 Standard_Real& theLast,
1090 Standard_Real& theTol1,
1091 Standard_Real& theTol2)
1092{
1093 theFirst = (theDomain.HasFirstPoint() ? theDomain.FirstParameter() : -Precision::Infinite());
1094 theLast = (theDomain.HasLastPoint() ? theDomain.LastParameter() : Precision::Infinite());
1095 theTol1 = (theDomain.HasFirstPoint() ? theDomain.FirstTolerance() : 0.);
1096 theTol2 = (theDomain.HasLastPoint() ? theDomain.LastTolerance() : 0.);
1097}
1098
1099
420399e3 1100//=======================================================================
1101//function : computeIntPoint
1102//purpose :
1103//=======================================================================
c2b14317 1104static Standard_Boolean computeIntPoint(const IntRes2d_Domain& theCurDomain,
420399e3 1105 const IntRes2d_Domain& theDomainOther,
1106 const gp_Lin2d& theCurLin,
1107 const gp_Lin2d& theOtherLin,
1108 Standard_Real theCosT1T2,
1109 Standard_Real theParCur, Standard_Real theParOther,
1110 Standard_Real& theResInf, Standard_Real& theResSup,
1111 Standard_Integer theNum,
1112 IntRes2d_TypeTrans theCurTrans,
1113 IntRes2d_IntersectionPoint& theNewPoint)
c2b14317
G
1114{
1115 if(fabs(theResSup-theParCur) > fabs(theResInf-theParCur))
1116 theResSup = theResInf;
1117
1118 Standard_Real aRes2 = theParOther + (theResSup - theParCur) * theCosT1T2;
1119
420399e3 1120 Standard_Real aFirst2, aLast2, aTol21, aTol22, aTol11, aTol12 ;
1121
1122 getDomainParametrs(theDomainOther,aFirst2, aLast2, aTol21, aTol22);
1123
1124 if( aRes2 < aFirst2 - aTol21 || aRes2 > aLast2 + aTol22 ) {
1125 return Standard_False;
1126 }
c2b14317
G
1127
1128 //------ compute parameters of intersection point --
1129 IntRes2d_Transition aT1,aT2;
1130 IntRes2d_Position aPos1a = FindPositionLL(theResSup,theCurDomain);
1131 IntRes2d_Position aPos2a = FindPositionLL(aRes2,theDomainOther);
1132 IntRes2d_TypeTrans anOtherTrans = ( theCurTrans == IntRes2d_Out ?
1133 IntRes2d_In : ( theCurTrans == IntRes2d_In ? IntRes2d_Out : IntRes2d_Undecided ) );
1134
1135 if( theCurTrans != IntRes2d_Undecided )
1136 {
1137 aT1.SetValue(Standard_False, aPos1a, theCurTrans);
1138 aT2.SetValue(Standard_False, aPos2a, anOtherTrans);
1139 }
1140 else
1141 {
1142 Standard_Boolean anOpposite = theCosT1T2 < 0.;
1143 aT1.SetValue(Standard_False,aPos1a,IntRes2d_Unknown,anOpposite);
1144 aT2.SetValue(Standard_False,aPos2a,IntRes2d_Unknown,anOpposite);
1145 }
1146 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1147 //--------------------------------------------------
1148 //gka bug 0022833
1149 Standard_Real aResU1 = theParCur;
1150 Standard_Real aResU2 = theParOther;
1151
1152 Standard_Real aFirst1, aLast1;
420399e3 1153 getDomainParametrs(theCurDomain,aFirst1, aLast1, aTol11, aTol12);
c2b14317
G
1154
1155 Standard_Boolean isInside1 = (theParCur >= aFirst1 && theParCur <= aLast1);
1156 Standard_Boolean isInside2 = (theParOther >= aFirst2 && theParOther <= aLast2);
1157
1158 if(!isInside1 || !isInside2)
1159 {
1160 if(isInside1)
1161 {
1162 gp_Pnt2d Pt1=ElCLib::Value(aRes2,theOtherLin);
1163 aResU2 = aRes2;
1164 Standard_Real aPar1 = ElCLib::Parameter(theCurLin,Pt1);
1165 aResU1 =((aPar1 >= aFirst1 && aPar1<= aLast1) ? aPar1 : theResSup);
1166
1167 }
1168 else if(isInside2)
1169 {
1170 gp_Pnt2d aPt1=ElCLib::Value(theResSup,theCurLin);
1171 aResU1 = theResSup;
1172 Standard_Real aPar2 = ElCLib::Parameter(theOtherLin,aPt1);
1173 aResU2= ((aPar2 >= aFirst2 && aPar2<= aLast2) ? aPar2 : aRes2);
1174 }
1175 else
1176 {
420399e3 1177 //PKVf
1178 // check that parameters are within range on both curves
1179 if ( theParCur < aFirst1-aTol11 || theParCur > aLast1+aTol12 ||
1180 theParOther < aFirst2-aTol21 || theParOther > aLast2+aTol22) {
1181 return Standard_False;
1182 }
1183 //PKVt
c2b14317
G
1184 aResU1 = theResSup;
1185 aResU2= aRes2;
1186 }
1187 }
1188 gp_Pnt2d aPres((ElCLib::Value(aResU1,theCurLin).XY() + ElCLib::Value(aResU2,theOtherLin).XY()) * 0.5 );
1189 if(theNum == 1 )
1190 theNewPoint.SetValues(aPres, aResU1, aResU2 ,aT1, aT2, Standard_False);
1191 else
1192 theNewPoint.SetValues(aPres, aResU2, aResU1 ,aT2, aT1, Standard_False);
1193 return Standard_True;
1194}
1195
ba5ab97f 1196//=======================================================================
1197//function : CheckLLCoincidence
1198//purpose : Returns true if input are trimmed curves and they coincide
1199// within tolerance
1200//=======================================================================
1201static Standard_Boolean CheckLLCoincidence(const gp_Lin2d& L1,
1202 const gp_Lin2d& L2,
1203 const IntRes2d_Domain& Domain1,
1204 const IntRes2d_Domain& Domain2,
1205 const Standard_Real theTol)
1206{
1207 Standard_Boolean isFirst1 = (Domain1.HasFirstPoint() &&
1208 L2.Distance(Domain1.FirstPoint()) < theTol);
1209 Standard_Boolean isLast1 = (Domain1.HasLastPoint() &&
1210 L2.Distance(Domain1.LastPoint()) < theTol);
1211 if (isFirst1 && isLast1)
1212 return Standard_True;
1213 Standard_Boolean isFirst2 = (Domain2.HasFirstPoint() &&
1214 L1.Distance(Domain2.FirstPoint()) < theTol);
1215 Standard_Boolean isLast2 = (Domain2.HasLastPoint() &&
1216 L1.Distance(Domain2.LastPoint()) < theTol);
1217 return isFirst2 && isLast2;
1218}
1219
7fd59977 1220//----------------------------------------------------------------------
1221void IntCurve_IntConicConic::Perform(const gp_Lin2d& L1
c2b14317 1222 ,const IntRes2d_Domain& Domain1
7fd59977 1223 ,const gp_Lin2d& L2
1224 ,const IntRes2d_Domain& Domain2
1225 ,const Standard_Real,const Standard_Real TolR) {
1226 this->ResetFields();
1227
1228 //-- Coordonnees du point d intersection sur chacune des 2 droites
1229 Standard_Real U1,U2;
1230 //-- Nombre de points solution : 1 : Intersection
1231 //-- 0 : Non Confondues
1232 //-- 2 : Confondues a la tolerance pres
1233 Standard_Integer nbsol;
1234 IntRes2d_IntersectionPoint PtSeg1,PtSeg2;
1235 Standard_Real SINL1L2;
1236 Standard_Real Tol = TolR;
1237 if(TolR< 1e-10) Tol = 1e-10;
1238
1239
1240 LineLineGeometricIntersection(L1,L2,Tol,U1,U2,SINL1L2,nbsol);
1241
1242 gp_Vec2d Tan1=L1.Direction();
1243 gp_Vec2d Tan2=L2.Direction();
c2b14317
G
1244
1245 Standard_Real aCosT1T2 = Tan1.Dot(Tan2);
1246 Standard_Boolean Opposite=(aCosT1T2 < 0.0)? Standard_True : Standard_False;
7fd59977 1247
1248 done=Standard_True;
1249
ba5ab97f 1250 if(nbsol==1 && CheckLLCoincidence(L1, L2, Domain1, Domain2, Tol))
1251 nbsol = 2;
1252
7fd59977 1253 if(nbsol==1) {
1254 //---------------------------------------------------
1255 //-- d: distance du point I a partir de laquelle les
1256 //-- points de parametre U1+d et U2+-d sont ecartes
1257 //-- d une distance superieure a Tol.
1258 //---------------------------------------------------
1259 IntRes2d_Position Pos1a,Pos2a,Pos1b,Pos2b;
1260 Standard_Real d=Tol/(SINL1L2);
1261 Standard_Real U1inf=U1-d;
1262 Standard_Real U1sup=U1+d;
1263 Standard_Real U1mU2=U1-U2;
1264 Standard_Real U1pU2=U1+U2;
1265 Standard_Real Res1inf,Res1sup;
1266 Standard_Real ProdVectTan;
1267
1268
1269 //---------------------------------------------------
1270 //-- On agrandit la zone U1inf U1sup pour tenir compte
1271 //-- des tolerances des points en bout
1272 //--
1273 if(Domain1.HasFirstPoint()) {
1274 if(L2.Distance(Domain1.FirstPoint()) < Domain1.FirstTolerance()) {
1275 if(U1inf > Domain1.FirstParameter()) {
1276 U1inf = Domain1.FirstParameter();
1277 }
1278 if(U1sup < Domain1.FirstParameter()) {
1279 U1sup = Domain1.FirstParameter();
1280 }
1281 }
1282 }
1283 if(Domain1.HasLastPoint()) {
1284 if(L2.Distance(Domain1.LastPoint()) < Domain1.LastTolerance()) {
1285 if(U1inf > Domain1.LastParameter()) {
1286 U1inf = Domain1.LastParameter();
1287 }
1288 if(U1sup < Domain1.LastParameter()) {
1289 U1sup = Domain1.LastParameter();
1290 }
1291 }
1292 }
1293 if(Domain2.HasFirstPoint()) {
1294 if(L1.Distance(Domain2.FirstPoint()) < Domain2.FirstTolerance()) {
1295 Standard_Real p = ElCLib::Parameter(L1,Domain2.FirstPoint());
1296 if(U1inf > p) {
1297 U1inf = p;
1298 }
1299 if(U1sup < p) {
1300 U1sup = p;
1301 }
1302 }
1303 }
1304 if(Domain2.HasLastPoint()) {
1305 if(L1.Distance(Domain2.LastPoint()) < Domain2.LastTolerance()) {
1306 Standard_Real p = ElCLib::Parameter(L1,Domain2.LastPoint());
1307 if(U1inf > p) {
1308 U1inf = p;
1309 }
1310 if(U1sup < p) {
1311 U1sup = p;
1312 }
1313 }
1314 }
1315 //-----------------------------------------------------------------
1316
1317 DomainIntersection(Domain1,U1inf,U1sup,Res1inf,Res1sup,Pos1a,Pos1b);
1318
1319 if((Res1sup-Res1inf)<0.0) {
1320 //-- Si l intersection est vide
1321 //--
1322 }
1323 else { //-- (Domain1 INTER Zone Intersection) non vide
1324
1325 ProdVectTan=Tan1.Crossed(Tan2);
1326
7fd59977 1327 //#####################################################################
1328 //## Longueur Minimale d un segment Sur Courbe 1
1329 //#####################################################################
1330
1331 Standard_Real LongMiniSeg=Tol;
1332
1333
1334 if(((Res1sup-Res1inf)<=LongMiniSeg)
c2b14317
G
1335 || ((Pos1a==Pos1b)&&(Pos1a!=IntRes2d_Middle)))
1336 {
1337 //------------------------------- Un seul Point -------------------
1338 //--- lorsque la longueur du segment est inferieure a ??
1339 //--- ou si deux points designent le meme bout
1340 //gka #0022833
1341 IntRes2d_TypeTrans aCurTrans = ( ProdVectTan >= TOLERANCE_ANGULAIRE ?
1342 IntRes2d_Out : ( ProdVectTan <= -TOLERANCE_ANGULAIRE ? IntRes2d_In : IntRes2d_Undecided ) );
1343
1344 IntRes2d_IntersectionPoint NewPoint1;
1345 if( computeIntPoint(Domain1, Domain2, L1, L2, aCosT1T2, U1, U2, Res1inf, Res1sup, 1, aCurTrans, NewPoint1 ) )
1346 Append(NewPoint1);
1347
1348 //------------------------------------------------------
1349
1350
ba5ab97f 1351 } //--------------- Fin du cas : 1 seul point --------------------
7fd59977 1352
1353 else {
1354 //-- Intersection AND Domain1 --------> Segment ---------------------
1355 Standard_Real U2inf,U2sup;
1356 Standard_Real Res2inf,Res2sup;
1357
1358 if(Opposite) { U2inf = U1pU2 -Res1sup; U2sup= U1pU2-Res1inf; }
1359 else { U2inf = Res1inf-U1mU2; U2sup= Res1sup-U1mU2; }
1360
1361 DomainIntersection(Domain2,U2inf,U2sup,Res2inf,Res2sup,Pos2a,Pos2b);
1362
1363 //####################################################################
1364 //## Test sur la longueur minimale d un segment sur Ligne2
1365 //####################################################################
1366 Standard_Real Res2sup_m_Res2inf = Res2sup-Res2inf;
1367 if(Res2sup_m_Res2inf < 0.0) {
1368 //-- Pas de solutions On retourne Vide
1369 }
1370 else if(((Res2sup-Res2inf) > LongMiniSeg)
1371 || ((Pos2a==Pos2b)&&(Pos2a!=IntRes2d_Middle))) {
1372 //----------- Calcul des attributs du segment --------------
1373 //-- Attention, les bornes Res1inf(sup) bougent donc il faut
1374 //-- eventuellement recalculer les attributs
1375
1376 if(Opposite) { Res1inf=U1pU2-Res2sup; Res1sup=U1pU2-Res2inf;
1377 Standard_Real Tampon=Res2inf; Res2inf=Res2sup; Res2sup=Tampon;
1378 IntRes2d_Position Pos=Pos2a; Pos2a=Pos2b; Pos2b=Pos;
1379 }
1380 else { Res1inf=U1mU2+Res2inf; Res1sup=U1mU2+Res2sup; }
1381
1382 Pos1a=FindPositionLL(Res1inf,Domain1);
1383 Pos1b=FindPositionLL(Res1sup,Domain1);
1384
1385 IntRes2d_Transition T1a,T2a,T1b,T2b;
1386
1387 if(ProdVectTan>=TOLERANCE_ANGULAIRE) { // &&&&&&&&&&&&&&&
1388 T1a.SetValue(Standard_False,Pos1a,IntRes2d_Out);
1389 T2a.SetValue(Standard_False,Pos2a,IntRes2d_In);
1390 }
1391 else if(ProdVectTan<=-TOLERANCE_ANGULAIRE) {
1392 T1a.SetValue(Standard_False,Pos1a,IntRes2d_In);
1393 T2a.SetValue(Standard_False,Pos2a,IntRes2d_Out);
1394 }
1395 else {
1396 T1a.SetValue(Standard_False,Pos1a,IntRes2d_Unknown,Opposite);
1397 T2a.SetValue(Standard_False,Pos2a,IntRes2d_Unknown,Opposite);
1398 }
1399
1400
1401 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1402 //~~~~~~~ C O N V E N T I O N - S E G M E N T ~~~~~~~
1403 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1404 //~~ On Renvoie un segment dans les cas suivants : ~~
1405 //~~ (1) Extremite L1 L2 ------> Extremite L1 L2 ~~
1406 //~~ (2) Extremite L1 L2 ------> Intersection ~~
1407 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1408
1409 Standard_Boolean ResultIsAPoint=Standard_False;
1410
1411 if(((Res1sup-Res1inf)<=LongMiniSeg)
1412 || (Abs(Res2sup-Res2inf)<=LongMiniSeg)) {
1413 //-- On force la creation d un point
1414 ResultIsAPoint=Standard_True;
1415 }
1416 else {
1417 //------------------------------------------------------------
1418 //-- On traite les cas ou l intersection est situee du
1419 //-- Mauvais cote du domaine
1420 //-- Attention : Res2inf <-> Pos2a Res2sup <-> Pos2b
1421 //-- et Res1inf <-> Pos1a Res1sup <-> Pos1b
1422 //-- avec Res1inf <= Res1sup
1423 //------------------------------------------------------------
1424 //-- Le point sera : Res1inf,Res2inf,T1a(Pos1a),T2a(Pos2a)
1425 //------------------------------------------------------------
1426
1427 if(Pos1a==IntRes2d_Head) {
1428 if(Pos1b!=IntRes2d_End && U1<Res1inf) { ResultIsAPoint=Standard_True; U1=Res1inf; U2=Res2inf; }
1429 }
1430 if(Pos1b==IntRes2d_End) {
1431 if(Pos1a!=IntRes2d_Head && U1>Res1sup) { ResultIsAPoint=Standard_True; U1=Res1sup; U2=Res2sup; }
1432 }
1433
1434 if(Pos2a==IntRes2d_Head) {
1435 if(Pos2b!=IntRes2d_End && U2<Res2inf) { ResultIsAPoint=Standard_True; U2=Res2inf; U1=Res1inf; }
1436 }
1437 else {
1438 if(Pos2a==IntRes2d_End) {
1439 if(Pos2b!=IntRes2d_Head && U2>Res2inf) { ResultIsAPoint=Standard_True; U2=Res2inf; U1=Res1inf; }
1440 }
1441 }
1442 if(Pos2b==IntRes2d_Head) {
1443 if(Pos2a!=IntRes2d_End && U2<Res2sup) { ResultIsAPoint=Standard_True; U2=Res2sup; U1=Res1sup; }
1444 }
1445 else {
1446 if(Pos2b==IntRes2d_End) {
1447 if(Pos2a!=IntRes2d_Head && U2>Res2sup) { ResultIsAPoint=Standard_True; U2=Res2sup; U1=Res1sup; }
1448 }
1449 }
1450 }
1451
1452
1453
1454 if((!ResultIsAPoint) && (Pos1a!=IntRes2d_Middle || Pos2a!=IntRes2d_Middle)) {
7fd59977 1455 if(ProdVectTan>=TOLERANCE_ANGULAIRE) { //&&&&&&&&&&&&&&
1456 T1b.SetValue(Standard_False,Pos1b,IntRes2d_Out);
1457 T2b.SetValue(Standard_False,Pos2b,IntRes2d_In);
1458 }
1459 else if(ProdVectTan<=-TOLERANCE_ANGULAIRE) { //&&&&&&&&&&&&&&
1460 T1b.SetValue(Standard_False,Pos1b,IntRes2d_In);
1461 T2b.SetValue(Standard_False,Pos2b,IntRes2d_Out);
1462 }
1463 else {
1464 T1b.SetValue(Standard_False,Pos1b,IntRes2d_Unknown,Opposite);
1465 T2b.SetValue(Standard_False,Pos2b,IntRes2d_Unknown,Opposite);
1466 }
1467 gp_Pnt2d Ptdebut;
1468 if(Pos1a==IntRes2d_Middle) {
1469 Standard_Real t3;
1470 if(Opposite) {
1471 t3 = (Pos2a == IntRes2d_Head)? Res2sup : Res2inf;
1472 }
1473 else {
1474 t3 = (Pos2a == IntRes2d_Head)? Res2inf : Res2sup;
1475 }
1476 Ptdebut=ElCLib::Value(t3,L2);
1477 Res1inf=ElCLib::Parameter(L1,Ptdebut);
1478 }
1479 else {
1480 Standard_Real t4 = (Pos1a == IntRes2d_Head)? Res1inf : Res1sup;
1481 Ptdebut=ElCLib::Value(t4,L1);
1482 Res2inf=ElCLib::Parameter(L2,Ptdebut);
1483 }
1484 PtSeg1.SetValues(Ptdebut,Res1inf,Res2inf,T1a,T2a,Standard_False);
1485 if(Pos1b!=IntRes2d_Middle || Pos2b!=IntRes2d_Middle) {
1486 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1487 //~~ Ajustement des parametres et du point renvoye
1488 gp_Pnt2d Ptfin;
1489 if(Pos1b==IntRes2d_Middle) {
1490 Ptfin=ElCLib::Value(Res2sup,L2);
1491 Res1sup=ElCLib::Parameter(L1,Ptfin);
1492 }
1493 else {
1494 Ptfin=ElCLib::Value(Res1sup,L1);
1495 Res2sup=ElCLib::Parameter(L2,Ptfin);
1496 }
1497 PtSeg2.SetValues(Ptfin,Res1sup,Res2sup,T1b,T2b,Standard_False);
1498 IntRes2d_IntersectionSegment Segment(PtSeg1,PtSeg2
1499 ,Opposite,Standard_False);
1500 Append(Segment);
1501 }
1502 else { //-- Extremite(L1 ou L2) ------> Point Middle(L1 et L2)
1503
1504 Pos1b=FindPositionLL(U1,Domain1);
1505 Pos2b=FindPositionLL(U2,Domain2);
1506 if(ProdVectTan>=TOLERANCE_ANGULAIRE) {
1507 T1b.SetValue(Standard_False,Pos1b,IntRes2d_Out);
1508 T2b.SetValue(Standard_False,Pos2b,IntRes2d_In);
1509 }
1510 else if(ProdVectTan<=-TOLERANCE_ANGULAIRE) {
1511 T1b.SetValue(Standard_False,Pos1b,IntRes2d_In);
1512 T2b.SetValue(Standard_False,Pos2b,IntRes2d_Out);
1513 }
1514 else {
1515 T1b.SetValue(Standard_False,Pos1b,IntRes2d_Unknown,Opposite);
1516 T2b.SetValue(Standard_False,Pos2b,IntRes2d_Unknown,Opposite);
1517 }
1518
1519 PtSeg2.SetValues(ElCLib::Value(U2,L2),U1,U2,T1b,T2b,Standard_False);
1520
1521 if((Abs(Res1inf-U1) >LongMiniSeg) && (Abs(Res2inf-U2) >LongMiniSeg)) {
1522 IntRes2d_IntersectionSegment Segment(PtSeg1,PtSeg2,Opposite,Standard_False);
1523 Append(Segment);
1524 }
1525 else {
1526 Append(SegmentToPoint(PtSeg1,T1a,T2a,PtSeg2,T1b,T2b));
1527 }
1528 }
1529
1530 } //-- (Pos1a!=IntRes2d_Middle || Pos2a!=IntRes2d_Middle) --
1531 else { //-- Pos1a == Pos2a == Middle
1532 if(Pos1b==IntRes2d_Middle) Pos1b=Pos1a;
1533 if(Pos2b==IntRes2d_Middle) Pos2b=Pos2a;
1534 if(ResultIsAPoint) {
1535 //-- Middle sur le segment A
1536 //--
1537 if(Pos1b!=IntRes2d_Middle || Pos2b!=IntRes2d_Middle) {
1538 gp_Pnt2d Ptfin;
1539 if(Pos1b==IntRes2d_Middle) {
1540 Standard_Real t2;
1541 if(Opposite) {
1542 t2 = (Pos2b == IntRes2d_Head)? Res2sup : Res2inf;
1543 }
1544 else {
1545 t2 = (Pos2b == IntRes2d_Head)? Res2inf : Res2sup;
1546 }
1547 Ptfin=ElCLib::Value(t2,L2);
1548 Res1sup=ElCLib::Parameter(L1,Ptfin);
1549//modified by NIZHNY-MKK Tue Feb 15 10:54:51 2000.BEGIN
1550 Pos1b=FindPositionLL(Res1sup,Domain1);
1551//modified by NIZHNY-MKK Tue Feb 15 10:54:55 2000.END
1552
1553 }
1554 else {
1555 Standard_Real t1 = (Pos1b == IntRes2d_Head)? Res1inf : Res1sup;
1556 Ptfin=ElCLib::Value(t1,L1);
1557 Res2sup=ElCLib::Parameter(L2,Ptfin);
1558//modified by NIZHNY-MKK Tue Feb 15 10:55:08 2000.BEGIN
1559 Pos2b=FindPositionLL(Res2sup,Domain2);
1560//modified by NIZHNY-MKK Tue Feb 15 10:55:11 2000.END
1561 }
1562 if(ProdVectTan>=TOLERANCE_ANGULAIRE) {
1563 T1b.SetValue(Standard_False,Pos1b,IntRes2d_Out);
1564 T2b.SetValue(Standard_False,Pos2b,IntRes2d_In);
1565 }
1566 else if(ProdVectTan<=-TOLERANCE_ANGULAIRE) {
1567 T1b.SetValue(Standard_False,Pos1b,IntRes2d_In);
1568 T2b.SetValue(Standard_False,Pos2b,IntRes2d_Out);
1569 }
1570 else {
1571 T1b.SetValue(Standard_False,Pos1b,IntRes2d_Unknown,Opposite);
1572 T2b.SetValue(Standard_False,Pos2b,IntRes2d_Unknown,Opposite);
1573 }
1574 PtSeg2.SetValues(Ptfin,Res1sup,Res2sup,T1b,T2b,Standard_False);
1575 Append(PtSeg2);
1576 }
1577 else {
1578 Pos1b=FindPositionLL(U1,Domain1);
1579 Pos2b=FindPositionLL(U2,Domain2);
1580
1581 if(ProdVectTan>=TOLERANCE_ANGULAIRE) {
1582 T1b.SetValue(Standard_False,Pos1b,IntRes2d_Out);
1583 T2b.SetValue(Standard_False,Pos2b,IntRes2d_In);
1584 }
1585 else if(ProdVectTan<=-TOLERANCE_ANGULAIRE) {
1586 T1b.SetValue(Standard_False,Pos1b,IntRes2d_In);
1587 T2b.SetValue(Standard_False,Pos2b,IntRes2d_Out);
1588 }
1589 else {
1590 T1b.SetValue(Standard_False,Pos1b,IntRes2d_Unknown,Opposite);
1591 T2b.SetValue(Standard_False,Pos2b,IntRes2d_Unknown,Opposite);
1592 }
1593 PtSeg1.SetValues(ElCLib::Value(U2,L2),U1,U2,T1b,T2b,Standard_False);
1594 Append(PtSeg1);
1595 }
1596 }
1597 else {
1598 PtSeg1.SetValues(ElCLib::Value(U2,L2),U1,U2,T1a,T2a,Standard_False);
1599
1600 if((Pos1b!=IntRes2d_Middle || Pos2b!=IntRes2d_Middle)) {
7fd59977 1601 if(ProdVectTan>=TOLERANCE_ANGULAIRE) {
1602 T1b.SetValue(Standard_False,Pos1b,IntRes2d_Out);
1603 T2b.SetValue(Standard_False,Pos2b,IntRes2d_In);
1604 }
1605 else if(ProdVectTan<=-TOLERANCE_ANGULAIRE) {
1606 T1b.SetValue(Standard_False,Pos1b,IntRes2d_In);
1607 T2b.SetValue(Standard_False,Pos2b,IntRes2d_Out);
1608 }
1609 else {
1610 T1b.SetValue(Standard_False,Pos1b,IntRes2d_Unknown,Opposite);
1611 T2b.SetValue(Standard_False,Pos2b,IntRes2d_Unknown,Opposite);
1612 }
1613 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1614 //~~ Ajustement des parametres et du point renvoye
1615 gp_Pnt2d Ptfin;
1616 if(Pos1b==IntRes2d_Middle) {
1617 Ptfin=ElCLib::Value(Res2sup,L2);
1618 Res1sup=ElCLib::Parameter(L1,Ptfin);
1619 }
1620 else {
1621 Ptfin=ElCLib::Value(Res1sup,L1);
1622 Res2sup=ElCLib::Parameter(L2,Ptfin);
1623 }
1624
1625 PtSeg2.SetValues(Ptfin,Res1sup,Res2sup,T1b,T2b,Standard_False);
1626
1627 if((Abs(U1-Res1sup)>LongMiniSeg)
1628 ||(Abs(U2-Res2sup)>LongMiniSeg)) {
1629 //-- Modif du 1er Octobre 92 (Pour Composites)
1630
1631 IntRes2d_IntersectionSegment Segment(PtSeg1,PtSeg2
1632 ,Opposite,Standard_False);
1633 Append(Segment);
1634 }
1635 else {
1636 Append(SegmentToPoint(PtSeg1,T1a,T2a,PtSeg2,T1b,T2b));
1637 }
1638 }
1639 else {
1640 Append(PtSeg1);
1641 }
1642 }
1643 }
1644 } //----- Fin Creation Segment ----(Res2sup-Res2inf>Tol)-------------
1645 else {
1646 //------ (Intersection And Domain1) AND Domain2 --> Point ------
1647 //-- Attention Res1sup peut etre different de U2
1648 //-- Mais on a Res1sup-Res1inf < Tol
c2b14317 1649
ba5ab97f 1650 //gka #0022833
c2b14317
G
1651 IntRes2d_TypeTrans aCurTrans = ( ProdVectTan >= TOLERANCE_ANGULAIRE ?
1652 IntRes2d_In : ( ProdVectTan <= -TOLERANCE_ANGULAIRE ? IntRes2d_Out : IntRes2d_Undecided ) );
1653
ba5ab97f 1654 IntRes2d_IntersectionPoint NewPoint1;
c2b14317 1655 if( computeIntPoint(Domain2, Domain1, L2, L1, aCosT1T2, U2, U1, Res2inf, Res2sup, 2, aCurTrans, NewPoint1 ) )
ba5ab97f 1656 Append(NewPoint1);
c2b14317 1657
7fd59977 1658 }
1659 }
1660 }
1661 }
1662 else {
1663 if(nbsol==2) { //== Droites confondues a la tolerance pres
1664 //--On traite ici le cas de segments resultats non neccess. bornes
1665 //--
1666 //--On prend la droite D1 comme reference ( pour le sens positif )
1667 //--
1668 Standard_Integer ResHasFirstPoint=0;
1669 Standard_Integer ResHasLastPoint=0;
1d47d8d0 1670 Standard_Real ParamStart = 0.,ParamStart2,ParamEnd = 0.,ParamEnd2;
7fd59977 1671 Standard_Real Org2SurL1=ElCLib::Parameter(L1,L2.Location());
1672 //== 3 : L1 et L2 bornent
1673 //== 2 : L2 borne
1674 //== 1 : L1 borne
1675 if(Domain1.HasFirstPoint()) ResHasFirstPoint=1;
1676 if(Domain1.HasLastPoint()) ResHasLastPoint=1;
1677 if(Opposite) {
1678 if(Domain2.HasLastPoint()) ResHasFirstPoint+=2;
1679 if(Domain2.HasFirstPoint()) ResHasLastPoint+=2;
1680 }
1681 else {
1682 if(Domain2.HasLastPoint()) ResHasLastPoint+=2;
1683 if(Domain2.HasFirstPoint()) ResHasFirstPoint+=2;
1684 }
1685 if(ResHasFirstPoint==0 && ResHasLastPoint==0) {
1686 //~~~~ Creation d un segment infini avec Opposite
1687 Append(IntRes2d_IntersectionSegment(Opposite));
1688 }
1689 else { //-- On obtient au pire une demi-droite
1690 switch(ResHasFirstPoint) {
1691 case 1:
1692 ParamStart=Domain1.FirstParameter();
1693 ParamStart2=(Opposite)? (Org2SurL1-ParamStart)
1694 :(ParamStart-Org2SurL1);
1695 break;
1696 case 2:
1697 if(Opposite) {
1698 ParamStart2=Domain2.LastParameter();
1699 ParamStart=Org2SurL1 - ParamStart2;
1700 }
1701 else {
1702 ParamStart2=Domain2.FirstParameter();
1703 ParamStart=Org2SurL1 + ParamStart2;
1704 }
1705 break;
1706 case 3:
1707 if(Opposite) {
1708 ParamStart2=Domain2.LastParameter();
1709 ParamStart=Org2SurL1 - ParamStart2;
1710 if(ParamStart < Domain1.FirstParameter()) {
1711 ParamStart=Domain1.FirstParameter();
1712 ParamStart2=Org2SurL1 - ParamStart;
1713 }
1714 }
1715 else {
1716 ParamStart2=Domain2.FirstParameter();
1717 ParamStart=Org2SurL1 + ParamStart2;
1718 if(ParamStart < Domain1.FirstParameter()) {
1719 ParamStart=Domain1.FirstParameter();
1720 ParamStart2=ParamStart - Org2SurL1;
1721 }
1722 }
1723 break;
1724 default: //~~~ Segment Infini a gauche
1725 break;
1726 }
1727
1728 switch(ResHasLastPoint) {
1729 case 1:
1730 ParamEnd=Domain1.LastParameter();
1731 ParamEnd2=(Opposite)? (Org2SurL1-ParamEnd)
1732 :(ParamEnd-Org2SurL1);
1733 break;
1734 case 2:
1735 if(Opposite) {
1736 ParamEnd2=Domain2.FirstParameter();
1737 ParamEnd=Org2SurL1 - ParamEnd2;
1738 }
1739 else {
1740 ParamEnd2=Domain2.LastParameter();
1741 ParamEnd=Org2SurL1 + ParamEnd2;
1742 }
1743 break;
1744 case 3:
1745 if(Opposite) {
1746 ParamEnd2=Domain2.FirstParameter();
1747 ParamEnd=Org2SurL1 - ParamEnd2;
1748 if(ParamEnd > Domain1.LastParameter()) {
1749 ParamEnd=Domain1.LastParameter();
1750 ParamEnd2=Org2SurL1 - ParamEnd;
1751 }
1752 }
1753 else {
1754 ParamEnd2=Domain2.LastParameter();
1755 ParamEnd=Org2SurL1 + ParamEnd2;
1756 if(ParamEnd > Domain1.LastParameter()) {
1757 ParamEnd=Domain1.LastParameter();
1758 ParamEnd2=ParamEnd - Org2SurL1;
1759 }
1760 }
1761 default: //~~~ Segment Infini a droite
1762 break;
1763 }
1764
1765 IntRes2d_Transition Tinf,Tsup;
1766
1767 if(ResHasFirstPoint) {
1768 if(ResHasLastPoint) {
1769 //~~~ Creation de la borne superieure
1770 //~~~ L1 : |-------------> ou |-------------->
1771 //~~~ L2 : <------------| ou <----|
1772 if(ParamEnd >= (ParamStart-Tol)) {
1773 //~~~ Creation d un segment
1774 IntRes2d_Position Pos1,Pos2;
1775 Pos1=FindPositionLL(ParamStart,Domain1);
1776 Pos2=FindPositionLL(ParamStart2,Domain2);
1777 Tinf.SetValue(Standard_True,Pos1,IntRes2d_Unknown,Opposite);
1778 Tsup.SetValue(Standard_True,Pos2,IntRes2d_Unknown,Opposite);
1779 IntRes2d_IntersectionPoint P1(ElCLib::Value(ParamStart,L1)
1780 ,ParamStart,ParamStart2
1781 ,Tinf,Tsup,Standard_False);
1782 if(ParamEnd > (ParamStart+Tol)) {
1783 //~~~ Le segment est assez long
1784 Pos1=FindPositionLL(ParamEnd,Domain1);
1785 Pos2=FindPositionLL(ParamEnd2,Domain2);
1786 Tinf.SetValue(Standard_True,Pos1,IntRes2d_Unknown,Opposite);
1787 Tsup.SetValue(Standard_True,Pos2,IntRes2d_Unknown,Opposite);
1788
1789 IntRes2d_IntersectionPoint P2(ElCLib::Value(ParamEnd,L1)
1790 ,ParamEnd,ParamEnd2
1791 ,Tinf,Tsup,Standard_False);
1792 IntRes2d_IntersectionSegment Seg(P1,P2,Opposite,Standard_False);
1793 Append(Seg);
1794 }
1795 else { //~~~~ le segment est de longueur inferieure a Tol
1796 Append(P1);
1797 }
1798 } //-- if( ParamEnd >= ...)
1799 } //-- if(ResHasLastPoint)
1800 else {
1801 //~~~ Creation de la demi droite |----------->
1802 IntRes2d_Position Pos1=FindPositionLL(ParamStart,Domain1);
1803 IntRes2d_Position Pos2=FindPositionLL(ParamStart2,Domain2);
1804 Tinf.SetValue(Standard_True,Pos1,IntRes2d_Unknown,Opposite);
1805 Tsup.SetValue(Standard_True,Pos2,IntRes2d_Unknown,Opposite);
1806
1807 IntRes2d_IntersectionPoint P(ElCLib::Value(ParamStart,L1)
1808 ,ParamStart,ParamStart2
1809 ,Tinf,Tsup,Standard_False);
1810 IntRes2d_IntersectionSegment Seg(P,Standard_True,Opposite,Standard_False);
1811 Append(Seg);
1812 }
1813 }
1814 else {
1815 IntRes2d_Position Pos1=FindPositionLL(ParamEnd,Domain1);
1816 IntRes2d_Position Pos2=FindPositionLL(ParamEnd2,Domain2);
1817 Tinf.SetValue(Standard_True,Pos1,IntRes2d_Unknown,Opposite);
1818 Tsup.SetValue(Standard_True,Pos2,IntRes2d_Unknown,Opposite);
1819
1820 IntRes2d_IntersectionPoint P2(ElCLib::Value(ParamEnd,L1)
1821 ,ParamEnd,ParamEnd2
1822 ,Tinf,Tsup,Standard_False);
1823 IntRes2d_IntersectionSegment Seg(P2,Standard_False,Opposite,Standard_False);
1824 Append(Seg);
1825 //~~~ Creation de la demi droite <-----------|
1826 }
1827 }
1828 }
1829 }
1830}
1831
1832
1833//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1834//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1835void IntCurve_IntConicConic::Perform(const gp_Lin2d& Line
1836 ,const IntRes2d_Domain& LIG_Domain
1837 ,const gp_Circ2d& Circle
1838 ,const IntRes2d_Domain& CIRC_Domain
1839 ,const Standard_Real TolConf,const Standard_Real Tol) {
1840
1841//-- if(! CIRC_Domain.IsClosed()) {
1842//-- Standard_ConstructionError::Raise("Domaine incorrect");
1843//-- }
1844
1845 Standard_Boolean TheReversedParameters=ReversedParameters();
1846 this->ResetFields();
1847 this->SetReversedParameters(TheReversedParameters);
1848
1849 Standard_Integer nbsol=0;
1850 PeriodicInterval CInt1,CInt2;
1851
1852 LineCircleGeometricIntersection(Line,Circle,TolConf,Tol
1853 ,CInt1,CInt2
1854 ,nbsol);
1855
1856 done=Standard_True;
1857
1858 if(nbsol==0) { //-- Pas de solutions
1859 return;
1860 }
1861
1862// Modified by Sergey KHROMOV - Mon Dec 18 11:13:18 2000 Begin
1863 if (nbsol == 2 && CInt2.Bsup == CInt1.Binf + PIpPI) {
1864 Standard_Real FirstBound = CIRC_Domain.FirstParameter();
1865 Standard_Real LastBound = CIRC_Domain.LastParameter();
1866 Standard_Real FirstTol = CIRC_Domain.FirstTolerance();
1867 Standard_Real LastTol = CIRC_Domain.LastTolerance();
1868 if (CInt1.Binf == 0 && FirstBound - FirstTol > CInt1.Bsup) {
1869 nbsol = 1;
1870 CInt1.SetValues(CInt2.Binf, CInt2.Bsup);
1871 } else if (CInt2.Bsup == PIpPI && LastBound + LastTol < CInt2.Binf)
1872 nbsol = 1;
1873 }
1874// Modified by Sergey KHROMOV - Mon Dec 18 11:13:20 2000 End
1875
1876 PeriodicInterval CDomain(CIRC_Domain);
1877 Standard_Real deltat = CDomain.Bsup-CDomain.Binf;
1878 while(CDomain.Binf >= PIpPI) CDomain.Binf-=PIpPI;
1879 while(CDomain.Binf < 0.0) CDomain.Binf+=PIpPI;
1880 CDomain.Bsup=CDomain.Binf+deltat;
1881
1882 //------------------------------------------------------------
1883 //-- Ajout : Jeudi 28 mars 96
1884 //-- On agrandit artificiellement les domaines
1885 Standard_Real BinfModif = CDomain.Binf;
1886 Standard_Real BsupModif = CDomain.Bsup;
1887 BinfModif-=CIRC_Domain.FirstTolerance() / Circle.Radius();
1888 BsupModif+=CIRC_Domain.LastTolerance() / Circle.Radius();
1889 deltat = BsupModif-BinfModif;
1890 if(deltat<=PIpPI) {
1891 CDomain.Binf = BinfModif;
1892 CDomain.Bsup = BsupModif;
1893 }
1894 else {
1895 Standard_Real t=PIpPI-deltat;
1896 t*=0.5;
1897 CDomain.Binf = BinfModif+t;
1898 CDomain.Bsup = BsupModif-t;
1899 }
1900 deltat = CDomain.Bsup-CDomain.Binf;
1901 while(CDomain.Binf >= PIpPI) CDomain.Binf-=PIpPI;
1902 while(CDomain.Binf < 0.0) CDomain.Binf+=PIpPI;
1903 CDomain.Bsup=CDomain.Binf+deltat;
1904 //-- ------------------------------------------------------------
1905
1906 Interval LDomain(LIG_Domain);
1907
1908 Standard_Integer NbSolTotal=0;
1909
1910 PeriodicInterval SolutionCircle[4];
1911 Interval SolutionLine[4];
1912
1913 //----------------------------------------------------------------------
1914 //----------- Traitement du premier intervalle Geometrique CInt1 ----
1915 //----------------------------------------------------------------------
1916 //-- NbSolTotal est incremente a chaque Intervalle solution.
1917 //-- On stocke les intervalles dans les tableaux : SolutionCircle[4]
1918 //-- et SolutionLine[4]
1919 //-- des Exemples faciles donnent 3 Intersections
1920 //-- des Problemes numeriques peuvent peut etre en donner 4 ??????
1921 //--
1922 PeriodicInterval CDomainAndRes=CDomain.FirstIntersection(CInt1);
1923
1924 ProjectOnLAndIntersectWithLDomain(Circle,Line
1925 ,CDomainAndRes
1926 ,LDomain
1927 ,SolutionCircle
1928 ,SolutionLine
1929 ,NbSolTotal
1930 ,LIG_Domain
1931 ,CIRC_Domain);
1932
1933 CDomainAndRes=CDomain.SecondIntersection(CInt1);
1934
1935 ProjectOnLAndIntersectWithLDomain(Circle,Line
1936 ,CDomainAndRes
1937 ,LDomain
1938 ,SolutionCircle
1939 ,SolutionLine
1940 ,NbSolTotal
1941 ,LIG_Domain
1942 ,CIRC_Domain);
1943
1944 //----------------------------------------------------------------------
1945 //----------- Traitement du second intervalle Geometrique C1_Int2 ----
1946 //----------------------------------------------------------------------
1947 if(nbsol==2) {
1948 CDomainAndRes=CDomain.FirstIntersection(CInt2);
1949
1950 ProjectOnLAndIntersectWithLDomain(Circle,Line
1951 ,CDomainAndRes
1952 ,LDomain
1953 ,SolutionCircle
1954 ,SolutionLine
1955 ,NbSolTotal
1956 ,LIG_Domain
1957 ,CIRC_Domain);
1958
1959 //--------------------------------------------------------------------
1960 CDomainAndRes=CDomain.SecondIntersection(CInt2);
1961
1962
1963 ProjectOnLAndIntersectWithLDomain(Circle,Line
1964 ,CDomainAndRes
1965 ,LDomain
1966 ,SolutionCircle
1967 ,SolutionLine
1968 ,NbSolTotal
1969 ,LIG_Domain
1970 ,CIRC_Domain);
1971 }
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981 //----------------------------------------------------------------------
1982 //-- Calcul de toutes les transitions et Positions.
1983 //--
1984 //-- On determine si des intervalles sont reduit a des points
1985 //-- ( Rayon * Intervalle.Length() < TolConf ) ### Modif 19 Nov Tol-->TolConf
1986 //--
1987 Standard_Real R=Circle.Radius();
1988 Standard_Integer i ;
1989 Standard_Real MaxTol = TolConf;
1990 if(MaxTol<Tol) MaxTol = Tol;
1991 if(MaxTol<1.0e-10) MaxTol = 1.0e-10;
1992
1993 for( i=0; i<NbSolTotal ; i++) {
1994 if((R * SolutionCircle[i].Length())<MaxTol
1995 && (SolutionLine[i].Length())<MaxTol) {
1996
1997 Standard_Real t=(SolutionCircle[i].Binf+SolutionCircle[i].Bsup)*0.5;
1998 SolutionCircle[i].Binf=SolutionCircle[i].Bsup=t;
1999
2000 t=(SolutionLine[i].Binf+SolutionLine[i].Bsup)*0.5;
2001 SolutionLine[i].Binf=SolutionLine[i].Bsup=t;
2002 }
2003 }
2004#if 0
2005 if(NbSolTotal == 2) {
2006 if(SolutionLine[0].Binf==SolutionLine[0].BSup) {
2007 if(SolutionLine[1].Binf==SolutionLine[1].BSup) {
2008 if(Abs(SolutionLine[0].Binf-SolutionLine[1].Binf)<TolConf) {
2009 SolutionLine[0].Binf=0.5*(SolutionLine[0].BSup+SolutionLine[1].BSup);
2010 SolutionLine[0].BSup=SolutionLine[0].Binf;
2011 NbSolTotal = 1;
2012 }
2013 }
2014 }
2015 }
2016#endif
2017 //----------------------------------------------------------------------
2018 //-- Traitement des intervalles (ou des points obtenus)
2019 //--
2020 if(NbSolTotal) {
2021 gp_Ax22d CircleAxis=Circle.Axis();
2022 gp_Ax2d LineAxis=Line.Position();
2023 gp_Pnt2d P1a,P2a,P1b,P2b;
2024 gp_Vec2d Tan1,Tan2,Norm1;
2025 gp_Vec2d Norm2(0.0,0.0);
2026 IntRes2d_Transition T1a,T2a,T1b,T2b;
2027 IntRes2d_Position Pos1a,Pos1b,Pos2a,Pos2b;
2028
2029 ElCLib::CircleD1(SolutionCircle[0].Binf,CircleAxis,R,P1a,Tan1);
2030 ElCLib::LineD1(SolutionLine[0].Binf,LineAxis,P2a,Tan2);
2031
2032 Standard_Boolean Opposite=((Tan1.Dot(Tan2))<0.0)? Standard_True : Standard_False;
2033
2034
2035 for(i=0; i<NbSolTotal; i++ ) {
2036
2037
2038 //-- 7 aout 97
2039 //-- On recentre Bin et Bsup de facon a avoir une portion commune avec CIRC_Domain
2040 Standard_Real p1=SolutionCircle[i].Binf;
2041 Standard_Real p2=SolutionCircle[i].Bsup;
2042 Standard_Real q1=CIRC_Domain.FirstParameter();
2043 Standard_Real q2=CIRC_Domain.LastParameter();
2044 //-- |------ CircDomain ------| [-- Sol --]
2045 if(p1>q2) {
2046 do {
2047 p1-=PIpPI;
2048 p2-=PIpPI;
2049 }
2050 while( (p1>q2) );
2051 }
2052 else if(p2<q1) {
2053 do {
2054 p1+=PIpPI;
2055 p2+=PIpPI;
2056 }
2057 while( (p2<q1) );
2058 }
2059 if(p1<q1 && p2>q1) {
2060 p1=q1;
2061 }
2062 if(p1<q2 && p2>q2) {
2063 p2=q2;
2064 }
2065
2066#if 0
2067 if(SolutionCircle[i].Binf!=p1 || SolutionCircle[i].Bsup!=p2) {
2068 printf("\n IntCurve_IntConicConic_1.cxx : (%g , %g) --> (%g , %g)\n",
2069 SolutionCircle[i].Binf,SolutionCircle[i].Bsup,p1,p2);
2070 }
2071#endif
2072 SolutionCircle[i].Binf=p1;
2073 SolutionCircle[i].Bsup=p2;
2074
2075//-- Fin 7 aout 97
2076
2077
2078 Standard_Real Linf=(Opposite)? SolutionLine[i].Bsup : SolutionLine[i].Binf;
2079 Standard_Real Lsup=(Opposite)? SolutionLine[i].Binf : SolutionLine[i].Bsup;
2080
2081 //---------------------------------------------------------------
2082 //-- Si les parametres sur le cercle sont en premier
2083 //-- On doit retourner ces parametres dans l ordre croissant
2084 //---------------------------------------------------------------
2085 if(Linf > Lsup) {
2086 Standard_Real T=SolutionCircle[i].Binf;
2087 SolutionCircle[i].Binf=SolutionCircle[i].Bsup;
2088 SolutionCircle[i].Bsup=T;
2089
2090 T=Linf; Linf=Lsup; Lsup=T;
2091 }
2092
2093
2094 ElCLib::CircleD2(SolutionCircle[i].Binf,CircleAxis,R,P1a,Tan1,Norm1);
2095 ElCLib::LineD1(Linf,LineAxis,P2a,Tan2);
2096
2097 IntImpParGen::DeterminePosition(Pos1a,CIRC_Domain,P1a,SolutionCircle[i].Binf);
2098 IntImpParGen::DeterminePosition(Pos2a,LIG_Domain,P2a,Linf);
2099 Determine_Transition_LC(Pos1a,Tan1,Norm1,T1a , Pos2a,Tan2,Norm2,T2a, Tol);
2100 Standard_Real Cinf;
2101 if(Pos1a==IntRes2d_End) {
2102 Cinf = CIRC_Domain.LastParameter();
2103 P1a = CIRC_Domain.LastPoint();
2104 Linf = ElCLib::Parameter(Line,P1a);
2105
2106 ElCLib::CircleD2(Cinf,CircleAxis,R,P1a,Tan1,Norm1);
2107 ElCLib::LineD1(Linf,LineAxis,P2a,Tan2);
2108 IntImpParGen::DeterminePosition(Pos1a,CIRC_Domain,P1a,Cinf);
2109 IntImpParGen::DeterminePosition(Pos2a,LIG_Domain,P2a,Linf);
2110 Determine_Transition_LC(Pos1a,Tan1,Norm1,T1a , Pos2a,Tan2,Norm2,T2a, Tol);
2111 }
2112 else if(Pos1a==IntRes2d_Head) {
2113 Cinf = CIRC_Domain.FirstParameter();
2114 P1a = CIRC_Domain.FirstPoint();
2115 Linf = ElCLib::Parameter(Line,P1a);
2116
2117 ElCLib::CircleD2(Cinf,CircleAxis,R,P1a,Tan1,Norm1);
2118 ElCLib::LineD1(Linf,LineAxis,P2a,Tan2);
2119 IntImpParGen::DeterminePosition(Pos1a,CIRC_Domain,P1a,Cinf);
2120 IntImpParGen::DeterminePosition(Pos2a,LIG_Domain,P2a,Linf);
2121 Determine_Transition_LC(Pos1a,Tan1,Norm1,T1a , Pos2a,Tan2,Norm2,T2a, Tol);
2122 }
2123 else {
2124 Cinf=NormalizeOnCircleDomain(SolutionCircle[i].Binf,CIRC_Domain);
2125 }
2126
2127 IntRes2d_IntersectionPoint NewPoint1(P1a,Linf,Cinf,T2a,T1a,ReversedParameters());
2128
2129 if((SolutionLine[i].Length()+SolutionCircle[i].Length()) >0.0) {
2130
2131 ElCLib::CircleD2(SolutionCircle[i].Bsup,CircleAxis,R,P1b,Tan1,Norm1);
2132 ElCLib::LineD1(Lsup,LineAxis,P2b,Tan2);
2133
2134 IntImpParGen::DeterminePosition(Pos1b,CIRC_Domain,P1b,SolutionCircle[i].Bsup);
2135 IntImpParGen::DeterminePosition(Pos2b,LIG_Domain,P2b,Lsup);
2136 Determine_Transition_LC(Pos1b,Tan1,Norm1,T1b , Pos2b,Tan2,Norm2,T2b, Tol);
2137 Standard_Real Csup;
2138 if(Pos1b==IntRes2d_End) {
2139 Csup = CIRC_Domain.LastParameter();
2140 P1b = CIRC_Domain.LastPoint();
2141 Lsup = ElCLib::Parameter(Line,P1b);
2142 ElCLib::CircleD2(Csup,CircleAxis,R,P1b,Tan1,Norm1);
2143 ElCLib::LineD1(Lsup,LineAxis,P2b,Tan2);
2144
2145 IntImpParGen::DeterminePosition(Pos1b,CIRC_Domain,P1b,Csup);
2146 IntImpParGen::DeterminePosition(Pos2b,LIG_Domain,P2b,Lsup);
2147 Determine_Transition_LC(Pos1b,Tan1,Norm1,T1b , Pos2b,Tan2,Norm2,T2b, Tol);
2148 }
2149 else if(Pos1b==IntRes2d_Head) {
2150 Csup = CIRC_Domain.FirstParameter();
2151 P1b = CIRC_Domain.FirstPoint();
2152 Lsup = ElCLib::Parameter(Line,P1b);
2153 ElCLib::CircleD2(Csup,CircleAxis,R,P1b,Tan1,Norm1);
2154 ElCLib::LineD1(Lsup,LineAxis,P2b,Tan2);
2155
2156 IntImpParGen::DeterminePosition(Pos1b,CIRC_Domain,P1b,Csup);
2157 IntImpParGen::DeterminePosition(Pos2b,LIG_Domain,P2b,Lsup);
2158 Determine_Transition_LC(Pos1b,Tan1,Norm1,T1b , Pos2b,Tan2,Norm2,T2b, Tol);
2159 }
2160 else {
2161 Csup=NormalizeOnCircleDomain(SolutionCircle[i].Bsup,CIRC_Domain);
2162 }
2163
2164 IntRes2d_IntersectionPoint NewPoint2(P1b,Lsup,Csup,T2b,T1b,ReversedParameters());
2165
2166 if(((Abs(Csup-Cinf)*R > MaxTol) && (Abs(Lsup-Linf) > MaxTol))
2167 || (T1a.TransitionType() != T2a.TransitionType())) {
2168 //-- Verifier egalement les transitions
2169
2170 IntRes2d_IntersectionSegment NewSeg(NewPoint1,NewPoint2
2171 ,Opposite,ReversedParameters());
2172 Append(NewSeg);
2173 }
2174 else {
2175 if(Pos1a!=IntRes2d_Middle || Pos2a!=IntRes2d_Middle) {
2176 Insert(NewPoint1);
2177 }
2178 if(Pos1b!=IntRes2d_Middle || Pos2b!=IntRes2d_Middle) {
2179 Insert(NewPoint2);
2180 }
2181
2182 }
2183 }
2184 else {
2185 //--Standard_Real Cmid=NormalizeOnCircleDomain(0.5*(SolutionCircle[i].Bsup+SolutionCircle[i].Binf)
2186 //-- ,CIRC_Domain);
2187 //--IntRes2d_IntersectionPoint NewPoint(P2a,0.5*(Linf+Lsup)
2188 //-- ,Cmid
2189 //-- ,T2a,T1a,ReversedParameters());
2190 Insert(NewPoint1);
2191 }
2192 }
2193 }
2194}
2195
2196
2197
2198
2199const IntRes2d_IntersectionPoint SegmentToPoint( const IntRes2d_IntersectionPoint& Pa
2200 ,const IntRes2d_Transition& T1a
2201 ,const IntRes2d_Transition& T2a
2202 ,const IntRes2d_IntersectionPoint& Pb
2203 ,const IntRes2d_Transition& T1b
2204 ,const IntRes2d_Transition& T2b) {
2205
2206 if((T1b.PositionOnCurve() == IntRes2d_Middle)
2207 && (T2b.PositionOnCurve() == IntRes2d_Middle)) {
2208 return(Pa);
2209 }
2210 if((T1a.PositionOnCurve() == IntRes2d_Middle)
2211 && (T2a.PositionOnCurve() == IntRes2d_Middle)) {
2212 return(Pb);
2213 }
2214
2215 IntRes2d_Transition t1 = T1a;
2216 IntRes2d_Transition t2 = T2a;
2217 Standard_Real u1 = Pa.ParamOnFirst();
2218 Standard_Real u2 = Pa.ParamOnSecond();
2219
2220
2221 if(t1.PositionOnCurve() == IntRes2d_Middle) {
2222 t1.SetPosition(T1b.PositionOnCurve());
2223 u1 = Pb.ParamOnFirst();
2224 }
2225 if(t2.PositionOnCurve() == IntRes2d_Middle) {
2226 t2.SetPosition(T2b.PositionOnCurve());
2227 u2 = Pb.ParamOnSecond();
2228 }
2229 return(IntRes2d_IntersectionPoint(Pa.Value(),u1,u2,t1,t2,Standard_False));
2230}