]> OCCT Git - occt.git/commitdiff
0032807: Modeling Algorithms - Bad result of sweep operation when the UEdges has...
authormgerus <mgerus@opencascade.com>
Wed, 11 May 2022 13:08:55 +0000 (16:08 +0300)
committersmoskvin <smoskvin@opencascade.com>
Mon, 16 May 2022 18:08:21 +0000 (21:08 +0300)
Add choosing the intersect point taking into account the tangentCross when prev UEdge and next UEdge has more than one intersect points;
Add exact correction of edge tolerance (it fix problems with edge tolerance on Linux);
Add exact check of edge tolerance in testcase

src/Approx/Approx_SameParameter.cxx
src/Approx/Approx_SameParameter.hxx
src/BRepFill/BRepFill_Sweep.cxx
src/BRepFill/BRepFill_TrimShellCorner.cxx
src/BRepFill/BRepFill_TrimShellCorner.hxx
tests/bugs/modalg_7/bug29204
tests/bugs/modalg_7/bug29663
tests/evolved/voluved/HMC008
tests/pipe/bugs/bug32807 [new file with mode: 0644]

index a4e467e611082625b651f2d2bc2703476846f253..9bb7b22e24fbb21ceadd8856e2ec132995bb07fb 100644 (file)
@@ -526,6 +526,8 @@ void Approx_SameParameter::Build(const Standard_Real Tolerance)
     }
     myDone = Standard_True;
   }
+  
+  myCurveOnSurface = Handle(Adaptor3d_CurveOnSurface)::DownCast(aData.myCOnS.ShallowCopy());
 }
 
 //=======================================================================
index 617c2b257324637349bbeae1c121dc6bdb86d1c4..257a01933603e4acd45a25b7ac7895b3a5de96ac 100644 (file)
@@ -81,6 +81,21 @@ public:
     return myCurve2d;
   }
 
+  //! Returns the 3D curve that has the same parameter as
+  //! the 3D curve once evaluated on the surface up to the
+  //! specified tolerance.
+  Handle(Adaptor3d_Curve) Curve3d() const
+  {
+    return myC3d;
+  }
+
+  //! Returns the 3D curve on surface that has the same parameter as
+  //! the 3D curve up to the specified tolerance.
+  Handle(Adaptor3d_CurveOnSurface) CurveOnSurface() const
+  {
+    return myCurveOnSurface;
+  }
+
 private:
 
   //! Internal data structure to unify access to the most actively used data.
@@ -176,6 +191,7 @@ private:
   Handle(Adaptor2d_Curve2d) myHCurve2d;
   Handle(Adaptor3d_Curve) myC3d;
   Handle(Adaptor3d_Surface) mySurf;
+  Handle(Adaptor3d_CurveOnSurface) myCurveOnSurface;
 };
 
 #endif // _Approx_SameParameter_HeaderFile
index a74fdfc45286809f0076402757cc4125510f7cb7..1be188dd79316f8e55b2aacab4ffc60a17a676f0 100644 (file)
@@ -85,6 +85,7 @@
 #include <TopTools_HArray2OfShape.hxx>
 #include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
 #include <TopTools_ListOfShape.hxx>
+#include <GeomLib_CheckCurveOnSurface.hxx>
 
 #include <stdio.h>
 //#include <BRepFill_TrimCorner.hxx>
@@ -289,6 +290,34 @@ static Standard_Boolean CheckSameParameter
   return Standard_True;
 }
 
+//=======================================================================
+//function : CheckSameParameterExact
+//purpose  : Check a posteriori that sameparameter has worked correctly
+// with exact calculation method of edge tolerance 
+//=======================================================================
+static Standard_Boolean CheckSameParameterExact
+(const Handle(Adaptor3d_Curve)& C3d,
+  const Handle(Adaptor3d_CurveOnSurface)& curveOnSurface,
+  const Standard_Real             tol3d,
+  Standard_Real& tolreached)
+{
+  GeomLib_CheckCurveOnSurface aCheckCurveOnSurface(C3d);
+  aCheckCurveOnSurface.SetParallel(Standard_False);
+  aCheckCurveOnSurface.Perform(curveOnSurface);
+
+  tolreached = aCheckCurveOnSurface.MaxDistance();
+
+  if (tolreached > tol3d) {
+    return Standard_False;
+  }
+  else
+  {
+    tolreached = Max(tolreached, Precision::Confusion());
+    tolreached *= 1.05;
+  }
+  return Standard_True;
+}
+
 //=======================================================================
 //function : SameParameter
 //purpose  : Encapsulation of Sameparameter
