0025445: Draw command incmesh should support all parameters used in BRepMesh
authoroan <oan@opencascade.com>
Thu, 6 Nov 2014 13:05:14 +0000 (16:05 +0300)
committerbugmaster <bugmaster@opencascade.com>
Thu, 6 Nov 2014 13:05:48 +0000 (16:05 +0300)
Test-case for issue #25445

src/MeshTest/MeshTest.cxx
tests/bugs/demo/bug25445 [new file with mode: 0644]
tests/bugs/mesh/bug24968_1
tests/bugs/mesh/bug24968_2
tests/mesh/advanced_incmesh/begin
tests/mesh/advanced_incmesh_parallel/begin
tests/mesh/end
tests/mesh/standard_incmesh/begin
tests/mesh/standard_incmesh_parallel/begin

index ab35f16c079c81e01054e65b26e189833d8c6e50..519e01e29e3193a621e1221c677474609d0b55dd 100644 (file)
@@ -54,6 +54,7 @@
 #include <Geom_Surface.hxx>
 #include <Draw_Marker3D.hxx>
 #include <Draw_Segment2D.hxx>
+#include <TCollection_AsciiString.hxx>
 
 #include <GCPnts_UniformAbscissa.hxx>
 #include <GeomAdaptor_Curve.hxx>
@@ -118,33 +119,66 @@ OSD_Chronometer chIsos, chPointsOnIsos;
 //function : incrementalmesh
 //purpose  : 
 //=======================================================================
