0030780: [Regression to 7.3.0] BRepMesh fails triangulating one face of the shape
authoroan <oan@opencascade.com>
Mon, 24 Jun 2019 16:03:45 +0000 (19:03 +0300)
committerapn <apn@opencascade.com>
Tue, 25 Jun 2019 16:46:09 +0000 (19:46 +0300)
Added new parameter KeepSmallEdges to IMeshTools_Parameters allowing to compute min size for each edge locally, depending on the length of particular edge.
Parameter -smalledges now available for incmesh command.

src/BRepMesh/BRepMesh_CurveTessellator.cxx
src/IMeshTools/IMeshTools_Parameters.hxx
src/MeshTest/MeshTest.cxx
tests/bugs/mesh/bug30780 [new file with mode: 0644]

index d7e73f0..bb780d2 100644 (file)
@@ -26,6 +26,7 @@
 #include <Adaptor3d_HCurveOnSurface.hxx>
 #include <Adaptor2d_HCurve2d.hxx>
 #include <Standard_Failure.hxx>
+#include <GCPnts_AbscissaPoint.hxx>
 
 //=======================================================================
 //function : Constructor
@@ -79,21 +80,28 @@ void BRepMesh_CurveTessellator::init()
     aPreciseLinDef *= 0.5;
   }
 
-  aPreciseLinDef = Max(aPreciseLinDef, Precision::Confusion());
-  aPreciseAngDef = Max(aPreciseAngDef, Precision::Angular());
+  aPreciseLinDef = Max (aPreciseLinDef, Precision::Confusion());
+  aPreciseAngDef = Max (aPreciseAngDef, Precision::Angular());
+
+  Standard_Real aMinSize = myParameters.MinSize;
+  if (myParameters.AdjustMinSize)
+  {
+    aMinSize = Min (aMinSize, myParameters.RelMinSize() * GCPnts_AbscissaPoint::Length (
+      myCurve, myCurve.FirstParameter(), myCurve.LastParameter(), aPreciseLinDef));
+  }
 
   mySquareEdgeDef = aPreciseLinDef * aPreciseLinDef;
-  mySquareMinSize = Max(mySquareEdgeDef, myParameters.MinSize * myParameters.MinSize);
+  mySquareMinSize = Max (mySquareEdgeDef, aMinSize * aMinSize);
 
-  myEdgeSqTol  = BRep_Tool::Tolerance(myEdge);
+  myEdgeSqTol  = BRep_Tool::Tolerance (myEdge);
   myEdgeSqTol *= myEdgeSqTol;
 
   const Standard_Integer aMinPntNb = (myCurve.GetType() == GeomAbs_Circle) ? 4 : 2; //OCC287
 
-  myDiscretTool.Initialize(myCurve,
-                           myCurve.FirstParameter(), myCurve.LastParameter(),
-                           aPreciseAngDef, aPreciseLinDef, aMinPntNb,
-                           Precision::PConfusion(), myParameters.MinSize);
+  myDiscretTool.Initialize (myCurve,
+                            myCurve.FirstParameter(), myCurve.LastParameter(),
+                            aPreciseAngDef, aPreciseLinDef, aMinPntNb,
+                            Precision::PConfusion(), aMinSize);
 
   if (myCurve.IsCurveOnSurface())
   {
index fedfff3..6279708 100644 (file)
@@ -33,7 +33,8 @@ struct IMeshTools_Parameters {
     Relative (Standard_False),
     InternalVerticesMode (Standard_True),
     ControlSurfaceDeflection (Standard_True),
-    CleanModel(Standard_True)
+    CleanModel (Standard_True),
+    AdjustMinSize (Standard_False)
   {
   }
 
@@ -78,6 +79,10 @@ struct IMeshTools_Parameters {
 
   //! Cleans temporary data model when algorithm is finished.
   Standard_Boolean                                 CleanModel;
+
+  //! Enables/disables local adjustment of min size depending on edge size.
+  //! Disabled by default.
+  Standard_Boolean                                 AdjustMinSize;
 };
 
 #endif
index 404cdac..8dcf5c3 100644 (file)
@@ -88,7 +88,7 @@ options:\n\
         -surf_def_off   disables control of deflection of mesh from real\n\
                         surface (enabled by default)\n\
         -parallel       enables parallel execution (switched off by default)\n\
-        -adaptive       enables adaptive computation of minimal value in parametric space\n";
+        -adjust_min     enables local adjustment of min size depending on edge size (switched off by default)\n";
     return 0;
   }
 
@@ -121,6 +121,8 @@ options:\n\
         aMeshParams.InternalVerticesMode = Standard_False;
       else if (aOpt == "-surf_def_off")
         aMeshParams.ControlSurfaceDeflection = Standard_False;
+      else if (aOpt == "-adjust_min")
+        aMeshParams.AdjustMinSize = Standard_True;
       else if (i < nbarg)
       {
         Standard_Real aVal = Draw::Atof(argv[i++]);
diff --git a/tests/bugs/mesh/bug30780 b/tests/bugs/mesh/bug30780
new file mode 100644 (file)
index 0000000..b151df7
--- /dev/null
@@ -0,0 +1,18 @@
+puts "========="
+puts "0030780: BRepMesh fails triangulating one face of the shape"
+puts "========="
+puts ""
+
+binrestore [locate_data_file bug30780_full.bin] result
+
+tclean result
+incmesh result 7.066 -a 20 -adjust_min
+
+checktrinfo result -tri
+
+set log [tricheck result]
+if { [llength $log] != 0 } {
+  puts "Error : Invalid mesh"
+} else {
+  puts "Mesh is OK"
+}