1 // Created on: 1996-11-07
2 // Created by: Laurent BUCHARD
3 // Copyright (c) 1996-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
6 // This file is part of Open CASCADE Technology software library.
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.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
17 #include <IntPatch_LineConstructor.ixx>
19 #include <IntPatch_GLine.hxx>
20 #include <IntPatch_ALine.hxx>
21 #include <IntPatch_WLine.hxx>
22 #include <IntPatch_RLine.hxx>
23 #include <Adaptor2d_HCurve2d.hxx>
29 #include <IntSurf_Quadric.hxx>
30 #include <IntSurf_PntOn2S.hxx>
31 #include <Standard_ConstructionError.hxx>
32 #include <GeomAbs_SurfaceType.hxx>
34 #include <Geom2dInt_TheProjPCurOfGInter.hxx>
35 #include <TColStd_SequenceOfInteger.hxx>
36 #include <TColStd_IndexedMapOfTransient.hxx>
37 #include <TColStd_Array1OfTransient.hxx>
38 #include <TColStd_Array1OfReal.hxx>
41 //=======================================================================
44 //=======================================================================
46 static void Recadre(const Handle(Adaptor3d_HSurface)& myHS1,
47 const Handle(Adaptor3d_HSurface)& myHS2,
52 Standard_Real f,l,lmf;
53 GeomAbs_SurfaceType typs1 = myHS1->GetType();
54 GeomAbs_SurfaceType typs2 = myHS2->GetType();
56 Standard_Boolean myHS1IsUPeriodic,myHS1IsVPeriodic;
58 case GeomAbs_Cylinder:
62 myHS1IsUPeriodic = Standard_True;
63 myHS1IsVPeriodic = Standard_False;
68 myHS1IsUPeriodic = myHS1IsVPeriodic = Standard_True;
73 //-- Le cas de biparametrees periodiques est gere en amont
74 myHS1IsUPeriodic = myHS1IsVPeriodic = Standard_False;
79 Standard_Boolean myHS2IsUPeriodic,myHS2IsVPeriodic;
81 case GeomAbs_Cylinder:
85 myHS2IsUPeriodic = Standard_True;
86 myHS2IsVPeriodic = Standard_False;
91 myHS2IsUPeriodic = myHS2IsVPeriodic = Standard_True;
96 //-- Le cas de biparametrees periodiques est gere en amont
97 myHS2IsUPeriodic = myHS2IsVPeriodic = Standard_False;
101 if(myHS1IsUPeriodic) {
102 lmf = M_PI+M_PI; //-- myHS1->UPeriod();
103 f = myHS1->FirstUParameter();
104 l = myHS1->LastUParameter();
105 while(u1 < f) { u1+=lmf; }
106 while(u1 > l) { u1-=lmf; }
108 if(myHS1IsVPeriodic) {
109 lmf = M_PI+M_PI; //-- myHS1->VPeriod();
110 f = myHS1->FirstVParameter();
111 l = myHS1->LastVParameter();
112 while(v1 < f) { v1+=lmf; }
113 while(v1 > l) { v1-=lmf; }
115 if(myHS2IsUPeriodic) {
116 lmf = M_PI+M_PI; //-- myHS2->UPeriod();
117 f = myHS2->FirstUParameter();
118 l = myHS2->LastUParameter();
119 while(u2 < f) { u2+=lmf; }
120 while(u2 > l) { u2-=lmf; }
122 if(myHS2IsVPeriodic) {
123 lmf = M_PI+M_PI; //-- myHS2->VPeriod();
124 f = myHS2->FirstVParameter();
125 l = myHS2->LastVParameter();
126 while(v2 < f) { v2+=lmf; }
127 while(v2 > l) { v2-=lmf; }
131 //=======================================================================
132 //function : Parameters
134 //=======================================================================
136 static void Parameters(const Handle(Adaptor3d_HSurface)& myHS1,
137 const Handle(Adaptor3d_HSurface)& myHS2,
144 IntSurf_Quadric quad1,quad2;
145 GeomAbs_SurfaceType typs = myHS1->Surface().GetType();
148 quad1.SetValue(myHS1->Surface().Plane());
150 case GeomAbs_Cylinder:
151 quad1.SetValue(myHS1->Surface().Cylinder());
154 quad1.SetValue(myHS1->Surface().Cone());
157 quad1.SetValue(myHS1->Surface().Sphere());
160 quad1.SetValue(myHS1->Surface().Torus());
163 Standard_ConstructionError::Raise("IntPatch_IntSS::MakeCurve");
166 typs = myHS2->Surface().GetType();
169 quad2.SetValue(myHS2->Surface().Plane());
171 case GeomAbs_Cylinder:
172 quad2.SetValue(myHS2->Surface().Cylinder());
175 quad2.SetValue(myHS2->Surface().Cone());
178 quad2.SetValue(myHS2->Surface().Sphere());
181 quad2.SetValue(myHS2->Surface().Torus());
184 Standard_ConstructionError::Raise("IntPatch_IntSS::MakeCurve");
186 quad1.Parameters(Ptref,U1,V1);
187 quad2.Parameters(Ptref,U2,V2);
190 //=======================================================================
191 //function : LocalFirstParameter
193 //=======================================================================
195 static Standard_Real LocalFirstParameter (const Handle(IntPatch_Line)& L)
197 Standard_Real firstp =0.;
198 IntPatch_IType typl = L->ArcType();
200 case IntPatch_Analytic:
202 Handle(IntPatch_ALine)& alin = *((Handle(IntPatch_ALine) *)&L);
203 if (alin->HasFirstPoint()) {
204 firstp = alin->FirstPoint().ParameterOnLine();
207 Standard_Boolean included;
208 firstp = alin->FirstParameter(included);
210 firstp +=Epsilon(firstp);
216 case IntPatch_Restriction:
218 Handle(IntPatch_RLine)& rlin = *((Handle(IntPatch_RLine) *)&L);
219 if (rlin->HasFirstPoint()) {
220 firstp = rlin->FirstPoint().ParameterOnLine();
223 firstp = -Precision::Infinite(); // a voir selon le type de la ligne 2d
227 case IntPatch_Walking:
230 Handle(IntPatch_WLine)& wlin = *((Handle(IntPatch_WLine) *) &L);
231 if (wlin->HasFirstPoint()) {
232 firstp = wlin->FirstPoint().ParameterOnLine();
242 Handle(IntPatch_GLine)& glin = *((Handle(IntPatch_GLine) *)&L);
243 if (glin->HasFirstPoint()) {
244 firstp = glin->FirstPoint().ParameterOnLine();
249 case IntPatch_Parabola:
250 case IntPatch_Hyperbola:
251 firstp = -Precision::Infinite();
254 case IntPatch_Circle:
255 case IntPatch_Ellipse:
269 //=======================================================================
270 //function : LocalLastParameter
272 //=======================================================================
274 static Standard_Real LocalLastParameter (const Handle(IntPatch_Line)& L)
276 Standard_Real lastp =0.;
277 IntPatch_IType typl = L->ArcType();
279 case IntPatch_Analytic:
281 Handle(IntPatch_ALine)& alin = *((Handle(IntPatch_ALine) *)&L);
283 if (alin->HasLastPoint()) {
284 lastp = alin->LastPoint().ParameterOnLine();
287 Standard_Boolean included;
288 lastp = alin->LastParameter(included);
290 lastp -=Epsilon(lastp);
296 case IntPatch_Restriction:
298 Handle(IntPatch_RLine)& rlin = *((Handle(IntPatch_RLine) *)&L);
300 if (rlin->HasLastPoint()) {
301 lastp = rlin->LastPoint().ParameterOnLine();
304 lastp = Precision::Infinite(); // a voir selon le type de la ligne 2d
308 case IntPatch_Walking:
310 Handle(IntPatch_WLine)& wlin = *((Handle(IntPatch_WLine) *)&L);
312 if (wlin->HasLastPoint()) {
313 lastp = wlin->LastPoint().ParameterOnLine();
316 lastp = wlin->NbPnts();
323 Handle(IntPatch_GLine)& glin = *((Handle(IntPatch_GLine) *)&L);
325 if (glin->HasLastPoint()) {
326 lastp = glin->LastPoint().ParameterOnLine();
331 case IntPatch_Parabola:
332 case IntPatch_Hyperbola:
333 lastp = Precision::Infinite();
336 case IntPatch_Circle:
337 case IntPatch_Ellipse:
351 // modified by NIZHNY-MKK Tue Apr 3 15:03:06 2001.BEGIN
352 //=======================================================================
353 //function : ComputeParametricTolerance
355 //=======================================================================
357 static Standard_Real ComputeParametricTolerance(const Standard_Real theTol3d,
358 const gp_Vec& theD1u,
359 const gp_Vec& theD1v) {
360 Standard_Real nad1u = theD1u.Magnitude();
361 Standard_Real nad1v = theD1v.Magnitude();
362 Standard_Real tolu = 0., tolv = 0.;
364 tolu = theTol3d/nad1u;
367 tolv = theTol3d/nad1v;
369 Standard_Real aTolerance = (tolu > tolv) ? tolu : tolv;
372 // modified by NIZHNY-MKK Tue Apr 3 15:03:11 2001.END
375 //=======================================================================
376 //function : IntPatch_LineConstructor
378 //=======================================================================
380 IntPatch_LineConstructor::IntPatch_LineConstructor(const Standard_Integer )
384 //=======================================================================
385 //function : AppendSameVertexA
387 //=======================================================================
389 static Standard_Integer AppendSameVertexA(Handle(IntPatch_ALine)&alig,
390 const Handle(IntPatch_ALine)& L,
391 const Standard_Integer index,
392 Standard_Integer *TabIndex) {
393 Standard_Integer i,a,n;
396 const IntPatch_Point& Vtxindex = L->Vertex(index);
397 Standard_Real thetol1=Vtxindex.Tolerance();
400 const IntPatch_Point& Vtxi = L->Vertex(i);
401 Standard_Real thetol2=Vtxi.Tolerance();
404 Standard_Real d_4=Vtxindex.Value().Distance(Vtxi.Value());
406 alig->AddVertex(Vtxi);
408 TabIndex[i]=TabIndex[index];
415 //=======================================================================
416 //function : AppendSameVertexG
418 //=======================================================================
420 static Standard_Integer AppendSameVertexG(Handle(IntPatch_GLine)& glig,const Handle(IntPatch_GLine)&L,
421 const Standard_Integer index,
422 const Standard_Real decal,
423 Standard_Integer *TabIndex) {
424 Standard_Integer i,a,n;
425 Standard_Real p1,p2,d; //,tol
426 Standard_Boolean aajouter;
429 const IntPatch_Point& Vtxindex = L->Vertex(index);
430 Standard_Real thetol1=Vtxindex.Tolerance();
433 const IntPatch_Point& Vtxi = L->Vertex(i);
434 aajouter=Standard_False;
435 Standard_Real thetol2=Vtxi.Tolerance();
438 d=Vtxindex.Value().Distance(Vtxi.Value());
440 aajouter=Standard_True;
444 //-- Le test suivant a ete ajoute le 20 aout 98 (??? mefiance ???)
446 p1=Vtxindex.ParameterOnLine();
447 p2=Vtxi.ParameterOnLine();
448 if(Abs(p1-p2)<Precision::PConfusion()) {
449 aajouter=Standard_True;
453 p1= Vtxindex.ParameterOnLine();
454 IntPatch_Point aVtx = Vtxi;
455 aVtx.SetParameter(p1+decal);
456 glig->AddVertex(aVtx);
458 TabIndex[i]=TabIndex[index];
465 //=======================================================================
466 //function : AppendSameVertexW
468 //=======================================================================
470 static Standard_Integer AppendSameVertexW(Handle(IntPatch_WLine)& wlig,
471 const Handle(IntPatch_WLine)&L,
472 const Standard_Integer index,
473 const Standard_Real par,
474 Standard_Integer *TabIndex) {
475 Standard_Integer i,a,n;
478 const IntPatch_Point& Vtxindex = L->Vertex(index);
479 const gp_Pnt& Pntindex = Vtxindex.Value();
480 Standard_Real thetol1=Vtxindex.Tolerance();
483 IntPatch_Point Vtxi = L->Vertex(i);
484 Standard_Real d_2 = Pntindex.Distance(Vtxi.Value());
485 Standard_Real thetol2=Vtxi.Tolerance();
488 //-- le debugger voit 2 fois la variable d ici. ???? -> d_2
490 Vtxi.SetParameter(par);
491 Standard_Real u1,v1,u2,v2;
492 Vtxindex.ParametersOnS1(u1,v1);
493 Vtxindex.ParametersOnS2(u2,v2);
494 Vtxi.SetParameters(u1,v1,u2,v2);
495 Vtxi.SetValue(Pntindex);
496 wlig->AddVertex(Vtxi);
498 TabIndex[i]=TabIndex[index];
505 //=======================================================================
506 //function : AppendSameVertexR
508 //=======================================================================
510 static Standard_Integer AppendSameVertexR(Handle(IntPatch_RLine)&rlig,
511 const Handle(IntPatch_RLine)& L,
512 const Standard_Integer index,
513 Standard_Integer *TabIndex) {
514 Standard_Integer i,a,n;
517 const IntPatch_Point& Vtxindex = L->Vertex(index);
518 Standard_Real thetol1=Vtxindex.Tolerance();
521 const IntPatch_Point& Vtxi = L->Vertex(i);
522 Standard_Real d_3=Vtxindex.Value().Distance(Vtxi.Value());
523 Standard_Real thetol2=Vtxi.Tolerance();
527 if(Vtxi.ParameterOnLine() != Vtxindex.ParameterOnLine()) {
528 IntPatch_Point Vtxicop = L->Vertex(i);
529 Vtxicop.SetParameter(Vtxindex.ParameterOnLine());
530 rlig->AddVertex(Vtxicop);
533 rlig->AddVertex(Vtxi);
536 TabIndex[i]=TabIndex[index];
543 //=======================================================================
546 //=======================================================================
548 static void AddLine(const Handle(IntPatch_Line)& L,
549 const Standard_Integer i,
550 const Standard_Integer j,
551 // const GeomAbs_SurfaceType TypeS1,
552 const GeomAbs_SurfaceType ,
553 // const GeomAbs_SurfaceType TypeS2,
554 const GeomAbs_SurfaceType ,
555 Standard_Integer *TabIndex,
556 IntPatch_SequenceOfLine& slin) {
557 Standard_Integer IndexFirstVertex = 1;
558 Standard_Integer IndexLastVertex = 2;
562 IntPatch_IType typl = L->ArcType();
564 case IntPatch_Analytic: {
565 Handle(IntPatch_ALine)& ALine = *((Handle(IntPatch_ALine) *)&L);
566 Handle(IntPatch_ALine) alig;
567 if(L->TransitionOnS1() == IntSurf_Undecided)
568 alig = new IntPatch_ALine(ALine->Curve(),L->IsTangent());
569 else if(L->TransitionOnS1() == IntSurf_Touch)
570 alig = new IntPatch_ALine(ALine->Curve(),L->IsTangent(),L->SituationS1(),L->SituationS2());
572 alig = new IntPatch_ALine(ALine->Curve(),L->IsTangent(),L->TransitionOnS1(),L->TransitionOnS2());
573 alig->AddVertex(ALine->Vertex(i));
574 IndexLastVertex+=AppendSameVertexA(alig,ALine,i,TabIndex);
576 alig->AddVertex(ALine->Vertex(j));
577 IndexLastVertex+=AppendSameVertexA(alig,ALine,j,TabIndex);
579 alig->SetFirstPoint(IndexFirstVertex);
580 alig->SetLastPoint(IndexLastVertex);
584 case IntPatch_Walking: { //-- ****************************************
585 Handle(IntPatch_WLine)& WLine = *((Handle(IntPatch_WLine) *)&L);
586 const Handle(IntSurf_LineOn2S)& Lori = WLine->Curve();
587 Handle(IntSurf_LineOn2S) LineOn2S = new IntSurf_LineOn2S();
588 Standard_Integer ParamMinOnLine = (Standard_Integer) WLine->Vertex(i).ParameterOnLine();
589 Standard_Integer ParamMaxOnLine = (Standard_Integer) WLine->Vertex(j).ParameterOnLine();
590 for(Standard_Integer k=ParamMinOnLine; k<=ParamMaxOnLine; k++) {
591 LineOn2S->Add(Lori->Value(k));
593 Handle(IntPatch_WLine) wlig;
594 if(L->TransitionOnS1() == IntSurf_Undecided)
595 wlig = new IntPatch_WLine(LineOn2S,L->IsTangent());
596 else if(L->TransitionOnS1() == IntSurf_Touch)
597 wlig = new IntPatch_WLine(LineOn2S,L->IsTangent(),L->SituationS1(),L->SituationS2());
599 wlig = new IntPatch_WLine(LineOn2S,L->IsTangent(),L->TransitionOnS1(),L->TransitionOnS2());
600 if(WLine->HasArcOnS1()) {
601 wlig->SetArcOnS1(WLine->GetArcOnS1());
603 if(WLine->HasArcOnS2()) {
604 wlig->SetArcOnS2(WLine->GetArcOnS2());
606 IntPatch_Point Vtx=WLine->Vertex(i);
608 wlig->AddVertex(Vtx);
609 IndexLastVertex+=AppendSameVertexW(wlig,WLine,i,1,TabIndex);
611 Vtx=WLine->Vertex(j);
612 Vtx.SetParameter(LineOn2S->NbPoints());
613 wlig->AddVertex(Vtx);
614 IndexLastVertex+=AppendSameVertexW(wlig,WLine,j,LineOn2S->NbPoints(),TabIndex);
616 wlig->SetFirstPoint(IndexFirstVertex);
617 wlig->SetLastPoint(IndexLastVertex);
618 wlig->SetPeriod(WLine->U1Period(),WLine->V1Period(),WLine->U2Period(),WLine->V2Period());
619 wlig->ComputeVertexParameters(Precision::Confusion());
621 //-- **********************************************************************
625 case IntPatch_Restriction: {
626 Handle(IntPatch_RLine)& RLine = *((Handle(IntPatch_RLine) *)&L);
629 Handle(IntPatch_RLine) rlig;
630 if(L->TransitionOnS1() == IntSurf_Undecided)
631 rlig = new IntPatch_RLine(L->IsTangent());
632 else if(L->TransitionOnS1() == IntSurf_Touch)
633 rlig = new IntPatch_RLine(L->IsTangent(),L->SituationS1(),L->SituationS2());
635 rlig = new IntPatch_RLine(L->IsTangent(),L->TransitionOnS1(),L->TransitionOnS2());
636 if(RLine->IsArcOnS1()) { rlig->SetArcOnS1(RLine->ArcOnS1()); }
637 if(RLine->IsArcOnS2()) { rlig->SetArcOnS2(RLine->ArcOnS2()); }
639 rlig->AddVertex(RLine->Vertex(i));
641 IndexLastVertex+=AppendSameVertexR(rlig,RLine,i,TabIndex);
643 for(Standard_Integer k=i+1; k<j;k++) {
644 rlig->AddVertex(RLine->Vertex(k));
648 rlig->AddVertex(RLine->Vertex(j));
650 IndexLastVertex+=AppendSameVertexR(rlig,RLine,j,TabIndex);
653 rlig->SetFirstPoint(IndexFirstVertex);
654 rlig->SetLastPoint(IndexLastVertex);
655 rlig->ComputeVertexParameters(Precision::Confusion());
660 case IntPatch_Parabola:
661 case IntPatch_Hyperbola:
662 case IntPatch_Circle:
663 case IntPatch_Ellipse: {
664 Handle(IntPatch_GLine)& GLine = *((Handle(IntPatch_GLine) *)&L);
665 Handle(IntPatch_GLine) glig;
668 if(L->TransitionOnS1() == IntSurf_Undecided)
669 glig = new IntPatch_GLine(GLine->Line(),L->IsTangent());
670 else if(L->TransitionOnS1() == IntSurf_Touch)
671 glig = new IntPatch_GLine(GLine->Line(),L->IsTangent(),L->SituationS1(),L->SituationS2());
673 glig = new IntPatch_GLine(GLine->Line(),L->IsTangent(),L->TransitionOnS1(),L->TransitionOnS2());
675 case IntPatch_Parabola:
676 if(L->TransitionOnS1() == IntSurf_Undecided)
677 glig = new IntPatch_GLine(GLine->Parabola(),L->IsTangent());
678 else if(L->TransitionOnS1() == IntSurf_Touch)
679 glig = new IntPatch_GLine(GLine->Parabola(),L->IsTangent(),L->SituationS1(),L->SituationS2());
681 glig = new IntPatch_GLine(GLine->Parabola(),L->IsTangent(),L->TransitionOnS1(),L->TransitionOnS2());
683 case IntPatch_Hyperbola:
684 if(L->TransitionOnS1() == IntSurf_Undecided)
685 glig = new IntPatch_GLine(GLine->Hyperbola(),L->IsTangent());
686 else if(L->TransitionOnS1() == IntSurf_Touch)
687 glig = new IntPatch_GLine(GLine->Hyperbola(),L->IsTangent(),L->SituationS1(),L->SituationS2());
689 glig = new IntPatch_GLine(GLine->Hyperbola(),L->IsTangent(),L->TransitionOnS1(),L->TransitionOnS2());
691 case IntPatch_Circle:
692 if(L->TransitionOnS1() == IntSurf_Undecided)
693 glig = new IntPatch_GLine(GLine->Circle(),L->IsTangent());
694 else if(L->TransitionOnS1() == IntSurf_Touch)
695 glig = new IntPatch_GLine(GLine->Circle(),L->IsTangent(),L->SituationS1(),L->SituationS2());
697 glig = new IntPatch_GLine(GLine->Circle(),L->IsTangent(),L->TransitionOnS1(),L->TransitionOnS2());
699 case IntPatch_Ellipse: default:
700 if(L->TransitionOnS1() == IntSurf_Undecided)
701 glig = new IntPatch_GLine(GLine->Ellipse(),L->IsTangent());
702 else if(L->TransitionOnS1() == IntSurf_Touch)
703 glig = new IntPatch_GLine(GLine->Ellipse(),L->IsTangent(),L->SituationS1(),L->SituationS2());
705 glig = new IntPatch_GLine(GLine->Ellipse(),L->IsTangent(),L->TransitionOnS1(),L->TransitionOnS2());
708 glig->AddVertex(GLine->Vertex(i));
709 IndexLastVertex+=AppendSameVertexG(glig,GLine,i,0,TabIndex);
711 if ((typl == IntPatch_Circle || typl == IntPatch_Ellipse) && i>j) {
712 IntPatch_Point Vtx=GLine->Vertex(j);
713 Vtx.SetParameter(GLine->Vertex(j).ParameterOnLine()+M_PI+M_PI);
714 glig->AddVertex(Vtx);
715 IndexLastVertex+=AppendSameVertexG(glig,GLine,j,M_PI+M_PI,TabIndex);
718 glig->AddVertex(GLine->Vertex(j));
719 IndexLastVertex+=AppendSameVertexG(glig,GLine,j,0,TabIndex);
722 glig->SetFirstPoint(IndexFirstVertex);
723 glig->SetLastPoint(IndexLastVertex);
728 Standard_ConstructionError::Raise("IntPatch_LineConstructor::AddLine");
734 //=======================================================================
737 //=======================================================================
739 Handle(IntPatch_Line) IntPatch_LineConstructor::Line(const Standard_Integer l) const {
740 return(slin.Value(l));
743 //=======================================================================
746 //=======================================================================
748 Standard_Integer IntPatch_LineConstructor::NbLines() const {
749 return(slin.Length());
752 //=======================================================================
753 //function : GetVertexTolerance
755 //=======================================================================
757 static Standard_Real GetVertexTolerance(const IntPatch_Point& vtx/*,
758 const Handle(Adaptor3d_TopolTool)& aDomain1,
759 const Handle(Adaptor3d_TopolTool)& aDomain2*/)
761 Standard_Real tol = vtx.Tolerance();
762 // if (aDomain1->Has3d() && vtx.IsVertexOnS1()) {
763 // Standard_Real tolv = aDomain1->Tol3d(vtx.VertexOnS1());
764 // if (tolv > tol) tol = tolv;
766 // if (aDomain2->Has3d() && vtx.IsVertexOnS2()) {
767 // Standard_Real tolv = aDomain2->Tol3d(vtx.VertexOnS2());
768 // if (tolv > tol) tol = tolv;
773 //=======================================================================
774 //function : IsSegmentSmall
776 //=======================================================================
778 static Standard_Boolean IsSegmentSmall(const Handle(IntPatch_WLine)& WLine,
779 const Standard_Integer ivFirst,
780 const Standard_Integer ivLast/*,
781 const Standard_Real TolArc*/)
783 const IntPatch_Point& vtxF = WLine->Vertex(ivFirst);
784 const IntPatch_Point& vtxL = WLine->Vertex(ivLast);
785 Standard_Integer ipF = (Standard_Integer) vtxF.ParameterOnLine();
786 Standard_Integer ipL = (Standard_Integer) vtxL.ParameterOnLine();
787 if (ipF >= ipL) return Standard_True;
789 Standard_Real tolF = GetVertexTolerance(vtxF);
790 Standard_Real tolL = GetVertexTolerance(vtxL);
791 Standard_Real tol = Max (tolF, tolL);
793 Standard_Real len = 0.;
794 gp_Pnt p1 = WLine->Point(ipF).Value();
795 for (Standard_Integer i=ipF+1; i <= ipL; i++) {
796 const gp_Pnt& p2 = WLine->Point(i).Value();
797 len += p1.Distance(p2);
798 if (len > tol) break;
804 //=======================================================================
805 //function : TestWLineIsARLine
807 //=======================================================================
809 static Standard_Boolean TestWLineIsARLine(const IntPatch_SequenceOfLine& slinref,
810 const Handle(IntPatch_WLine)& wlin,
811 const Standard_Real tol2d) {
812 int nbpnt=wlin->NbPnts();
813 int indicepnt=nbpnt/2;
814 if(indicepnt<1) return(Standard_False);
815 const IntSurf_PntOn2S& POn2S=wlin->Point(indicepnt);
816 const IntSurf_PntOn2S& POn2S1=wlin->Point(indicepnt+1);
817 Standard_Integer lastl=slinref.Length();
818 for(int i=1;i<=lastl;i++) {
819 if(slinref.Value(i)->ArcType()==IntPatch_Restriction) {
820 Handle(IntPatch_RLine)& rlin = *((Handle(IntPatch_RLine) *)&(slinref(i)));
821 for (Standard_Integer is=0; is<2; is++) {
822 Standard_Boolean onFirst = is==0;
823 if((onFirst && rlin->IsArcOnS1()) || (!onFirst && rlin->IsArcOnS2())) {
824 Handle(Adaptor2d_HCurve2d) arc;
825 Standard_Real u,v,u1,v1;
827 arc = rlin->ArcOnS1();
828 POn2S.ParametersOnS1(u,v);
829 POn2S1.ParametersOnS1(u1,v1);
832 arc = rlin->ArcOnS2();
833 POn2S.ParametersOnS2(u,v);
834 POn2S1.ParametersOnS2(u1,v1);
836 if (indicepnt == 1) {
840 const Adaptor2d_Curve2d& C2d=arc->Curve2d();
841 gp_Pnt2d PObt,P2d(u,v);
842 Standard_Real par= Geom2dInt_TheProjPCurOfGInter::FindParameter(C2d,P2d,1e-7);
844 if(PObt.Distance(P2d) < tol2d) {
845 return Standard_True;
851 return Standard_False;
854 //=======================================================================
855 //function : TestIfWLineIsRestriction
857 //=======================================================================
859 static Standard_Boolean TestIfWLineIsRestriction(const IntPatch_SequenceOfLine& slinref,
860 const Handle(IntPatch_WLine)& wlin,
861 const Handle(Adaptor3d_HSurface)& S1,
862 const Handle(Adaptor3d_TopolTool)&D1,
863 const Handle(Adaptor3d_HSurface)& S2,
864 const Handle(Adaptor3d_TopolTool)&D2,
865 Standard_Real TolArc) {
867 Standard_Integer NbPnts = wlin->NbPnts();
868 Standard_Integer allon1=0,allon2=0,i;
869 Standard_Real tol2d1=0., tol2d2=0.;
870 for(i=1;i<=NbPnts;i++) {
871 const IntSurf_PntOn2S& Pmid = wlin->Point(i);
872 Standard_Real u1,v1,u2,v2;
873 Pmid.Parameters(u1,v1,u2,v2);
874 //-- Estimation d un majorant de Toluv a partir de Tol
878 //------------------------------------------
879 S1->D1(u1,v1,ap,ad1u,ad1v);
880 tol = ComputeParametricTolerance(TolArc,ad1u,ad1v);
881 if (tol > tol2d1) tol2d1 = tol;
883 if(allon1+1 == i && D1->IsThePointOn(gp_Pnt2d(u1,v1),tol)) {
886 //------------------------------------------
887 S2->D1(u2,v2,ap,ad1u,ad1v);
888 tol = ComputeParametricTolerance(TolArc,ad1u,ad1v);
889 if (tol > tol2d2) tol2d2 = tol;
891 if(allon2+1 == i && D2->IsThePointOn(gp_Pnt2d(u2,v2),tol)) {
894 if(allon1!=i && allon2!=i)
897 if(allon1==NbPnts || allon2==NbPnts) {
899 cout<<" IntPatch_LineConstructor.gxx : CC**ONS"<<(allon1==NbPnts?1:2)<<"** Traitement WLIne + ARC CLASS "<<endl;
901 Standard_Real tol2d = Max(tol2d1,tol2d2);
902 return TestWLineIsARLine(slinref,wlin,tol2d);
904 return Standard_False;
907 //=======================================================================
908 //function : ProjectOnArc
910 //=======================================================================
912 static Standard_Boolean ProjectOnArc(const Standard_Real u,
913 const Standard_Real v,
914 const Handle(Adaptor2d_HCurve2d)& arc,
915 const Handle(Adaptor3d_HSurface)& surf,
916 const Standard_Real TolArc,
922 surf->D1(u,v,aPbid,ad1u,ad1v);
923 Standard_Real tol2d = ComputeParametricTolerance(TolArc,ad1u,ad1v);
924 const Adaptor2d_Curve2d& C2d=arc->Curve2d();
925 gp_Pnt2d aP(u,v),aPprj;
926 par=Geom2dInt_TheProjPCurOfGInter::FindParameter(C2d,aP,1e-7);
927 aPprj=C2d.Value(par);
928 dist = aPprj.Distance(aP);
929 return dist <= tol2d;
932 //=======================================================================
933 //function : TestWLineToRLine
935 //=======================================================================
937 static void TestWLineToRLine(const IntPatch_SequenceOfLine& slinref,
938 IntPatch_SequenceOfLine& slin,
939 const Handle(Adaptor3d_HSurface)& mySurf1,
940 const Handle(Adaptor3d_TopolTool)& myDom1,
941 const Handle(Adaptor3d_HSurface)& mySurf2,
942 const Handle(Adaptor3d_TopolTool)& myDom2,
943 const Standard_Real TolArc) {
945 Standard_Integer lastwline=slin.Length();
946 Handle(IntPatch_WLine)& WLine = *((Handle(IntPatch_WLine) *)& (slin.Value(lastwline)));
948 Standard_Integer nbvtx=WLine->NbVertex();
949 if (nbvtx < 2) return;
950 Standard_Integer ParamMinOnLine = (Standard_Integer) WLine->Vertex(1).ParameterOnLine();
951 Standard_Integer ParamMaxOnLine = (Standard_Integer) WLine->Vertex(nbvtx).ParameterOnLine();
952 if (ParamMinOnLine >= ParamMaxOnLine) return;
953 Standard_Integer midInd = (ParamMaxOnLine + ParamMinOnLine) / 2;
955 TColStd_SequenceOfInteger indicesV1,indicesV2;
957 for (iv=1; iv <= nbvtx; iv++) {
958 Standard_Integer plin = (Standard_Integer) WLine->Vertex(iv).ParameterOnLine();
959 if (plin == ParamMinOnLine) indicesV1.Append(iv);
960 else if (plin == ParamMaxOnLine) indicesV2.Append(iv);
963 Standard_Boolean isRLine = Standard_False;
965 typedef void (IntSurf_PntOn2S::* PiParOnS)(Standard_Real&,Standard_Real&) const;
966 typedef Standard_Boolean (IntPatch_Point::* PQuery)() const;
967 typedef const Handle(Adaptor2d_HCurve2d)& (IntPatch_Point::* PArcOnS)() const;
968 typedef Standard_Real (IntPatch_Point::* PParOnArc)() const;
970 // cycle for both surfaces
972 for (is=0; is<2; is++) {
973 Standard_Boolean onFirst = is==0;
974 if(( onFirst && WLine->HasArcOnS1()) ||
975 (!onFirst && WLine->HasArcOnS2())) {
980 Handle(Adaptor3d_HSurface) surf;
981 Handle(Adaptor3d_TopolTool) aDomain;
983 piParOnS = &IntSurf_PntOn2S::ParametersOnS1;
984 pIsOnDomS = &IntPatch_Point::IsOnDomS1;
985 pArcOnS = &IntPatch_Point::ArcOnS1;
986 pParOnArc = &IntPatch_Point::ParameterOnArc1;
991 piParOnS = &IntSurf_PntOn2S::ParametersOnS2;
992 pIsOnDomS = &IntPatch_Point::IsOnDomS2;
993 pArcOnS = &IntPatch_Point::ArcOnS2;
994 pParOnArc = &IntPatch_Point::ParameterOnArc2;
999 // resolve arcs for vertices not having a link to an arc
1000 Standard_Real utst,vtst;
1001 TColStd_Array1OfReal paramsResolved(1,nbvtx);
1002 TColStd_Array1OfTransient arcsResolved(1,nbvtx);
1003 arcsResolved.Init(Handle(Adaptor2d_HCurve2d)());
1004 for (iv=1; iv <= nbvtx; iv++) {
1005 if (!(WLine->Vertex(iv).*pIsOnDomS)()) {
1006 Standard_Integer ip = (Standard_Integer) WLine->Vertex(iv).ParameterOnLine();
1007 (WLine->Point(ip).*piParOnS)(utst,vtst);
1008 Standard_Real distmin=RealLast();
1009 for (aDomain->Init(); aDomain->More(); aDomain->Next()) {
1010 const Handle(Adaptor2d_HCurve2d)& arc = aDomain->Value();
1011 Standard_Real par,dist;
1012 if (ProjectOnArc(utst,vtst,arc,surf,TolArc,par,dist) && dist < distmin) {
1013 arcsResolved(iv) = arc;
1014 paramsResolved(iv) = par;
1021 // prepare list of common arcs for both ends of wline
1022 TColStd_IndexedMapOfTransient mapArcsV1,mapArcs;
1024 for (i=1; i <= indicesV1.Length(); i++) {
1026 Handle(Adaptor2d_HCurve2d) arc;
1027 if ((WLine->Vertex(iv).*pIsOnDomS)()) arc = (WLine->Vertex(iv).*pArcOnS)();
1028 else arc = (const Handle(Adaptor2d_HCurve2d)&) arcsResolved(iv);
1029 if (!arc.IsNull()) mapArcsV1.Add(arc);
1031 for (i=1; i <= indicesV2.Length(); i++) {
1033 Handle(Adaptor2d_HCurve2d) arc;
1034 if ((WLine->Vertex(iv).*pIsOnDomS)()) arc = (WLine->Vertex(iv).*pArcOnS)();
1035 else arc = (const Handle(Adaptor2d_HCurve2d)&) arcsResolved(iv);
1036 if (!arc.IsNull() && mapArcsV1.Contains(arc)) mapArcs.Add(arc);
1039 // for each common arc
1040 for (Standard_Integer ia=1; ia <= mapArcs.Extent(); ia++) {
1041 const Handle(Adaptor2d_HCurve2d)& arc = (const Handle(Adaptor2d_HCurve2d)&) mapArcs(ia);
1042 // get end vertices of wline linked with this arc
1043 Standard_Integer iv1=0,iv2=0;
1044 for (i=1; i <= indicesV1.Length() && iv1==0; i++) {
1046 Handle(Adaptor2d_HCurve2d) arc1;
1047 if ((WLine->Vertex(iv).*pIsOnDomS)()) arc1 = (WLine->Vertex(iv).*pArcOnS)();
1048 else arc1 = (const Handle(Adaptor2d_HCurve2d)&) arcsResolved(iv);
1049 if (!arc1.IsNull() && arc1 == arc) iv1 = iv;
1051 for (i=1; i <= indicesV2.Length() && iv2==0; i++) {
1053 Handle(Adaptor2d_HCurve2d) arc1;
1054 if ((WLine->Vertex(iv).*pIsOnDomS)()) arc1 = (WLine->Vertex(iv).*pArcOnS)();
1055 else arc1 = (const Handle(Adaptor2d_HCurve2d)&) arcsResolved(iv);
1056 if (!arc1.IsNull() && arc1 == arc) iv2 = iv;
1060 cout<<" Pb getting vertices linked with arc"<<endl;
1064 Standard_Real par1 = (arcsResolved(iv1).IsNull()
1065 ? (WLine->Vertex(iv1).*pParOnArc)()
1066 : paramsResolved(iv1));
1067 Standard_Real par2 = (arcsResolved(iv2).IsNull()
1068 ? (WLine->Vertex(iv2).*pParOnArc)()
1069 : paramsResolved(iv2));
1071 cout<<"****** Parameters on arc on S"<<is+1<<": "<<par1<<" "<<par2<<endl;
1074 // check that the middle point is on arc
1075 (WLine->Point(midInd).*piParOnS)(utst,vtst);
1076 if (midInd == ParamMinOnLine) {
1077 Standard_Real utst1=0.0,vtst1=0.0;
1078 (WLine->Point(midInd+1).*piParOnS)(utst1,vtst1);
1079 utst = (utst+utst1)*0.5;
1080 vtst = (vtst+vtst1)*0.5;
1082 Standard_Real par,dist;
1083 if (!ProjectOnArc(utst,vtst,arc,surf,TolArc,par,dist)) {
1085 cout<<" Pb en projection ds IntPatch_LineConstructor"<<endl;
1090 //-- codage de la WLine en RLine
1091 Handle(IntPatch_RLine) rlig = new IntPatch_RLine(Standard_True,IntSurf_Unknown,IntSurf_Unknown);
1092 if (onFirst) rlig->SetArcOnS1(arc);
1093 else rlig->SetArcOnS2(arc);
1095 Handle(IntSurf_LineOn2S) LineOn2S = new IntSurf_LineOn2S();
1096 const Handle(IntSurf_LineOn2S)& Lori = WLine->Curve();
1097 Standard_Integer ivmin,ivmax;
1098 Standard_Real parmin, parmax;
1099 Standard_Boolean reverse = Standard_False;
1100 TColStd_SequenceOfInteger *pIndVmin, *pIndVmax;
1102 for(i=ParamMinOnLine; i<=ParamMaxOnLine; i++) {
1103 LineOn2S->Add(Lori->Value(i));
1105 ivmin = iv1; ivmax = iv2;
1106 parmin = par1; parmax = par2;
1107 pIndVmin = &indicesV1; pIndVmax = &indicesV2;
1110 for(i=ParamMaxOnLine; i>=ParamMinOnLine; i--) {
1111 LineOn2S->Add(Lori->Value(i));
1113 ivmin = iv2; ivmax = iv1;
1114 parmin = par2; parmax = par1;
1115 pIndVmin = &indicesV2; pIndVmax = &indicesV1;
1116 reverse = Standard_True;
1118 rlig->Add(LineOn2S);
1119 IntSurf_Transition TransitionUndecided;
1120 IntPatch_Point VtxFirst = WLine->Vertex(ivmin);
1121 VtxFirst.SetParameter(parmin);
1122 if (!arcsResolved(ivmin).IsNull())
1123 VtxFirst.SetArc(onFirst,arc,parmin,TransitionUndecided,TransitionUndecided);
1125 VtxFirst.ReverseTransition(); //-- inversion des transitions
1126 rlig->AddVertex(VtxFirst);
1127 for (i=1; i <= pIndVmin->Length(); i++) {
1128 iv = pIndVmin->Value(i);
1130 IntPatch_Point Vtx=WLine->Vertex(iv);
1131 Vtx.SetParameter(parmin);
1132 if (!arcsResolved(iv).IsNull())
1133 Vtx.SetArc(onFirst,arc,parmin,TransitionUndecided,TransitionUndecided);
1135 Vtx.ReverseTransition();
1136 rlig->AddVertex(Vtx);
1139 for (i=1; i <= pIndVmax->Length(); i++) {
1140 iv = pIndVmax->Value(i);
1142 IntPatch_Point Vtx=WLine->Vertex(iv);
1143 Vtx.SetParameter(parmax);
1144 if (!arcsResolved(iv).IsNull())
1145 Vtx.SetArc(onFirst,arc,parmax,TransitionUndecided,TransitionUndecided);
1147 Vtx.ReverseTransition();
1148 rlig->AddVertex(Vtx);
1151 IntPatch_Point VtxLast=WLine->Vertex(ivmax);
1152 VtxLast.SetParameter(parmax);
1153 if (!arcsResolved(ivmax).IsNull())
1154 VtxLast.SetArc(onFirst,arc,parmax,TransitionUndecided,TransitionUndecided);
1156 VtxLast.ReverseTransition();
1157 rlig->AddVertex(VtxLast);
1158 rlig->SetFirstPoint(1);
1159 rlig->SetLastPoint(indicesV1.Length()+indicesV2.Length());
1161 isRLine = Standard_True;
1167 TestIfWLineIsRestriction(slinref,WLine,
1171 slin.Remove(lastwline);
1175 //=======================================================================
1176 //function : Perform
1178 //=======================================================================
1180 void IntPatch_LineConstructor::Perform(const IntPatch_SequenceOfLine& slinref,
1181 const Handle(IntPatch_Line)& L,
1182 const Handle(Adaptor3d_HSurface)& mySurf1,
1183 const Handle(Adaptor3d_TopolTool)& myDom1,
1184 const Handle(Adaptor3d_HSurface)& mySurf2,
1185 const Handle(Adaptor3d_TopolTool)& myDom2,
1186 const Standard_Real TolArc) {
1188 Standard_Integer i=1,nbvtx;
1189 Standard_Real firstp,lastp;
1190 Standard_Real Tol = Precision::PConfusion()*100.; // JMB le 13 Jan 2000. Report de la correction du PRO19653
1191 GeomAbs_SurfaceType typs1 = mySurf1->GetType();
1192 GeomAbs_SurfaceType typs2 = mySurf2->GetType();
1194 IntPatch_IType typl = L->ArcType();
1195 if(typl == IntPatch_Analytic) {
1196 Standard_Real u1,v1,u2,v2;
1197 Handle(IntPatch_ALine)& ALine
1198 = *((Handle(IntPatch_ALine) *)&L);
1200 nbvtx = ALine->NbVertex();
1201 //-- -------------------------------------------------------------------
1202 Standard_Integer *TabIndex=new Standard_Integer [nbvtx+2];
1203 Standard_Integer numline=0;
1204 for(i=1;i<=nbvtx;i++) {
1205 //for(Standard_Integer i=1;i<=nbvtx;i++) {
1208 //-- -------------------------------------------------------------------
1209 for(i=1;i<nbvtx;i++) {
1210 const IntPatch_Point& ALine_Vertex_i =ALine->Vertex(i);
1211 const IntPatch_Point& ALine_Vertex_ip1=ALine->Vertex(i+1);
1212 firstp = ALine_Vertex_i.ParameterOnLine();
1213 lastp = ALine_Vertex_ip1.ParameterOnLine();
1215 Standard_Real pmid = (firstp+lastp)*0.5;
1216 gp_Pnt Pmid = ALine->Value(pmid);
1217 Parameters(mySurf1,mySurf2,Pmid,u1,v1,u2,v2);
1218 Recadre(mySurf1,mySurf2,u1,v1,u2,v2);
1219 TopAbs_State in1,in2;
1220 in1 = myDom1->Classify(gp_Pnt2d(u1,v1),Tol,Standard_False);
1221 in2 = (in1!=TopAbs_OUT)? myDom2->Classify(gp_Pnt2d(u2,v2),Tol,Standard_False) : TopAbs_OUT;
1222 if(in1 == TopAbs_OUT || in2 == TopAbs_OUT) {
1225 //-- cout<<"Analytic : firtsp="<<firstp<<" lastp="<<lastp<<" Vtx:"<<i<<","<<i+1<<endl;
1226 TabIndex[i]=TabIndex[i+1]=++numline;
1227 AddLine(L,i,i+1,typs1,typs2,TabIndex,slin);
1231 //-- -------------------------------------------------------------------
1232 //-- On recherche les vertex interference Edge Edge Externe
1233 //-- Ces vertex ne figurent sur aucune ligne et sont Restriction
1234 //-- sur les 2 edges
1235 for(i=1;i<=nbvtx;i++) {
1236 if(TabIndex[i]==0) {
1237 const IntPatch_Point& ALine_Vertex_i =ALine->Vertex(i);
1238 if(ALine_Vertex_i.IsOnDomS1() && ALine_Vertex_i.IsOnDomS2()) {
1239 TabIndex[i]=++numline;
1240 AddLine(L,i,i,typs1,typs2,TabIndex,slin);
1245 //-- -------------------------------------------------------------------
1248 else if(typl == IntPatch_Walking) {
1249 Standard_Real u1,v1,u2,v2;
1250 Handle(IntPatch_WLine)& WLine
1251 = *((Handle(IntPatch_WLine) *)&L);
1253 nbvtx = WLine->NbVertex();
1254 //-- -------------------------------------------------------------------
1255 Standard_Integer *TabIndex=new Standard_Integer [nbvtx+2];
1256 Standard_Integer numline=0;
1257 for(i=1;i<=nbvtx;i++) {
1258 //for(Standard_Integer i=1;i<=nbvtx;i++) {
1261 //-- -------------------------------------------------------------------
1262 for(i=1;i<nbvtx;i++) {
1263 const IntPatch_Point& WLineVertex_i = WLine->Vertex(i);
1264 const IntPatch_Point& WLineVertex_ip1 = WLine->Vertex(i+1);
1265 firstp = WLineVertex_i.ParameterOnLine();
1266 lastp = WLineVertex_ip1.ParameterOnLine();
1267 if(firstp!=lastp && !IsSegmentSmall(WLine,i,i+1/*,TolArc*/)) {
1268 Standard_Integer pmid;
1269 pmid = (Standard_Integer)((firstp+lastp)/2);
1270 Standard_Integer int_lastp = (Standard_Integer)lastp;
1271 Standard_Integer int_firstp = (Standard_Integer)firstp;
1272 if(pmid==int_lastp) pmid=int_firstp;
1273 const IntSurf_PntOn2S& Pmid = WLine->Point(pmid);
1274 Pmid.Parameters(u1,v1,u2,v2);
1275 Recadre(mySurf1,mySurf2,u1,v1,u2,v2);
1277 // modified by NIZHNY-MKK Tue Apr 3 15:03:40 2001.BEGIN
1278 //------------------------------------------
1281 mySurf1->D1(u1,v1,ap,ad1u,ad1v);
1282 Standard_Real aTolerance = ComputeParametricTolerance(TolArc, ad1u, ad1v);
1283 //------------------------------------------
1285 //TopAbs_State in1 = myDom1->Classify(gp_Pnt2d(u1,v1),Tol,Standard_False);
1286 TopAbs_State in1 = myDom1->Classify(gp_Pnt2d(u1,v1), aTolerance, Standard_False);
1287 //TopAbs_State in2 = (in1!=TopAbs_OUT)? myDom2->Classify(gp_Pnt2d(u2,v2),Tol,Standard_False) : TopAbs_OUT;
1288 TopAbs_State in2 = TopAbs_OUT;
1289 if (in1!=TopAbs_OUT) {
1290 //------------------------------------------
1291 mySurf2->D1(u2,v2,ap,ad1u,ad1v);
1292 aTolerance = ComputeParametricTolerance(TolArc, ad1u, ad1v);
1293 //------------------------------------------
1294 in2 = myDom2->Classify(gp_Pnt2d(u2,v2), aTolerance, Standard_False);
1296 // modified by NIZHNY-MKK Tue Apr 3 15:06:31 2001.END
1298 // modified by NIZHNY-OFV Wed Jun 13 17:31:23 2001
1299 // --purpose: If on a face (lastp-firstp) == 1,
1300 // sometimes it could mean a bad parametrisation of WLine.
1301 // In this case we try to classify the "virtual" WLine point:
1302 // the geometrical point between two vertexes. This emulates
1303 // situation when (lastp-firstp) != 1.
1304 if(Abs(int_lastp-int_firstp) == 1)
1306 Standard_Real vFu1,vFv1,vFu2,vFv2,vLu1,vLv1,vLu2,vLv2;
1307 const IntSurf_PntOn2S& vF = WLineVertex_i. PntOn2S();
1308 const IntSurf_PntOn2S& vL = WLineVertex_ip1. PntOn2S();
1309 vF.Parameters(vFu1,vFv1,vFu2,vFv2);
1310 Recadre(mySurf1,mySurf2,vFu1,vFv1,vFu2,vFv2);
1311 vL.Parameters(vLu1,vLv1,vLu2,vLv2);
1312 Recadre(mySurf1,mySurf2,vLu1,vLv1,vLu2,vLv2);
1313 if(in1 != TopAbs_IN)
1315 Standard_Real du,dv;
1316 gp_Pnt2d pvF(vFu1,vFv1);
1317 gp_Pnt2d pvL(vLu1,vLv1);
1318 gp_Pnt2d pPm(u1,v1);
1319 Standard_Real dpvFpPm = pvF.Distance(pPm);
1320 Standard_Real dpvLpPm = pvL.Distance(pPm);
1321 if(dpvFpPm > dpvLpPm)
1323 du = (vFu1 + u1) * 0.5;
1324 dv = (vFv1 + v1) * 0.5;
1328 du = (vLu1 + u1) * 0.5;
1329 dv = (vLv1 + v1) * 0.5;
1331 mySurf1->D1(du,dv,ap,ad1u,ad1v);
1332 aTolerance = ComputeParametricTolerance(TolArc, ad1u, ad1v);
1333 in1 = myDom1->Classify(gp_Pnt2d(du,dv), aTolerance, Standard_False);
1335 if(in2 != TopAbs_IN)
1337 Standard_Real du,dv;
1338 gp_Pnt2d pvF(vFu2,vFv2);
1339 gp_Pnt2d pvL(vLu2,vLv2);
1340 gp_Pnt2d pPm(u2,v2);
1341 Standard_Real dpvFpPm = pvF.Distance(pPm);
1342 Standard_Real dpvLpPm = pvL.Distance(pPm);
1343 if(dpvFpPm > dpvLpPm)
1345 du = (vFu2 + u2) * 0.5;
1346 dv = (vFv2 + v2) * 0.5;
1350 du = (vLu2 + u2) * 0.5;
1351 dv = (vLv2 + v2) * 0.5;
1353 mySurf2->D1(du,dv,ap,ad1u,ad1v);
1354 aTolerance = ComputeParametricTolerance(TolArc, ad1u, ad1v);
1355 in2 = myDom2->Classify(gp_Pnt2d(du,dv), aTolerance, Standard_False);
1357 } //end of if(Abs(int_lastp-int_firstp) == 1)
1359 if (in1 != TopAbs_OUT && in2 != TopAbs_OUT)
1361 Standard_Boolean LignetropPetite=Standard_False;
1362 Standard_Real u1a,v1a,u2a,v2a;
1363 const IntSurf_PntOn2S& Pmid1 = WLine->Point((Standard_Integer)firstp);
1364 Pmid1.Parameters(u1a,v1a,u2a,v2a);
1365 Recadre(mySurf1,mySurf2,u1a,v1a,u2a,v2a);
1367 const IntSurf_PntOn2S& Pmid2 = WLine->Point((Standard_Integer)lastp);
1368 Standard_Real u1b,v1b,u2b,v2b;
1369 Pmid2.Parameters(u1b,v1b,u2b,v2b);
1370 Recadre(mySurf1,mySurf2,u1b,v1b,u2b,v2b);
1372 Standard_Real dd12_u=Abs(u1a-u1b);
1373 Standard_Real dd12_v=Abs(v1a-v1b);
1374 if(dd12_u+dd12_v < 1e-12) {
1377 if(dd12_u+dd12_v < 1e-12) {
1378 LignetropPetite=Standard_True;
1381 if(LignetropPetite==Standard_False) {
1382 //-- cout<<"WLine : firtsp="<<firstp<<" lastp="<<lastp<<" Vtx:"<<i<<","<<i+1<<endl;
1383 TabIndex[i]=TabIndex[i+1]=++numline;
1384 AddLine(L,i,i+1,typs1,typs2,TabIndex,slin);
1385 TestWLineToRLine(slinref,slin,mySurf1,myDom1,mySurf2,myDom2,TolArc); //-- on teste la derniere entree de slin
1387 } //end of if (in1 != TopAbs_OUT && in2 != TopAbs_OUT)
1388 } //end of if(firstp!=lastp && !IsSegmentSmall(WLine,i,i+1/*,TolArc*/))
1389 } //end of for(i=1;i<nbvtx;i++)
1391 //-- -------------------------------------------------------------------
1392 //-- On recherche les vertex interference Edge Edge Externe
1393 //-- Ces vertex ne figurent sur aucune ligne et sont Restriction
1394 //-- sur les 2 edges
1395 for(i=1;i<=nbvtx;i++) {
1396 if(TabIndex[i]==0) {
1397 const IntPatch_Point& WLine_Vertex_i =WLine->Vertex(i);
1398 if(WLine_Vertex_i.IsOnDomS1() && WLine_Vertex_i.IsOnDomS2()) {
1399 TabIndex[i]=++numline;
1400 AddLine(L,i,i,typs1,typs2,TabIndex,slin);
1405 //-- -------------------------------------------------------------------
1408 else if (typl != IntPatch_Restriction) { // JAG 01.07.96
1409 Standard_Real u1,v1,u2,v2;
1410 Handle(IntPatch_GLine)& GLine
1411 = *((Handle(IntPatch_GLine) *)&L);
1413 nbvtx = GLine->NbVertex();
1414 //-- -------------------------------------------------------------------
1415 Standard_Integer *TabIndex=new Standard_Integer [nbvtx+2];
1416 Standard_Integer numline=0;
1417 // for(Standard_Integer i=1;i<=nbvtx;i++) {
1418 for(i=1;i<=nbvtx;i++) {
1421 //-- -------------------------------------------------------------------
1422 Standard_Boolean intrvtested = Standard_False;
1423 for(i=1;i<nbvtx;i++) {
1424 firstp = GLine->Vertex(i).ParameterOnLine();
1425 lastp = GLine->Vertex(i+1).ParameterOnLine();
1426 if(Abs(firstp-lastp)>Precision::PConfusion()) {
1427 intrvtested = Standard_True;
1428 Standard_Real pmid = (firstp+lastp)*0.5;
1430 if (typl == IntPatch_Lin) {
1431 Pmid = ElCLib::Value(pmid,GLine->Line());
1433 else if (typl == IntPatch_Circle) {
1434 Pmid = ElCLib::Value(pmid,GLine->Circle());
1436 else if (typl == IntPatch_Ellipse) {
1437 Pmid = ElCLib::Value(pmid,GLine->Ellipse());
1439 else if (typl == IntPatch_Hyperbola) {
1440 Pmid = ElCLib::Value(pmid,GLine->Hyperbola());
1442 else if (typl == IntPatch_Parabola) {
1443 Pmid = ElCLib::Value(pmid,GLine->Parabola());
1445 Parameters(mySurf1,mySurf2,Pmid,u1,v1,u2,v2);
1446 Recadre(mySurf1,mySurf2,u1,v1,u2,v2);
1451 if (myDom2->More()) {
1452 mySurf1->D1(u1,v1,P,Du,Dv);
1453 Tol = ComputeParametricTolerance( myDom1->Tol3d(myDom1->Value()) ,Du,Dv);
1455 TopAbs_State in1 = myDom1->Classify(gp_Pnt2d(u1,v1),Tol,Standard_False);
1458 if (in1 != TopAbs_OUT && myDom2->More() ) {
1459 mySurf2->D1(u2,v2,P,Du,Dv);
1460 Tol = ComputeParametricTolerance( myDom2->Tol3d(myDom2->Value()) ,Du,Dv);
1462 TopAbs_State in2 = (in1!=TopAbs_OUT)? myDom2->Classify(gp_Pnt2d(u2,v2),Tol,Standard_False) : TopAbs_OUT;
1463 // modified by NIZHNY-OFV Wed May 30 17:04:08 2001.BEGIN
1464 // --purpose: section algo with infinite prism works now!!!
1465 if(in1 == TopAbs_UNKNOWN) in1 = TopAbs_OUT;
1466 if(in2 == TopAbs_UNKNOWN) in2 = TopAbs_OUT;
1467 // modified by NIZHNY-OFV Wed May 30 17:05:47 2001.END
1468 if(in1 == TopAbs_OUT || in2 == TopAbs_OUT) {
1471 //-- cout<<"GLine : firtsp="<<firstp<<" lastp="<<lastp<<" Vtx:"<<i<<","<<i+1<<endl;
1472 TabIndex[i]=TabIndex[i+1]=++numline;
1473 AddLine(L,i,i+1,typs1,typs2,TabIndex,slin);
1477 if(typl == IntPatch_Circle || typl == IntPatch_Ellipse) {
1478 firstp = GLine->Vertex(nbvtx).ParameterOnLine();
1479 lastp = M_PI + M_PI + GLine->Vertex(1).ParameterOnLine();
1480 Standard_Real cadrinf = LocalFirstParameter(L);
1481 Standard_Real cadrsup = LocalLastParameter(L);
1482 Standard_Real acadr = (firstp+lastp)*0.5;
1483 while(acadr < cadrinf) { acadr+=M_PI+M_PI; }
1484 while(acadr > cadrsup) { acadr-=M_PI+M_PI; }
1485 if(acadr>=cadrinf && acadr<=cadrsup) {
1486 if(Abs(firstp-lastp)>Precision::PConfusion()) {
1487 intrvtested = Standard_True;
1488 Standard_Real pmid = (firstp+lastp)*0.5;
1490 if (typl == IntPatch_Circle) {
1491 Pmid = ElCLib::Value(pmid,GLine->Circle());
1494 Pmid = ElCLib::Value(pmid,GLine->Ellipse());
1496 Parameters(mySurf1,mySurf2,Pmid,u1,v1,u2,v2);
1497 Recadre(mySurf1,mySurf2,u1,v1,u2,v2);
1498 TopAbs_State in1 = myDom1->Classify(gp_Pnt2d(u1,v1),Tol,Standard_False);
1499 TopAbs_State in2 = (in1!=TopAbs_OUT)? myDom2->Classify(gp_Pnt2d(u2,v2),Tol,Standard_False) : TopAbs_OUT;
1500 // modified by NIZHNY-OFV Wed May 30 17:04:08 2001.BEGIN
1501 // --purpose: section algo with infinite prism works now!!!
1502 if(in1 == TopAbs_UNKNOWN) in1 = TopAbs_OUT;
1503 if(in2 == TopAbs_UNKNOWN) in2 = TopAbs_OUT;
1504 // modified by NIZHNY-OFV Wed May 30 17:05:47 2001.END
1505 if(in1 == TopAbs_OUT || in2 == TopAbs_OUT) {
1508 //-- cout<<"GLine bis : firtsp="<<firstp<<" lastp="<<lastp<<" Vtx:"<<i<<","<<i+1<<endl;
1509 TabIndex[nbvtx]=TabIndex[1]=++numline;
1510 AddLine(L,nbvtx,1,typs1,typs2,TabIndex,slin);
1516 // on garde a priori. Il faudrait un point 2d sur chaque
1517 // surface pour prendre la decision. Sera fait dans
1520 // TabIndex[nbvtx]=TabIndex[1]=++numline;
1521 // AddLine(L,1,nbvtx,typs1,typs2,TabIndex,slin);
1523 //cout<<"\nIntPatch_LineConstructor : Cas de ligne ou firstp==lastp"<<endl;
1527 //-- -------------------------------------------------------------------
1528 //-- On recherche les vertex interference Edge Edge Externe
1529 //-- Ces vertex ne figurent sur aucune ligne et sont Restriction
1530 //-- sur les 2 edges
1531 for(i=1;i<=nbvtx;i++) {
1532 if(TabIndex[i]==0) {
1533 const IntPatch_Point& GLine_Vertex_i =GLine->Vertex(i);
1534 if(GLine_Vertex_i.IsOnDomS1() && GLine_Vertex_i.IsOnDomS2()) {
1535 TabIndex[i]=++numline;
1536 AddLine(L,i,i,typs1,typs2,TabIndex,slin);
1541 //-- -------------------------------------------------------------------
1544 else { //-- Restriction
1545 Handle(IntPatch_RLine)& RLine
1546 = *((Handle(IntPatch_RLine) *)&L);
1548 Standard_Integer NbVtx = RLine->NbVertex();
1549 Standard_Boolean RestOnS1 = RLine->IsArcOnS1();
1550 Standard_Boolean RestOnS2 = RLine->IsArcOnS2();
1551 //-- -------------------------------------------------------------------
1552 Standard_Integer *TabIndex=new Standard_Integer [NbVtx+2];
1553 //Standard_Integer numline=0;
1554 for(i=1; i<=NbVtx; i++) {
1557 //-- -------------------------------------------------------------------
1558 for(i=1; i<NbVtx; i++) {
1559 const IntPatch_Point& Vtx1=RLine->Vertex(i);
1560 const IntPatch_Point& Vtx2=RLine->Vertex(i+1);
1561 if(RestOnS1 && RestOnS2) {
1562 AddLine(L,i,i+1,typs1,typs2,TabIndex,slin);
1564 else if(RestOnS1) { //-- On na classifie pas sur 1
1565 Standard_Real u0 = Vtx1.ParameterOnLine();
1566 Standard_Real u1 = Vtx2.ParameterOnLine();
1567 if(Abs(u1-u0)>Precision::PConfusion()) {
1568 Standard_Real u = (999.0*u0+u1)*0.001;
1570 gp_Pnt P0=Vtx1.Value();
1571 gp_Pnt2d Px2d=RLine->ArcOnS1()->Value(u);
1572 gp_Pnt Px = mySurf1->Value(Px2d.X(),Px2d.Y());
1573 gp_Vec P0Px=gp_Vec(P0,Px);
1575 Standard_Real U1,V1,U2,V2;
1576 Vtx1.PntOn2S().Parameters(U1,V1,U2,V2);
1580 mySurf2->D1(U2,V2,P,D1u,D1v);
1583 Tol = ComputeParametricTolerance( myDom2->Tol3d(myDom2->Value()), D1u,D1v);
1585 //-- le 23 mars 1999
1586 TopAbs_State bornin = myDom2->Classify(gp_Pnt2d(U2,V2),Tol,Standard_False);
1587 if(bornin!=TopAbs_OUT) {
1588 Standard_Real U1t,V1t,U2t,V2t;
1589 Vtx2.PntOn2S().Parameters(U1t,V1t,U2t,V2t);
1590 bornin = myDom2->Classify(gp_Pnt2d(U2t,V2t),Tol,Standard_False);
1592 if (bornin==TopAbs_OUT) continue;
1595 //-- Attention , on faisait une estimatoin de deltau et deltav
1597 //-- POPx . D1u = deltau * D1u.D1u + deltav * D1u.D1v
1598 //-- POPx . D1v = deltau * D1u.D1v + deltav * D1v.D1v
1601 Standard_Real D1uD1v,TgD1u,TgD1v,D1uD1u,D1vD1v,DIS;
1602 //Standard_Real DeltaU,DeltaV;
1603 D1uD1u = D1u.Dot(D1u);
1604 D1vD1v = D1v.Dot(D1v);
1605 D1uD1v = D1u.Dot(D1v);
1606 TgD1u = P0Px.Dot(D1u);
1607 TgD1v = P0Px.Dot(D1v);
1608 DIS = D1uD1u * D1vD1v - D1uD1v * D1uD1v;
1610 Standard_Real deltau=1e-10;
1611 Standard_Real deltav=1e-10;
1612 if(DIS<-1e-10 || DIS>1e-10) {
1613 deltau=(TgD1u*D1vD1v-TgD1v*D1uD1v)/DIS;
1614 deltav=(TgD1v*D1uD1u-TgD1u*D1uD1v)/DIS;
1619 if(bornin!=TopAbs_OUT) {
1620 TopAbs_State in2 = myDom2->Classify(gp_Pnt2d(U2,V2),Tol,Standard_False);
1623 if(in2==TopAbs_OUT) {
1624 in2 = myDom2->Classify(gp_Pnt2d(U2+deltau,V2),Tol,Standard_False);
1626 if(in2==TopAbs_OUT) {
1627 in2 = myDom2->Classify(gp_Pnt2d(U2-deltau,V2),Tol,Standard_False);
1629 if(in2==TopAbs_OUT) {
1630 in2 = myDom2->Classify(gp_Pnt2d(U2,V2+deltav),Tol,Standard_False);
1632 if(in2==TopAbs_OUT) {
1633 in2 = myDom2->Classify(gp_Pnt2d(U2,V2-deltav),Tol,Standard_False);
1636 if(in2!=TopAbs_OUT) {
1637 //-- cout<<"RLine ons1 : u0 ="<<u0<<" u1 ="<<u1<<" Vtx:"<<i<<","<<i+1<<endl;
1638 AddLine(L,i,i+1,typs1,typs2,TabIndex,slin);
1644 Standard_Real u0 = Vtx1.ParameterOnLine();
1645 Standard_Real u1 = Vtx2.ParameterOnLine();
1646 if(Abs(u1-u0)>Precision::PConfusion()) {
1647 Standard_Real u = (999.0*u0+u1)*0.001;
1649 gp_Pnt P0=Vtx1.Value();
1650 gp_Pnt2d Px2d=RLine->ArcOnS2()->Value(u);
1651 gp_Pnt Px = mySurf2->Value(Px2d.X(),Px2d.Y());
1652 gp_Vec P0Px=gp_Vec(P0,Px);
1654 Standard_Real U1,V1,U2,V2;
1655 Vtx1.PntOn2S().Parameters(U1,V1,U2,V2);
1659 mySurf1->D1(U1,V1,P,D1u,D1v);
1662 Tol = ComputeParametricTolerance( myDom1->Tol3d(myDom1->Value()) ,D1u,D1v);
1664 //-- le 23 mars 1999
1665 TopAbs_State bornin = myDom1->Classify(gp_Pnt2d(U1,V1),Tol,Standard_False);
1666 if(bornin!=TopAbs_OUT) {
1667 Standard_Real U1t,V1t,U2t,V2t;
1668 Vtx2.PntOn2S().Parameters(U1t,V1t,U2t,V2t);
1669 bornin = myDom1->Classify(gp_Pnt2d(U1t,V1t),Tol,Standard_False);
1671 if (bornin==TopAbs_OUT) continue;
1674 //-- Attention , on faisait une estimatoin de deltau et deltav
1676 //-- POPx . D1u = deltau * D1u.D1u + deltav * D1u.D1v
1677 //-- POPx . D1v = deltau * D1u.D1v + deltav * D1v.D1v
1680 Standard_Real D1uD1v,TgD1u,TgD1v,D1uD1u,D1vD1v,DIS;
1681 //Standard_Real DeltaU,DeltaV;
1682 D1uD1u = D1u.Dot(D1u);
1683 D1vD1v = D1v.Dot(D1v);
1684 D1uD1v = D1u.Dot(D1v);
1685 TgD1u = P0Px.Dot(D1u);
1686 TgD1v = P0Px.Dot(D1v);
1687 DIS = D1uD1u * D1vD1v - D1uD1v * D1uD1v;
1689 Standard_Real deltau=1e-10;
1690 Standard_Real deltav=1e-10;
1691 if(DIS<-1e-10 || DIS>1e-10) {
1692 deltau=(TgD1u*D1vD1v-TgD1v*D1uD1v)/DIS;
1693 deltav=(TgD1v*D1uD1u-TgD1u*D1uD1v)/DIS;
1699 if(bornin!=TopAbs_OUT) {
1700 TopAbs_State in2 = myDom1->Classify(gp_Pnt2d(U1,V1),Tol,Standard_False);
1703 if(in2==TopAbs_OUT) {
1704 in2 = myDom1->Classify(gp_Pnt2d(U1+deltau,V1),Tol,Standard_False);
1706 if(in2==TopAbs_OUT) {
1707 in2 = myDom1->Classify(gp_Pnt2d(U1-deltau,V1),Tol,Standard_False);
1709 if(in2==TopAbs_OUT) {
1710 in2 = myDom1->Classify(gp_Pnt2d(U1,V1+deltav),Tol,Standard_False);
1712 if(in2==TopAbs_OUT) {
1713 in2 = myDom1->Classify(gp_Pnt2d(U1,V1-deltav),Tol,Standard_False);
1716 if(in2!=TopAbs_OUT) {
1717 //-- cout<<"RLine ons2 : u0 ="<<u0<<" u1 ="<<u1<<" Vtx:"<<i<<","<<i+1<<endl;
1719 AddLine(L,i,i+1,typs1,typs2,TabIndex,slin);