]> OCCT Git - occt-copy.git/commitdiff
0026241: Sewing algorithm computes tolerance of joint vertex too rough
authorika <ika@opencascade.com>
Thu, 18 Jun 2015 11:03:53 +0000 (14:03 +0300)
committerbugmaster <bugmaster@opencascade.com>
Thu, 18 Jun 2015 11:04:52 +0000 (14:04 +0300)
Upgrade method of computing vertex tolerance.
Update function, which used the old method.
Test case for issue CR26241
Delete obsolete variables.
Small correction of test cases for issue CR26241

24 files changed:
src/BRepBuilderAPI/BRepBuilderAPI_Sewing.cxx
tests/bugs/modalg_2/bug22770_10
tests/bugs/modalg_2/bug22770_11
tests/bugs/modalg_2/bug22770_23
tests/bugs/modalg_2/bug22770_24
tests/bugs/modalg_2/bug22770_25
tests/bugs/modalg_2/bug22770_26
tests/bugs/modalg_2/bug22770_27
tests/bugs/modalg_2/bug22770_28
tests/bugs/modalg_2/bug22770_30
tests/bugs/modalg_2/bug22770_8
tests/bugs/modalg_2/bug22770_9
tests/bugs/modalg_5/bug24390_2
tests/bugs/modalg_6/bug24357
tests/bugs/modalg_6/bug26241 [new file with mode: 0755]
tests/bugs/moddata_2/bug343
tests/bugs/moddata_2/bug42
tests/sewing/tol_1/S5 [changed mode: 0644->0755]
tests/sewing/tol_100/I5 [changed mode: 0644->0755]
tests/sewing/tol_100/I6 [changed mode: 0644->0755]
tests/sewing/tol_100/I9 [changed mode: 0644->0755]
tests/sewing/tol_100/J3 [changed mode: 0644->0755]
tests/sewing/tol_100/T8
tests/sewing/tol_100/U1 [changed mode: 0644->0755]

index 853ad482417c777ebe0d792ca17abeb76df77081..44d83f78155e113b2a9bb75a4839f556cce3e13b 100644 (file)
@@ -492,9 +492,83 @@ static Standard_Boolean findNMVertices(const TopoDS_Edge& theEdge,
   return Standard_True;
 }
 