@@ -340,8 +369,10 @@ static Standard_Boolean SameParameter(TopoDS_Edge&    E,
     return Standard_False;
   }
 
-  ResTol = sp.TolReached();
-  if(ResTol > tolreached ){
+  Handle(Adaptor3d_Curve) curve3d = sp.Curve3d();
+  Handle(Adaptor3d_CurveOnSurface) curveOnSurface = sp.CurveOnSurface();
+
+  if (!CheckSameParameterExact(curve3d, curveOnSurface, tol3d, ResTol) &&  ResTol > tolreached) {
 #ifdef OCCT_DEBUG
     std::cout<<"SameParameter : Tolerance not reached!"<<std::endl;
     std::cout<<"tol visee : "<<tol3d<<" tol obtained : "<<ResTol<<std::endl;
@@ -3253,7 +3284,7 @@ TopoDS_Shape BRepFill_Sweep::Tape(const Standard_Integer Index) const
 
   Tang = T1 + T2; //Average direction
   gp_Dir NormalOfBisPlane = Tang;
-
+  gp_Vec anIntersectPointCrossDirection = T1.Crossed(T2);
   if (isTangent) {
     Sortant -= Tang.Dot(Tang)*Tang;
   }
@@ -3300,7 +3331,7 @@ TopoDS_Shape BRepFill_Sweep::Tape(const Standard_Integer Index) const
     }
   }
 
-  BRepFill_TrimShellCorner aTrim(aFaces, Transition, AxeOfBisPlane);
+  BRepFill_TrimShellCorner aTrim(aFaces, Transition, AxeOfBisPlane, anIntersectPointCrossDirection);
   aTrim.AddBounds(Bounds);
   aTrim.AddUEdges(aUEdges);
   aTrim.AddVEdges(myVEdges, Index);
