]> OCCT Git - occt.git/commitdiff
0031395: Mesh - BRepMesh produces poor mesh on shape with hidden self-intersections
authoroan <oan@opencascade.com>
Wed, 23 Nov 2022 16:32:13 +0000 (19:32 +0300)
committeroan <oan@opencascade.com>
Tue, 27 Dec 2022 11:25:59 +0000 (14:25 +0300)
Take vertex tolerance into account to avoid excessive points leading to self-intersections in discrete model

src/BRepMesh/BRepMesh_CurveTessellator.cxx
tests/bugs/mesh/bug31395 [new file with mode: 0644]

index c8e942ec3a686f217139febcdfd93c40d0c5fa88..ac1784766771704532f2126f9fc7ddbed1f2f5a2 100644 (file)
@@ -226,7 +226,7 @@ Standard_Boolean BRepMesh_CurveTessellator::isInToleranceOfVertex (
   const TopoDS_Vertex& theVertex) const
 {
   const gp_Pnt        aPoint     = BRep_Tool::Pnt(theVertex);
-  const Standard_Real aTolerance = BRep_Tool::Tolerance(theVertex);
+  const Standard_Real aTolerance = BRep_Tool::Tolerance(theVertex) * 1.1;
 
   return (thePoint.SquareDistance (aPoint) < aTolerance * aTolerance);
 }
@@ -243,9 +243,9 @@ Standard_Boolean BRepMesh_CurveTessellator::Value (
   thePoint     = myDiscretTool.Value     (theIndex);
   theParameter = myDiscretTool.Parameter (theIndex);
 
-  /*if (!isInToleranceOfVertex(thePoint, myFirstVertex) &&
+  if (!isInToleranceOfVertex(thePoint, myFirstVertex) &&
       !isInToleranceOfVertex(thePoint, myLastVertex))
-  {*/
+  {
     if (!myCurve.IsCurveOnSurface())
     {
       return Standard_True;
@@ -281,9 +281,9 @@ Standard_Boolean BRepMesh_CurveTessellator::Value (
     aSurface->D0(aUV.X(), aUV.Y(), aPntOnSurf);
 
     return (thePoint.SquareDistance(aPntOnSurf) < myEdgeSqTol);
-  /*}
+  }
 
-  return Standard_False;*/
+  return Standard_False;
 }
 
 //=======================================================================
diff --git a/tests/bugs/mesh/bug31395 b/tests/bugs/mesh/bug31395
new file mode 100644 (file)
index 0000000..6c07dd6
--- /dev/null
@@ -0,0 +1,22 @@
+puts "========"
+puts "0031395: Mesh - BRepMesh produces poor mesh on shape with hidden self-intersections"
+puts "========"
+puts ""
+
+restore [locate_data_file log368.brep] result
+
+tclean result
+incmesh result 0.2
+
+vinit
+vsetdispmode 1
+vdefaults -autoTriang 0
+
+checkview -display result -3d -path ${imagedir}/${test_image}.png
+
+set log [tricheck result]
+if { [llength $log] != 0 } {
+  puts "Error : Invalid mesh"
+} else {
+  puts "Mesh is OK"
+}