]> OCCT Git - occt-copy.git/commitdiff
0030880: Bug in BRepExtrema_ExtCF
authoremv <emv@opencascade.com>
Thu, 22 Aug 2019 10:54:53 +0000 (13:54 +0300)
committeremv <emv@opencascade.com>
Mon, 2 Sep 2019 05:14:56 +0000 (08:14 +0300)
Correct tolerance management during intersection of the classification ray with edges of the face.

src/BRepClass/BRepClass_Intersector.cxx
src/QABugs/QABugs_20.cxx
tests/bugs/modalg_7/bug30880_1 [new file with mode: 0644]
tests/bugs/modalg_7/bug30880_2 [new file with mode: 0644]

index a141f56d054b0e563f22f26ec7e0228f1d04b092..5c606e9f4c550fd0915ee228e111fd1a3da15f31 100644 (file)
@@ -130,18 +130,15 @@ void  BRepClass_Intersector::Perform(const gp_Lin2d& L,
   gp_Pnt2d pdeb,pfin;
   C.D0(deb,pdeb);
   C.D0(fin,pfin);
-  Standard_Real toldeb = 1.e-5, tolfin = 1.e-5;
 
   IntRes2d_Domain DL;
-  //
-  if(P!=RealLast()) {
-    DL.SetValues(L.Location(),0.,Precision::PConfusion(),ElCLib::Value(P,L),P,Precision::PConfusion());
-  }
-  else { 
-    DL.SetValues(L.Location(),0.,Precision::PConfusion(),Standard_True);
-  }
+  if (P != RealLast())
+    DL.SetValues (L.Location(),         0., Precision::PConfusion(),
+                  ElCLib::Value (P, L), P,  Precision::PConfusion());
+  else
+    DL.SetValues (L.Location(), 0., Precision::PConfusion(), Standard_True);
 
-  IntRes2d_Domain DE(pdeb,deb,toldeb,pfin,fin,tolfin);
+  IntRes2d_Domain DE (pdeb, deb, Tol, pfin, fin, Tol);
   // temporary periodic domain
   if (C.Curve()->IsPeriodic()) {
     DE.SetEquivalentParameters(C.FirstParameter(),
index 996c7b8e1a62309ddfb84fe02f7d453289c8df4c..6539581ab3b3bd319cdfbd9ab2825658e9ea415e 100644 (file)
@@ -3239,6 +3239,76 @@ static Standard_Integer OCC30869 (Draw_Interpretor& theDI, Standard_Integer theA
   return 0;
 }
 
+#include <BRepExtrema_ExtCF.hxx>
+//=======================================================================
+//function : OCC30880
+//purpose  :
+//=======================================================================
+static Standard_Integer OCC30880 (Draw_Interpretor& theDI, Standard_Integer theArgc, const char** theArgv)
+{
+  if (theArgc != 3)
+  {
+    theDI.PrintHelp (theArgv[0]);
+    return 1;
+  }
+
+  TopoDS_Shape anEdge = DBRep::Get (theArgv[1]);
+  if (anEdge.IsNull() || anEdge.ShapeType() != TopAbs_EDGE)
+  {
+    theDI << theArgv[1] << " is not an edge.\n";
+    return 1;
+  }
+
+  TopoDS_Shape aFace = DBRep::Get (theArgv[2]);
+  if (aFace.IsNull() || aFace.ShapeType() != TopAbs_FACE)
+  {
+    theDI << theArgv[2] << " is not a face.\n";
+    return 1;
+  }
+
+  BRepExtrema_ExtCF anExtCF (TopoDS::Edge (anEdge),
+                             TopoDS::Face (aFace));
+  if (!anExtCF.IsDone())
+  {
+    theDI << "Not done\n";
+    return 0;
+  }
+
+  if (!anExtCF.NbExt())
+  {
+    theDI << "No solutions\n";
+    return 0;
+  }
+
+  if (anExtCF.IsParallel())
+  {
+    theDI << "Infinite number of solutions, distance - " << Sqrt (anExtCF.SquareDistance (1)) << "\n";
+    return 0;
+  }
+
+  Standard_Real aDistMin = RealLast();
+  Standard_Integer aSolMin = -1;
+  // Look for the minimal solution
+  for (int i = 1; i <= anExtCF.NbExt(); ++i)
+  {
+    Standard_Real aDist = anExtCF.SquareDistance (i);
+    if (aDist < aDistMin)
+    {
+      aDistMin = aDist;
+      aSolMin = i;
+    }
+  }
+
+  if (aSolMin < 0)
+  {
+    theDI << "Failed\n";
+    return 0;
+  }
+
+  theDI << "Minimal distance - " << Sqrt (aDistMin) << "\n";
+  return 0;
+}
+
 void QABugs::Commands_20(Draw_Interpretor& theCommands) {
   const char *group = "QABugs";
 
@@ -3296,5 +3366,9 @@ void QABugs::Commands_20(Draw_Interpretor& theCommands) {
                                "Usage: OCC30869 wire",
                    __FILE__, OCC30869, group);
 
+  theCommands.Add ("OCC30880", "Looks for extrema between edge and face.\n"
+                               "Usage: OCC30880 edge face",
+                   __FILE__, OCC30880, group);
+
   return;
 }
diff --git a/tests/bugs/modalg_7/bug30880_1 b/tests/bugs/modalg_7/bug30880_1
new file mode 100644 (file)
index 0000000..f0f8dbf
--- /dev/null
@@ -0,0 +1,11 @@
+puts "========"
+puts "0030880: Bug in BRepExtrema_ExtCF"
+puts "========"
+puts ""
+
+restore [locate_data_file bug30880_edge.brep] e
+restore [locate_data_file bug30880_face.brep] f
+
+if {![regexp "No solutions" [OCC30880 e f]]} {
+  puts "Error: Incorrect extrema solutions"
+}
diff --git a/tests/bugs/modalg_7/bug30880_2 b/tests/bugs/modalg_7/bug30880_2
new file mode 100644 (file)
index 0000000..49a67cb
--- /dev/null
@@ -0,0 +1,10 @@
+puts "========"
+puts "0030880: Bug in BRepExtrema_ExtCF"
+puts "========"
+puts ""
+
+restore [locate_data_file bug30880_face.brep] f
+point p2d -0.0034857302428251678 0.016350559703980902
+if {![regexp "OUT" [b2dclassify f p2d -tol 1.e-7]]} {
+  puts "Error: Incorrect classification of the point"
+}