0027468: Incorrect processing of some cases by HLR algorithm
[occt.git] / src / HLRBRep / HLRBRep_Intersector.cxx
1 // Created on: 1992-10-22
2 // Created by: Christophe MARION
3 // Copyright (c) 1992-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
5 //
6 // This file is part of Open CASCADE Technology software library.
7 //
8 // This library is free software; you can redistribute it and/or modify it under
9 // the terms of the GNU Lesser General Public License version 2.1 as published
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.
13 //
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
16
17 #ifndef No_Exception
18 #define No_Exception
19 #endif
20
21
22 #include <Bnd_Box.hxx>
23 #include <ElCLib.hxx>
24 #include <gp.hxx>
25 #include <gp_Lin.hxx>
26 #include <HLRBRep_Curve.hxx>
27 #include <HLRBRep_CurveTool.hxx>
28 #include <HLRBRep_EdgeData.hxx>
29 #include <HLRBRep_Intersector.hxx>
30 #include <HLRBRep_SurfaceTool.hxx>
31 #include <HLRBRep_ThePolygonOfInterCSurf.hxx>
32 #include <HLRBRep_ThePolyhedronOfInterCSurf.hxx>
33 #include <IntCurveSurface_IntersectionPoint.hxx>
34 #include <IntCurveSurface_IntersectionSegment.hxx>
35 #include <IntImpParGen.hxx>
36 #include <IntRes2d_IntersectionPoint.hxx>
37 #include <IntRes2d_IntersectionSegment.hxx>
38 #include <IntRes2d_Position.hxx>
39 #include <IntRes2d_Transition.hxx>
40 #include <StdFail_UndefinedDerivative.hxx>
41
42 #include <stdio.h>
43 #define PERF 0
44
45 #if PERF
46 static Standard_Integer NbIntersCS=0;
47 static Standard_Integer NbIntersCSVides=0;
48 static Standard_Integer NbIntersAuto=0;
49 static Standard_Integer NbIntersSimulate=0;
50  static Standard_Integer NbInters=0;
51  static Standard_Integer NbIntersVides=0;
52  static Standard_Integer NbInters1Segment=0;
53  static Standard_Integer NbInters1Point=0;
54  static Standard_Integer NbIntersNPoints=0;
55  static Standard_Integer NbIntersNSegments=0;
56  static Standard_Integer NbIntersPointEtSegment=0;
57 #endif
58
59 //=======================================================================
60 //function : HLRBRep_Intersector
61 //purpose  : 
62 //=======================================================================
63
64 HLRBRep_Intersector::HLRBRep_Intersector () :
65 myPolyhedron(NULL)
66 {
67 #if PERF
68   if(NbInters) { 
69     printf("\n--------------------------------------");
70     printf("\nNbIntersSimulate  : %6d",NbIntersSimulate);
71     printf("\nNbIntersCrvSurf   : %6d",NbIntersCS);
72     printf("\n      -> vide     : %6d",NbIntersCSVides);
73     printf("\nNbAutoInters      : %6d\n",NbIntersAuto);
74     printf("\nNbInters          : %6d",NbInters);
75     printf("\n        Vides     : %6d",NbIntersVides);
76     printf("\n        1 Segment : %6d",NbInters1Segment);
77     printf("\n        1 Point   : %6d",NbInters1Point);
78     printf("\n       >1 Point   : %6d",NbIntersNPoints);
79     printf("\n       >1 Segment : %6d",NbIntersNSegments);
80     printf("\n     >1 Pt et Seg : %6d",NbIntersPointEtSegment);
81     printf("\n--------------------------------------\n");
82   }
83   NbIntersSimulate=NbIntersAuto=NbIntersCS
84   =NbInters=NbIntersVides=NbInters1Segment=NbInters1Point=NbIntersNPoints
85   = NbIntersNSegments=NbIntersPointEtSegment=NbIntersCSVides=0;
86 #endif
87 }
88
89 //=======================================================================
90 //function : Perform
91 //purpose  : 
92 //=======================================================================
93
94 void  HLRBRep_Intersector::Perform (const Standard_Address A1,
95                                     const Standard_Real da1,
96                                     const Standard_Real db1)
97 {
98 #if PERF 
99   NbIntersAuto++;
100 #endif
101
102
103   Standard_Address myC1 = ((HLRBRep_EdgeData*) A1)->Curve();
104
105   myTypePerform = 1;
106
107   gp_Pnt2d pa,pb;//,pa1,pb1;
108   Standard_Real a,b,d,tol;
109   Standard_ShortReal ta,tb;
110   
111   ((HLRBRep_EdgeData*) A1)->Status().Bounds(a,ta,b,tb);
112   d = b - a;
113   if (da1 != 0) a = a + d * da1;
114   if (db1 != 0) b = b - d * db1;
115   ((HLRBRep_Curve*)myC1)->D0(a,pa);
116   ((HLRBRep_Curve*)myC1)->D0(b,pb);
117   a = ((HLRBRep_Curve*)myC1)->Parameter2d(a);
118   b = ((HLRBRep_Curve*)myC1)->Parameter2d(b);
119   IntRes2d_Domain D1(pa,a,(Standard_Real)ta,pb,b,(Standard_Real)tb);
120
121   //modified by jgv, 18.04.2016 for OCC27341
122   //tol = (Standard_Real)(((HLRBRep_EdgeData*) A1)->Tolerance());
123   tol = Precision::Confusion();
124   //////////////////////////////////////////
125
126   myIntersector.Perform(myC1,D1,tol,tol);
127 }
128
129 //=======================================================================
130 //function : Perform
131 //purpose  : 
132 //=======================================================================
133
134 void  HLRBRep_Intersector::Perform (const Standard_Integer /*nA*/,
135                                     const Standard_Address A1,
136                                     const Standard_Real da1,
137                                     const Standard_Real db1,
138                                     const Standard_Integer /*nB*/,
139                                     const Standard_Address A2,
140                                     const Standard_Real da2,
141                                     const Standard_Real db2,
142                                     const Standard_Boolean EnBout)
143 {
144
145
146 //  if(EnBout) { 
147 //    myTypePerform=43; 
148 //    return;
149 //  }
150
151   Standard_Address myC1 = ((HLRBRep_EdgeData*) A1)->Curve();
152   Standard_Address myC2 = ((HLRBRep_EdgeData*) A2)->Curve();
153
154   myTypePerform = 1;
155
156   gp_Pnt2d pa1,pb1,pa2,pb2;
157   gp_Vec2d va1,vb1,va2,vb2;
158   Standard_Real a1,b1,a2,b2,d,dd,tol,tol1,tol2;
159   Standard_ShortReal ta,tb;
160
161   //modified by jgv, 18.04.2016 for OCC27341
162   //tol1 = (Standard_Real)(((HLRBRep_EdgeData*) A1)->Tolerance());
163   //tol2 = (Standard_Real)(((HLRBRep_EdgeData*) A2)->Tolerance());
164   tol1 = Precision::Confusion();
165   tol2 = Precision::Confusion();
166   //////////////////////////////////////////
167   if (tol1 > tol2) tol = tol1;
168   else             tol = tol2;
169
170
171   Standard_Boolean PasBon;
172   Standard_Real    decalagea1=100.0;
173   Standard_Real    decalagea2=100.0;
174   Standard_Real    decalageb1=100.0;
175   Standard_Real    decalageb2=100.0;
176   do { 
177     PasBon=Standard_False;
178     ((HLRBRep_EdgeData*) A1)->Status().Bounds(a1,ta,b1,tb); //--   -> Parametres 3d 
179     Standard_Real mtol = tol;
180     if(mtol<ta) mtol=ta;
181     if(mtol<tb) mtol=tb;
182     d = b1 - a1;
183
184     Standard_Real    pdist = tol;
185     if(pdist<0.0000001) pdist = 0.0000001;
186     
187
188     if (da1 != 0)  { 
189       //-- a = a + d * da1;
190       ((HLRBRep_Curve*)myC1)->D1(a1,pa1,va1);
191       Standard_Real qwe=va1.Magnitude();
192       if(qwe>1e-12) { 
193         dd=pdist*decalagea1/qwe;
194         if(dd<d*0.4) { 
195           a1+=dd;
196         }
197         else { 
198           a1+= d * da1; decalagea1=-1;
199         }
200       }
201       else { 
202         a1+=d * da1;  decalagea1=-1;
203       }
204     }
205     
206     if (db1 != 0) { 
207       //-- b = b - d * db1;
208       ((HLRBRep_Curve*)myC1)->D1(b1,pb1,vb1);
209       Standard_Real qwe=vb1.Magnitude();
210       if(qwe>1e-12) { 
211         dd=pdist*decalageb1/qwe;
212         if(dd<d*0.4) { 
213           b1-=dd;
214         }
215         else { 
216           b1-= d * db1; decalageb1=-1;
217         }
218       }
219       else { 
220         b1-=d * db1; decalageb1=-1;
221       }
222     }
223
224
225 //    if(EnBout) {  //-- ************************************************************
226 //      Standard_Real d=b1-a1;
227 //      a1+=d*0.45;
228 //      b1-=d*0.45;
229 //    }
230
231
232     
233     ((HLRBRep_Curve*)myC1)->D0(a1,pa1);
234     ((HLRBRep_Curve*)myC1)->D0(b1,pb1);
235     
236     a1 = ((HLRBRep_Curve*)myC1)->Parameter2d(a1);
237     b1 = ((HLRBRep_Curve*)myC1)->Parameter2d(b1);
238     
239     if(EnBout) { 
240       ta=tb=-1.;
241     }
242     
243     if(ta>tol) ta=(Standard_ShortReal) tol;
244     if(tb>tol) tb=(Standard_ShortReal) tol;
245     
246     IntRes2d_Domain D1(pa1,a1,(Standard_Real)ta,pb1,b1,(Standard_Real)tb);  
247     
248     ((HLRBRep_EdgeData*) A2)->Status().Bounds(a2,ta,b2,tb);
249     mtol = tol;
250     if(mtol<ta) mtol=ta;
251     if(mtol<tb) mtol=tb;
252     
253     d = b2-a2;
254     
255     if (da2 != 0)  { 
256       //-- a = a + d * da2;
257       ((HLRBRep_Curve*)myC2)->D1(a2,pa2,va2);
258       Standard_Real qwe=va2.Magnitude();
259       if(qwe>1e-12) { 
260         dd=pdist*decalagea2/qwe;
261         if(dd<d*0.4) { 
262           a2+=dd;
263         }
264         else { 
265           a2+= d * da2;   decalagea2=-1;
266         }
267       }
268       else { 
269         a2+=d * da2;      decalagea2=-1;
270       }
271     }
272     
273     if (db2 != 0) { 
274       //-- b = b - d * db2;
275       ((HLRBRep_Curve*)myC2)->D1(b2,pb2,vb2);
276       Standard_Real qwe=vb2.Magnitude();
277       if(qwe>1e-12) { 
278         dd=pdist*decalageb2/qwe;
279         if(dd<d*0.4) { 
280           b2-=dd;
281         }
282         else { 
283           b2-= d * db2;           decalageb2=-1;
284         }
285       }
286       else { 
287         b2-=d * db2;      decalageb2=-1;
288       }
289     }
290
291
292
293 //    if(EnBout) { //-- ************************************************************
294 //      Standard_Real d=b2-a2;
295 //      a2+=d*0.45;
296 //      b2-=d*0.45;
297 //    }
298
299
300
301
302
303     
304     ((HLRBRep_Curve*)myC2)->D0(a2,pa2);
305     ((HLRBRep_Curve*)myC2)->D0(b2,pb2);
306     
307     a2 = ((HLRBRep_Curve*)myC2)->Parameter2d(a2);
308     b2 = ((HLRBRep_Curve*)myC2)->Parameter2d(b2);
309     
310     if(EnBout) { 
311       ta=tb=-1.;
312     }
313     
314     if(ta>tol) ta=(Standard_ShortReal) tol;
315     if(tb>tol) tb=(Standard_ShortReal) tol;
316     
317     IntRes2d_Domain D2(pa2,a2,(Standard_Real)ta,pb2,b2,(Standard_Real)tb);
318     
319     
320     if(EnBout) { 
321       Standard_Real a1a2 = (da1 || da2)? pa1.Distance(pa2) : RealLast();
322       Standard_Real a1b2 = (da1 || db2)? pa1.Distance(pb2) : RealLast();
323       Standard_Real b1a2 = (db1 || da2)? pb1.Distance(pa2) : RealLast();
324       Standard_Real b1b2 = (db1 || db2)? pb1.Distance(pb2) : RealLast();
325       
326       Standard_Integer cote=1;
327       Standard_Real mindist = a1a2;      //-- cas 1 
328       if(mindist>a1b2) { mindist = a1b2; cote=2; } 
329       if(mindist>b1a2) { mindist = b1a2; cote=3; } 
330       if(mindist>b1b2) { mindist = b1b2; cote=4; } 
331
332       
333
334       //--printf("\n----- Edge %3d  %3d   [%7.5g  %7.5g] [%7.5g  %7.5g] Mindist:%8.5g   1000*Tol:%8.5g\n",
335       //--     nA,nB,decalagea1,decalageb1,decalagea2,decalageb2,mindist,1000.0*tol);
336       
337       
338       if(mindist < tol*1000) { 
339         PasBon=Standard_True;
340         switch (cote) { 
341         case 1:  { decalagea1*=2; decalagea2*=2; break; } 
342         case 2:  { decalagea1*=2; decalageb2*=2; break; } 
343         case 3:  { decalageb1*=2; decalagea2*=2; break; } 
344         default: { decalageb1*=2; decalageb2*=2; break; } 
345         }
346         if(decalagea1<0.0 || decalagea2<0.0 || decalageb1<0.0 || decalageb2<=0.0) { 
347           PasBon=Standard_False; 
348         }
349       }
350     }
351     if(PasBon==Standard_False) { 
352       myIntersector.Perform(myC1,D1,myC2,D2,tol,tol);
353     }
354   }
355   while(PasBon);
356   
357
358   
359   
360 #if PERF
361   NbInters++;
362   if(myIntersector.NbPoints()==1) { 
363     if(myIntersector.NbSegments()==0) { 
364       NbInters1Point++;
365     }
366     else { 
367       NbIntersPointEtSegment++;
368     }
369   }
370   else if(myIntersector.NbPoints()==0) { 
371     if(myIntersector.NbSegments()==0) {
372       NbIntersVides++;
373     }
374     else if(myIntersector.NbSegments()==1) {
375       NbInters1Segment++;
376     }
377     else { 
378       NbIntersNSegments++;
379     }
380   }
381   else {
382     if(myIntersector.NbSegments()==0) { 
383       NbIntersNPoints++;
384     }
385     else { 
386       NbIntersPointEtSegment++;
387     }
388   } 
389 #endif
390 }
391
392 //=======================================================================
393 //function : SimulateOnePoint
394 //purpose  : 
395 //=======================================================================
396
397 void  HLRBRep_Intersector::SimulateOnePoint(const Standard_Address A1,
398                                             const Standard_Real    u,
399                                             const Standard_Address A2,
400                                             const Standard_Real    v) { 
401 #if PERF
402   NbIntersSimulate++;
403 #endif
404   Standard_Address myC1 = ((HLRBRep_EdgeData*) A1)->Curve();
405   Standard_Address myC2 = ((HLRBRep_EdgeData*) A2)->Curve();
406
407   Standard_Real u3= ((HLRBRep_Curve*)myC1)->Parameter3d(u);
408   Standard_Real v3= ((HLRBRep_Curve*)myC2)->Parameter3d(v);
409   gp_Pnt2d P13,P23;   
410   gp_Vec2d T13,T23;
411   ((HLRBRep_Curve*)myC1)->D1(u3,P13,T13);
412   ((HLRBRep_Curve*)myC2)->D1(v3,P23,T23);
413   
414   IntRes2d_Transition Tr1,Tr2;
415   IntRes2d_Position Pos1,Pos2;
416   Pos1=Pos2=IntRes2d_Middle;
417   
418   IntImpParGen::DetermineTransition(Pos1,T13,Tr1,Pos2,T23,Tr2,0.0);
419   myTypePerform = 0;
420   mySinglePoint.SetValues(P13,u,v,Tr1,Tr2,Standard_False);
421 }
422
423
424
425 //=======================================================================
426 //function : Load
427 //purpose  : 
428 //=======================================================================
429
430 void  HLRBRep_Intersector::Load (Standard_Address& A)
431 {
432   mySurface = A;
433   if (myPolyhedron != NULL) { 
434     delete (HLRBRep_ThePolyhedronOfInterCSurf*)myPolyhedron;
435     myPolyhedron = NULL;
436   }
437 }
438
439 //=======================================================================
440 //function : Perform
441 //purpose  : 
442 //=======================================================================
443
444 void  HLRBRep_Intersector::Perform (const gp_Lin& L,
445                                     const Standard_Real P)
446 {
447   myTypePerform = 2;
448   GeomAbs_SurfaceType typ = HLRBRep_SurfaceTool::GetType(mySurface);
449   switch (typ) {
450   case GeomAbs_Plane :
451   case GeomAbs_Cylinder :
452   case GeomAbs_Cone :
453   case GeomAbs_Sphere :
454   case GeomAbs_Torus :
455     myCSIntersector.Perform(L,mySurface);
456     break;
457     default :
458     {
459       if (myPolyhedron == NULL) {
460         Standard_Integer nbsu,nbsv;
461         Standard_Real u1,v1,u2,v2;
462         u1   = HLRBRep_SurfaceTool::FirstUParameter(mySurface);
463         v1   = HLRBRep_SurfaceTool::FirstVParameter(mySurface);
464         u2   = HLRBRep_SurfaceTool::LastUParameter(mySurface);
465         v2   = HLRBRep_SurfaceTool::LastVParameter(mySurface);   
466         nbsu = HLRBRep_SurfaceTool::NbSamplesU(mySurface,u1,u2);
467         nbsv = HLRBRep_SurfaceTool::NbSamplesV(mySurface,v1,v2);
468         myPolyhedron = (Standard_Address)
469           (new HLRBRep_ThePolyhedronOfInterCSurf
470            (mySurface,nbsu,nbsv,u1,v1,u2,v2));
471       }
472       Standard_Real x0,y0,z0,x1,y1,z1,pmin,pmax;//,pp;
473       ((HLRBRep_ThePolyhedronOfInterCSurf*)myPolyhedron)
474         ->Bounding().Get(x0,y0,z0,x1,y1,z1);
475 #if 0
476       pmax = pmin = ElCLib::Parameter(L, gp_Pnt((x1+x0)*0.5,
477                                                 (y1+y0)*0.5,
478                                                 (z1+z0)*0.5));
479       Standard_Real d = (x1-x0) + (y1-y0) + (z1-z0);
480       pmin -= d;
481       pmax += d;
482       if (pmin > P) pmin = P - d;
483       if (pmax > P) pmax = P;
484       HLRBRep_ThePolygonOfInterCSurf Polygon(L,pmin,pmax,3);
485       myCSIntersector.Perform(L,Polygon,mySurface,
486                               *((HLRBRep_ThePolyhedronOfInterCSurf*)
487                                 myPolyhedron));
488       break;
489 #else 
490       //-- On va rejeter tous les points de parametres > P
491       Standard_Real p;
492       p = ElCLib::Parameter(L, gp_Pnt(x0,y0,z0));  pmin=pmax=p;
493       p = ElCLib::Parameter(L, gp_Pnt(x0,y0,z1));  if(pmin>p) pmin=p; if(pmax<p) pmax=p;
494
495       p = ElCLib::Parameter(L, gp_Pnt(x1,y0,z0));  if(pmin>p) pmin=p; if(pmax<p) pmax=p;
496       p = ElCLib::Parameter(L, gp_Pnt(x1,y0,z1));  if(pmin>p) pmin=p; if(pmax<p) pmax=p;
497
498       p = ElCLib::Parameter(L, gp_Pnt(x0,y1,z0));  if(pmin>p) pmin=p; if(pmax<p) pmax=p;
499       p = ElCLib::Parameter(L, gp_Pnt(x0,y1,z1));  if(pmin>p) pmin=p; if(pmax<p) pmax=p;
500
501       p = ElCLib::Parameter(L, gp_Pnt(x1,y1,z0));  if(pmin>p) pmin=p; if(pmax<p) pmax=p;
502       p = ElCLib::Parameter(L, gp_Pnt(x1,y1,z1));  if(pmin>p) pmin=p; if(pmax<p) pmax=p;
503       pmin-=0.000001; pmax+=0.000001;
504
505       if(pmin>P) { pmin=pmax+1; pmax=pmax+2; } //-- on va rejeter avec les boites
506       else { 
507         if(pmax>P) pmax=P+0.0000001;
508       }
509       HLRBRep_ThePolygonOfInterCSurf Polygon(L,pmin,pmax,3);
510       myCSIntersector.Perform(L,Polygon,mySurface,
511                               *((HLRBRep_ThePolyhedronOfInterCSurf*)
512                                 myPolyhedron));
513       
514       break;
515 #endif
516
517     }
518   }
519 #if PERF
520   NbIntersCS++;
521   if(myCSIntersector.NbPoints()==0) { 
522     NbIntersCSVides++;
523   }
524 #endif
525  
526 }
527
528 //=======================================================================
529 //function : IsDone
530 //purpose  : 
531 //=======================================================================
532
533 Standard_Boolean HLRBRep_Intersector::IsDone () const
534
535   if(myTypePerform == 1) 
536     return myIntersector  .IsDone();
537   else if(myTypePerform ==2) 
538     return myCSIntersector.IsDone();
539   else 
540     return(Standard_True);
541 }
542
543 //=======================================================================
544 //function : NbPoints
545 //purpose  : 
546 //=======================================================================
547
548 Standard_Integer HLRBRep_Intersector::NbPoints() const
549 {
550   if(myTypePerform==43) return(0);
551
552   if (myTypePerform == 1) 
553     return myIntersector  .NbPoints();
554   else if(myTypePerform == 2) 
555     return myCSIntersector.NbPoints();
556   else 
557     return(1);
558 }
559
560 //=======================================================================
561 //function : Point
562 //purpose  : 
563 //=======================================================================
564
565 const IntRes2d_IntersectionPoint &
566 HLRBRep_Intersector::Point (const Standard_Integer N) const
567 {
568   if(myTypePerform==0) 
569     return(mySinglePoint);
570   else 
571     return myIntersector.Point(N);
572 }
573
574 //=======================================================================
575 //function : CSPoint
576 //purpose  : 
577 //=======================================================================
578
579 const IntCurveSurface_IntersectionPoint &
580  HLRBRep_Intersector::CSPoint (const Standard_Integer N) const
581 {
582   return myCSIntersector.Point(N);
583 }
584
585 //=======================================================================
586 //function : NbSegments
587 //purpose  : 
588 //=======================================================================
589
590 Standard_Integer HLRBRep_Intersector::NbSegments () const
591 {
592   if(myTypePerform == 1) 
593     return myIntersector  .NbSegments();
594   else if(myTypePerform==2) 
595     return myCSIntersector.NbSegments();
596   else 
597     return(0);
598 }
599
600 //=======================================================================
601 //function : Segment
602 //purpose  : 
603 //=======================================================================
604
605 const IntRes2d_IntersectionSegment &
606 HLRBRep_Intersector::Segment (const Standard_Integer N) const
607 {
608   return myIntersector .Segment(N);
609 }
610
611 //=======================================================================
612 //function : CSSegment
613 //purpose  : 
614 //=======================================================================
615
616 const IntCurveSurface_IntersectionSegment & 
617 HLRBRep_Intersector::CSSegment (const Standard_Integer N) const
618 {
619   return myCSIntersector.Segment(N);
620 }
621
622 //=======================================================================
623 //function : Destroy
624 //purpose  : 
625 //=======================================================================
626
627 void HLRBRep_Intersector::Destroy ()
628 {
629   if (myPolyhedron != NULL)
630     delete (HLRBRep_ThePolyhedronOfInterCSurf *)myPolyhedron;
631 }
632
633
634
635
636
637
638
639
640
641
642 /* ********************************************************************************
643    
644    sauvegarde de l etat du 23 janvier 98 
645    
646    
647 void  HLRBRep_Intersector::Perform (const Standard_Integer nA,
648                                     const Standard_Address A1,
649                                     const Standard_Real da1,
650                                     const Standard_Real db1,
651                                     const Standard_Integer nB,
652                                     const Standard_Address A2,
653                                     const Standard_Real da2,
654                                     const Standard_Real db2,
655                                     const Standard_Boolean EnBout)
656 {
657   Standard_Address myC1 = ((HLRBRep_EdgeData*) A1)->Curve();
658   Standard_Address myC2 = ((HLRBRep_EdgeData*) A2)->Curve();
659
660   myTypePerform = 1;
661
662   gp_Pnt2d pa,pb;
663   Standard_Real a,b,d,tol,tol1,tol2;
664   Standard_ShortReal ta,tb;
665
666   tol1 = (Standard_Real)(((HLRBRep_EdgeData*) A1)->Tolerance());
667   tol2 = (Standard_Real)(((HLRBRep_EdgeData*) A2)->Tolerance());
668   if (tol1 > tol2) tol = tol1;
669   else             tol = tol2;
670
671   ((HLRBRep_EdgeData*) A1)->Status().Bounds(a,ta,b,tb); //--   -> Parametres 3d 
672   Standard_Real mtol = tol;
673   if(mtol<ta) mtol=ta;
674   if(mtol<tb) mtol=tb;
675   d = b - a;
676   if (da1 != 0) a = a + d * da1;
677   if (db1 != 0) b = b - d * db1;
678   ((HLRBRep_Curve*)myC1)->D0(a,pa);
679   ((HLRBRep_Curve*)myC1)->D0(b,pb);
680
681   a = ((HLRBRep_Curve*)myC1)->Parameter2d(a);
682   b = ((HLRBRep_Curve*)myC1)->Parameter2d(b);
683
684   if(EnBout) { 
685     ta=tb=0;
686   }
687   
688   if(ta>tol) ta=tol;
689   if(tb>tol) tb=tol;
690
691
692   IntRes2d_Domain D1(pa,a,(Standard_Real)ta,pb,b,(Standard_Real)tb);  
693
694   ((HLRBRep_EdgeData*) A2)->Status().Bounds(a,ta,b,tb);
695   mtol = tol;
696   if(mtol<ta) mtol=ta;
697   if(mtol<tb) mtol=tb;
698
699   d = b - a;
700   if (da2 != 0) a = a + d * da2;
701   if (db2 != 0) b = b - d * db2;
702   ((HLRBRep_Curve*)myC2)->D0(a,pa);
703   ((HLRBRep_Curve*)myC2)->D0(b,pb);
704
705   a = ((HLRBRep_Curve*)myC2)->Parameter2d(a);
706   b = ((HLRBRep_Curve*)myC2)->Parameter2d(b);
707  
708   if(EnBout) { 
709     ta=tb=0;
710   }
711
712   if(ta>tol) ta=tol;
713   if(tb>tol) tb=tol;
714
715
716  IntRes2d_Domain D2(pa,a,(Standard_Real)ta,pb,b,(Standard_Real)tb);
717
718   myIntersector.Perform(myC1,D1,myC2,D2,tol,tol);
719   
720   
721   
722   
723   
724 #if PERF
725   NbInters++;
726   if(myIntersector.NbPoints()==1) { 
727     if(myIntersector.NbSegments()==0) { 
728       NbInters1Point++;
729     }
730     else { 
731       NbIntersPointEtSegment++;
732     }
733   }
734   else if(myIntersector.NbPoints()==0) { 
735     if(myIntersector.NbSegments()==0) {
736       NbIntersVides++;
737     }
738     else if(myIntersector.NbSegments()==1) {
739       NbInters1Segment++;
740     }
741     else { 
742       NbIntersNSegments++;
743     }
744   }
745   else {
746     if(myIntersector.NbSegments()==0) { 
747       NbIntersNPoints++;
748     }
749     else { 
750       NbIntersPointEtSegment++;
751     }
752   } 
753 #endif
754 }
755 ******************************************************************************** */