-static inline Standard_Real ComputeToleranceVertex(const Standard_Real dist, const Standard_Real Tol1, const Standard_Real Tol2)
+static void ComputeToleranceVertex(TopoDS_Vertex theV1, TopoDS_Vertex theV2,
+                                   TopoDS_Vertex& theNewV)
 {
-  return (dist * 0.5 + Tol1 + Tol2);
+  Standard_Integer m, n;
+  Standard_Real aR[2], dR, aD, aEps;
+  TopoDS_Vertex aV[2];
+  gp_Pnt aP[2];
+  BRep_Builder aBB;
+  //
+  aEps = RealEpsilon();
+  aV[0] = theV1;
+  aV[1] = theV2;
+  for (m = 0; m < 2; ++m) {
+    aP[m] = BRep_Tool::Pnt(aV[m]);
+    aR[m] = BRep_Tool::Tolerance(aV[m]);
+    }  
+    //
+  m=0; // max R
+  n=1; // min R
+  if (aR[0] < aR[1]) {
+    m=1;
+    n=0;
+  }
+  //
+  dR = aR[m] - aR[n]; // dR >= 0.
+  gp_Vec aVD(aP[m], aP[n]);
+  aD = aVD.Magnitude();
+  //
+  if (aD <= dR || aD < aEps) { 
+    aBB.MakeVertex (theNewV, aP[m], aR[m]);
+  }
+  else {
+    Standard_Real aRr;
+    gp_XYZ aXYZr;
+    gp_Pnt aPr;
+    //
+    aRr = 0.5 * (aR[m] + aR[n] + aD);
+    aXYZr = 0.5 * (aP[m].XYZ() + aP[n].XYZ() - aVD.XYZ() * (dR/aD));
+    aPr.SetXYZ(aXYZr);
+    //
+    aBB.MakeVertex (theNewV, aPr, aRr);
+  }
+  return;
+}
+
+static void ComputeToleranceVertex(TopoDS_Vertex theV1, TopoDS_Vertex theV2,
+                                   TopoDS_Vertex theV3, TopoDS_Vertex& theNewV)
+{
+  Standard_Real aDi, aDmax;
+  gp_Pnt aCenter;
+  gp_Pnt aP[3];
+  Standard_Real aR[3];
+  TopoDS_Vertex aV[3];
+  gp_XYZ aXYZ(0.,0.,0.);
+  aV[0] = theV1;
+  aV[1] = theV2;
+  aV[2] = theV3;
+  for (Standard_Integer i = 0; i < 3; ++i) {
+    aP[i] = BRep_Tool::Pnt(aV[i]);
+    aR[i] = BRep_Tool::Tolerance(aV[i]);
+    aXYZ = aXYZ + aP[i].XYZ();
+  }
+  //
+  aXYZ.Divide(3.0);
+  aCenter.SetXYZ(aXYZ);
+  //
+  aDmax=-1.;
+  for ( Standard_Integer i = 0; i < 3; ++i) {
+    aDi = aCenter.Distance(aP[i]);
+    aDi += aR[i];
+    if (aDi > aDmax)
+      aDmax = aDi;
+  }
+
+  BRep_Builder aBB;
+  aBB.MakeVertex (theNewV, aCenter, aDmax);
+  return;
 }
 
 TopoDS_Edge BRepBuilderAPI_Sewing::SameParameterEdge(const TopoDS_Edge& edgeFirst,
@@ -605,111 +679,54 @@ TopoDS_Edge BRepBuilderAPI_Sewing::SameParameterEdge(const TopoDS_Edge& edgeFirs
     //V21 = TopoDS::Vertex(myReShape->Apply(V21));
     //V22 = TopoDS::Vertex(myReShape->Apply(V22));
 
-    gp_Pnt p11 = BRep_Tool::Pnt(V11);
-    gp_Pnt p12 = BRep_Tool::Pnt(V12);
-    gp_Pnt p21 = BRep_Tool::Pnt(V21); 
-    gp_Pnt p22 = BRep_Tool::Pnt(V22);
-
-    
-
     //Standard_Boolean isRev = Standard_False;
-    gp_Pnt pfirst;
-    Standard_Real Tol1 = 0.;
     if (isClosed1 || isClosed2) {
       // at least one of the edges is closed
       if (isClosed1 && isClosed2) {
         // both edges are closed
-        pfirst.SetXYZ(0.5*(p11.XYZ() + p21.XYZ()));
-        gp_Vec v1 =  p21.XYZ() - p11.XYZ();
-        Standard_Real d1 = v1.Magnitude();
-        Tol1 = ComputeToleranceVertex(d1,BRep_Tool::Tolerance(V11),BRep_Tool::Tolerance(V21));
-        //Tol1 = Max(pfirst.Distance(p11),pfirst.Distance(p21));
+        ComputeToleranceVertex(V11, V21, V1New);
       }
       else if (isClosed1) {
         // only first edge is closed
-        gp_XYZ pt =0.5*(p21.XYZ()+ p22.XYZ());
-        pfirst.SetXYZ(0.5*(p11.XYZ() + pt));
-        gp_Vec v1 =  p22.XYZ() - p21.XYZ();
-        Standard_Real d1 = v1.Magnitude();
-        Tol1= ComputeToleranceVertex(d1,BRep_Tool::Tolerance(V22),BRep_Tool::Tolerance(V21));
-        gp_Vec v2 =  p11.XYZ() - pt;
-        Standard_Real d2 = v2.Magnitude();
-        Tol1= ComputeToleranceVertex(d2,Tol1,BRep_Tool::Tolerance(V11));
-        //Tol1 = Max(pfirst.Distance(p21),pfirst.Distance(p22));
-        //Tol1 = Max(pfirst.Distance(p11),Tol1);
+        ComputeToleranceVertex(V22, V21, V11, V1New);
       }
       else {
         // only second edge is closed
-        gp_XYZ pt = 0.5*(p11.XYZ()+ p12.XYZ());
-        pfirst.SetXYZ(0.5*(p21.XYZ() + pt));
-        gp_Vec v1 =  p11.XYZ() - p12.XYZ();
-        Standard_Real d1 = v1.Magnitude();
-        Tol1 = ComputeToleranceVertex(d1,BRep_Tool::Tolerance(V11),BRep_Tool::Tolerance(V12));
-        gp_Vec v2 =  p21.XYZ() - pt;
-        Standard_Real d2 = v2.Magnitude();
-        Tol1 = ComputeToleranceVertex(d2,Tol1,BRep_Tool::Tolerance(V21));
-        //Tol1 = Max(pfirst.Distance(p11),pfirst.Distance(p12));
-        //Tol1 = Max(pfirst.Distance(p21),Tol1);
+        ComputeToleranceVertex(V11, V12, V21, V1New);
       }
-      aBuilder.MakeVertex(V1New,pfirst,Tol1);
       V2New = V1New;
     }
     else {
       // both edges are open
-      gp_Pnt plast;
-      Standard_Real Tol2 = 0.;
       Standard_Boolean isOldFirst = ( secForward ? V11.IsSame(V21) :  V11.IsSame(V22) );
       Standard_Boolean isOldLast = ( secForward ? V12.IsSame(V22) : V12.IsSame(V21)) ;
       if (secForward) {
         //case if vertices already sewed
         if(!isOldFirst)
         {
-          pfirst.SetXYZ(0.5*(p11.XYZ() + p21.XYZ()));
-          gp_Vec v1 =  p21.XYZ() - p11.XYZ();
-          Standard_Real d1 = v1.Magnitude();
-          Tol1 = ComputeToleranceVertex(d1,BRep_Tool::Tolerance(V11),BRep_Tool::Tolerance(V21));
+          ComputeToleranceVertex(V11, V21, V1New);
         }
         if(!isOldLast)
         {
-          plast.SetXYZ(0.5*(p12.XYZ() + p22.XYZ()));
-
-          gp_Vec v2 =  p22.XYZ() - p12.XYZ();
-          Standard_Real d2 = v2.Magnitude();
-
-          Tol2 = ComputeToleranceVertex(d2,BRep_Tool::Tolerance(V12),BRep_Tool::Tolerance(V22));
+          ComputeToleranceVertex(V12, V22, V2New);
         }
-
       }
       else {
         if(!isOldFirst)
         {
-          pfirst.SetXYZ(0.5*(p11.XYZ() + p22.XYZ()));
-          gp_Vec v1 =  p22.XYZ() - p11.XYZ();
-          Standard_Real d1 = v1.Magnitude();
-          Tol1 = ComputeToleranceVertex(d1,BRep_Tool::Tolerance(V11),BRep_Tool::Tolerance(V22));
+          ComputeToleranceVertex(V11, V22, V1New);
         }
         if(!isOldLast)
         {
-          plast.SetXYZ(0.5*(p12.XYZ() + p21.XYZ()));
-          gp_Vec v2 =  p21.XYZ() - p12.XYZ();
-          Standard_Real d2 = v2.Magnitude();
-          Tol2 = ComputeToleranceVertex(d2,BRep_Tool::Tolerance(V12),BRep_Tool::Tolerance(V21));
+          ComputeToleranceVertex(V12, V21, V2New);
         }
-
       }
-      if(!isOldFirst)
-        aBuilder.MakeVertex(V1New,pfirst,Tol1);
-      else
+      if(isOldFirst)
         V1New = V11;
-       
 
-      if(!isOldLast)
-        aBuilder.MakeVertex(V2New,plast,Tol2);
-      else
+      if(isOldLast)
         V2New = V12;
-
     }
-
     // Add the vertices in the good sense
     TopoDS_Shape anEdge = edge.Oriented(TopAbs_FORWARD);
     TopoDS_Shape aLocalEdge = V1New.Oriented(TopAbs_FORWARD); //(listNode.First()).Oriented(TopAbs_FORWARD);
index f01a692fa0d9a77c07cbbfe6d313cc1e4402e456..77b658ada2719ad4537d25a37254306a70ffb6cb 100755 (executable)
@@ -14,18 +14,21 @@ sewing result +t 0.01 a b +mint 0.01 -a
 
 set square 1.88469e+07
 
-set nb_v_good 478
-set nb_e_good 748
-set nb_w_good 273
-set nb_f_good 259
-set nb_sh_good 2
-set nb_sol_good 0
-set nb_compsol_good 0
-set nb_compound_good 1
-set nb_shape_good 1761
+checkmaxtol result 0.00087010032709666047
+checkfreebounds result 12
 
-checkmaxtol result 0.002196807453775285
-checknbshapes result -shell 2
-checkfreebounds result 10
+set nbshapes_expected "
+Number of shapes in shape
+ VERTEX    : 479
+ EDGE      : 748
+ WIRE      : 273
+ FACE      : 259
+ SHELL     : 2
+ SOLID     : 0
+ COMPSOLID : 0
+ COMPOUND  : 1
+ SHAPE     : 1762
+"
+checknbshapes result -ref ${nbshapes_expected} -t -m "sewing result"
 
-set 3dviewer 0
+set 3dviewer 1
index 531cf047326df0be0939af75466fbef668f2fa8b..7e97ac48a0aeb85bcd523df07f4a4b3ea10bbb9c 100755 (executable)
@@ -24,7 +24,7 @@ set nb_compsol_good 0
 set nb_compound_good 1
 set nb_shape_good 1759
 
-checkmaxtol result 0.002196807453775285
+checkmaxtol result 0.00087010032709666047
 checknbshapes result -shell 2
 checkfreebounds result 6
 
index c92fa3c603106a23967dd5314d8efa50d7582d99..25ff17843b877450b557ded1e40e46b44c81a164 100755 (executable)
@@ -25,7 +25,7 @@ set nb_compsol_good 0
 set nb_compound_good 1
 set nb_shape_good 1756
 
-checkmaxtol result 0.002196807453775285
+checkmaxtol result 0.00087010032709666047
 checknbshapes result -shell 2
 checkfreebounds result 0
 
index 044cab7a10ee3cb9c3ef0684f61b4e6dc84af0e7..816d4cd68b66bc4242f4b1060c3d6975909b75e7 100755 (executable)
@@ -27,7 +27,7 @@ set nb_compsol_good 0
 set nb_compound_good 1
 set nb_shape_good 1759
 
-checkmaxtol result 0.002196807453775285
+checkmaxtol result 0.00087010032709666047
 checknbshapes result -shell 2
 checkfreebounds result 0
 
index 2415d1b063aa7873c329df3b82896ea493b18143..debd9cc4a8e2366122c561e35e0b7a9a0bc4b4ff 100755 (executable)
@@ -27,8 +27,8 @@ set nb_compsol_good 0
 set nb_compound_good 1
 set nb_shape_good 1761
 
-checkmaxtol result 0.002196807453775285
+checkmaxtol result 0.00087010032709666047
 checknbshapes result -shell 2
-checkfreebounds result 4
+checkfreebounds result 6
 
 set 3dviewer 0
index 0299d9eae0d413d83322850e6be216eaeab55ff2..310be2b896c92f4c274f320829ad649d9611fab9 100755 (executable)
@@ -27,7 +27,7 @@ set nb_compsol_good 0
 set nb_compound_good 1
 set nb_shape_good 1759
 
-checkmaxtol result 0.002196807453775285
+checkmaxtol result 0.00087010032709666047
 checknbshapes result -shell 2
 checkfreebounds result 0
 
index 53c80dfaac44a6e0b224d0ed124645babe31316c..c611e0eeb65a128ba881d2673518094329fbd62d 100755 (executable)
@@ -25,7 +25,7 @@ set nb_compsol_good 0
 set nb_compound_good 1
 set nb_shape_good 1762
 
-checkmaxtol result 0.002196807453775285
+checkmaxtol result 0.00087010032709666047
 checknbshapes result -shell 2
 checkfreebounds result 9
 
index d4c86f7c56fba721e46e3977d02fc71a6b42431b..a9fdbb4c7c29794faf168c68df3a52db84ee54d1 100755 (executable)
@@ -25,7 +25,7 @@ set nb_compsol_good 0
 set nb_compound_good 1
 set nb_shape_good 1756
 
-checkmaxtol result 0.002196807453775285
+checkmaxtol result 0.00087010032709666047
 checknbshapes result -shell 2
 checkfreebounds result 0
 
index d95aecef38a705d566602799aa4b99d5a3415195..9cfcba4f4beb8b18325bba13beb4e5059662ebff 100755 (executable)
@@ -25,7 +25,7 @@ set nb_compsol_good 0
 set nb_compound_good 1
 set nb_shape_good 1756
 
-checkmaxtol result 0.002196807453775285
+checkmaxtol result 0.00087010032709666047
 checknbshapes result -shell 2
 checkfreebounds result 0
 
index 582ea12863b6ee9b85ef40229c1b46a6568726a7..868538644d0fc41460c6b62d2692bb5b40d46619 100755 (executable)
@@ -26,7 +26,7 @@ set nb_compsol_good 0
 set nb_compound_good 1
 set nb_shape_good 1761
 
-checkmaxtol result 0.002196807453775285
+checkmaxtol result 0.00087010032709666047
 checknbshapes result -shell 2
 checkfreebounds result 6
 
index 36eacac7b3f0bd6b9de55dfc139c6147e1e59966..74a612900923a74cc1bb5c853aa32a03ea2b3544 100755 (executable)
@@ -24,7 +24,7 @@ set nb_compsol_good 0
 set nb_compound_good 1
 set nb_shape_good 1759
 
-checkmaxtol result 0.002196807453775285
+checkmaxtol result 0.00087010032709666047
 checknbshapes result -shell 2
 checkfreebounds result 6
 
index 88bea95be3336f7ed522d78f83be1fb979a18382..05c77f8d62b6b647e64111b075520ef29ccc8bf0 100755 (executable)
@@ -14,7 +14,7 @@ restore [locate_data_file bug24390_face2.brep] f2
 sewing result f1 f2
 
 checkshape result
-checkmaxtol result 0.028334611098393123 {f1 f2} -min_tol 0 -multi_tol 5.
+checkmaxtol result 0.016556973295771653 {f1 f2} -min_tol 0 -multi_tol 5.
 checknbshapes result -shell 1
 checkfreebounds result 6
 
index 669bcee297a0ddb3534c122eb3698edb297b0f34..5d9737b6b621c5b7935bd24d0a087e447880c3d5 100755 (executable)
@@ -15,7 +15,7 @@ whatis r
 regexp {Tolerance +MAX=([-0-9.+eE]+)} [tolerance r] full MaxTolerance
 puts "MaxTolerance=$MaxTolerance"
 
-set expected_MaxTolerance 0.00082956492865075794
+set expected_MaxTolerance 0.00068453844086764995
 set tol_abs_MaxTolerance  0.00001
 set tol_rel_MaxTolerance  0.00001
 checkreal "MaxTolerance" ${MaxTolerance} ${expected_MaxTolerance} ${tol_abs_MaxTolerance} ${tol_rel_MaxTolerance}
diff --git a/tests/bugs/modalg_6/bug26241 b/tests/bugs/modalg_6/bug26241
new file mode 100755 (executable)
index 0000000..18193e9
--- /dev/null
@@ -0,0 +1,22 @@
+puts "========"
+puts "OCC26241"
+puts "========"
+puts ""
+###########################################################
+# Sewing algorithm computes tolerance of joint vertex too rough
+###########################################################
+
+plane p 0 0 0 0 0 1 1 0 0
+mkface f1 p 0 10 0 10
+mkface f2 p 0 10 11 21
+settolerance f1 2
+settolerance f2 3
+sewing res 3 f1 f2
+
+regexp {Tolerance +MAX=([-0-9.+eE]+)} [tolerance res] full MaxTolerance
+puts "MaxTolerance=$MaxTolerance"
+
+set expected_MaxTolerance 3.0
+set tol_abs_MaxTolerance 0.1
+set tol_rel_MaxTolerance 0.1
+checkreal "MaxTolerance" ${MaxTolerance} ${expected_MaxTolerance} ${tol_abs_MaxTolerance} ${tol_rel_MaxTolerance}
index b91ba145eb32b39af59d0f8c8cf4db744da1fa7a..3da8854036cafa226628cf49d9ef3e10f4b8d5f1 100755 (executable)
@@ -18,7 +18,7 @@ if [catch {igesbrep $filepath a *} catch_result] {
     #
     sewing result1 100. a
 
-    checkmaxtol result1 0.21325393968565914
+    checkmaxtol result1 0.20874930847108514
     checknbshapes result1 -shell 1
     checkfreebounds result1 86
 
@@ -71,7 +71,7 @@ if [catch {igesbrep $filepath a *} catch_result] {
         tpcompound a
        sewing result2 100. a
 
-        checkmaxtol result2 0.21325393968565914
+        checkmaxtol result2 0.20874930847108514
         checknbshapes result2 -shell 1
         checkfreebounds result2 86
 
index f1143b0c3ac2d981e844994402575c96ee08c578..8fb43c01527496296d85bc7da8f4b81297456830 100755 (executable)
@@ -34,7 +34,7 @@ if { [llength $closed_wires] != 1} {
    puts "Error : Amount of free closed wires is not equal 1"
 }
 
-checkmaxtol result 0.21325393955468794
+checkmaxtol result 0.20874930847108514
 checknbshapes result -shell 1
 checkfreebounds result 86
 
old mode 100644 (file)
new mode 100755 (executable)
index a85821f..ae3285d
@@ -2,7 +2,7 @@ restore [locate_data_file CIN001_a20.rle] a
 
 sewing result $tol a
 
-checkmaxtol result 0.0049520649253341166
+checkmaxtol result 0.0035009498713573254
 checknbshapes result -shell 1
 checkfreebounds result 74
 checkfaults result a 0
old mode 100644 (file)
new mode 100755 (executable)
index 287cdf1..c2d90b4
@@ -4,7 +4,7 @@ restore [locate_data_file CIN901_intcqhmi.rle] a
 
 sewing result $tol a
 
-checkmaxtol result 27.029859224903987
+checkmaxtol result 15.355207687279844
 checknbshapes result -shell 1
-checkfreebounds result 0
+checkfreebounds result 3
 checkfaults result a 6
old mode 100644 (file)
new mode 100755 (executable)
index c5157e9..f99d539
@@ -4,7 +4,7 @@ restore [locate_data_file CIN901_intcqhmj.rle] a
 
 sewing result $tol a
 
-checkmaxtol result 153.66065674630602
+checkmaxtol result 71.039012505679182
 checknbshapes result -shell 1
 checkfreebounds result 34
 checkfaults result a 3
old mode 100644 (file)
new mode 100755 (executable)
index 882b6d2..9f32467
@@ -4,7 +4,7 @@ restore [locate_data_file CIN902_intcqhmm.rle] a
 
 sewing result $tol a
 
-checkmaxtol result 30.472070989451943
+checkmaxtol result 15.98267511059735
 checknbshapes result -shell 1
 checkfreebounds result 28
 checkfaults result a 11
old mode 100644 (file)
new mode 100755 (executable)
index 34af835..83a8521
@@ -4,7 +4,7 @@ restore [locate_data_file CIN902_intcqhmp.rle] a
 
 sewing result $tol a
 
-checkmaxtol result 268.87290128183184
+checkmaxtol result 122.47700432877426
 checknbshapes result -shell 1
 checkfreebounds result 19
 checkfaults result a 7
index cdcc2c13c178badaadff0faf52ca4f00a71fd997..c843e7f34019d24cfe874b04b851502d62f1d3cb 100755 (executable)
@@ -2,7 +2,7 @@ restore [locate_data_file ma-test3.rle] a
 
 sewing result $tol a
 
-checkmaxtol result 6.2643182979358158
+checkmaxtol result 5.8186555567983991
 checknbshapes result -shell 1
 checkfreebounds result 0
 checkfaults result a 0
old mode 100644 (file)
new mode 100755 (executable)
index 9e3e148..f7257b1
@@ -2,7 +2,7 @@ restore [locate_data_file ma-test5.rle] a
 
 sewing result $tol a
 
-checkmaxtol result 2.1507390207569199
+checkmaxtol result 1.14347452525616
 checknbshapes result -shell 1
 checkfreebounds result 0
 checkfaults result a 0