]> OCCT Git - occt-copy.git/commitdiff
Some modifications according to remarks
authorifv <ifv@opencascade.com>
Wed, 25 Dec 2019 09:47:09 +0000 (12:47 +0300)
committerifv <ifv@opencascade.com>
Mon, 20 Jan 2020 14:42:03 +0000 (17:42 +0300)
src/BRepBuilderAPI/BRepBuilderAPI_Sewing.cxx
src/BRepLib/BRepLib.hxx
src/BRepLib/BRepLib_1.cxx
src/BRepTest/BRepTest_BasicCommands.cxx

index 07639cec0b1d48c58072a77ab45879c39da0a104..507e6a4fea212e9db995405a4f6b1c465a75f1a2 100644 (file)
@@ -622,6 +622,7 @@ TopoDS_Edge BRepBuilderAPI_Sewing::SameParameterEdge(const TopoDS_Edge& edgeFirs
       whichSec = 1;
     }
   }
+  //
 
   Standard_Real first, last;
   BRep_Tool::Range(edge1, first, last);
@@ -957,8 +958,20 @@ TopoDS_Edge BRepBuilderAPI_Sewing::SameParameterEdge(const TopoDS_Edge& edgeFirs
         static_cast<BRep_TVertex*>(aV1edge.TShape().get())->Tolerance(aTolV1);
         static_cast<BRep_TVertex*>(aV2edge.TShape().get())->Tolerance(aTolV2);
 
-        BRepLib::SetPCurve(edge, c2d2edge, fac2, myTolerance,
-                                  aTolReached_3, aProjCurve);
+        Standard_Real aLimTol = myTolerance;
+        aLimTol = Max(aLimTol, BRep_Tool::Tolerance(edgeFirst));
+        aLimTol = Max(aLimTol, BRep_Tool::Tolerance(edgeLast));
+
+        if (whichSec == 1) itf2.Initialize(listFacesLast);
+        else               itf2.Initialize(listFacesFirst);
+        for (; itf2.More(); itf2.Next()) {
+          Handle(Geom2d_Curve) c2d2, c2d21;
+          Standard_Real firstOld, lastOld;
+          fac2 = TopoDS::Face(itf2.Value());
+          c2d2 = BRep_Tool::CurveOnSurface(edge2, fac2, firstOld, lastOld);
+          BRepLib::SetPCurve(edge, c2d2, fac2, aLimTol, Standard_True,
+            aTolReached_3, aProjCurve);
+        }
       }
       else
       {
index b8039cf702f5d21c643b536f09a9a83308fdbcb1..5fd14015909b6b656b0ec9ad30c8f445691b3f6b 100644 (file)
@@ -124,7 +124,7 @@ public:
   //! Algorithm sets in theTolReached tolerance of edge after setting pcurve.
   Standard_EXPORT static void SetPCurve(const TopoDS_Edge& theE, 
     const Handle(Geom2d_Curve)& theC, 
-    const TopoDS_Face& theF, const Standard_Real theMaxTol, 
+    const TopoDS_Face& theF, const Standard_Real theMaxTol, const Standard_Boolean theForceProj,
     Standard_Real& theTolReached, Handle(Geom2d_Curve)& theProjCurve);
 
   //! Sets the pcurve theC1, theC2 for the edge theE on the closed face theF.
@@ -137,7 +137,7 @@ public:
   //! Algorithm sets in theTolReached tolerance of edge after setting pcurve.
   Standard_EXPORT static void SetPCurve(const TopoDS_Edge& theE,
     const Handle(Geom2d_Curve)& theC1, const Handle(Geom2d_Curve)& theC2,
-    const TopoDS_Face& theF, const Standard_Real theMaxTol,
+    const TopoDS_Face& theF, const Standard_Real theMaxTol, const Standard_Boolean theForceProj,
     Standard_Real& theTolReached, 
     Handle(Geom2d_Curve)& theProjCurve1, 
     Handle(Geom2d_Curve)& theProjCurve2);
index af3ebc36caabf32ba7e179145c0a953ac9d03e1e..411dc3f522d453c5305ab92a27d538d7666fc2f5 100644 (file)
@@ -363,55 +363,71 @@ static void UpdateTol(const TopoDS_Edge& theE, const Standard_Real theTol)
 void BRepLib::SetPCurve(const TopoDS_Edge& theE,
                         const Handle(Geom2d_Curve)& theC,
                         const TopoDS_Face& theF, 
-                        const Standard_Real theMaxTol,
+                        const Standard_Real theMaxTol, const Standard_Boolean theForceProj,
                         Standard_Real& theTolReached, Handle(Geom2d_Curve)& theProjCurve)
 {
+  Standard_Real aNewTol = -1;
   Standard_Real aSMTol = Precision::PConfusion();
-  Standard_Real aTol = BRep_Tool::Tolerance(theE);
-  BRep_Builder aBB;
   Standard_Real fr, lr, f, l;
-  BRep_Tool::Range(theE, fr, lr);
-  Handle(Geom2d_Curve) aC = theC;
-  f = theC->FirstParameter();
-  l = theC->LastParameter();
-  if (!(Precision::IsInfinite(f) || Precision::IsInfinite(l)))
-  {
-    GeomLib::SameRange(aSMTol, theC, f, l, fr, lr, aC);
-  }
-  aBB.UpdateEdge(theE, aC, theF, aTol);
-  Handle(Geom_Surface) anS = BRep_Tool::Surface(theF);
   Handle(Geom_Curve) aC3D = BRep_Tool::Curve(theE, f, l);
-  Standard_Real aTol1 = CompTol(aC3D, aC, anS, fr, lr);
-  if (aTol1 <= aTol)
-  {
-    theTolReached = aTol1;
-    aBB.SameParameter(theE, Standard_True);
-    return;
-  }
-  else if (theMaxTol < aTol && aTol1 < 2.*aTol)
-  {
-    theTolReached = aTol1;
-    UpdateTol(theE, theTolReached);
-    return;
-  }
-  aBB.SameParameter(theE, Standard_False);
-  Standard_Real aNewTol = -1;
-  BRepLib::SameParameter(theE, aTol, aNewTol, Standard_True);
-  if (aNewTol > 0)
-  {
-    //Set old tolerance for edge, which has been changed by sameparameter
-    static_cast<BRep_TEdge*>(theE.TShape().get())->Tolerance(aTol);
-  }
-  if (aNewTol > 0.)
+  Handle(Geom_Surface) anS = BRep_Tool::Surface(theF);
+  Handle(Geom2d_Curve) aC = theC;
+  BRep_Builder aBB;
+  Standard_Real aTol1 = RealLast();
+  BRep_Tool::Range(theE, fr, lr);
+  if (!theForceProj)
   {
-    aC = BRep_Tool::CurveOnSurface(theE, theF, f, l);
-    aNewTol = CompTol(aC3D, aC, anS, fr, lr);
-    if (aNewTol < theMaxTol)
+    Standard_Real aTol = BRep_Tool::Tolerance(theE);
+    f = theC->FirstParameter();
+    l = theC->LastParameter();
+    if (!(Precision::IsInfinite(f) || Precision::IsInfinite(l)))
+    {
+      GeomLib::SameRange(aSMTol, theC, f, l, fr, lr, aC);
+    }
+    //
+    if (anS.IsNull())
+    {
+      return;
+    }
+    //
+    if (aC3D.IsNull())
+    {
+      return;
+    }
+    //
+    aBB.UpdateEdge(theE, aC, theF, aTol);
+    //
+    aTol1 = CompTol(aC3D, aC, anS, fr, lr);
+    if (aTol1 <= aTol)
     {
+      theTolReached = aTol1;
       aBB.SameParameter(theE, Standard_True);
-      theTolReached = aNewTol;
+      return;
+    }
+    else if (theMaxTol < aTol && aTol1 < 2.*aTol)
+    {
+      theTolReached = aTol1;
       UpdateTol(theE, theTolReached);
-      return ;
+      return;
+    }
+    aBB.SameParameter(theE, Standard_False);
+    BRepLib::SameParameter(theE, aTol, aNewTol, Standard_True);
+    if (aNewTol < 0)
+    {
+      //Set old tolerance for edge, which has been changed by sameparameter
+      static_cast<BRep_TEdge*>(theE.TShape().get())->Tolerance(aTol);
+    }
+    if (aNewTol > 0.)
+    {
+      aC = BRep_Tool::CurveOnSurface(theE, theF, f, l);
+      aNewTol = CompTol(aC3D, aC, anS, fr, lr);
+      if (aNewTol < theMaxTol)
+      {
+        aBB.SameParameter(theE, Standard_True);
+        theTolReached = aNewTol;
+        UpdateTol(theE, theTolReached);
+        return;
+      }
     }
   }
   //Projection
@@ -508,7 +524,7 @@ void BRepLib::SetPCurve(const TopoDS_Edge& theE,
 void BRepLib::SetPCurve(const TopoDS_Edge& theE,
   const Handle(Geom2d_Curve)& theC1, const Handle(Geom2d_Curve)& theC2,
   const TopoDS_Face& theF,
-  const Standard_Real theMaxTol,
+  const Standard_Real theMaxTol, const Standard_Boolean theForceProj,
   Standard_Real& theTolReached, 
   Handle(Geom2d_Curve)& theProjCurve1,
   Handle(Geom2d_Curve)& theProjCurve2)
@@ -521,49 +537,64 @@ void BRepLib::SetPCurve(const TopoDS_Edge& theE,
   Handle(Geom2d_Curve) aC1 = theC1, aC2 = theC2;
   f = theC1->FirstParameter();
   l = theC1->LastParameter();
-  if (!(Precision::IsInfinite(f) || Precision::IsInfinite(l)))
-  {
-    GeomLib::SameRange(aSMTol, theC1, f, l, fr, lr, aC1);
-  }
-  f = theC2->FirstParameter();
-  l = theC2->LastParameter();
-  if (!(Precision::IsInfinite(f) || Precision::IsInfinite(l)))
-  {
-    GeomLib::SameRange(aSMTol, theC2, f, l, fr, lr, aC2);
-  }
-  aBB.UpdateEdge(theE, aC1, aC2, theF, aTol);
+  Standard_Real aTol1 = RealLast();
+  Standard_Real aNewTol = -1.;
   Handle(Geom_Surface) anS = BRep_Tool::Surface(theF);
   Handle(Geom_Curve) aC3D = BRep_Tool::Curve(theE, f, l);
-  Standard_Real aTol1 = CompTol(aC3D, aC1, anS, fr, lr);
-  aTol1 = Max(aTol1, CompTol(aC3D, aC2, anS, fr, lr));
-  if (aTol1 <= aTol)
-  {
-    theTolReached = aTol1;
-    aBB.SameParameter(theE, Standard_True);
-    return;
-  }
-  aBB.SameParameter(theE, Standard_False);
-  Standard_Real aNewTol = -1;
-  BRepLib::SameParameter(theE, aTol, aNewTol, Standard_False);
-  if (aNewTol > 0)
+  if (!theForceProj)
   {
-    //Set old tolerance for edge, which has been changed by sameparameter
-    static_cast<BRep_TEdge*>(theE.TShape().get())->Tolerance(aTol);
-  }
-  if (aNewTol > 0. && aNewTol < theMaxTol)
-  {
-    TopoDS_Vertex aV1, aV2;
-    TopExp::Vertices(theE, aV1, aV2);
-    if (!aV1.IsNull())
+    if (!(Precision::IsInfinite(f) || Precision::IsInfinite(l)))
     {
-      aBB.UpdateVertex(aV1, aNewTol);
+      GeomLib::SameRange(aSMTol, theC1, f, l, fr, lr, aC1);
     }
-    if (!aV2.IsNull())
+    f = theC2->FirstParameter();
+    l = theC2->LastParameter();
+    if (!(Precision::IsInfinite(f) || Precision::IsInfinite(l)))
     {
-      aBB.UpdateVertex(aV2, aNewTol);
+      GeomLib::SameRange(aSMTol, theC2, f, l, fr, lr, aC2);
+    }
+    aBB.UpdateEdge(theE, aC1, aC2, theF, aTol);
+    //
+    if (anS.IsNull())
+    {
+      return;
+    }
+    //
+    if (aC3D.IsNull())
+    {
+      return;
+    }
+    //
+    aTol1 = CompTol(aC3D, aC1, anS, fr, lr);
+    aTol1 = Max(aTol1, CompTol(aC3D, aC2, anS, fr, lr));
+    if (aTol1 <= aTol)
+    {
+      theTolReached = aTol1;
+      aBB.SameParameter(theE, Standard_True);
+      return;
+    }
+    aBB.SameParameter(theE, Standard_False);
+    BRepLib::SameParameter(theE, aTol, aNewTol, Standard_False);
+    if (aNewTol > 0)
+    {
+      //Set old tolerance for edge, which has been changed by sameparameter
+      static_cast<BRep_TEdge*>(theE.TShape().get())->Tolerance(aTol);
+    }
+    if (aNewTol > 0. && aNewTol < theMaxTol)
+    {
+      TopoDS_Vertex aV1, aV2;
+      TopExp::Vertices(theE, aV1, aV2);
+      if (!aV1.IsNull())
+      {
+        aBB.UpdateVertex(aV1, aNewTol);
+      }
+      if (!aV2.IsNull())
+      {
+        aBB.UpdateVertex(aV2, aNewTol);
+      }
+      theTolReached = aNewTol;
+      return;
     }
-    theTolReached = aNewTol;
-    return;
   }
   //Projection
   Handle(BRepAdaptor_HSurface) aBAHS = new BRepAdaptor_HSurface(theF);
index f07940b722c71067ba54e573d7d67d96a4f94f94..2a038bb14a9796d94f0a6188d8f357119c4448c4 100644 (file)
@@ -125,11 +125,17 @@ static Standard_Integer setpcurve(Draw_Interpretor&, Standard_Integer n, const c
   if (n > 4) {
     tol = Draw::Atof(a[4]);
   }
+  Standard_Boolean ForceProj = Standard_False;
+  if (n > 5)
+  {
+    Standard_Integer i = Draw::Atoi(a[5]);
+    if (i > 0) ForceProj = Standard_True;
+  }
   //BRep_Builder BB;
   //BB.UpdateEdge(TopoDS::Edge(E), PC, TopoDS::Face(F), tol);
   Standard_Real tolreached;
   Handle(Geom2d_Curve) ProjC;
-  BRepLib::SetPCurve(TopoDS::Edge(E), PC, TopoDS::Face(F), tol,
+  BRepLib::SetPCurve(TopoDS::Edge(E), PC, TopoDS::Face(F), tol, ForceProj,
     tolreached, ProjC);
   DBRep::Set(a[1], E);
   return 0;
@@ -1427,7 +1433,7 @@ void  BRepTest::BasicCommands(Draw_Interpretor& theCommands)
                  __FILE__,
                  addpcurve,g);
   theCommands.Add("setpcurve",
-                  "addpcurve edge 2dcurve face [tol (default 1.e-4)]",
+                  "setpcurve edge 2dcurve face [tol (default 1.e-4)] [proj]",
                   __FILE__,
                   setpcurve, g);