-
 static Standard_Integer incrementalmesh(Draw_Interpretor& di, Standard_Integer nbarg, const char** argv)
 {
-  if (nbarg < 3) {
-    di << " use incmesh shape deflection [inParallel (0/1) : 0 by default]\n";
+  if (nbarg < 3)
+  {
+    di << "\
+Builds triangular mesh for the shape\n\
+usage: incmesh Shape LinearDeflection [options]\n\
+options:\n\
+        -a val          angular deflection in deg (default ~28.64 deg = 0.5 rad)\n\
+        -relative       notifies that relative deflection is used\n\
+                        (switched off by default)\n\
+        -parallel       enables parallel execution (switched off by default)\n";
     return 0;
   }
 
   TopoDS_Shape aShape = DBRep::Get(argv[1]);
-  if (aShape.IsNull()) {
-    di << " null shapes is not allowed here\n";
+  if (aShape.IsNull())
+  {
+    di << " Null shapes are not allowed here\n";
     return 0;
   }
-  Standard_Real aDeflection = Draw::Atof(argv[2]);
 
+  Standard_Real aLinDeflection  = Max(Draw::Atof(argv[2]), Precision::Confusion());
+  Standard_Real aAngDeflection  = 0.5;
+  Standard_Boolean isRelative   = Standard_False;
   Standard_Boolean isInParallel = Standard_False;
-  if (nbarg == 4) {
-       isInParallel = Draw::Atoi(argv[3]) == 1;
+
+  if (nbarg > 3)
+  {
+    Standard_Integer i = 3;
+    while (i < nbarg)
+    {
+      TCollection_AsciiString aOpt(argv[i++]);
+      aOpt.LowerCase();
+
+      if (aOpt == "")
+        continue;
+      else if (aOpt == "-relative")
+        isRelative = Standard_True;
+      else if (aOpt == "-parallel")
+        isInParallel = Standard_True;
+      else if (i < nbarg)
+      {
+        Standard_Real aVal = Draw::Atof(argv[i++]);
+        if (aOpt == "-a")
+          aAngDeflection = aVal * M_PI / 180.;
+        else
+          --i;
+      }
+    }
   }
+
   di << "Incremental Mesh, multi-threading "
-    << (isInParallel ? "ON\n" : "OFF\n");
-  
-  BRepMesh_IncrementalMesh MESH(aShape, aDeflection, Standard_False, 0.5, isInParallel);
-  Standard_Integer statusFlags = MESH.GetStatusFlags();  
+     << (isInParallel ? "ON" : "OFF") << "\n";
 
-  di << "Meshing statuses: ";
+  BRepMesh_IncrementalMesh aMesher(aShape, aLinDeflection, isRelative, 
+    aAngDeflection, isInParallel);
 
+  di << "Meshing statuses: ";
+  Standard_Integer statusFlags = aMesher.GetStatusFlags();
   if( !statusFlags )
   {
     di << "NoError";
@@ -1542,7 +1576,7 @@ void  MeshTest::Commands(Draw_Interpretor& theCommands)
 
   g = "Mesh Commands";
 
-  theCommands.Add("incmesh","incmesh shape deflection [inParallel (0/1) : 0 by default]",__FILE__, incrementalmesh, g);
+  theCommands.Add("incmesh","Builds triangular mesh for the shape, run w/o args for help",__FILE__, incrementalmesh, g);
   theCommands.Add("MemLeakTest","MemLeakTest",__FILE__, MemLeakTest, g);
   theCommands.Add("fastdiscret","fastdiscret shape deflection [shared [nbiter]]",__FILE__, fastdiscret, g);
   theCommands.Add("mesh","mesh result Shape deflection",__FILE__, triangule, g);
diff --git a/tests/bugs/demo/bug25445 b/tests/bugs/demo/bug25445
new file mode 100644 (file)
index 0000000..1915098
--- /dev/null
@@ -0,0 +1,28 @@
+puts "========"
+puts "OCC25445"
+puts "========"
+puts ""
+#######################################################################
+# Draw command incmesh should support all parameters used in BRepMesh
+#######################################################################
+
+pcone aCone 100 10 100
+
+tclean aCone
+incmesh aCone 0.01 -a 0.4
+set bug_info [trinfo aCone]
+set NbTrian_1 [lindex $bug_info 3]
+set NbNodes_1 [lindex $bug_info 5]
+
+tclean aCone
+incmesh aCone 0.01 -a 0.3
+set bug_info [trinfo aCone]
+set NbTrian_2 [lindex $bug_info 3]
+set NbNodes_2 [lindex $bug_info 5]
+
+if {$NbTrian_1 == $NbTrian_2} {
+  puts "ERROR: OCC25445 is not fixed. Number of triangles are equal for both meshes."
+}
+if {$NbNodes_1 == $NbNodes_2} {
+  puts "ERROR: OCC25445 is not fixed. Number of nodes are equal for both meshes."
+}
index 44995b57b2c42432594b45113555a3d2dd7a7934..4882dad2eb3796fba48f0715d8ba9090a5e10b93 100644 (file)
@@ -13,7 +13,7 @@ restore [locate_data_file bug24968_Shape_1.brep] result
 tclean result
 dchrono h reset
 dchrono h start
-incmesh result 0.1 0
+incmesh result 0.1
 dchrono h stop
 
 set info [dchrono h show]
index 0c21ea35ec41877c078136eba17fe6d02e17e7d5..e38ff4354908adbdb6a9d26393b9db75cf8b4d69 100644 (file)
@@ -13,7 +13,7 @@ restore [locate_data_file bug24968_Shape_1.brep] result
 tclean result
 dchrono h reset
 dchrono h start
-incmesh result 0.1 1
+incmesh result 0.1 -parallel
 dchrono h stop
 
 set info [dchrono h show]
index 8ed30037535451a24137723aeee524b154a4f370..807dcb2a59efa90b13e09907db45007ae6707489 100644 (file)
@@ -1,3 +1,3 @@
 set command incmesh
 set group advanced
-set parallel 0
+set parallel ""
index cdd1e764394b251d22ba0a7a7e38f0e711d8c4bc..579f49fcc758fe3a24e9a65c29f64e0470f8a5ac 100644 (file)
@@ -1,3 +1,3 @@
 set command incmesh
 set group advanced
-set parallel 1
+set parallel -parallel
index 5640b83cee1086c257a39bd7ceeb1ce67bf39656..6598eb6e9a345f393c1432d4fa622689c2a09724 100644 (file)
@@ -33,7 +33,7 @@ if { [string compare $command "incmesh"] == 0 } {
     if {[array get env os_type] != ""} {
        set os $env(os_type)
     }
-    if { $parallel != 1 || [info exists count_parallel] == 0 } {
+    if { [string compare $parallel "-parallel"] != 0 || [info exists count_parallel] == 0 } {
        set count_parallel 1
     }
     for {set i 1} {$i <= $count_parallel} {incr i} {
index be09a2056cea19b91d3d884179d8b2d73fe5a26d..007b5372cb5f5827e9d9b7876fd29be741c51721 100644 (file)
@@ -1,3 +1,3 @@
 set command incmesh
 set group standard
-set parallel 0
+set parallel ""
index aefc3e6a8bd3ba037a6634cb1c446f21fe0ffa6d..378b383444ba26747969c4eb6d937cb3bf848834 100644 (file)
@@ -1,3 +1,3 @@
 set command incmesh
 set group standard
-set parallel 1
+set parallel -parallel