]> OCCT Git - occt-copy.git/commitdiff
First version (without tangential neighbors) CR0_winwerth_3
authorjgv <jgv@opencascade.com>
Tue, 8 Aug 2017 17:57:12 +0000 (20:57 +0300)
committerjgv <jgv@opencascade.com>
Tue, 8 Aug 2017 17:58:04 +0000 (20:58 +0300)
14 files changed:
src/BRepAlgo/BRepAlgo_Loop.cxx
src/BRepOffset/BRepOffset_Inter2d.cxx
src/BRepOffset/BRepOffset_Inter2d.hxx
src/BRepOffset/BRepOffset_Inter3d.cxx
src/BRepOffset/BRepOffset_Inter3d.hxx
src/BRepOffset/BRepOffset_MakeOffset.cxx
src/BRepOffset/BRepOffset_MakeOffset.hxx
src/BRepOffset/BRepOffset_MakeOffset_1.cxx
src/BRepOffset/BRepOffset_Offset.cxx
src/BRepOffset/BRepOffset_Offset.hxx
src/BRepOffset/BRepOffset_Tool.cxx
src/BRepOffset/BRepOffset_Tool.hxx
src/BRepTest/BRepTest_FeatureCommands.cxx
src/BiTgte/BiTgte_Blend.cxx

index 9510e4cd38a2fc7094e8895ac77c555e5838aa26..01a01f7a444fa7faed423f3a8ea218cee70b716a 100644 (file)
@@ -264,10 +264,10 @@ static void RemovePendingEdges(TopTools_IndexedDataMapOfShapeListOfShape& MVE)
 //purpose  : 
 //=======================================================================
 