index 8b2a07fa347566914dd42faf68c69202f0901705..77efa8fbabe25c7b33c4bb6d8ae5c9a754b89fe5 100644 (file)
@@ -76,12 +76,14 @@ static Standard_Boolean FindCommonVertex(const TopoDS_Edge&   theFirstEdge,
 static Standard_Boolean FindCommonVertex(const BOPDS_PDS&         theDS,
                                          const Standard_Integer   theEIndex1,
                                          const Standard_Integer   theEIndex2,
+                                         const gp_Vec&            theCrossDirection,
                                          TopoDS_Vertex&           theCommonVertex,
                                          Standard_Real&           theParamOnE1,
                                          Standard_Real&           theParamOnE2);
 
 static Standard_Boolean SplitUEdges(const Handle(TopTools_HArray2OfShape)&     theUEdges, 
                                     const BOPDS_PDS&                           theDS,
+                                       const gp_Vec&                              theCrossDirection,
                                     TopTools_DataMapOfShapeListOfShape&        theHistMap);
 
 static void StoreVedgeInHistMap(const Handle(TopTools_HArray1OfShape)&     theVEdges,
@@ -194,9 +196,11 @@ static void UpdateSectionEdge(TopoDS_Edge&         theEdge,
 // ===========================================================================================
 BRepFill_TrimShellCorner::BRepFill_TrimShellCorner(const Handle(TopTools_HArray2OfShape)& theFaces,
                                                    const BRepFill_TransitionStyle         theTransition,
-                                                   const gp_Ax2&                          theAxeOfBisPlane) :
+                                                   const gp_Ax2&                          theAxeOfBisPlane,
+                                                   const gp_Vec&                          theIntPointCrossDir) :
   myTransition(theTransition),
   myAxeOfBisPlane(theAxeOfBisPlane),
+  myIntPointCrossDir(theIntPointCrossDir),
   myDone(Standard_False),
   myHasSection(Standard_False)
 {
@@ -309,7 +313,7 @@ void BRepFill_TrimShellCorner::Perform()
   BOPDS_VectorOfInterfFF& aFFs = theDS->InterfFF();
   Standard_Integer aNbFFs = aFFs.Length();
 
-  if(!SplitUEdges(myUEdges, theDS, myHistMap)) {
+  if(!SplitUEdges(myUEdges, theDS, myIntPointCrossDir, myHistMap)) {
     return;
   }
 
@@ -425,7 +429,7 @@ BRepFill_TrimShellCorner::MakeFacesNonSec(const Standard_Integer
   Standard_Real apar1 = 0., apar2 = 0.;
 
   Standard_Boolean bvertexfound = 
-    FindCommonVertex(theDS, anIndex1, anIndex2, aCommonVertex, apar1, apar2);
+    FindCommonVertex(theDS, anIndex1, anIndex2, myIntPointCrossDir, aCommonVertex, apar1, apar2);
   // search common vertex between bounds. end
 
   Handle(BRepTools_ReShape) aSubstitutor = new BRepTools_ReShape();
@@ -697,9 +701,9 @@ BRepFill_TrimShellCorner::MakeFacesSec(const Standard_Integer
 
   TopoDS_Vertex FirstVertex, LastVertex;
   Standard_Real ParamOnLeftE1, ParamOnLeftE2, ParamOnRightE1, ParamOnRightE2;
-  FindCommonVertex(theDS, IndexOfLeftE1, IndexOfLeftE2,
+  FindCommonVertex(theDS, IndexOfLeftE1, IndexOfLeftE2, myIntPointCrossDir,
                    FirstVertex, ParamOnLeftE1, ParamOnLeftE2);
-  FindCommonVertex(theDS, IndexOfRightE1, IndexOfRightE2,
+  FindCommonVertex(theDS, IndexOfRightE1, IndexOfRightE2, myIntPointCrossDir,
                    LastVertex, ParamOnRightE1, ParamOnRightE2);
 
   TopoDS_Shape SecWire;
@@ -1079,7 +1083,8 @@ Standard_Boolean BRepFill_TrimShellCorner::ChooseSection(const TopoDS_Shape& Com
 // purpose:
 // ------------------------------------------------------------------------------------------
 Standard_Boolean SplitUEdges(const Handle(TopTools_HArray2OfShape)&     theUEdges, 
-                             const BOPDS_PDS&                           theDS,
+                             const BOPDS_PDS&                           theDS, 
+                                const gp_Vec&                              theCrossDirection,
                              TopTools_DataMapOfShapeListOfShape&        theHistMap) {
 
   const BOPDS_VectorOfInterfVV& aVVs = theDS->InterfVV();
@@ -1105,7 +1110,7 @@ Standard_Boolean SplitUEdges(const Handle(TopTools_HArray2OfShape)&     theUEdge
     TopoDS_Vertex aCommonVertex;
     Standard_Real apar1 = 0., apar2 = 0.;
     Standard_Boolean bvertexfound = 
-      FindCommonVertex(theDS, anEIndex1, anEIndex2, aCommonVertex, apar1, apar2);
+      FindCommonVertex(theDS, anEIndex1, anEIndex2, theCrossDirection, aCommonVertex, apar1, apar2);
     //
     if(!bvertexfound) {
       TopoDS_Vertex V1 = TopExp::LastVertex(TopoDS::Edge(aE1));
@@ -1217,6 +1222,7 @@ void FindFreeVertices(const TopoDS_Shape&         theShape,
 Standard_Boolean FindCommonVertex(const BOPDS_PDS&         theDS,
                                   const Standard_Integer   theEIndex1,
                                   const Standard_Integer   theEIndex2,
+                                     const gp_Vec&            theCrossDirection,
                                   TopoDS_Vertex&           theCommonVertex,
                                   Standard_Real&           theParamOnE1,
                                   Standard_Real&           theParamOnE2) {
@@ -1227,6 +1233,10 @@ Standard_Boolean FindCommonVertex(const BOPDS_PDS&         theDS,
   TopoDS_Vertex aCommonVertex;
   Standard_Integer eeit = 0;
 
+  TopoDS_Edge theE1 = TopoDS::Edge(theDS->Shape(theEIndex1));
+  TopoDS_Edge theE2 = TopoDS::Edge(theDS->Shape(theEIndex2));
+  BRepAdaptor_Curve aBC1(theE1), aBC2(theE2);
+
   Standard_Integer aNbEEs;
   aNbEEs = aEEs.Length();
   for(eeit = 0; eeit < aNbEEs; ++eeit) {
@@ -1247,10 +1257,21 @@ Standard_Boolean FindCommonVertex(const BOPDS_PDS&         theDS,
           IntTools_Tools::VertexParameters(aCP, theParamOnE1, theParamOnE2);
         else
           IntTools_Tools::VertexParameters(aCP, theParamOnE2, theParamOnE1);
-       
-        //
-        bvertexfound = Standard_True;
-        break;
+
+        gp_Pnt aPt;
+        gp_Vec aDirOnE1, aDirOnE2;
+        gp_Dir aIntersectPointCrossDir;
+
+        // intersect point aDirOnE1.cross(aDirOnE2) should same direction with path theCrossDirection
+        aBC1.D1(theParamOnE1, aPt, aDirOnE1);
+        aBC2.D1(theParamOnE2, aPt, aDirOnE2);
+        aIntersectPointCrossDir = aDirOnE1.Crossed(aDirOnE2);
+
+        if (aIntersectPointCrossDir.Dot(theCrossDirection) > Precision::SquareConfusion()) 
+        {
+          bvertexfound = Standard_True;
+          break;
+        }
       }
     }
   }
index 283e546b913f93fb40f740f90f6b8e9400ba1cb0..f25e1171df12e59b3d30ca22606f16617c220142 100644 (file)
@@ -41,9 +41,12 @@ public:
   //! Constructor: takes faces to intersect,
   //! type of transition (it can be RightCorner or RoundCorner)
   //! and axis of bisector plane
+  //! theIntersectPointCrossDirection : prev path direction at the origin point of theAxeOfBisPlane
+  //! cross next path direction at the origin point of theAxeOfBisPlane. used when EE has more than one vertices
   Standard_EXPORT BRepFill_TrimShellCorner(const Handle(TopTools_HArray2OfShape)& theFaces,
                                            const BRepFill_TransitionStyle         theTransition,
-                                           const gp_Ax2&                          theAxeOfBisPlane);
+                                           const gp_Ax2&                          theAxeOfBisPlane,
+                                           const gp_Vec&                          theIntPointCrossDir);
 
   Standard_EXPORT void AddBounds (const Handle(TopTools_HArray2OfShape)& Bounds);
   
@@ -92,6 +95,7 @@ private:
 
   BRepFill_TransitionStyle myTransition;
   gp_Ax2 myAxeOfBisPlane;
+  gp_Vec myIntPointCrossDir;
   TopoDS_Shape myShape1;
   TopoDS_Shape myShape2;
   Handle(TopTools_HArray2OfShape) myBounds;
index 8ce39b7bdc7cbc97147bb308438f140a314fb82d..80d4fde2d08e019ca81b8aa5532d195d4c37c86d 100644 (file)
@@ -19,7 +19,7 @@ checknbshapes result -solid 1 -shell 1 -face 28 -wire 28 -edge 64 -vertex 36 -sh
 
 set tolres [checkmaxtol result]
 
-if { ${tolres} > 0.001} {
+if { ${tolres} > 0.003} {
    puts "Error: bad tolerance of result"
 }
 
index af381765e9e10256ebf1365f73bb8ccc3c4cfc55..eb1b2911afde31b085e4c025691f7e44788c2c21 100644 (file)
@@ -21,7 +21,7 @@ fixshape result rr
 checkshape result
 checkprops result -s 2.14316e+011
 
-checkmaxtol result -ref 0.049038750060552701
+checkmaxtol result -ref 0.046703571498366049
 
 checknbshapes result -shell 1 -face 201 -wire 201
 
index 63c57b51176bb57164b5a38bd6aad2d2e0d86ea8..ce56438bf11e68a96c78810eb7b1678761d14e2c 100644 (file)
@@ -212,7 +212,7 @@ if {[regexp "Faulties" [bopargcheck result]]} {
 # the dimensions of the shape "result" are about 1.0e+5.
 # So, this tolerance seems to be OK.
 
-checkmaxtol result -ref 1.7319951447770465
+checkmaxtol result -ref 1.6514213338573371
 
 smallview
 don result sw tw
diff --git a/tests/pipe/bugs/bug32807 b/tests/pipe/bugs/bug32807
new file mode 100644 (file)
index 0000000..a86c2e8
--- /dev/null
@@ -0,0 +1,17 @@
+puts "========"
+puts "bug32807: Sweep algorithm deal with EE more than one intersect points"
+puts "========"
+puts ""
+
+restore [locate_data_file bug32807_path.brep] p
+restore [locate_data_file bug32807_profile.brep] pr
+
+mksweep p
+setsweep -CF
+addsweep pr
+
+buildsweep result -C -S
+
+checkshape result -exact
+checknbshapes result -vertex 34 -edge 68 -wire 34 -face 34 -shell 1
+checkview -display result -2d -path ${imagedir}/${test_image}.png