0027772: Foundation Classes - define Standard_Boolean using C++ type "bool" instead...
[occt.git] / src / ChFi3d / ChFi3d_Builder_C1.cxx
index 7e45e48..3579aa8 100644 (file)
@@ -161,11 +161,7 @@ extern void ChFi3d_ResultChron(OSD_Chronometer & ch,Standard_Real& time);
 #include <Geom2dAdaptor_Curve.hxx>
 #include <IntRes2d_IntersectionSegment.hxx>
 #include <Geom_BezierCurve.hxx>
-//  Modified by Sergey KHROMOV - Fri Dec 21 17:08:19 2001 Begin
-Standard_Boolean isTangentFaces(const TopoDS_Edge &theEdge,
-                               const TopoDS_Face &theFace1,
-                               const TopoDS_Face &theFace2);
-//  Modified by Sergey KHROMOV - Fri Dec 21 17:08:19 2001 End
+#include <Geom_BoundedSurface.hxx>
 
 static Standard_Real recadre(const Standard_Real p,
                             const Standard_Real ref,
@@ -187,9 +183,9 @@ static Standard_Real recadre(const Standard_Real p,
 //           parameter in FaceInterference.
 //=======================================================================
 
-static Standard_Boolean Update(Handle(Adaptor3d_HSurface)& fb,
-                              Handle(Adaptor2d_HCurve2d)& pcfb,
-                              Handle(Adaptor3d_HSurface)& surf,
+static Standard_Boolean Update(const Handle(Adaptor3d_HSurface)& fb,
+                              const Handle(Adaptor2d_HCurve2d)& pcfb,
+                              const Handle(Adaptor3d_HSurface)& surf,
                               ChFiDS_FaceInterference&  fi,
                               ChFiDS_CommonPoint&       cp,
                               gp_Pnt2d&                 p2dbout,
@@ -229,8 +225,8 @@ static Standard_Boolean Update(Handle(Adaptor3d_HSurface)& fb,
 //           and <p2dbout>
 //=======================================================================
 
-static Standard_Boolean Update(Handle(Adaptor3d_HSurface)& fb,
-                              Handle(Adaptor3d_HCurve)&   ct,
+static Standard_Boolean Update(const Handle(Adaptor3d_HSurface)& fb,
+                              const Handle(Adaptor3d_HCurve)&   ct,
                               ChFiDS_FaceInterference&  fi,
                               ChFiDS_CommonPoint&       cp,
                               gp_Pnt2d&                 p2dbout,
@@ -338,7 +334,7 @@ static Standard_Boolean IntersUpdateOnSame(Handle(GeomAdaptor_HSurface)& HGs,
   if ( Update(HBs,Hc3df,FIop,CPop,FprolUV,isFirst,c3dU) )
     return Standard_True;
 
-  if (!isTangentFaces(Eprol,Fprol,Fop))
+  if (!ChFi3d_isTangentFaces(Eprol,Fprol,Fop))
     return Standard_False;
 
   Handle(Geom2d_Curve) gpcprol = BRep_Tool::CurveOnSurface(Eprol,Fprol,uf,ul);
@@ -356,9 +352,9 @@ static Standard_Boolean IntersUpdateOnSame(Handle(GeomAdaptor_HSurface)& HGs,
 //           face at end.
 //=======================================================================
 
-static Standard_Boolean Update(Handle(Adaptor3d_HSurface)& face,
-                              Handle(Adaptor2d_HCurve2d)& edonface,
-                              Handle(Adaptor3d_HSurface)& surf,
+static Standard_Boolean Update(const Handle(Adaptor3d_HSurface)& face,
+                              const Handle(Adaptor2d_HCurve2d)& edonface,
+                              const Handle(Adaptor3d_HSurface)& surf,
                               ChFiDS_FaceInterference&  fi,
                               ChFiDS_CommonPoint&       cp,
                               const Standard_Boolean    isfirst)
@@ -424,42 +420,25 @@ static void ChFi3d_ExtendSurface (Handle(Geom_Surface) & S ,
                                   Standard_Integer & prol )
 {
   if (prol) return;
-  Handle(Geom_BSplineSurface) S1;
-  Handle(Geom_BezierSurface) S2;
+
+  prol = (S->IsKind (STANDARD_TYPE(Geom_BSplineSurface)) ? 1 :
+          S->IsKind (STANDARD_TYPE(Geom_BezierSurface))  ? 2 : 0);
+  if ( ! prol )
+    return;
+
   Standard_Real length,umin,umax,vmin,vmax;
   gp_Pnt P1,P2;
   S->Bounds(umin,umax,vmin,vmax);
   S->D0(umin,vmin,P1);
   S->D0(umax,vmax,P2);
   length=P1.Distance(P2);
-  prol=0;
-  S1=Handle(Geom_BSplineSurface)::DownCast(S);
-  S2=Handle(Geom_BezierSurface)::DownCast(S);
-  if (!S1.IsNull()) {
-                  GeomLib::ExtendSurfByLength(S1,length,1,Standard_False,
-                  Standard_True);
-                  GeomLib::ExtendSurfByLength(S1,length,1,Standard_True,
-                  Standard_True);
-                  GeomLib::ExtendSurfByLength(S1,length,1,Standard_False,
-                  Standard_False);
-                  GeomLib::ExtendSurfByLength(S1,length,1,Standard_True,
-                  Standard_False);
-                  S=S1;
-                  prol=1;
-   }
-   if (!S2.IsNull()) {
-                 GeomLib::ExtendSurfByLength(S2,length,1,Standard_False,
-                 Standard_True);
-                 GeomLib::ExtendSurfByLength(S2,length,1,Standard_True,
-                 Standard_True);
-                 GeomLib::ExtendSurfByLength(S2,length,1,Standard_False,
-                 Standard_False);
-                 GeomLib::ExtendSurfByLength(S2,length,1,Standard_True,
-                 Standard_False);
-                 S=S2;
-                 prol=2;
 
-  }
+  Handle(Geom_BoundedSurface) aBS = Handle(Geom_BoundedSurface)::DownCast(S);
+  GeomLib::ExtendSurfByLength (aBS, length, 1, Standard_False, Standard_True);
+  GeomLib::ExtendSurfByLength (aBS, length, 1, Standard_True,  Standard_True);
+  GeomLib::ExtendSurfByLength (aBS, length, 1, Standard_False, Standard_False);
+  GeomLib::ExtendSurfByLength (aBS, length, 1, Standard_True,  Standard_False);
+  S = aBS;
 }
 
 //=======================================================================
@@ -467,7 +446,7 @@ static void ChFi3d_ExtendSurface (Handle(Geom_Surface) & S ,
 //purpose  : calculate the 2d of the curve Ct on face Face
 //=======================================================================
 
-static void  ComputeCurve2d (Handle(Geom_Curve )& Ct,
+static void  ComputeCurve2d (const Handle(Geom_Curve )& Ct,
                        TopoDS_Face & Face,
                        Handle(Geom2d_Curve) & C2d)
 {
@@ -1662,14 +1641,14 @@ void ChFi3d_Builder::PerformIntersectionAtEnd(const Standard_Integer Index)
     ChFi3d_edge_common_faces(myEFMap(Eadj1),Fga,Fdr);
 //  Modified by Sergey KHROMOV - Fri Dec 21 17:57:32 2001 Begin
 //  reg1=BRep_Tool::Continuity(Eadj1,Fga,Fdr)!=GeomAbs_C0;
-    reg1=isTangentFaces(Eadj1,Fga,Fdr);
+    reg1 = ChFi3d_isTangentFaces(Eadj1,Fga,Fdr);
 //  Modified by Sergey KHROMOV - Fri Dec 21 17:57:33 2001 End
     if (F2.IsSame(facecouture)) Eadj2=edgecouture;
     else ChFi3d_cherche_element(Vtx,EdgeSpine,F2,Eadj2,Vbid1);
     ChFi3d_edge_common_faces(myEFMap(Eadj2),Fga,Fdr);
 //  Modified by Sergey KHROMOV - Fri Dec 21 17:58:22 2001 Begin
 //  reg2=BRep_Tool::Continuity(Eadj2,Fga,Fdr)!=GeomAbs_C0;
-    reg2=isTangentFaces(Eadj2,Fga,Fdr);
+    reg2 = ChFi3d_isTangentFaces(Eadj2,Fga,Fdr);
 //  Modified by Sergey KHROMOV - Fri Dec 21 17:58:24 2001 End
 
 // two faces common to the edge are found
@@ -2092,9 +2071,9 @@ void ChFi3d_Builder::PerformIntersectionAtEnd(const Standard_Integer Index)
       else if (nbarete==5) {
        //pro15368
 //  Modified by Sergey KHROMOV - Fri Dec 21 18:07:43 2001 End
-       Standard_Boolean isTangent0 = isTangentFaces(Edge[0],F1,Face[0]);
-       Standard_Boolean isTangent1 = isTangentFaces(Edge[1],Face[0],Face[1]);
-       Standard_Boolean isTangent2 = isTangentFaces(Edge[2],Face[1],Face[2]);
+       Standard_Boolean isTangent0 = ChFi3d_isTangentFaces(Edge[0],F1,Face[0]);
+       Standard_Boolean isTangent1 = ChFi3d_isTangentFaces(Edge[1],Face[0],Face[1]);
+       Standard_Boolean isTangent2 = ChFi3d_isTangentFaces(Edge[2],Face[1],Face[2]);
        if ((isTangent0 || isTangent2) && isTangent1) {
 //         GeomAbs_Shape cont0,cont1,cont2;
 //         cont0=BRep_Tool::Continuity(Edge[0],F1,Face[0]);
@@ -2267,8 +2246,8 @@ void ChFi3d_Builder::PerformIntersectionAtEnd(const Standard_Integer Index)
       inters.Perform(HC, HGs);
       if ( !prolface[nn] && ( !inters.IsDone() || (inters.NbPoints()==0) )) {
        // extend surface of conge
-        Handle(Geom_BSplineSurface) S1=
-          Handle(Geom_BSplineSurface)::DownCast(DStr.Surface(Fd->Surf()).Surface());
+        Handle(Geom_BoundedSurface) S1=
+          Handle(Geom_BoundedSurface)::DownCast(DStr.Surface(Fd->Surf()).Surface());
         if (!S1.IsNull()) {
           Standard_Real length = 0.5 * Max(Fi1Length,Fi2Length);
           GeomLib::ExtendSurfByLength(S1,length,1,Standard_False,!isfirst);
@@ -2278,6 +2257,25 @@ void ChFi3d_Builder::PerformIntersectionAtEnd(const Standard_Integer Index)
             inters.Perform(HC, HGs);
             if (inters.IsDone()&& inters.NbPoints()!=0) {
               Fd->ChangeSurf(DStr.AddSurface(TopOpeBRepDS_Surface(S1, DStr.ChangeSurface(Isurf).Tolerance())));
+              //update history
+              if (myEVIMap.IsBound(EdgeSpine))
+              {
+                TColStd_ListIteratorOfListOfInteger itl(myEVIMap.ChangeFind(EdgeSpine));
+                for (; itl.More(); itl.Next())
+                  if (itl.Value() == Isurf)
+                  {
+                    myEVIMap.ChangeFind(EdgeSpine).Remove(itl);
+                    break;
+                  }
+                myEVIMap.ChangeFind(EdgeSpine).Append(Fd->Surf());
+              }
+              else
+              {
+                TColStd_ListOfInteger IndexList;
+                IndexList.Append(Fd->Surf());
+                myEVIMap.Bind(EdgeSpine, IndexList);
+              }
+              ////////////////
               Isurf=Fd->Surf();
             }
           }
@@ -2650,7 +2648,7 @@ void ChFi3d_Builder::PerformIntersectionAtEnd(const Standard_Integer Index)
               Pl=C1->Value(C1->LastParameter());
               //Standard_Boolean sens;
               sens=Pl.Distance(pext)<tolpt;
-              GeomLib::ExtendCurveToPoint(C1,CV1.Point(),1,sens);
+              GeomLib::ExtendCurveToPoint (C1, CV1.Point(), 1, sens != 0);
               csau=C1;
             }
           }
@@ -2660,7 +2658,7 @@ void ChFi3d_Builder::PerformIntersectionAtEnd(const Standard_Integer Index)
               Pl=C1->Value(C1->LastParameter());
               //Standard_Boolean sens;
               sens=Pl.Distance(pext)<tolpt;
-              GeomLib::ExtendCurveToPoint(C1,CV2.Point(),1,sens);
+              GeomLib::ExtendCurveToPoint (C1, CV2.Point(), 1, sens != 0);
               csau=C1;
             }
           }
@@ -3978,7 +3976,7 @@ void ChFi3d_Builder::IntersectMoreCorner(const Standard_Integer Index)
     inters = Update(HBs,Hc3df,FiopArc,CPopArc,p2dbout,isfirst,wop);
 //  Modified by Sergey KHROMOV - Fri Dec 21 18:08:27 2001 Begin
 //  if(!inters && BRep_Tool::Continuity(Arcprol,Fv,Fop) != GeomAbs_C0){
-    if(!inters && isTangentFaces(Arcprol,Fv,Fop)){
+    if(!inters && ChFi3d_isTangentFaces(Arcprol,Fv,Fop)){
 //  Modified by Sergey KHROMOV - Fri Dec 21 18:08:29 2001 End
       // Arcprol is an edge of tangency, ultimate adjustment by an extrema curve/curve is attempted.
       Standard_Real ff,ll;