0024624: Lost word in license statement in source files
[occt.git] / src / Intf / Intf_InterferencePolygon2d.cxx
CommitLineData
b311480e 1// Created on: 1991-06-24
2// Created by: Didier PIFFAULT
3// Copyright (c) -1999 Matra Datavision
4// Copyright (c) 1991-1999 Matra Datavision
973c2be1 5// Copyright (c) 1999-2014 OPEN CASCADE SAS
b311480e 6//
973c2be1 7// This file is part of Open CASCADE Technology software library.
b311480e 8//
d5f74e42 9// This library is free software; you can redistribute it and/or modify it under
10// the terms of the GNU Lesser General Public License version 2.1 as published
973c2be1 11// by the Free Software Foundation, with special exception defined in the file
12// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
13// distribution for complete text of the license and disclaimer of any warranty.
b311480e 14//
973c2be1 15// Alternatively, this file may be used under the terms of Open CASCADE
16// commercial license or contractual agreement.
9530af27 17
18#include <Intf_InterferencePolygon2d.ixx>
19
20#include <gp_Pnt2d.hxx>
21#include <Bnd_Box2d.hxx>
22#include <Intf_SectionPoint.hxx>
23#include <Intf_SeqOfSectionPoint.hxx>
24#include <Intf_TangentZone.hxx>
25#include <Intf_SeqOfTangentZone.hxx>
26#include <Precision.hxx>
27#include <TColStd_ListOfInteger.hxx>
28
29// Angular precision (sinus) below that value two right segments
30// are considered as having a potential zone of tangency.
31namespace
32{
33 static const Standard_Real PRCANG = Precision::Angular();
34};
35
36//=======================================================================
37//function : Intf_InterferencePolygon2d
38//purpose : constructor empty
39//=======================================================================
40
41Intf_InterferencePolygon2d::Intf_InterferencePolygon2d()
42: Intf_Interference (Standard_False),
43 oClos (Standard_False),
44 tClos (Standard_False),
45 nbso (0)
46{}
47
48//=======================================================================
49//function : Intf_InterferencePolygon2d
50//purpose : Constructor of the interference beetween two Polygon.
51//=======================================================================
52
53Intf_InterferencePolygon2d::Intf_InterferencePolygon2d
54 (const Intf_Polygon2d& Obje1, const Intf_Polygon2d& Obje2)
55: Intf_Interference (Standard_False),
56 oClos (Standard_False),
57 tClos (Standard_False),
58 nbso (0)
59{
60 if (!Obje1.Bounding().IsOut(Obje2.Bounding())) {
61 Tolerance=Obje1.DeflectionOverEstimation()+
62 Obje2.DeflectionOverEstimation();
63 if (Tolerance==0.)
64 Tolerance=Epsilon(1000.);
65 nbso=Obje1.NbSegments();
66 oClos=Obje1.Closed();
67 tClos=Obje2.Closed();
68 Interference(Obje1, Obje2);
69 Clean();
70 }
71}
72
73
74//=======================================================================
75//function : Intf_InterferencePolygon2d
76//purpose : Constructor of the auto interference of a Polygon.
77//=======================================================================
78
79Intf_InterferencePolygon2d::Intf_InterferencePolygon2d
80 (const Intf_Polygon2d& Obje)
81: Intf_Interference (Standard_True),
82 oClos (Standard_False),
83 tClos (Standard_False),
84 nbso (0)
85{
86 Tolerance=Obje.DeflectionOverEstimation()*2;
87 if (Tolerance==0.)
88 Tolerance=Epsilon(1000.);
89 oClos=Obje.Closed();
90 tClos=oClos;
91 Interference(Obje);
92 Clean();
93}
94
95//=======================================================================
96//function : Perform
97//purpose :
98//=======================================================================
99
100void Intf_InterferencePolygon2d::Perform
101 (const Intf_Polygon2d& Obje1, const Intf_Polygon2d& Obje2)
102{
103 SelfInterference(Standard_False);
104 if (!Obje1.Bounding().IsOut(Obje2.Bounding())) {
105 Tolerance=Obje1.DeflectionOverEstimation()+
106 Obje2.DeflectionOverEstimation();
107 if (Tolerance==0.)
108 Tolerance=Epsilon(1000.);
109 nbso=Obje1.NbSegments();
110 oClos=Obje1.Closed();
111 tClos=Obje2.Closed();
112 Interference(Obje1, Obje2);
113 Clean();
114 }
115}
116
117//=======================================================================
118//function : Perform
119//purpose :
120//=======================================================================
121
122void Intf_InterferencePolygon2d::Perform
123 (const Intf_Polygon2d& Obje)
124{
125 SelfInterference(Standard_True);
126 Tolerance=Obje.DeflectionOverEstimation()*2;
127 if (Tolerance==0.)
128 Tolerance=Epsilon(1000.);
129 oClos=Obje.Closed();
130 tClos=oClos;
131 Interference(Obje);
132 Clean();
133}
134
135//=======================================================================
136//function : Pnt2dValue
137//purpose : Give the section point of range Index in the interference.
138//=======================================================================
139
140gp_Pnt2d Intf_InterferencePolygon2d::Pnt2dValue
141 (const Standard_Integer Index) const
142{
143 return gp_Pnt2d((mySPoins(Index)).Pnt().X(),
144 (mySPoins(Index)).Pnt().Y());
145}
146
147
148//=======================================================================
149//function : Interference
150//purpose :
151//=======================================================================
152
153void Intf_InterferencePolygon2d::Interference
154 (const Intf_Polygon2d& Obje1,
155 const Intf_Polygon2d& Obje2)
156{
157 Bnd_Box2d bSO;
158 Bnd_Box2d bST;
159
96a85238
RL
160 Standard_Integer iObje1, iObje2, n1 = nbso, n2 = Obje2.NbSegments();
161 Standard_Real d1 = Obje1.DeflectionOverEstimation(),
162 d2 = Obje2.DeflectionOverEstimation();
9530af27 163
164 gp_Pnt2d p1b, p1e, p2b, p2e;
96a85238 165 for (iObje1=1; iObje1<=n1; iObje1++)
9530af27 166 {
167 bSO.SetVoid();
168 Obje1.Segment(iObje1,p1b,p1e);
169 bSO.Add(p1b);
170 bSO.Add(p1e);
96a85238 171 bSO.Enlarge(d1);
9530af27 172 if (!Obje2.Bounding().IsOut(bSO)) {
96a85238 173 for (iObje2=1; iObje2<=n2; iObje2++) {
9530af27 174 bST.SetVoid();
175 Obje2.Segment(iObje2,p2b,p2e);
176 bST.Add(p2b);
177 bST.Add(p2e);
96a85238 178 bST.Enlarge(d2);
9530af27 179 if (!bSO.IsOut(bST))
180 Intersect(iObje1, iObje2, p1b, p1e, p2b, p2e);
181 }
182 }
183 }
184}
185
186//=======================================================================
187//function : Interference
188//purpose :
189//=======================================================================
190
191void Intf_InterferencePolygon2d::Interference
192 (const Intf_Polygon2d& Obje)
193{
194 Bnd_Box2d bSO;
195 Bnd_Box2d bST;
196
96a85238
RL
197 Standard_Integer iObje1, iObje2, n = Obje.NbSegments();
198 Standard_Real d = Obje.DeflectionOverEstimation();
9530af27 199
200 gp_Pnt2d p1b, p1e, p2b, p2e;
96a85238 201 for (iObje1=1; iObje1<=n; iObje1++) {
9530af27 202 bSO.SetVoid();
203 Obje.Segment(iObje1,p1b,p1e);
204 bSO.Add(p1b);
205 bSO.Add(p1e);
96a85238 206 bSO.Enlarge(d);
9530af27 207 if (!Obje.Bounding().IsOut(bSO)) {
96a85238 208 for (iObje2=iObje1+1;iObje2<=n;iObje2++){
9530af27 209 bST.SetVoid();
210 Obje.Segment(iObje2,p2b,p2e);
211 bST.Add(p2b);
212 bST.Add(p2e);
96a85238 213 bST.Enlarge(d);
9530af27 214 if (!bSO.IsOut(bST))
215 Intersect(iObje1, iObje2, p1b, p1e, p2b, p2e);
216 }
217 }
218 }
219}
220
221
222//=======================================================================
223//function : Clean
224//purpose :
225//=======================================================================
226
227void Intf_InterferencePolygon2d::Clean()
228{
229
230// The zones of tangency that concerns only one couple of segments are
231// conserved if the angle between the segments is less than <PRCANG> and
232// if there is no real point of intersection EDGE/EDGE:
233 Standard_Integer nbIt=myTZones.Length();
234 Standard_Integer decal=0;
235 Standard_Integer addr1, addr2;
236 Intf_PIType dim1, dim2;
237 Standard_Real par;
238 Standard_Integer tsp, tsps;
239 Standard_Integer lpi, ltz;
240 Standard_Boolean Only1Seg=Standard_False;
241
242#define PI1 (myTZones(ltz-decal).GetPoint(lpi))
243#define PI2 (myTZones(ltz-decal).GetPoint(tsp))
244
245 for (ltz=1; ltz<=nbIt; ltz++) {
246 tsp=tsps=0;
247 Standard_Real pr1mi,pr1ma,pr2mi,pr2ma,delta1,delta2;
248 myTZones(ltz-decal).ParamOnFirst(pr1mi,pr1ma);
249 delta1=pr1ma-pr1mi;
250 myTZones(ltz-decal).ParamOnSecond(pr2mi,pr2ma);
251 delta2=pr2ma-pr2mi;
252 if (delta1<1. && delta2<1.) Only1Seg=Standard_True;
253 if (delta1==0. || delta2==0.) Only1Seg=Standard_True;
254
255 for (lpi=1; lpi<=myTZones(ltz-decal).NumberOfPoints(); lpi++) {
256 if (PI1.Incidence()<=PRCANG) {tsp=tsps=0;break;}
257 PI1.InfoFirst(dim1,addr1,par);
258 PI1.InfoSecond(dim2,addr2,par);
259 if (dim1==Intf_EDGE && dim2==Intf_EDGE) {
260 tsps=0;
261 if (tsp>0) {
262 tsp=0;
263 Only1Seg=Standard_False;
264 break;
265 }
266 tsp=lpi;
267 }
268 else if (dim1!=Intf_EXTERNAL && dim2!=Intf_EXTERNAL) {
269 tsps=lpi;
270 }
271 }
272 if (tsp>0) {
273 mySPoins.Append(myTZones(ltz-decal).GetPoint(tsp));
274 myTZones.Remove(ltz-decal);
275 decal++;
276 }
277 else if (Only1Seg && tsps!=0) {
278 mySPoins.Append(myTZones(ltz-decal).GetPoint(tsps));
279 myTZones.Remove(ltz-decal);
280 decal++;
281 }
282 }
283
284
285// The points of intersection located in the tangency zone are
286// removed from the list :
287 nbIt=mySPoins.Length();
288 decal=0;
289
290 for (lpi=1; lpi<=nbIt; lpi++) {
291 for (ltz=1; ltz<=myTZones.Length(); ltz++) {
292 if (myTZones(ltz).RangeContains(mySPoins(lpi-decal))) {
293 mySPoins.Remove(lpi-decal);
294 decal++;
295 break;
296 }
297 }
298 }
299}
300
301
302//=======================================================================
303//function : Intersect
304//purpose :
305//=======================================================================
306
307void Intf_InterferencePolygon2d::Intersect
308 (const Standard_Integer iObje1, const Standard_Integer iObje2,
309 const gp_Pnt2d& BegO, const gp_Pnt2d& EndO,
310 const gp_Pnt2d& BegT, const gp_Pnt2d& EndT)
311{
312 if(SelfIntf) {
313 if(Abs(iObje1-iObje2)<=1) return; //-- Ajout du 15 jan 98
314 }
315
316 Standard_Integer nbpi=0;
317 Standard_Real parO[8];
318 Standard_Real parT[8];
319 Intf_SeqOfSectionPoint thePi;
320 gp_XY segT =EndT.XY()-BegT.XY();
321 gp_XY segO =EndO.XY()-BegO.XY();
322
323// If the length of segment is zero, nothing is done
324 Standard_Real lgT =Sqrt(segT*segT);
325 if (lgT<=0.) return;
326 Standard_Real lgO =Sqrt(segO*segO);
327 if (lgO<=0.) return;
328
329// Direction of parsing of segments
330 Standard_Real sigPS=(segO*segT)>0.0 ? 1.0 : -1.0;
331
332// Precision of calculation
333 Standard_Real floatgap=Epsilon(lgO+lgT);
334
335// Angle between two straight lines and radius of interference
336 Standard_Real sinTeta=(segO.CrossMagnitude(segT)/lgO)/lgT;
337 Standard_Real rayIntf=0.;
338 if (sinTeta>0.) rayIntf=Tolerance/sinTeta;
339
340// Interference <begO> <segT>
341 Standard_Real dbOT=((BegO.XY()-BegT.XY())^segT)/lgT;
342 Standard_Real dbObT=BegO.Distance(BegT);
343 Standard_Real dbOeT=BegO.Distance(EndT);
344 if (Abs(dbOT)<=Tolerance) {
345 if (dbObT<=Tolerance) {
346 nbpi++;
347 parO[nbpi]=0.;parT[nbpi]=0.;
348 thePi.Append(Intf_SectionPoint(BegO,Intf_VERTEX,iObje1,0.,
349 Intf_VERTEX,iObje2,0.,sinTeta));
350 }
351 if (dbOeT<=Tolerance) {
352 nbpi++;
353 parO[nbpi]=0.;parT[nbpi]=1.;
354 thePi.Append(Intf_SectionPoint(BegO,Intf_VERTEX,iObje1,0.,
355 Intf_VERTEX,iObje2+1,0.,sinTeta));
356 }
357 if (dbObT>Tolerance && dbOeT>Tolerance &&
358 dbObT+dbOeT<=(lgT+Tolerance)) {
359 nbpi++;
360 parO[nbpi]=0.;parT[nbpi]=dbObT/lgT;
361 thePi.Append(Intf_SectionPoint(BegO,Intf_VERTEX,iObje1,0.,
362 Intf_EDGE,iObje2,parT[nbpi],sinTeta));
363 }
364 }
365
366// Interference <endO> <segT>
367 Standard_Real deOT=((EndO.XY()-BegT.XY())^segT)/lgT;
368 Standard_Real deObT=EndO.Distance(BegT);
369 Standard_Real deOeT=EndO.Distance(EndT);
370 if (Abs(deOT)<=Tolerance) {
371 if (deObT<=Tolerance) {
372 nbpi++;
373 parO[nbpi]=1.;parT[nbpi]=0.;
374 thePi.Append(Intf_SectionPoint(EndO,Intf_VERTEX,iObje1+1,0.,
375 Intf_VERTEX,iObje2,0.,sinTeta));
376 }
377 if (deOeT<=Tolerance) {
378 nbpi++;
379 parO[nbpi]=1.;parT[nbpi]=1.;
380 thePi.Append(Intf_SectionPoint(EndO,Intf_VERTEX,iObje1+1,0.,
381 Intf_VERTEX,iObje2+1,0.,sinTeta));
382 }
383 if (deObT>Tolerance && deOeT>Tolerance &&
384 deObT+deOeT<=(lgT+Tolerance)) {
385 nbpi++;
386 parO[nbpi]=1.;parT[nbpi]=deObT/lgT;
387 thePi.Append(Intf_SectionPoint(EndO,Intf_VERTEX,iObje1+1,0.,
388 Intf_EDGE,iObje2,parT[nbpi],sinTeta));
389 }
390 }
391
392// Interference <begT> <segO>
393 Standard_Real dbTO=((BegT.XY()-BegO.XY())^segO)/lgO;
394 if (Abs(dbTO)<=Tolerance) {
395 if (dbObT>Tolerance && deObT>Tolerance &&
396 dbObT+deObT<=(lgO+Tolerance)) {
397 nbpi++;
398 parO[nbpi]=dbObT/lgO;parT[nbpi]=0.;
399 thePi.Append(Intf_SectionPoint(BegT,Intf_EDGE,iObje1,parO[nbpi],
400 Intf_VERTEX,iObje2,0.,sinTeta));
401 }
402 }
403
404// Interference <endT> <segO>
405 Standard_Real deTO=((EndT.XY()-BegO.XY())^segO)/lgO;
406 if (Abs(deTO)<=Tolerance) {
407 if (dbOeT>Tolerance && deOeT>Tolerance &&
408 dbOeT+deOeT<=(lgO+Tolerance)) {
409 nbpi++;
410 parO[nbpi]=dbOeT/lgO;parT[nbpi]=1.;
411 thePi.Append(Intf_SectionPoint(EndT,Intf_EDGE,iObje1,parO[nbpi],
412 Intf_VERTEX,iObje2+1,0.,sinTeta));
413 }
414 }
415
416 Standard_Boolean edgeSP=Standard_False;
417 Standard_Real parOSP=0, parTSP=0;
418
419 if (Abs(dbOT-deOT)>floatgap && Abs(dbTO-deTO)>floatgap) {
420 parOSP=dbOT/(dbOT-deOT);
421 parTSP=dbTO/(dbTO-deTO);
422 if (dbOT*deOT<=0. && dbTO*deTO<=0.) {
423 edgeSP=Standard_True;
424 }
425 else if (nbpi==0) return;
426
427// If there is no interference it is necessary to take the points segment by segment
428 if (nbpi==0 && sinTeta>PRCANG) {
429 nbpi++;
430 parO[nbpi]=parOSP;
431 parT[nbpi]=parTSP;
432 thePi.Append(Intf_SectionPoint(gp_Pnt2d (BegO.X()+ (segO.X()*parOSP),
433 BegO.Y()+ (segO.Y()*parOSP)),
434 Intf_EDGE,iObje1,parOSP,
435 Intf_EDGE,iObje2,parTSP,sinTeta));
436 }
437
438// Otherwise it is required to check if there is no other
439 else if (rayIntf>=Tolerance) {
440 Standard_Real deltaO=rayIntf/lgO;
441 Standard_Real deltaT=rayIntf/lgT;
442 Standard_Real x, y;
443 Standard_Real parOdeb=parOSP-deltaO;
444 Standard_Real parOfin=parOSP+deltaO;
445 Standard_Real parTdeb=parTSP-sigPS*deltaT;
446 Standard_Real parTfin=parTSP+sigPS*deltaT;
447 if (nbpi==0) {
448 parO[1]=parOdeb;
449 parO[2]=parOfin;
450 parT[1]=parTdeb;
451 parT[2]=parTfin;
452 while (nbpi<2) {
453 nbpi++;
454 x=BegO.X()+ (segO.X()*parO[nbpi]);
455 y=BegO.Y()+ (segO.Y()*parO[nbpi]);
456 thePi.Append(Intf_SectionPoint(gp_Pnt2d(x, y),
457 Intf_EXTERNAL, iObje1, parO[nbpi],
458 Intf_EXTERNAL, iObje2, parT[nbpi],
459 sinTeta));
460 }
461 }
462 else { //nbpi>0
463 if (nbpi==1) {
464 Standard_Boolean ok=Standard_True;
465 if (0.<parOdeb && parOdeb<1. && 0.<parTdeb && parTdeb<1. ) {
466 parO[nbpi+1]=parOdeb;
467 parT[nbpi+1]=parTdeb;
468 }
469 else if (0.<parOfin && parOfin<1. && 0.<parTfin && parTfin<1. ) {
470 parO[nbpi+1]= parOfin;
471 parT[nbpi+1]= parTfin;
472 }
473 else {
474 ok=Standard_False;
475 }
476
477 if (ok) {
478 x=BegO.X()+ (segO.X()*parO[nbpi+1]);
479 y=BegO.Y()+ (segO.Y()*parO[nbpi+1]);
480 if (thePi(1).Pnt().Distance(gp_Pnt(x, y, 0)) >= (Tolerance/4.)) {
481 nbpi++;
482 thePi.Append(Intf_SectionPoint(gp_Pnt2d(x, y),
483 Intf_EXTERNAL, iObje1, parO[nbpi],
484 Intf_EXTERNAL, iObje2, parT[nbpi],
485 sinTeta));
486 }
487 }
488 }
489 else { // plus d une singularite
490 Standard_Real parOmin=parO[1];
491 Standard_Real parOmax=parO[1];
492 Standard_Real parTmin=parT[1];
493 Standard_Real parTmax=parT[1];
494 for (Standard_Integer i=2; i<=nbpi; i++) {
495 parOmin=Min(parOmin, parO[i]);
496 parOmax=Max(parOmax, parO[i]);
497 parTmin=Min(parTmin, parT[i]);
498 parTmax=Max(parTmax, parT[i]);
499 }
500
501 Standard_Real delta;
502 if (parOdeb<0.) {
503 delta=-parOdeb;
504 parOdeb=0.;
505 parTdeb=parTdeb+sigPS*(delta*(deltaT/deltaO));
506 }
507 if (parOfin>1.) {
508 delta=parOfin-1.;
509 parOfin=1.;
510 parTfin=parTfin-sigPS*(delta*(deltaT/deltaO));
511 }
512 if (sigPS>0.) {
513 if (parTdeb<0.) {
514 delta=-parTdeb;
515 parTdeb=0.;
516 parOdeb=parOdeb+delta*(deltaO/deltaT);
517 }
518 if (parTfin>1.) {
519 delta=parTfin-1.;
520 parTfin=1.;
521 parOfin=parOfin-delta*(deltaO/deltaT);
522 }
523 }
524 else {
525 if (parTdeb>1.) {
526 delta=parTdeb-1.;
527 parTdeb=1.;
528 parOdeb=parOdeb+delta*(deltaO/deltaT);
529 }
530 if (parTfin<0.) {
531 delta=-parTfin;
532 parTfin=0.;
533 parOfin=parOfin-delta*(deltaO/deltaT);
534 }
535 }
536
537 if ((parOdeb<parOmin && parOmin>0.) ||
538 (sigPS>0. && parTdeb<parTmin && parTmin>0.) ||
539 (sigPS<0. && parTdeb>parTmax && parTmax<1.)) {
540 nbpi++;
541 parO[nbpi]=Max(0., Min(1., parOdeb));
542 parT[nbpi]=Max(0., Min(1., parTdeb));
543 x=BegO.X()+ (segO.X()*parO[nbpi]);
544 y=BegO.Y()+ (segO.Y()*parO[nbpi]);
545 thePi.Append(Intf_SectionPoint(gp_Pnt2d(x, y),
546 Intf_EXTERNAL, iObje1, parO[nbpi],
547 Intf_EXTERNAL, iObje2, parT[nbpi],
548 sinTeta));
549 }
550
551 if ((parOfin>parOmax && parOmax<1.) ||
552 (sigPS<0. && parTfin<parTmin && parTmin>0.) ||
553 (sigPS>0. && parTfin>parTmax && parTmax<1.)) {
554 nbpi++;
555 parO[nbpi]=Min(1., Max(0., parOfin));
556 parT[nbpi]=Min(1., Max(0., parTfin));
557 x=BegO.X()+ (segO.X()*parO[nbpi]);
558 y=BegO.Y()+ (segO.Y()*parO[nbpi]);
559 thePi.Append(Intf_SectionPoint(gp_Pnt2d(x, y),
560 Intf_EXTERNAL, iObje1, parO[nbpi],
561 Intf_EXTERNAL, iObje2, parT[nbpi],
562 sinTeta));
563 }
564 }
565 }
566 }
567 }
568
569 //-- lbr : The points too close to each other are suspended
570 Standard_Boolean suppr;
571 do {
572 suppr=Standard_False;
573 for(Standard_Integer i=2; suppr==Standard_False && i<=nbpi; i++) {
574 const gp_Pnt& Pim1 = thePi(i-1).Pnt();
575 const gp_Pnt& Pi = thePi(i).Pnt();
576 Standard_Real d=Pi.Distance(Pim1);
577 d*=50.0;
578 if(d<lgT && d<lgO) {
579 for(Standard_Integer j=i; j<nbpi; j++) {
580 thePi(j)=thePi(j+1);
581 }
582 nbpi--;
583 suppr=Standard_True;
584 }
585 }
586 }
587 while(suppr==Standard_True);
588
589
590
591
592
593
594 if (nbpi==1) {
595 if (edgeSP) {
596 thePi(1)=Intf_SectionPoint(gp_Pnt2d (BegO.X()+ (segO.X()*parOSP),
597 BegO.Y()+ (segO.Y()*parOSP)),
598 Intf_EDGE,iObje1,parOSP,
599 Intf_EDGE,iObje2,parTSP,sinTeta);
600 parO[1]=parOSP;
601 parT[1]=parTSP;
602 }
603 if (!SelfIntf) {
604 Standard_Boolean contains = Standard_False;
605 for (Standard_Integer i = 1; i <= mySPoins.Length(); i++)
606 if (thePi(1).IsEqual(mySPoins(i))) {
607 contains = Standard_True;
608 break;
609 }
610 if (!contains)
611 mySPoins.Append(thePi(1));
612 }
613 else if (iObje2-iObje1!=1 &&
614 (!oClos || (iObje1!=1 && iObje2!=nbso))) {
615 mySPoins.Append(thePi(1));
616 }
617 }
618
619 else if (nbpi>=2) {
620 Intf_TangentZone TheTZ;
621 if (nbpi==2) {
622 TheTZ.PolygonInsert(thePi(1));
623 TheTZ.PolygonInsert(thePi(2));
624 }
625 else {
626 Standard_Integer lpj;
627 Standard_Integer lmin=1;
628 Standard_Integer lmax=1;
629 for (lpj=2; lpj<=nbpi; lpj++) {
630 if (parO[lpj]<parO[lmin]) lmin=lpj;
631 else if (parO[lpj]>parO[lmax]) lmax=lpj;
632 }
633 TheTZ.PolygonInsert(thePi(lmin));
634 TheTZ.PolygonInsert(thePi(lmax));
635
636 Standard_Integer ltmin=1;
637 Standard_Integer ltmax=1;
638 for (lpj=2; lpj<=nbpi; lpj++) {
639 if (parT[lpj]<parT[ltmin]) ltmin=lpj;
640 else if (parT[lpj]>parT[ltmax]) ltmax=lpj;
641 }
642 if (ltmin!=lmin && ltmin!=lmax) TheTZ.PolygonInsert(thePi(ltmin));
643 if (ltmax!=lmin && ltmax!=lmax) TheTZ.PolygonInsert(thePi(ltmax));
644 }
645
646 if (edgeSP) TheTZ.PolygonInsert(Intf_SectionPoint
647 (gp_Pnt2d (BegO.X()+ (segO.X()*parOSP),
648 BegO.Y()+ (segO.Y()*parOSP)),
649 Intf_EDGE,iObje1,parOSP,
650 Intf_EDGE,iObje2,parTSP,sinTeta));
651
652 Standard_Integer nbtz=myTZones.Length();
653#if 0
654 Standard_Integer decaltz=0;
655 for (Standard_Integer ltz=1; ltz<=nbtz; ltz++) {
656 if (TheTZ.HasCommonRange(myTZones(ltz-decaltz))) {
657 TheTZ.Append(myTZones(ltz-decaltz));
658 myTZones.Remove(ltz-decaltz);
659 decaltz++;
660 }
661 }
662 myTZones.Append(TheTZ);
663#else
664 TColStd_ListOfInteger LIndex;
665 for (Standard_Integer ltz=1; ltz<=nbtz; ltz++) {
666 if (TheTZ.HasCommonRange(myTZones(ltz))) {
667 LIndex.Append(ltz);
668 }
669 }
670 //------------------------------------------------------------------------
671 //-- The list is parsed in ascending order by index, zone and tg
672 //--
673 if(LIndex.IsEmpty()) {
674 myTZones.Append(TheTZ);
675 }
676 else {
677 Standard_Integer indexfirst = LIndex.First();
678 LIndex.RemoveFirst();
679 Standard_Integer decal = 0;
680 myTZones(indexfirst).Append(TheTZ);
681 while(!LIndex.IsEmpty()) {
682 Standard_Integer index = LIndex.First();
683 LIndex.RemoveFirst();
684 myTZones(indexfirst).Append(myTZones(index-decal));
685 myTZones.Remove(index-decal);
686 decal++;
687 }
688 }
689#endif
690 }
691}