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