-static Standard_Boolean  SamePnt2d(TopoDS_Vertex  V,
-                                  TopoDS_Edge&   E1,
-                                  TopoDS_Edge&   E2,
-                                  TopoDS_Face&   F)
+static Standard_Boolean  SamePnt2d(const TopoDS_Vertex&  V,
+                                  const TopoDS_Edge&   E1,
+                                  const TopoDS_Edge&   E2,
+                                  const TopoDS_Face&   F)
 {
   Standard_Real   f1,f2,l1,l2;
   gp_Pnt2d        P1,P2;
@@ -649,6 +649,7 @@ void BRepAlgo_Loop::Perform()
     //--------------------------------------------------
     // Add new wire to the set of wires
     //------------------------------------------------
+    /*
     Standard_Real Tol = 0.001; //5.e-05; //5.e-07;
     TopExp_Explorer explo( NW, TopAbs_VERTEX );
     for (; explo.More(); explo.Next())
@@ -665,6 +666,7 @@ void BRepAlgo_Loop::Perform()
       TE->Tolerance( Tol );
       TE->Modified( Standard_True );
       }
+    */
 
     if (VF.IsSame(CV) && SamePnt2d(VF,EF,CE,myFace))
     {
index 778e7d97bd4c4f0a69004bd120e6a268e52d53a2..3a7474e51cc86e456e89cb2cea6f74a05f90c6da 100644 (file)
@@ -78,6 +78,7 @@
 #include <TopTools_ListOfShape.hxx>
 #include <BOPCol_ListOfShape.hxx>
 #include <BOPTools_AlgoTools.hxx>
+#include <Extrema_ExtPC2d.hxx>
 
 #include <stdio.h>
 #ifdef DRAW 
@@ -496,6 +497,9 @@ static void RefEdgeInter(const TopoDS_Face&              F,
                          const BRepAdaptor_Surface&      BAsurf,
                          const TopoDS_Edge&              E1,
                          const TopoDS_Edge&              E2,
+                         const TopoDS_Vertex&            Vref,
+                         const Standard_Boolean          IsConstantE1,
+                         const Standard_Boolean          IsConstantE2,
                          const Handle(BRepAlgo_AsDes)&   AsDes,
                          Standard_Real                   Tol,
                          Standard_Boolean                WithOri,
@@ -545,125 +549,170 @@ static void RefEdgeInter(const TopoDS_Face&              F,
   Standard_Boolean WithDegen = BRep_Tool::Degenerated(E1) || BRep_Tool::Degenerated(E2);
   
   if (WithDegen)
+  {
+    Standard_Integer ideg = (BRep_Tool::Degenerated(E1))? 1 : 2;
+    TopoDS_Iterator iter( EI[ideg] );
+    if (iter.More())
     {
-      Standard_Integer ideg = (BRep_Tool::Degenerated(E1))? 1 : 2;
-      TopoDS_Iterator iter( EI[ideg] );
-      if (iter.More())
-        {
-          const TopoDS_Vertex& vdeg = TopoDS::Vertex(iter.Value());
-          DegPoint = BRep_Tool::Pnt(vdeg);
-        }
-      else
-        {
-          BRepAdaptor_Curve CEdeg( EI[ideg], F );
-          DegPoint = CEdeg.Value( CEdeg.FirstParameter() );
-        }
+      const TopoDS_Vertex& vdeg = TopoDS::Vertex(iter.Value());
+      DegPoint = BRep_Tool::Pnt(vdeg);
+    }
+    else
+    {
+      BRepAdaptor_Curve CEdeg( EI[ideg], F );
+      DegPoint = CEdeg.Value( CEdeg.FirstParameter() );
     }
+  }
   //
+  
   Handle(Geom2d_Curve) pcurve1 = BRep_Tool::CurveOnSurface(E1, F, f[1], l[1]);
   Handle(Geom2d_Curve) pcurve2 = BRep_Tool::CurveOnSurface(E2, F, f[2], l[2]);
   Geom2dAdaptor_Curve GAC1(pcurve1, f[1], l[1]);
   Geom2dAdaptor_Curve GAC2(pcurve2, f[2], l[2]);
-  Geom2dInt_GInter Inter2d( GAC1, GAC2, TolDub, TolDub );
+  
   //
-  if (!Inter2d.IsDone() || !Inter2d.NbPoints()) {
-    theCoincide = (Inter2d.NbSegments() &&
-                  (GAC1.GetType() == GeomAbs_Line) &&
-                  (GAC2.GetType() == GeomAbs_Line));
-    return;
+  if (!Vref.IsNull())
+  {
+    gp_Pnt P3d = BRep_Tool::Pnt(Vref);
+    ResPoints.Append( P3d );
+    Standard_Real ParOnFirst, ParOnSecond;
+    if (IsConstantE1 && IsConstantE2)
+    {
+      ParOnFirst  = BRep_Tool::Parameter(Vref, E1);
+      ParOnSecond = BRep_Tool::Parameter(Vref, E2);
+    }
+    else if (IsConstantE1)
+    {
+      ParOnFirst  = BRep_Tool::Parameter(Vref, E1);
+      gp_Pnt2d aPnt2d = BRep_Tool::Parameters(Vref, F);
+      //Handle(Geom2d_Curve) pcurve2 = BRep_Tool::CurveOnSurface(E2, F, f[2], l[2]);
+      //Geom2dAdaptor_Curve GAC2(pcurve2, f[2], l[2]);
+      Extrema_ExtPC2d Projector(aPnt2d, GAC2);
+      Standard_Integer imin = 1;
+      for (Standard_Integer i = 2; i <= Projector.NbExt(); i++)
+        if (Projector.SquareDistance(i) < Projector.SquareDistance(imin))
+          imin = i;
+      ParOnSecond = Projector.Point(imin).Parameter();
+    }
+    else
+    {
+      ParOnSecond = BRep_Tool::Parameter(Vref, E2);
+      gp_Pnt2d aPnt2d = BRep_Tool::Parameters(Vref, F);
+      //Handle(Geom2d_Curve) pcurve1 = BRep_Tool::CurveOnSurface(E1, F, f[1], l[1]);
+      //Geom2dAdaptor_Curve GAC1(pcurve1, f[1], l[1]);
+      Extrema_ExtPC2d Projector(aPnt2d, GAC1);
+      Standard_Integer imin = 1;
+      for (Standard_Integer i = 2; i <= Projector.NbExt(); i++)
+        if (Projector.SquareDistance(i) < Projector.SquareDistance(imin))
+          imin = i;
+      ParOnFirst = Projector.Point(imin).Parameter();
+    }
+    ResParamsOnE1.Append( ParOnFirst );
+    ResParamsOnE2.Append( ParOnSecond );
   }
-  //
-  for (i = 1; i <= Inter2d.NbPoints(); i++)
+  else
+  {
+    Geom2dInt_GInter Inter2d( GAC1, GAC2, TolDub, TolDub );
+    //
+    if (!Inter2d.IsDone() || !Inter2d.NbPoints()) {
+      theCoincide = (Inter2d.NbSegments() &&
+                     (GAC1.GetType() == GeomAbs_Line) &&
+                     (GAC2.GetType() == GeomAbs_Line));
+      return;
+    }
+    //
+    for (i = 1; i <= Inter2d.NbPoints(); i++)
     {
       gp_Pnt P3d;
       if (WithDegen)
         P3d = DegPoint;
       else
-        {
-          gp_Pnt2d P2d = Inter2d.Point(i).Value();
-          P3d = BAsurf.Value( P2d.X(), P2d.Y() );
-        }
+      {
+        gp_Pnt2d P2d = Inter2d.Point(i).Value();
+        P3d = BAsurf.Value( P2d.X(), P2d.Y() );
+      }
       ResPoints.Append( P3d );
       ResParamsOnE1.Append( Inter2d.Point(i).ParamOnFirst() );
       ResParamsOnE2.Append( Inter2d.Point(i).ParamOnSecond() );
     }
+  } //else (without Vref)
   
   for (i = 1; i <= ResPoints.Length(); i++)
+  {
+    Standard_Real aT1 = ResParamsOnE1(i); //ponc1.Parameter();
+    Standard_Real aT2 = ResParamsOnE2(i); //ponc2.Parameter();
+    if (Precision::IsInfinite(aT1) || Precision::IsInfinite(aT2))
     {
-      Standard_Real aT1 = ResParamsOnE1(i); //ponc1.Parameter();
-      Standard_Real aT2 = ResParamsOnE2(i); //ponc2.Parameter();
-      if (Precision::IsInfinite(aT1) || Precision::IsInfinite(aT2))
-        {
 #ifdef OCCT_DEBUG
-          cout << "Inter2d : Solution rejected due to infinite parameter"<<endl;
+      cout << "Inter2d : Solution rejected due to infinite parameter"<<endl;
 #endif
-          continue;
-        }
-      
-      gp_Pnt P = ResPoints(i); //ponc1.Value();
-      TopoDS_Vertex aNewVertex = BRepLib_MakeVertex(P);
-      aNewVertex.Orientation(TopAbs_INTERNAL);
-      B.UpdateVertex( aNewVertex, aT1, E1, Tol );
-      B.UpdateVertex( aNewVertex, aT2, E2, Tol );
-      gp_Pnt P1 = CE1.Value(aT1);
-      gp_Pnt P2 = CE2.Value(aT2);
-      Standard_Real dist1, dist2, dist3;
-      dist1 = P1.Distance(P);
-      dist2 = P2.Distance(P);
-      dist3 = P1.Distance(P2);
-      dist1 = Max( dist1, dist2 );
-      dist1 = Max( dist1, dist3 );
-      B.UpdateVertex( aNewVertex, dist1 );
-      
+      continue;
+    }
+    
+    gp_Pnt P = ResPoints(i); //ponc1.Value();
+    TopoDS_Vertex aNewVertex = BRepLib_MakeVertex(P);
+    aNewVertex.Orientation(TopAbs_INTERNAL);
+    B.UpdateVertex( aNewVertex, aT1, E1, Tol );
+    B.UpdateVertex( aNewVertex, aT2, E2, Tol );
+    gp_Pnt P1 = CE1.Value(aT1);
+    gp_Pnt P2 = CE2.Value(aT2);
+    Standard_Real dist1, dist2, dist3;
+    dist1 = P1.Distance(P);
+    dist2 = P2.Distance(P);
+    dist3 = P1.Distance(P2);
+    dist1 = Max( dist1, dist2 );
+    dist1 = Max( dist1, dist3 );
+    B.UpdateVertex( aNewVertex, dist1 );
+    
 #ifdef OCCT_DEBUG
-      if (aT1 < f[1]-Tol  || aT1 > l[1]+Tol)
-        {
-          cout << "out of limit"<<endl;
-          cout<<"aT1 = "<<aT1<<", f[1] = "<<f[1]<<", l[1] = "<<l[1]<<endl;
-        }
-      if (aT2 < f[2]-Tol  || aT2 > l[2]+Tol)
-        {
-          cout << "out of limit"<<endl;
-          cout<<"aT2 = "<<aT2<<", f[2] = "<<f[2]<<", l[2] = "<<l[2]<<endl;
-        }
-      Standard_Real MilTol2 = 1000*Tol*Tol;
-      if (P1.SquareDistance(P) >  MilTol2 || P2.SquareDistance(P) > MilTol2 || P1.Distance(P2) > 2.*Tol)
-        {
-          cout << "Inter2d : Solution rejected"<<endl;
-          cout<<"P  = "<<P.X()<<" "<<P.Y()<<" "<<P.Z()<<endl;
-          cout<<"P1 = "<<P1.X()<<" "<<P1.Y()<<" "<<P1.Z()<<endl;
-          cout<<"P2 = "<<P2.X()<<" "<<P2.Y()<<" "<<P2.Z()<<endl;
-          cout<<"MaxDist = "<<dist1<<endl;
-        }
+    if (aT1 < f[1]-Tol  || aT1 > l[1]+Tol)
+    {
+      cout << "out of limit"<<endl;
+      cout<<"aT1 = "<<aT1<<", f[1] = "<<f[1]<<", l[1] = "<<l[1]<<endl;
+    }
+    if (aT2 < f[2]-Tol  || aT2 > l[2]+Tol)
+    {
+      cout << "out of limit"<<endl;
+      cout<<"aT2 = "<<aT2<<", f[2] = "<<f[2]<<", l[2] = "<<l[2]<<endl;
+    }
+    Standard_Real MilTol2 = 1000*Tol*Tol;
+    if (P1.SquareDistance(P) >  MilTol2 || P2.SquareDistance(P) > MilTol2 || P1.Distance(P2) > 2.*Tol)
+    {
+      cout << "Inter2d : Solution rejected"<<endl;
+      cout<<"P  = "<<P.X()<<" "<<P.Y()<<" "<<P.Z()<<endl;
+      cout<<"P1 = "<<P1.X()<<" "<<P1.Y()<<" "<<P1.Z()<<endl;
+      cout<<"P2 = "<<P2.X()<<" "<<P2.Y()<<" "<<P2.Z()<<endl;
+      cout<<"MaxDist = "<<dist1<<endl;
+    }
 #endif
-      //define the orientation of a new vertex
-      TopAbs_Orientation OO1 = TopAbs_REVERSED;
-      TopAbs_Orientation OO2 = TopAbs_REVERSED;
-      if (WithOri)
-        {
-          BRepAdaptor_Curve2d PCE1( E1, F );
-          BRepAdaptor_Curve2d PCE2( E2, F );
-          gp_Pnt2d P2d1, P2d2;
-          gp_Vec2d V1, V2, V1or, V2or;
-          PCE1.D1( aT1, P2d1, V1 );
-          PCE2.D1( aT2, P2d2, V2 );
-          V1or = V1; V2or = V2;
-          if (E1.Orientation() == TopAbs_REVERSED) V1or.Reverse();
-          if (E2.Orientation() == TopAbs_REVERSED) V2or.Reverse();
-          Standard_Real CrossProd = V2or ^ V1;
+    //define the orientation of a new vertex
+    TopAbs_Orientation OO1 = TopAbs_REVERSED;
+    TopAbs_Orientation OO2 = TopAbs_REVERSED;
+    if (WithOri)
+    {
+      BRepAdaptor_Curve2d PCE1( E1, F );
+      BRepAdaptor_Curve2d PCE2( E2, F );
+      gp_Pnt2d P2d1, P2d2;
+      gp_Vec2d V1, V2, V1or, V2or;
+      PCE1.D1( aT1, P2d1, V1 );
+      PCE2.D1( aT2, P2d2, V2 );
+      V1or = V1; V2or = V2;
+      if (E1.Orientation() == TopAbs_REVERSED) V1or.Reverse();
+      if (E2.Orientation() == TopAbs_REVERSED) V2or.Reverse();
+      Standard_Real CrossProd = V2or ^ V1;
 #ifdef OCCT_DEBUG
-          if (Abs(CrossProd) <= gp::Resolution())
-            cout<<endl<<"CrossProd = "<<CrossProd<<endl;
+      if (Abs(CrossProd) <= gp::Resolution())
+        cout<<endl<<"CrossProd = "<<CrossProd<<endl;
 #endif
-          if (CrossProd > 0.)
-            OO1 = TopAbs_FORWARD;
-          CrossProd = V1or ^ V2;
-          if (CrossProd > 0.)
-            OO2 = TopAbs_FORWARD;
-        }
-      LV1.Append( aNewVertex.Oriented(OO1) );
-      LV2.Append( aNewVertex.Oriented(OO2) );
+      if (CrossProd > 0.)
+        OO1 = TopAbs_FORWARD;
+      CrossProd = V1or ^ V2;
+      if (CrossProd > 0.)
+        OO2 = TopAbs_FORWARD;
     }
+    LV1.Append( aNewVertex.Oriented(OO1) );
+    LV2.Append( aNewVertex.Oriented(OO2) );
+  }
   
   //----------------------------------
   // Test at end.
@@ -1427,6 +1476,7 @@ void BRepOffset_Inter2d::ConnexIntByInt
   BRepOffset_Offset&            OFI,
   TopTools_DataMapOfShapeShape& MES,
   const TopTools_DataMapOfShapeShape& Build,
+  const TopTools_MapOfShape&    MapConstantEdges,
   const Handle(BRepAlgo_AsDes)& AsDes2d,
   const Standard_Real           Offset,
   const Standard_Real           Tol,
@@ -1467,6 +1517,7 @@ void BRepOffset_Inter2d::ConnexIntByInt
   if (MES.IsBound(FIO)) FIO = TopoDS::Face(MES(FIO));
   //
   BRepAdaptor_Surface BAsurf(FIO);
+  BRep_Builder BB;
   
   TopExp_Explorer exp(FI.Oriented(TopAbs_FORWARD),TopAbs_WIRE);
   for (; exp.More(); exp.Next()) {
@@ -1493,6 +1544,12 @@ void BRepOffset_Inter2d::ConnexIntByInt
 
       TopoDS_Vertex Vref = CommonVertex(CurE, NextE); 
       gp_Pnt Pref = BRep_Tool::Pnt(Vref);
+      TopoDS_Vertex Vcommon;
+      Standard_Boolean IsConstantE1 = Standard_False, IsConstantE2 = Standard_False;
+      //Temporary : comment the following lines
+      if (MapConstantEdges.Contains(CurE) ||
+          MapConstantEdges.Contains(NextE))
+        Vcommon = Vref;
 
       TopoDS_Shape aLocalShape = OFI.Generated(CurE);
       TopoDS_Edge CEO = TopoDS::Edge(aLocalShape);
@@ -1502,7 +1559,7 @@ void BRepOffset_Inter2d::ConnexIntByInt
       // Inter processing of images of CurE NextE.
       //------------------------------------------
       TopTools_ListOfShape LV1,LV2;
-      Standard_Boolean     DoInter = 1;
+      Standard_Boolean     DoInter = 1, ToExchange = Standard_False;
       TopoDS_Shape         NE1,NE2;
       
       if (Build.IsBound(CurE) && Build.IsBound(NextE)) {
@@ -1516,6 +1573,7 @@ void BRepOffset_Inter2d::ConnexIntByInt
       else if (Build.IsBound(NextE) && MES.IsBound(CEO)) {
         NE1 = Build(NextE);
         NE2 = MES(CEO);
+        ToExchange = Standard_True;
       }
       else {
         DoInter = 0;
@@ -1530,8 +1588,35 @@ void BRepOffset_Inter2d::ConnexIntByInt
           const TopoDS_Edge& aE1 = TopoDS::Edge(Exp1.Current());
           for (Exp2.Init(NE2, TopAbs_EDGE); Exp2.More(); Exp2.Next()) {
             const TopoDS_Edge& aE2 = TopoDS::Edge(Exp2.Current());
-            RefEdgeInter(FIO, BAsurf, aE1, aE2, AsDes2d,
-                         Tol, Standard_True, Pref, theDMVV, bCoincide);
+            if (!Vcommon.IsNull())
+            {
+              TopoDS_Edge ProE1 = CurE, ProE2 = NextE;
+              if (ToExchange)
+              { ProE1 = NextE; ProE2 = CurE; }
+              if (MapConstantEdges.Contains(ProE1))
+                IsConstantE1 = Standard_True;
+              if (MapConstantEdges.Contains(ProE2))
+                IsConstantE2 = Standard_True;
+              if (IsConstantE1)
+              {
+                Standard_Real ParOnFirst  = BRep_Tool::Parameter(Vcommon, ProE1, FI);
+                BB.UpdateVertex(Vcommon, ParOnFirst, aE1, 0.);
+                BRepAdaptor_Curve2d BAcurve2d(ProE1, FI);
+                gp_Pnt2d aPnt2d = BAcurve2d.Value(ParOnFirst);
+                BB.UpdateVertex(Vcommon, aPnt2d.X(), aPnt2d.Y(), FIO, 0.);
+              }
+              if (IsConstantE2)
+              {
+                Standard_Real ParOnSecond = BRep_Tool::Parameter(Vcommon, ProE2, FI);
+                BB.UpdateVertex(Vcommon, ParOnSecond, aE2, 0.);
+                BRepAdaptor_Curve2d BAcurve2d(ProE2, FI);
+                gp_Pnt2d aPnt2d = BAcurve2d.Value(ParOnSecond);
+                BB.UpdateVertex(Vcommon, aPnt2d.X(), aPnt2d.Y(), FIO, 0.);
+              }
+            }
+            RefEdgeInter(FIO, BAsurf, aE1, aE2,
+                         Vcommon, IsConstantE1, IsConstantE2,
+                         AsDes2d, Tol, Standard_True, Pref, theDMVV, bCoincide);
           }
         }
         //
@@ -1567,6 +1652,7 @@ void BRepOffset_Inter2d::ConnexIntByIntInVert
   BRepOffset_Offset&            OFI,
   TopTools_DataMapOfShapeShape& MES,
   const TopTools_DataMapOfShapeShape& Build,
+  const TopTools_MapOfShape&    MapConstantEdges,
   const Handle(BRepAlgo_AsDes)& AsDes,
   const Handle(BRepAlgo_AsDes)& AsDes2d,
   const Standard_Real           Tol,
@@ -1616,6 +1702,15 @@ void BRepOffset_Inter2d::ConnexIntByIntInVert
         CurE = NextE;
         continue;
       }
+
+      TopoDS_Vertex Vcommon;
+      Standard_Boolean IsConstantE1 = Standard_False, IsConstantE2 = Standard_False;
+      /*
+      if (MapConstantEdges.Contains(CurE) ||
+          MapConstantEdges.Contains(NextE))
+        Vcommon = Vref;
+      */
+      
       //
       TopoDS_Shape aLocalShape = OFI.Generated(CurE);
       TopoDS_Edge CEO = TopoDS::Edge(aLocalShape);
@@ -1655,8 +1750,9 @@ void BRepOffset_Inter2d::ConnexIntByIntInVert
         // intersection with first edge
         for (Exp1.Init(NE1, TopAbs_EDGE); Exp1.More(); Exp1.Next()) {
           const TopoDS_Edge& aE1 = TopoDS::Edge(Exp1.Current());
-          RefEdgeInter(FIO, BAsurf, aE1, aE3, AsDes2d,
-            Tol, Standard_True, Pref, theDMVV, bCoincide);
+          RefEdgeInter(FIO, BAsurf, aE1, aE3,
+                       Vcommon, IsConstantE1, IsConstantE2,
+                       AsDes2d, Tol, Standard_True, Pref, theDMVV, bCoincide);
           if (bCoincide) {
             // in case of coincidence trim the edge E3 the same way as E1
             Store(aE3, AsDes2d->Descendant(aE1), Tol, Standard_True, AsDes2d, theDMVV);
@@ -1666,8 +1762,9 @@ void BRepOffset_Inter2d::ConnexIntByIntInVert
         // intersection with second edge
         for (Exp1.Init(NE2, TopAbs_EDGE); Exp1.More(); Exp1.Next()) {
           const TopoDS_Edge& aE2 = TopoDS::Edge(Exp1.Current());
-          RefEdgeInter(FIO, BAsurf, aE2, aE3, AsDes2d,
-            Tol, Standard_True, Pref, theDMVV, bCoincide);
+          RefEdgeInter(FIO, BAsurf, aE2, aE3,
+                       Vcommon, IsConstantE1, IsConstantE2,
+                       AsDes2d, Tol, Standard_True, Pref, theDMVV, bCoincide);
           if (bCoincide) {
             // in case of coincidence trim the edge E3 the same way as E2
             Store(aE3, AsDes2d->Descendant(aE2), Tol, Standard_True, AsDes2d, theDMVV);
@@ -1685,8 +1782,9 @@ void BRepOffset_Inter2d::ConnexIntByIntInVert
         for (Exp1.Next(); Exp1.More(); Exp1.Next()) {
           const TopoDS_Edge& aE3Next = TopoDS::Edge(Exp1.Current());
           if (aME.Contains(aE3Next)) {
-            RefEdgeInter(FIO, BAsurf, aE3Next, aE3, AsDes2d,
-              Tol, Standard_True, Pref, theDMVV, bCoincide);
+            RefEdgeInter(FIO, BAsurf, aE3Next, aE3,
+                         Vcommon, IsConstantE1, IsConstantE2,
+                         AsDes2d, Tol, Standard_True, Pref, theDMVV, bCoincide);
           }
         }
       }
index 4c0689027b520e209039d187eae29d75c6c3fd0b..a402f72f514e94f4d408e7215ed99044331f9a1f 100644 (file)
@@ -22,6 +22,7 @@
 #include <Standard_Handle.hxx>
 
 #include <TopTools_IndexedMapOfShape.hxx>
+#include <TopTools_MapOfShape.hxx>
 #include <Standard_Real.hxx>
 #include <TopTools_DataMapOfShapeShape.hxx>
 #include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
@@ -60,6 +61,7 @@ public:
                                               BRepOffset_Offset& OFI,
                                               TopTools_DataMapOfShapeShape& MES,
                                               const TopTools_DataMapOfShapeShape& Build,
+                                              const TopTools_MapOfShape&    MapConstantEdges,
                                               const Handle(BRepAlgo_AsDes)& AsDes2d,
                                               const Standard_Real Offset,
                                               const Standard_Real Tol,
@@ -76,6 +78,7 @@ public:
                                                     BRepOffset_Offset& OFI,
                                                     TopTools_DataMapOfShapeShape& MES,
                                                     const TopTools_DataMapOfShapeShape& Build,
+                                                    const TopTools_MapOfShape&    MapConstantEdges,
                                                     const Handle(BRepAlgo_AsDes)& AsDes,
                                                     const Handle(BRepAlgo_AsDes)& AsDes2d,
                                                     const Standard_Real Tol,
index 8309b18dcf8310e0991537a762762b9cd16dbb2d..3b3e498bdaa6537022d62f3ff39b3e5a9c6c89b4 100644 (file)
@@ -44,6 +44,7 @@
 #include <TopTools_ListIteratorOfListOfShape.hxx>
 #include <TopTools_MapIteratorOfMapOfShape.hxx>
 #include <TopTools_MapOfShape.hxx>
+//#include <BRepBuilderAPI_Copy.hxx>
 //
 #include <BRepBndLib.hxx>
 #include <BOPCol_BoxBndTree.hxx>
 //
 #include <BOPTools_AlgoTools.hxx>
 
+
+static void FindCommonEdges(const TopoDS_Face& theF1,
+                            const TopoDS_Face& theF2,
+                            TopTools_ListOfShape& theList)
+{
+  TopExp_Explorer Explo1(theF1.Oriented(TopAbs_FORWARD), TopAbs_EDGE);
+  for (; Explo1.More(); Explo1.Next())
+  {
+    const TopoDS_Shape& anEdge1 = Explo1.Current();
+    TopExp_Explorer Explo2(theF2, TopAbs_EDGE);
+    for (; Explo2.More(); Explo2.Next())
+    {
+      const TopoDS_Shape& anEdge2 = Explo2.Current();
+      if (anEdge1.IsSame(anEdge2))
+      {
+        theList.Append(anEdge1);
+        break;
+      }
+    }
+  }
+}
+
 //=======================================================================
 //function : BRepOffset_Inter3d
 //purpose  : 
@@ -269,14 +292,15 @@ void BRepOffset_Inter3d::FaceInter(const TopoDS_Face& F1,
         // many sections.
         //--------------------------------------------------------
         if (InterFaces) {
+          TopTools_ListOfShape aList;
           if (BRepOffset_Tool::FindCommonShapes(TopoDS::Face(InitF1),
                                                 TopoDS::Face(InitF2),LE,LV)) {
             if (!LE.IsEmpty()) {
-              BRepOffset_Tool::Inter3D (F1,F2,LInt1,LInt2,mySide,NullEdge);
+              BRepOffset_Tool::Inter3D (F1,F2,F1,F2,LInt1,LInt2,aList,mySide,NullEdge);
             }
           }
           else {
-            BRepOffset_Tool::Inter3D(F1,F2,LInt1,LInt2,mySide,NullEdge);
+            BRepOffset_Tool::Inter3D(F1,F2,F1,F2,LInt1,LInt2,aList,mySide,NullEdge);
           }
         }
       }
@@ -287,7 +311,8 @@ void BRepOffset_Inter3d::FaceInter(const TopoDS_Face& F1,
       BRepOffset_Tool::PipeInter(F1,F2,LInt1,LInt2,mySide);
     }
     else {
-      BRepOffset_Tool::Inter3D (F1,F2,LInt1,LInt2,mySide,NullEdge);
+      TopTools_ListOfShape aList;
+      BRepOffset_Tool::Inter3D (F1,F2,F1,F2,LInt1,LInt2,aList,mySide,NullEdge);
     }
   }
   Store (F1,F2,LInt1,LInt2);
@@ -327,7 +352,8 @@ void BRepOffset_Inter3d::ConnexIntByArc(const TopTools_ListOfShape& /*SetOfFaces
         F1 = TopoDS::Face(InitOffsetFace.Image(Anc.First()).First());
         F2 = TopoDS::Face(InitOffsetFace.Image(Anc.Last ()).First());
         if (!IsDone(F1,F2)) {
-          BRepOffset_Tool::Inter3D (F1,F2,LInt1,LInt2,mySide,E,Standard_True);
+          TopTools_ListOfShape aList;
+          BRepOffset_Tool::Inter3D (F1,F2,F1,F2,LInt1,LInt2,aList,mySide,E,Standard_True);
           Store (F1,F2,LInt1,LInt2);
         }
       }          
@@ -406,13 +432,14 @@ void BRepOffset_Inter3d::ConnexIntByArc(const TopTools_ListOfShape& /*SetOfFaces
               const TopTools_ListOfShape& AncE2        = Analyse.Ancestors(E2);
               Standard_Boolean            TangentFaces = Standard_False;
               if (AncE2.Extent() == 2) {
+                TopTools_ListOfShape aList;
                 TopoDS_Face InitF2 = TopoDS::Face(AncE2.First ());
                 TangentFaces = (InitF2.IsSame(AncE1.First()) || 
                                 InitF2.IsSame(AncE1.Last()));
                 if (!TangentFaces) {
                   F2 = TopoDS::Face(InitOffsetFace.Image(InitF2).First());
                   if (!IsDone(F1,F2)) {
-                    BRepOffset_Tool::Inter3D (F1,F2,LInt1,LInt2,mySide,NullEdge);
+                    BRepOffset_Tool::Inter3D (F1,F2,F1,F2,LInt1,LInt2,aList,mySide,NullEdge);
                     Store (F1,F2,LInt1,LInt2);
                   }
                 }
@@ -422,7 +449,7 @@ void BRepOffset_Inter3d::ConnexIntByArc(const TopTools_ListOfShape& /*SetOfFaces
                 if (!TangentFaces) {
                   F2 = TopoDS::Face(InitOffsetFace.Image(InitF2).First());
                   if (!IsDone(F1,F2)) {
-                    BRepOffset_Tool::Inter3D (F1,F2,LInt1,LInt2,mySide,NullEdge);
+                    BRepOffset_Tool::Inter3D (F1,F2,F1,F2,LInt1,LInt2,aList,mySide,NullEdge);
                     Store (F1,F2,LInt1,LInt2);
                   }
                 }
@@ -444,6 +471,7 @@ void BRepOffset_Inter3d::ConnexIntByArc(const TopTools_ListOfShape& /*SetOfFaces
 void BRepOffset_Inter3d::ConnexIntByInt
 (const TopoDS_Shape&                    SI,
  const BRepOffset_DataMapOfShapeOffset& MapSF,
+ const TopTools_MapOfShape&             MapModifyingFaces,
  const BRepOffset_Analyse&              Analyse,
  TopTools_DataMapOfShapeShape&          MES,
  TopTools_DataMapOfShapeShape&          Build,
@@ -592,10 +620,32 @@ void BRepOffset_Inter3d::ConnexIntByInt
       //
       OF1 = TopoDS::Face(MapSF(F1).Face());
       OF2 = TopoDS::Face(MapSF(F2).Face());
-      if (!MES.IsBound(OF1)) {
+
+      Standard_Boolean F1remains = Standard_False, F2remains = Standard_False;
+
+      F1remains = (!MapSF(F1).IsInputOffsetFace() &&
+                   MapSF(F1).Offset() == 0. &&
+                   !MapModifyingFaces.Contains(F1));
+      //Temporary
+      //F1remains = Standard_False;
+      ///////////
+      if (F1remains)
+      {
+        //NF1 = TopoDS::Face(BRepBuilderAPI_Copy(OF1));
+        NF1 = OF1;
+        MES.Bind(OF1,NF1);
+        //F1remains = Standard_True;
+      }
+      else if (!MES.IsBound(OF1)) {
         Standard_Boolean enlargeU = Standard_True;
         Standard_Boolean enlargeVfirst = Standard_True, enlargeVlast = Standard_True;
-        BRepOffset_Tool::CheckBounds( F1, Analyse, enlargeU, enlargeVfirst, enlargeVlast );
+        if (MapSF(F1).IsInputOffsetFace())
+        {
+          enlargeU = Standard_False;
+          enlargeVfirst = Standard_False; enlargeVlast = Standard_False;
+        }
+        else
+          BRepOffset_Tool::CheckBounds( F1, Analyse, enlargeU, enlargeVfirst, enlargeVlast );
         BRepOffset_Tool::EnLargeFace(OF1,NF1,Standard_True,Standard_True,enlargeU,enlargeVfirst,enlargeVlast);
         MES.Bind(OF1,NF1);
       }
@@ -603,20 +653,53 @@ void BRepOffset_Inter3d::ConnexIntByInt
         NF1 = TopoDS::Face(MES(OF1));
       }
       //
-      if (!MES.IsBound(OF2)) {
+      F2remains = (!MapSF(F2).IsInputOffsetFace() &&
+                   MapSF(F2).Offset() == 0. &&
+                   !MapModifyingFaces.Contains(F2));
+      //Temporary
+      //F2remains = Standard_False;
+      ///////////
+      if (F2remains)
+      {
+        //NF2 = TopoDS::Face(BRepBuilderAPI_Copy(OF2));
+        NF2 = OF2;
+        MES.Bind(OF2,NF2);
+        //F2remains = Standard_True;
+      }
+      else if (!MES.IsBound(OF2)) {
         Standard_Boolean enlargeU = Standard_True;
         Standard_Boolean enlargeVfirst = Standard_True, enlargeVlast = Standard_True;
-        BRepOffset_Tool::CheckBounds( F2, Analyse, enlargeU, enlargeVfirst, enlargeVlast );
+        if (MapSF(F2).IsInputOffsetFace())
+        {
+          enlargeU = Standard_False;
+          enlargeVfirst = Standard_False; enlargeVlast = Standard_False;
+        }
+        else
+          BRepOffset_Tool::CheckBounds( F2, Analyse, enlargeU, enlargeVfirst, enlargeVlast );
         BRepOffset_Tool::EnLargeFace(OF2,NF2,Standard_True,Standard_True,enlargeU,enlargeVfirst,enlargeVlast);
-        MES.Bind(OF2,NF2); 
+        MES.Bind(OF2,NF2);
       }
       else {
         NF2 = TopoDS::Face(MES(OF2));
       }
       //
       if (!IsDone(NF1,NF2)) {
-        TopTools_ListOfShape LInt1,LInt2;
-        BRepOffset_Tool::Inter3D (NF1,NF2,LInt1,LInt2,CurSide,E,bEdge);
+        TopTools_ListOfShape LInt1, LInt2, LInt;
+        if (F1remains || F2remains)
+          FindCommonEdges(F1, F2, LInt);
+        if (F1remains && F2remains)
+        {
+          LInt1.Assign(LInt);
+          TopTools_ListIteratorOfListOfShape itl(LInt1);
+          for (; itl.More(); itl.Next())
+            LInt2.Append(itl.Value().Reversed());
+        }
+        else
+        {
+          BRepOffset_Tool::Inter3D(NF1, NF2, F1, F2, LInt1, LInt2, LInt,
+                                   CurSide, E, bEdge,
+                                   F1remains, F2remains);
+        }
         if (LInt1.Extent() > 1) { 
           // intersection is in seceral edges (free sewing)
           SelectEdge(aS, LInt1);
@@ -1018,9 +1101,9 @@ void BRepOffset_Inter3d::ContextIntByInt
         }
         if (!IsDone(NF,CF)) {
           TopTools_ListOfShape LInt1,LInt2;
-          TopTools_ListOfShape LOE;
+          TopTools_ListOfShape LOE, aList;
           LOE.Append(OE);
-          BRepOffset_Tool::Inter3D (WCF,NF,LInt1,LInt2,Side,E,bEdge);
+          BRepOffset_Tool::Inter3D (WCF,NF,WCF,NF,LInt1,LInt2,aList,Side,E,bEdge);
           SetDone(NF,CF);
           if (!LInt1.IsEmpty()) {
             Store (CF,NF,LInt1,LInt2);
@@ -1241,7 +1324,8 @@ void BRepOffset_Inter3d::ContextIntByArc(const TopTools_IndexedMapOfShape& Conte
             // If no trace try intersection.
             //-------------------------------------------------------
             if (LInt1.IsEmpty()) {
-              BRepOffset_Tool::Inter3D (CF,OF1,LInt1,LInt2,mySide,NullEdge);
+              TopTools_ListOfShape aList;
+              BRepOffset_Tool::Inter3D (CF,OF1,CF,OF1,LInt1,LInt2,aList,mySide,NullEdge);
             }
             Store (CF,OF1,LInt1,LInt2);
           }
index e9607c89c5fefb47a8c05043507cb2f6817a236a..efda2344336819b4d220fa259196c1873e65efe5 100644 (file)
@@ -53,7 +53,14 @@ public:
   
   Standard_EXPORT void ConnexIntByArc (const TopTools_ListOfShape& SetOfFaces, const TopoDS_Shape& ShapeInit, const BRepOffset_Analyse& Analyse, const BRepAlgo_Image& InitOffsetFace);
   
-  Standard_EXPORT void ConnexIntByInt (const TopoDS_Shape& SI, const BRepOffset_DataMapOfShapeOffset& MapSF, const BRepOffset_Analyse& A, TopTools_DataMapOfShapeShape& MES, TopTools_DataMapOfShapeShape& Build, TopTools_ListOfShape& Failed, const Standard_Boolean bIsPlanar = Standard_False);
+  Standard_EXPORT void ConnexIntByInt (const TopoDS_Shape& SI,
+                                       const BRepOffset_DataMapOfShapeOffset& MapSF,
+                                       const TopTools_MapOfShape&             MapModifyingFaces,
+                                       const BRepOffset_Analyse& A,
+                                       TopTools_DataMapOfShapeShape& MES,
+                                       TopTools_DataMapOfShapeShape& Build,
+                                       TopTools_ListOfShape& Failed,
+                                       const Standard_Boolean bIsPlanar = Standard_False);
   
   Standard_EXPORT void ContextIntByInt (const TopTools_IndexedMapOfShape& ContextFaces, const Standard_Boolean ExtentContext, const BRepOffset_DataMapOfShapeOffset& MapSF, const BRepOffset_Analyse& A, TopTools_DataMapOfShapeShape& MES, TopTools_DataMapOfShapeShape& Build, TopTools_ListOfShape& Failed, const Standard_Boolean bIsPlanar = Standard_False);
   
index 94996734fa8c8d2dd55b5b25cfa7d9f858b9a532..91dba7de64447b24c8512d6b907005ff391eacba 100644 (file)
@@ -81,6 +81,7 @@
 #include <gp_Lin2d.hxx>
 #include <gp_Pnt.hxx>
 #include <GProp_GProps.hxx>
+#include <IntTools_Context.hxx>
 #include <IntTools_FClass2d.hxx>
 #include <NCollection_List.hxx>
 #include <Precision.hxx>
@@ -627,6 +628,9 @@ void BRepOffset_MakeOffset::Clear()
   myImageOffset    .Clear();
   myFaces          .Clear();  
   myFaceOffset     .Clear();
+  myMapFaceOffsetFace.Clear();
+  myMapModifyingFaces.Clear();
+  myMapConstantEdges.Clear();
   myAsDes          ->Clear();
   myDone     = Standard_False;
 }
@@ -658,6 +662,21 @@ void BRepOffset_MakeOffset::SetOffsetOnFace(const TopoDS_Face&  F,
   myFaceOffset.Bind(F,Off);
 }
 
+//=======================================================================
+//function : SetOffsetFace
+//purpose  : 
+//=======================================================================
+void BRepOffset_MakeOffset::SetOffsetFace(const TopoDS_Face& F,
+                                          const TopoDS_Face& OF)
+{
+  // Check the orientation of the offset face and make
+  // it oriented the same way as original
+  Handle(IntTools_Context) aCtx = new IntTools_Context;
+  Standard_Boolean bToReverse = BOPTools_AlgoTools::IsSplitToReverse(F, OF, aCtx);
+  TopoDS_Face anOffsetFace = bToReverse ? TopoDS::Face(OF.Reversed()) : OF;
+  myMapFaceOffsetFace.Bind(F, anOffsetFace);
+}
+
 //=======================================================================
 //function : RemoveCorks
 //purpose  : 
@@ -795,6 +814,50 @@ void BRepOffset_MakeOffset::MakeOffsetShape()
   //----------------------------
   UpdateFaceOffset();
 
+  //Filling of <myModifiedFaces> and <myMapConstantEdges>
+  TopTools_IndexedDataMapOfShapeListOfShape EFmap;
+  TopExp::MapShapesAndUniqueAncestors(myShape, TopAbs_EDGE, TopAbs_FACE, EFmap);
+  TopTools_DataMapIteratorOfDataMapOfShapeReal itr1(myFaceOffset);
+  for (; itr1.More(); itr1.Next())
+  {
+    const TopoDS_Shape& aFace = itr1.Key();
+    myMapModifyingFaces.Add(aFace);
+    TopExp_Explorer Explo(aFace, TopAbs_EDGE);
+    for (; Explo.More(); Explo.Next())
+    {
+      const TopoDS_Shape& anEdge = Explo.Current();
+      TopTools_ListIteratorOfListOfShape itl(EFmap.FindFromKey(anEdge));
+      for (; itl.More(); itl.Next())
+        myMapModifyingFaces.Add(itl.Value());
+    }
+  }
+  TopTools_DataMapIteratorOfDataMapOfShapeShape itr2(myMapFaceOffsetFace);
+  for (; itr2.More(); itr2.Next())
+  {
+    const TopoDS_Shape& aFace = itr2.Key();
+    myMapModifyingFaces.Add(aFace);
+    TopExp_Explorer Explo(aFace, TopAbs_EDGE);
+    for (; Explo.More(); Explo.Next())
+    {
+      const TopoDS_Shape& anEdge = Explo.Current();
+      TopTools_ListIteratorOfListOfShape itl(EFmap.FindFromKey(anEdge));
+      for (; itl.More(); itl.Next())
+        myMapModifyingFaces.Add(itl.Value());
+    }
+  }
+  TopExp_Explorer Explo(myShape, TopAbs_FACE);
+  for (; Explo.More(); Explo.Next())
+  {
+    const TopoDS_Shape& aFace = Explo.Current();
+    if (!myMapModifyingFaces.Contains(aFace))
+    {
+      TopExp_Explorer Explo2(aFace, TopAbs_EDGE);
+      for (; Explo2.More(); Explo2.Next())
+        myMapConstantEdges.Add(Explo2.Current());
+    }
+  }
+  ////////////////////////////////////////////////////
+
   if (myJoin == GeomAbs_Arc)          
     BuildOffsetByArc();
   else if (myJoin == GeomAbs_Intersection) 
@@ -1029,7 +1092,10 @@ void BRepOffset_MakeOffset::MakeOffsetFaces(BRepOffset_DataMapOfShapeOffset& the
   for (; aItLF.More(); aItLF.Next()) {
     const TopoDS_Face& aF = TopoDS::Face(aItLF.Value());
     aCurOffset = myFaceOffset.IsBound(aF) ? myFaceOffset(aF) : myOffset;
-    BRepOffset_Offset OF(aF, aCurOffset, ShapeTgt, OffsetOutside, myJoin);
+    TopoDS_Face InputOffsetFace;
+    if (myMapFaceOffsetFace.IsBound(aF))
+      InputOffsetFace = TopoDS::Face(myMapFaceOffsetFace(aF));
+    BRepOffset_Offset OF(aF, aCurOffset, InputOffsetFace, ShapeTgt, OffsetOutside, myJoin);
     TopTools_ListOfShape Let;
     myAnalyse.Edges(aF,BRepOffset_Tangent,Let);
     TopTools_ListIteratorOfListOfShape itl(Let);    
@@ -1103,7 +1169,7 @@ void BRepOffset_MakeOffset::BuildOffsetByInter()
 
   BRepOffset_Inter3d Inter3 (AsDes,Side,myTol);
   // Intersection between parallel faces
-  Inter3.ConnexIntByInt(myShape,MapSF,myAnalyse,MES,Build,Failed,myIsPlanar);
+  Inter3.ConnexIntByInt(myShape,MapSF,myMapModifyingFaces,myAnalyse,MES,Build,Failed,myIsPlanar);
   // Intersection with caps.
   Inter3.ContextIntByInt(myFaces,ExtentContext,MapSF,myAnalyse,MES,Build,Failed,myIsPlanar);
 
@@ -3549,6 +3615,9 @@ Standard_Boolean BRepOffset_MakeOffset::CheckInputData()
       }
     }
 
+    if (!myMapFaceOffsetFace.IsEmpty())
+      isFound = Standard_True;
+
     if (!isFound)
     {
       // No face with non-null offset found.
@@ -3817,7 +3886,8 @@ void BRepOffset_MakeOffset::IntersectEdges(const TopoDS_Shape& theShape,
     const TopoDS_Face& aF = TopoDS::Face(aExp.Current());
     aTolF = BRep_Tool::Tolerance(aF);
     BRepOffset_Inter2d::ConnexIntByInt
-      (aF, theMapSF(aF), theMES, theBuild, theAsDes2d, myOffset, aTolF, aMFV, aDMVV);
+      (aF, theMapSF(aF), theMES, theBuild, myMapConstantEdges, theAsDes2d,
+       myOffset, aTolF, aMFV, aDMVV);
   }
   // intersect edges created from vertices
   Standard_Integer i, aNbF = aMFV.Extent();
@@ -3825,7 +3895,8 @@ void BRepOffset_MakeOffset::IntersectEdges(const TopoDS_Shape& theShape,
     const TopoDS_Face& aF = TopoDS::Face(aMFV(i));
     aTolF = BRep_Tool::Tolerance(aF);
     BRepOffset_Inter2d::ConnexIntByIntInVert
-      (aF, theMapSF(aF), theMES, theBuild, theAsDes, theAsDes2d, aTolF, aDMVV);
+      (aF, theMapSF(aF), theMES, theBuild, myMapConstantEdges, theAsDes, theAsDes2d,
+       aTolF, aDMVV);
   }
   //
   // fuse vertices on edges
index 1fca4d4a6234b79f0e353aa795ee67ce019ffd9b..2add85029893bf5aa70af1569da077efda3a138c 100644 (file)
@@ -82,6 +82,9 @@ public:
   //! set the offset <Off> on the Face <F>
   Standard_EXPORT void SetOffsetOnFace (const TopoDS_Face& F, const Standard_Real Off);
   
+  //! Sets the offset face for the face in the shape.
+  Standard_EXPORT void SetOffsetFace (const TopoDS_Face& F, const TopoDS_Face& OF);
+  
   Standard_EXPORT void MakeOffsetShape();
   
   Standard_EXPORT void MakeThickSolid();
@@ -218,6 +221,9 @@ private:
   Standard_Boolean myIsPlanar;
   TopoDS_Shape myBadShape;
 
+  TopTools_DataMapOfShapeShape myMapFaceOffsetFace; // map of the face - extended offset face
+  TopTools_MapOfShape myMapModifyingFaces;
+  TopTools_MapOfShape myMapConstantEdges;
 };
 
 #endif // _BRepOffset_MakeOffset_HeaderFile
index 221226c980d3078f9b783d1edb61ec17a571cc4d..fc90f0caef1674193432a58113e955b93348003f 100644 (file)
@@ -4628,9 +4628,12 @@ void IntersectFaces(const TopoDS_Shape& theFInv,
 {
   // intersect faces
   TopAbs_State aSide = TopAbs_OUT;
-  TopTools_ListOfShape aLInt1, aLInt2;
+  TopTools_ListOfShape aLInt1, aLInt2, aList;
   TopoDS_Edge aNullEdge;
-  BRepOffset_Tool::Inter3D(TopoDS::Face(theFi), TopoDS::Face(theFj), aLInt1, aLInt2, aSide, aNullEdge);
+  BRepOffset_Tool::Inter3D(TopoDS::Face(theFi), TopoDS::Face(theFj),
+                           TopoDS::Face(theFi), TopoDS::Face(theFj),
+                           aLInt1, aLInt2, aList,
+                           aSide, aNullEdge);
   //
   if (aLInt1.IsEmpty()) {
     return;
index d6325b4c35032df71b9a25b7fba48d8674938cee..388dfbd437dd137da7ab05151e5865cf1fef105f 100644 (file)
@@ -82,6 +82,7 @@
 #include <TopTools_ListIteratorOfListOfShape.hxx>
 #include <TopTools_MapOfShape.hxx>
 #include <TopTools_SequenceOfShape.hxx>
+//#include <BRepBuilderAPI_Copy.hxx>
 
 #ifdef OCCT_DEBUG
 static Standard_Boolean Affich = Standard_False;
@@ -379,6 +380,8 @@ static void ComputeCurve3d(TopoDS_Edge           Edge,
 
 BRepOffset_Offset::BRepOffset_Offset()
 {
+  myOffset = 0.;
+  myIsInputOffsetFace = Standard_False;
 }
 
 
@@ -404,11 +407,12 @@ BRepOffset_Offset::BRepOffset_Offset(const TopoDS_Face&  Face,
 BRepOffset_Offset::BRepOffset_Offset
 (const TopoDS_Face&                  Face,
  const Standard_Real                 Offset,
+ const TopoDS_Face&                  InputOffsetFace,
  const TopTools_DataMapOfShapeShape& Created,
  const Standard_Boolean              OffsetOutside,
  const GeomAbs_JoinType              JoinType)
 {
-  Init(Face,Offset,Created,OffsetOutside,JoinType);
+  Init(Face,Offset,InputOffsetFace,Created,OffsetOutside,JoinType);
 }
 
 
@@ -476,7 +480,8 @@ void BRepOffset_Offset::Init(const TopoDS_Face&  Face,
                             const GeomAbs_JoinType JoinType)
 {
   TopTools_DataMapOfShapeShape Empty;
-  Init(Face,Offset,Empty,OffsetOutside,JoinType);
+  TopoDS_Face NullOffsetFace;
+  Init(Face,Offset,NullOffsetFace,Empty,OffsetOutside,JoinType);
 }
 
 
@@ -487,11 +492,31 @@ void BRepOffset_Offset::Init(const TopoDS_Face&  Face,
 
 void BRepOffset_Offset::Init(const TopoDS_Face&                  Face,
                             const Standard_Real                 Offset,
+                             const TopoDS_Face&                  InputOffsetFace,
                             const TopTools_DataMapOfShapeShape& Created,
                             const Standard_Boolean              OffsetOutside,
                             const GeomAbs_JoinType              JoinType)
 {
   myShape   = Face;
+  myOffset  = Offset;
+  myIsInputOffsetFace = Standard_False;
+
+  if (!InputOffsetFace.IsNull())
+  {
+    myFace = InputOffsetFace;
+    myIsInputOffsetFace = Standard_True;
+    myStatus = BRepOffset_Good;
+    return;
+  }
+  
+  if (Abs(Offset) <= Precision::Confusion())
+  {
+    //myFace = TopoDS::Face(BRepBuilderAPI_Copy(myShape));
+    myFace = Face;
+    myStatus = BRepOffset_Good;
+    return;
+  }
+  
   Standard_Real myOffset = Offset;
   if ( Face.Orientation() == TopAbs_REVERSED) 
     myOffset *= -1.;
@@ -1676,3 +1701,23 @@ BRepOffset_Status BRepOffset_Offset::Status() const
 {
   return myStatus;
 }
+
+//=======================================================================
+//function : Offset
+//purpose  : 
+//=======================================================================
+
+Standard_Real BRepOffset_Offset::Offset() const 
+{
+  return myOffset;
+}
+
+//=======================================================================
+//function : IsInputOffsetFace
+//purpose  : 
+//=======================================================================
+
+Standard_Boolean BRepOffset_Offset::IsInputOffsetFace() const 
+{
+  return myIsInputOffsetFace;
+}
index 8e25c559a873ce53d2ea07b7703a8bc6314249ef..5acac94d9a622769d74d9aeb9160fabc67b48a42 100644 (file)
@@ -49,7 +49,10 @@ public:
   
   Standard_EXPORT BRepOffset_Offset();
   
-  Standard_EXPORT BRepOffset_Offset(const TopoDS_Face& Face, const Standard_Real Offset, const Standard_Boolean OffsetOutside = Standard_True, const GeomAbs_JoinType JoinType = GeomAbs_Arc);
+  Standard_EXPORT BRepOffset_Offset(const TopoDS_Face& Face,
+                                    const Standard_Real Offset,
+                                    const Standard_Boolean OffsetOutside = Standard_True,
+                                    const GeomAbs_JoinType JoinType = GeomAbs_Arc);
   
   //! This method will be  called when you want to share
   //! the  edges  soon generated  from  an other  face.
@@ -63,27 +66,73 @@ public:
   //! E' = the image of E in the offseting  of
   //! another  face  sharing E  with a
   //! continuity at least G1
-  Standard_EXPORT BRepOffset_Offset(const TopoDS_Face& Face, const Standard_Real Offset, const TopTools_DataMapOfShapeShape& Created, const Standard_Boolean OffsetOutside = Standard_True, const GeomAbs_JoinType JoinType = GeomAbs_Arc);
-  
-  Standard_EXPORT BRepOffset_Offset(const TopoDS_Edge& Path, const TopoDS_Edge& Edge1, const TopoDS_Edge& Edge2, const Standard_Real Offset, const Standard_Boolean Polynomial = Standard_False, const Standard_Real Tol = 1.0e-4, const GeomAbs_Shape Conti = GeomAbs_C1);
-  
-  Standard_EXPORT BRepOffset_Offset(const TopoDS_Edge& Path, const TopoDS_Edge& Edge1, const TopoDS_Edge& Edge2, const Standard_Real Offset, const TopoDS_Edge& FirstEdge, const TopoDS_Edge& LastEdge, const Standard_Boolean Polynomial = Standard_False, const Standard_Real Tol = 1.0e-4, const GeomAbs_Shape Conti = GeomAbs_C1);
+  Standard_EXPORT BRepOffset_Offset(const TopoDS_Face& Face,
+                                    const Standard_Real Offset,
+                                    const TopoDS_Face& InputOffsetFace,
+                                    const TopTools_DataMapOfShapeShape& Created,
+                                    const Standard_Boolean OffsetOutside = Standard_True,
+                                    const GeomAbs_JoinType JoinType = GeomAbs_Arc);
+  
+  Standard_EXPORT BRepOffset_Offset(const TopoDS_Edge& Path,
+                                    const TopoDS_Edge& Edge1,
+                                    const TopoDS_Edge& Edge2,
+                                    const Standard_Real Offset,
+                                    const Standard_Boolean Polynomial = Standard_False,
+                                    const Standard_Real Tol = 1.0e-4,
+                                    const GeomAbs_Shape Conti = GeomAbs_C1);
+  
+  Standard_EXPORT BRepOffset_Offset(const TopoDS_Edge& Path,
+                                    const TopoDS_Edge& Edge1,
+                                    const TopoDS_Edge& Edge2,
+                                    const Standard_Real Offset,
+                                    const TopoDS_Edge& FirstEdge,
+                                    const TopoDS_Edge& LastEdge,
+                                    const Standard_Boolean Polynomial = Standard_False,
+                                    const Standard_Real Tol = 1.0e-4,
+                                    const GeomAbs_Shape Conti = GeomAbs_C1);
   
   //! Tol and Conti are only used if Polynomial is True
   //! (Used to perfrom the approximation)
   Standard_EXPORT BRepOffset_Offset(const TopoDS_Vertex& Vertex, const TopTools_ListOfShape& LEdge, const Standard_Real Offset, const Standard_Boolean Polynomial = Standard_False, const Standard_Real Tol = 1.0e-4, const GeomAbs_Shape Conti = GeomAbs_C1);
   
-  Standard_EXPORT void Init (const TopoDS_Face& Face, const Standard_Real Offset, const Standard_Boolean OffsetOutside = Standard_True, const GeomAbs_JoinType JoinType = GeomAbs_Arc);
-  
-  Standard_EXPORT void Init (const TopoDS_Face& Face, const Standard_Real Offset, const TopTools_DataMapOfShapeShape& Created, const Standard_Boolean OffsetOutside = Standard_True, const GeomAbs_JoinType JoinType = GeomAbs_Arc);
-  
-  Standard_EXPORT void Init (const TopoDS_Edge& Path, const TopoDS_Edge& Edge1, const TopoDS_Edge& Edge2, const Standard_Real Offset, const Standard_Boolean Polynomial = Standard_False, const Standard_Real Tol = 1.0e-4, const GeomAbs_Shape Conti = GeomAbs_C1);
-  
-  Standard_EXPORT void Init (const TopoDS_Edge& Path, const TopoDS_Edge& Edge1, const TopoDS_Edge& Edge2, const Standard_Real Offset, const TopoDS_Edge& FirstEdge, const TopoDS_Edge& LastEdge, const Standard_Boolean Polynomial = Standard_False, const Standard_Real Tol = 1.0e-4, const GeomAbs_Shape Conti = GeomAbs_C1);
+  Standard_EXPORT void Init (const TopoDS_Face& Face,
+                             const Standard_Real Offset,
+                             const Standard_Boolean OffsetOutside = Standard_True,
+                             const GeomAbs_JoinType JoinType = GeomAbs_Arc);
+  
+  Standard_EXPORT void Init (const TopoDS_Face& Face,
+                             const Standard_Real Offset,
+                             const TopoDS_Face& InputOffsetFace,
+                             const TopTools_DataMapOfShapeShape& Created,
+                             const Standard_Boolean OffsetOutside = Standard_True,
+                             const GeomAbs_JoinType JoinType = GeomAbs_Arc);
+  
+  Standard_EXPORT void Init (const TopoDS_Edge& Path,
+                             const TopoDS_Edge& Edge1,
+                             const TopoDS_Edge& Edge2,
+                             const Standard_Real Offset,
+                             const Standard_Boolean Polynomial = Standard_False,
+                             const Standard_Real Tol = 1.0e-4,
+                             const GeomAbs_Shape Conti = GeomAbs_C1);
+  
+  Standard_EXPORT void Init (const TopoDS_Edge& Path,
+                             const TopoDS_Edge& Edge1,
+                             const TopoDS_Edge& Edge2,
+                             const Standard_Real Offset,
+                             const TopoDS_Edge& FirstEdge,
+                             const TopoDS_Edge& LastEdge,
+                             const Standard_Boolean Polynomial = Standard_False,
+                             const Standard_Real Tol = 1.0e-4,
+                             const GeomAbs_Shape Conti = GeomAbs_C1);
   
   //! Tol and Conti are only used if Polynomial is True
   //! (Used to perfrom the approximation)
-  Standard_EXPORT void Init (const TopoDS_Vertex& Vertex, const TopTools_ListOfShape& LEdge, const Standard_Real Offset, const Standard_Boolean Polynomial = Standard_False, const Standard_Real Tol = 1.0e-4, const GeomAbs_Shape Conti = GeomAbs_C1);
+  Standard_EXPORT void Init (const TopoDS_Vertex& Vertex,
+                             const TopTools_ListOfShape& LEdge,
+                             const Standard_Real Offset,
+                             const Standard_Boolean Polynomial = Standard_False,
+                             const Standard_Real Tol = 1.0e-4,
+                             const GeomAbs_Shape Conti = GeomAbs_C1);
   
   //! Only used in Rolling Ball. Pipe on Free Boundary
   Standard_EXPORT void Init (const TopoDS_Edge& Edge, const Standard_Real Offset);
@@ -96,7 +145,9 @@ public:
   
   Standard_EXPORT BRepOffset_Status Status() const;
 
+  Standard_EXPORT Standard_Boolean IsInputOffsetFace() const;
 
+  Standard_EXPORT Standard_Real Offset() const;
 
 
 protected:
@@ -112,8 +163,8 @@ private:
   TopoDS_Shape myShape;
   BRepOffset_Status myStatus;
   TopoDS_Face myFace;
-  TopTools_DataMapOfShapeShape myMap;
-
+  Standard_Real myOffset;
+  Standard_Boolean myIsInputOffsetFace;
 
 };
 
index 96e5a1ab2148f076880ca88c930486ed1de9d750..80000131764b1ae16f8499e64e64ff8a187bb804 100644 (file)
@@ -1579,11 +1579,16 @@ static TopoDS_Edge AssembleEdge(const BOPDS_PDS& pDS,
 
 void BRepOffset_Tool::Inter3D(const TopoDS_Face& F1,
                              const TopoDS_Face& F2,
+                              const TopoDS_Face& ProF1,
+                              const TopoDS_Face& ProF2,
                              TopTools_ListOfShape& L1,
                              TopTools_ListOfShape& L2,
-                             const TopAbs_State    Side,
+                             const TopTools_ListOfShape& ListOnFirst,
+                             const TopAbs_State     Side,
                              const TopoDS_Edge&     RefEdge,
-                             const Standard_Boolean IsRefEdgeDefined)
+                             const Standard_Boolean IsRefEdgeDefined,
+                              const Standard_Boolean F1remains,
+                              const Standard_Boolean F2remains)
 {
 #ifdef DRAW
   if (AffichInter) {
@@ -1595,6 +1600,29 @@ void BRepOffset_Tool::Inter3D(const TopoDS_Face& F1,
   }
 #endif
 
+  BRep_Builder BB;
+  if (F1remains || F2remains)
+  {
+    TopoDS_Face ProFace = (F1remains)? ProF2 : ProF1;
+    TopoDS_Face NewFace = (F1remains)? F2 : F1;
+    TopTools_ListIteratorOfListOfShape itl(ListOnFirst);
+    for (; itl.More(); itl.Next())
+    {
+      TopoDS_Edge anEdge = TopoDS::Edge(itl.Value());
+      Standard_Real fpar, lpar;
+      Handle(Geom2d_Curve) aPCurve = BRep_Tool::CurveOnSurface(anEdge,ProFace,fpar,lpar);
+      Handle(Geom2d_Curve) NullPCurve;
+      BB.UpdateEdge(anEdge, NullPCurve, ProFace, 0.);
+      BB.UpdateEdge(anEdge, aPCurve, NewFace, 0.);
+      L1.Append(anEdge);
+      //L2.Append(anEdge.Reversed());
+      if (F1.Orientation() == F2.Orientation())
+        anEdge.Reverse();
+      L2.Append(anEdge);
+    }
+    return;
+  }
+
   // Check if the faces are planar and not trimmed - in this case
   // the IntTools_FaceFace intersection algorithm will be used directly.
   BRepAdaptor_Surface aBAS1(F1, Standard_False), aBAS2(F2, Standard_False);
@@ -3604,7 +3632,8 @@ void BRepOffset_Tool::ExtentFace (const TopoDS_Face&            F,
       if (ConstShapes.IsBound(E)) ToBuild.UnBind(E);
       if (ToBuild.IsBound(E)) {
         EnLargeFace(TopoDS::Face(ToBuild(E)),StopFace,Standard_False);
-        BRepOffset_Tool::Inter3D (EF,StopFace,LInt1,LInt2,Side,E,Standard_True);
+        TopTools_ListOfShape aList;
+        BRepOffset_Tool::Inter3D (EF,StopFace,EF,StopFace,LInt1,LInt2,aList,Side,E,Standard_True);
         // No intersection, it may happen for example for a chosen (non-offseted) planar face and 
         // its neighbour offseted cylindrical face, if the offset is directed so that 
         // the radius of the cylinder becomes smaller.
@@ -4148,4 +4177,4 @@ void PerformPlanes(const TopoDS_Face& theFace1,
 Standard_Boolean IsInf(const Standard_Real theVal)
 {
   return (theVal > TheInfini*0.9);
-}
\ No newline at end of file
+}
index 25ad516b1bbe29b07c1ff760dbffe8b3b6e004e6..76057fa18e12d72fdb3e942fceb09e6e8c6c0fb2 100644 (file)
@@ -83,7 +83,18 @@ public:
   //! edges solution   are  stored in <LInt1>  with  the
   //! orientation on <F1>, the sames edges are stored in
   //! <Lint2> with the orientation on <F2>.
-  Standard_EXPORT static void Inter3D (const TopoDS_Face& F1, const TopoDS_Face& F2, TopTools_ListOfShape& LInt1, TopTools_ListOfShape& LInt2, const TopAbs_State Side, const TopoDS_Edge& RefEdge, const Standard_Boolean IsRefEdgeDefined = Standard_False);
+  Standard_EXPORT static void Inter3D (const TopoDS_Face& F1,
+                                       const TopoDS_Face& F2,
+                                       const TopoDS_Face& ProF1,
+                                       const TopoDS_Face& ProF2,
+                                       TopTools_ListOfShape& LInt1,
+                                       TopTools_ListOfShape& LInt2,
+                                       const TopTools_ListOfShape& ListOnFirst,
+                                       const TopAbs_State Side,
+                                       const TopoDS_Edge& RefEdge,
+                                       const Standard_Boolean IsRefEdgeDefined = Standard_False,
+                                       const Standard_Boolean F1remains = Standard_False,
+                                       const Standard_Boolean F2remains = Standard_False);
   
   //! Find if the edges <Edges> of the face <F2> are on
   //! the face <F1>.
index 7f5f4d17554b92e8349467dcaa14c137076959f7..abb223cf1a2cc8c074a063e2737304bd4447e555 100644 (file)
@@ -1106,6 +1106,27 @@ Standard_Integer offsetonface(Draw_Interpretor&, Standard_Integer n, const char*
   return 0;
 }
 
+//=======================================================================
+//function : addoffsetface
+//purpose  : 
+//=======================================================================
+static Standard_Integer addoffsetface(Draw_Interpretor&, Standard_Integer n, const char** a)
+{
+  if ( n < 3) return 1;
+
+  for (Standard_Integer i = 1 ; i < n; i+=2) {
+    TopoDS_Shape  SF  = DBRep::Get(a[i],TopAbs_FACE);
+    if (!SF.IsNull()) {
+      TopoDS_Shape  OF  = DBRep::Get(a[i+1],TopAbs_FACE);
+      if (!OF.IsNull()) {
+        TheOffset.SetOffsetFace(TopoDS::Face(SF), TopoDS::Face(OF));
+      }
+    }
+  }
+  
+  return 0;
+}
+
 //=======================================================================
 //function : offsetperform
 //purpose  : 
@@ -2374,6 +2395,10 @@ void BRepTest::FeatureCommands (Draw_Interpretor& theCommands)
                  "offsetonface face1 offset1 face2 offset2 ...",
                  __FILE__,offsetonface,g);
 
+  theCommands.Add("addoffsetface",
+                 "addoffsetface face1 offset_face1 face2 offset_face2 ...",
+                 __FILE__,addoffsetface,g);
+
   theCommands.Add("offsetperform",
                  "offsetperform result",
                  __FILE__,offsetperform,g);
index bc521096ff0afd1cb1838146fa792a020d6f2dc8..0f28ae92c4394bc0c5ca9a5fd84ab63739d6ee88 100644 (file)
@@ -1554,12 +1554,13 @@ void BiTgte_Blend::ComputeCenters()
 
        if (AS.ShapeType() == TopAbs_FACE) {
          const TopoDS_Face& F = TopoDS::Face(myFaces(i));
+          TopoDS_Face NullFace;
          if ( TouchedByCork.Contains(F)) {
            BRepOffset_Tool::EnLargeFace(F,BigF,Standard_True);
-           OF1.Init(BigF,myRadius,EdgeTgt);
+           OF1.Init(BigF,myRadius,NullFace,EdgeTgt);
          }
          else {
-           OF1.Init(F,myRadius,EdgeTgt);
+           OF1.Init(F,myRadius,NullFace,EdgeTgt);
          }
        }
        else { // So this is a Free Border edge on which the ball rolls.