1 // File: IntPatch_ImpImpIntersection_2.gxx
2 // Created: Thu May 7 08:47:45 1992
3 // Author: Jacques GOUSSARD
4 // Copyright: OPEN CASCADE 1992
6 //=======================================================================
7 //function : IntPatch_ImpImpIntersection
9 //=======================================================================
10 IntPatch_ImpImpIntersection::IntPatch_ImpImpIntersection ():
14 //=======================================================================
15 //function : IntPatch_ImpImpIntersection
17 //=======================================================================
18 IntPatch_ImpImpIntersection::IntPatch_ImpImpIntersection
19 (const Handle(Adaptor3d_HSurface)& S1,
20 const Handle(Adaptor3d_TopolTool)& D1,
21 const Handle(Adaptor3d_HSurface)& S2,
22 const Handle(Adaptor3d_TopolTool)& D2,
23 const Standard_Real TolArc,
24 const Standard_Real TolTang)
26 Perform(S1,D1,S2,D2,TolArc,TolTang);
28 //=======================================================================
31 //=======================================================================
32 void IntPatch_ImpImpIntersection::Perform(const Handle(Adaptor3d_HSurface)& S1,
33 const Handle(Adaptor3d_TopolTool)& D1,
34 const Handle(Adaptor3d_HSurface)& S2,
35 const Handle(Adaptor3d_TopolTool)& D2,
36 const Standard_Real TolArc,
37 const Standard_Real TolTang) {
38 done = Standard_False;
43 tgte = Standard_False;
44 oppo = Standard_False;
46 Standard_Boolean all1 = Standard_False;
47 Standard_Boolean all2 = Standard_False;
48 Standard_Boolean SameSurf = Standard_False;
49 Standard_Boolean multpoint = Standard_False;
51 Standard_Boolean nosolonS1 = Standard_False;
52 // indique s il y a des points sur restriction du carreau 1
53 Standard_Boolean nosolonS2 = Standard_False;
54 // indique s il y a des points sur restriction du carreau 2
55 Standard_Integer i, nbpt, nbseg;
56 IntPatch_SequenceOfSegmentOfTheSOnBounds edg1,edg2;
57 IntPatch_SequenceOfPathPointOfTheSOnBounds pnt1,pnt2;
59 // On commence par intersecter les supports des surfaces
60 IntSurf_Quadric quad1;
61 IntSurf_Quadric quad2;
62 IntPatch_ArcFunction AFunc;
63 Standard_Real Tolang = 1.e-8;
64 GeomAbs_SurfaceType typs1 = S1->GetType();
65 GeomAbs_SurfaceType typs2 = S2->GetType();
71 quad1.SetValue(S1->Plane());
77 quad2.SetValue(S2->Plane());
78 if (!IntPP(quad1,quad2,Tolang,TolTang,SameSurf,slin)) {
85 case GeomAbs_Cylinder:
87 quad2.SetValue(S2->Cylinder());
88 if (!IntPCy(quad1,quad2,Tolang,TolTang,Standard_False,empt,slin)) {
100 quad2.SetValue(S2->Sphere());
101 //modified by NIZNHY-PKV Tue Sep 20 09:03:06 2011f
102 if (!IntPSp(quad1,quad2,Tolang,TolTang,Standard_False,empt,slin,spnt)) {
103 //if (!IntPSp(quad1,quad2,TolTang,Standard_False,empt,slin,spnt)) {
104 //modified by NIZNHY-PKV Tue Sep 20 09:03:10 2011t
108 done = Standard_True;
116 quad2.SetValue(S2->Cone());
117 if (!IntPCo(quad1,quad2,Tolang,TolTang,Standard_False,
118 empt,multpoint,slin,spnt)) {
122 done = Standard_True;
129 Standard_ConstructionError::Raise();
136 case GeomAbs_Cylinder:
138 quad1.SetValue(S1->Cylinder());
143 quad2.SetValue(S2->Plane());
144 if (!IntPCy(quad1,quad2,Tolang,TolTang,Standard_True,empt,slin)) {
148 done = Standard_True;
154 case GeomAbs_Cylinder:
156 quad2.SetValue(S2->Cylinder());
157 if (!IntCyCy(quad1,quad2,TolTang,empt,SameSurf,multpoint,slin,spnt)) {
161 done = Standard_True;
169 quad2.SetValue(S2->Sphere());
170 if (!IntCySp(quad1,quad2,TolTang,Standard_False,empt,multpoint,
175 done = Standard_True;
184 quad2.SetValue(S2->Cone());
185 if (!IntCyCo(quad1,quad2,TolTang,Standard_False,empt,multpoint,
190 done = Standard_True;
197 Standard_ConstructionError::Raise();
207 quad1.SetValue(S1->Sphere());
213 quad2.SetValue(S2->Plane());
214 //modified by NIZNHY-PKV Tue Sep 20 09:03:35 2011f
215 if (!IntPSp(quad1,quad2,Tolang,TolTang,Standard_True,empt,slin,spnt)) {
216 //if (!IntPSp(quad1,quad2,TolTang,Standard_True,empt,slin,spnt)) {
217 //modified by NIZNHY-PKV Tue Sep 20 09:03:38 2011t
221 done = Standard_True;
227 case GeomAbs_Cylinder:
229 quad2.SetValue(S2->Cylinder());
230 if (!IntCySp(quad1,quad2,TolTang,Standard_True,empt,multpoint,
235 done = Standard_True;
243 quad2.SetValue(S2->Sphere());
244 if (!IntSpSp(quad1,quad2,TolTang,empt,SameSurf,slin,spnt)) {
248 done = Standard_True;
256 quad2.SetValue(S2->Cone());
257 if (!IntCoSp(quad1,quad2,TolTang,Standard_True,empt,multpoint,
262 done = Standard_True;
269 Standard_ConstructionError::Raise();
279 quad1.SetValue(S1->Cone());
285 quad2.SetValue(S2->Plane());
286 if (!IntPCo(quad1,quad2,Tolang,TolTang,Standard_True,
287 empt,multpoint,slin,spnt)) {
291 done = Standard_True;
297 case GeomAbs_Cylinder:
299 quad2.SetValue(S2->Cylinder());
300 if (!IntCyCo(quad1,quad2,TolTang,Standard_True,empt,multpoint,
305 done = Standard_True;
313 quad2.SetValue(S2->Sphere());
314 if (!IntCoSp(quad1,quad2,TolTang,Standard_False,empt,multpoint,
319 done = Standard_True;
327 quad2.SetValue(S2->Cone());
328 if (!IntCoCo(quad1,quad2,TolTang,empt,SameSurf,multpoint,
333 done = Standard_True;
341 Standard_ConstructionError::Raise();
350 Standard_ConstructionError::Raise();
356 AFunc.SetQuadric(quad2);
359 solrst.Perform(AFunc, D1, TolArc, TolTang);
360 if (!solrst.IsDone()) {
364 if (solrst.AllArcSolution() && typs1 == typs2) {
365 all1 = Standard_True;
367 nbpt = solrst.NbPoints();
368 nbseg= solrst.NbSegments();
369 for (i=1; i<= nbpt; i++) {
370 pnt1.Append(solrst.Point(i));
372 for (i=1; i<= nbseg; i++) {
373 edg1.Append(solrst.Segment(i));
375 nosolonS1 = (nbpt == 0) && (nbseg == 0);
377 if (nosolonS1 && all1) { // cas de face sans restrictions
378 all1 = Standard_False;
382 nosolonS1 = Standard_True;
386 AFunc.SetQuadric(quad1);
389 solrst.Perform(AFunc, D2, TolArc, TolTang);
390 if (!solrst.IsDone()) {
394 if (solrst.AllArcSolution() && typs1 == typs2) {
395 all2 = Standard_True;
397 nbpt = solrst.NbPoints();
398 nbseg= solrst.NbSegments();
399 for (i=1; i<= nbpt; i++) {
400 pnt2.Append(solrst.Point(i));
403 for (i=1; i<= nbseg; i++) {
404 edg2.Append(solrst.Segment(i));
406 nosolonS2 = (nbpt == 0) && (nbseg == 0);
408 if (nosolonS2 && all2) { // cas de face sans restrictions
409 all2 = Standard_False;
413 nosolonS2 = Standard_True;
416 if (SameSurf || (all1 && all2)) {
417 // faces "paralleles" parfaites
418 empt = Standard_False;
419 tgte = Standard_True;
426 case GeomAbs_Plane: {
427 Ptreference = (S1->Plane()).Location();
430 case GeomAbs_Cylinder: {
431 Ptreference = ElSLib::Value(0.,0.,S1->Cylinder());
434 case GeomAbs_Sphere: {
435 Ptreference = ElSLib::Value(PI/4.,PI/4.,S1->Sphere());
439 Ptreference = ElSLib::Value(0.,10.,S1->Cone());
446 oppo = quad1.Normale(Ptreference).Dot(quad2.Normale(Ptreference)) < 0.0;
447 done = Standard_True;
449 }// if (SameSurf || (all1 && all2)) {
451 if (!nosolonS1 || !nosolonS2) {
452 empt = Standard_False;
453 // C est la qu il faut commencer a bosser...
454 PutPointsOnLine(S1,S2,pnt1, slin, Standard_True, D1, quad1,quad2,
457 PutPointsOnLine(S1,S2,pnt2, slin, Standard_False,D2, quad2,quad1,
460 if (edg1.Length() != 0) {
461 ProcessSegments(edg1,slin,quad1,quad2,Standard_True,TolArc);
464 if (edg2.Length() != 0) {
465 ProcessSegments(edg2,slin,quad1,quad2,Standard_False,TolArc);
468 if (edg1.Length() !=0 || edg2.Length() !=0) {
469 // ProcessRLine(slin,S1,S2,TolArc);
470 ProcessRLine(slin,quad1,quad2,TolArc);
472 }//if (!nosolonS1 || !nosolonS2) {
474 empt = ((slin.Length()==0) && (spnt.Length()==0));
477 Standard_Integer nblin, aNbPnt;
479 //modified by NIZNHY-PKV Tue Sep 06 10:03:35 2011f
480 aNbPnt=spnt.Length();
482 IntPatch_SequenceOfPoint aSIP;
484 for(i=1; i<=aNbPnt; ++i) {
485 Standard_Real aU1, aV1, aU2, aV2;
487 TopAbs_State aState1, aState2;
489 const IntPatch_Point& aIP=spnt(i);
490 aIP.Parameters(aU1, aV1, aU2, aV2);
492 aP2D.SetCoord(aU1, aV1);
493 aState1=D1->Classify(aP2D, TolArc);
495 aP2D.SetCoord(aU2, aV2);
496 aState2=D2->Classify(aP2D, TolArc);
498 if(aState1!=TopAbs_OUT && aState2!=TopAbs_OUT) {
505 aNbPnt=aSIP.Length();
506 for(i=1; i<=aNbPnt; ++i) {
507 const IntPatch_Point& aIP=aSIP(i);
512 //modified by NIZNHY-PKV Tue Sep 06 10:18:20 2011t
514 nblin = slin.Length();
515 for(i=1; i<=nblin; i++) {
516 IntPatch_IType thetype = slin.Value(i)->ArcType();
517 if( (thetype == IntPatch_Ellipse)
518 ||(thetype == IntPatch_Circle)
519 ||(thetype == IntPatch_Lin)
520 ||(thetype == IntPatch_Parabola)
521 ||(thetype == IntPatch_Hyperbola)) {
522 Handle(IntPatch_GLine)& glin = *((Handle(IntPatch_GLine)*)&slin.Value(i));
523 glin->ComputeVertexParameters(TolArc);
525 else if(thetype == IntPatch_Analytic) {
526 Handle(IntPatch_ALine)& aligold = *((Handle(IntPatch_ALine)*)&slin.Value(i));
527 aligold->ComputeVertexParameters(TolArc);
529 else if(thetype == IntPatch_Restriction) {
530 Handle(IntPatch_RLine)& rlig = *((Handle(IntPatch_RLine)*)&slin.Value(i));
531 rlig->ComputeVertexParameters(TolArc);
535 //----------------------------------------------------------------
536 //-- On place 2 vertex sur les courbes de GLine qui n en
537 //-- contiennent pas.
538 for(i=1; i<=nblin; i++) {
540 IntPatch_Point point;
541 Standard_Real u1,v1,u2,v2;
542 Standard_Integer nbv;
543 if(slin.Value(i)->ArcType() == IntPatch_Circle) {
544 const Handle(IntPatch_GLine)& glin = *((Handle(IntPatch_GLine)*)&slin.Value(i));
545 nbv = glin->NbVertex();
546 if(glin->NbVertex() == 0) {
547 gp_Circ Circ = glin->Circle();
548 P=ElCLib::Value(0.0,Circ);
549 quad1.Parameters(P,u1,v1);
550 quad2.Parameters(P,u2,v2);
551 point.SetValue(P,TolArc,Standard_False);
552 point.SetParameters(u1,v1,u2,v2);
553 point.SetParameter(0.0);
554 glin->AddVertex(point);
556 P=ElCLib::Value(0.0,Circ);
557 quad1.Parameters(P,u1,v1);
558 quad2.Parameters(P,u2,v2);
559 point.SetValue(P,TolArc,Standard_False);
560 point.SetParameters(u1,v1,u2,v2);
561 point.SetParameter(PI+PI);
562 glin->AddVertex(point);
566 else if(slin.Value(i)->ArcType() == IntPatch_Ellipse) {
567 const Handle(IntPatch_GLine)& glin = *((Handle(IntPatch_GLine)*)&slin.Value(i));
568 nbv = glin->NbVertex();
569 if(glin->NbVertex() == 0) {
570 gp_Elips Elips = glin->Ellipse();
571 P=ElCLib::Value(0.0,Elips);
572 quad1.Parameters(P,u1,v1);
573 quad2.Parameters(P,u2,v2);
574 point.SetValue(P,TolArc,Standard_False);
575 point.SetParameters(u1,v1,u2,v2);
576 point.SetParameter(0.0);
577 glin->AddVertex(point);
579 P=ElCLib::Value(0.0,Elips);
580 quad1.Parameters(P,u1,v1);
581 quad2.Parameters(P,u2,v2);
582 point.SetValue(P,TolArc,Standard_False);
583 point.SetParameters(u1,v1,u2,v2);
584 point.SetParameter(PI+PI);
585 glin->AddVertex(point);
589 done = Standard_True;