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