]> OCCT Git - occt.git/commitdiff
0032447: BRepOffsetAPI_MakePipeShell result in inaccurate shape when using -DT mode...
authorakaftasev <akaftasev@opencascade.com>
Wed, 11 May 2022 15:17:31 +0000 (18:17 +0300)
committerafokin <afokin@opencascade.com>
Fri, 27 May 2022 15:21:34 +0000 (18:21 +0300)
Added new option '-C' with possibility to set value of Angular and linear tolerances to 'mksweep' command to correct input spine by merging smooth connected neighboring edges

src/BRepTest/BRepTest_SweepCommands.cxx
tests/bugs/modalg_7/bug32447_1 [new file with mode: 0644]
tests/bugs/modalg_7/bug32447_2 [new file with mode: 0644]
tests/bugs/modalg_7/bug32447_3 [new file with mode: 0644]
tests/bugs/modalg_7/bug32447_4 [new file with mode: 0644]

index 40c0f6f1195104df2d4d83368d28508df543f819..100feb264450bb6b241f72f96e374968f6574b22 100644 (file)
@@ -57,6 +57,7 @@ static BRepOffsetAPI_ThruSections* Generator = 0;
 #include <Geom_Circle.hxx>
 #include <gp_Ax2.hxx>
 #include <Message.hxx>
+#include <ShapeUpgrade_UnifySameDomain.hxx>
 
 //=======================================================================
 // prism
@@ -533,16 +534,50 @@ Standard_Integer thrusections(Draw_Interpretor&, Standard_Integer n, const char*
 //=======================================================================
 //  mksweep
 //=======================================================================
-static Standard_Integer mksweep(Draw_Interpretor&,
+static Standard_Integer mksweep(Draw_Interpretor& di,
   Standard_Integer n, const char** a)
 {
-  if (n != 2) return 1;
+  if (n != 2 && n != 5) return 1;
   TopoDS_Shape Spine = DBRep::Get(a[1], TopAbs_WIRE);
   if (Spine.IsNull()) return 1;
   if (Sweep != 0)  {
     delete Sweep;
     Sweep = 0;
   }
+
+  if (n > 2 && n <= 5)
+  {
+    if (!strcmp(a[2], "-C"))
+    {
+      ShapeUpgrade_UnifySameDomain aUnif(Spine, Standard_True, Standard_False, Standard_True);
+
+      Standard_Real anAngTol = 5.;
+      Standard_Real aLinTol = 0.1;
+
+      if (n == 5)
+      {
+        anAngTol = Draw::Atof(a[3]);
+        aLinTol = Draw::Atof(a[4]);
+      }
+
+      aUnif.SetAngularTolerance(anAngTol * M_PI / 180.);
+      aUnif.SetLinearTolerance(aLinTol);
+      aUnif.Build();
+      Spine = aUnif.Shape();
+      if (BRepTest_Objects::IsHistoryNeeded())
+      {
+        BRepTest_Objects::SetHistory(aUnif.History());
+      }
+    }
+    else
+    {
+      di << "To correct input spine use 'mksweep wire -C [AngTol LinTol]'\n";
+      di << "By default, AngTol = 5, LinTol = 0.1";
+      return 1;
+    }
+  }
+
+
   Sweep = new BRepOffsetAPI_MakePipeShell(TopoDS::Wire(Spine));
   return 0;
 }
@@ -1010,7 +1045,9 @@ void  BRepTest::SweepCommands(Draw_Interpretor& theCommands)
     "\t\t-safe option allows to prevent the modifying of input shapes",
     __FILE__, thrusections, g);
 
-  theCommands.Add("mksweep", "mksweep wire",
+  theCommands.Add("mksweep", "mksweep wire [-C [AngTol LinTol]]\n"
+    "\t\tthe option -C correct input spine by merging smooth connected neighboring edges\n"
+    "\t\tthe AngTol is in degrees",
     __FILE__, mksweep, g);
 
   theCommands.Add("setsweep", "setsweep  no args to get help",
diff --git a/tests/bugs/modalg_7/bug32447_1 b/tests/bugs/modalg_7/bug32447_1
new file mode 100644 (file)
index 0000000..d20ffbd
--- /dev/null
@@ -0,0 +1,41 @@
+puts "============================================"
+puts "0032447: BRepOffsetAPI_MakePipeShell result in inaccurate shape when using -DT mode and DT_ShapeDivide on the spine"
+puts "============================================"
+puts ""
+
+restore [locate_data_file bug32447-spine.brep] s
+restore [locate_data_file bug32447-profile.brep] p
+
+mksweep s -C 5 0.001
+
+explode s e
+savehistory cor_hist
+modified sc_1 cor_hist s_1
+modified sc_2 cor_hist s_2
+modified sc_3 cor_hist s_4
+modified sc_4 cor_hist s_6 
+
+checkprops sc_1 -l 0.1816
+checkprops sc_2 -l 0.265078
+checkprops sc_3 -l 0.261167
+checkprops sc_4 -l 0.253542
+
+setsweep -DT
+addsweep p
+buildsweep r -C -S
+
+savehistory sweep_hist
+generated r1 sweep_hist sc_1
+generated r2 sweep_hist sc_2
+generated r3 sweep_hist sc_3
+generated r4 sweep_hist sc_4
+
+checkprops r1 -s 0.0483501
+checkprops r2 -s 0.060163
+checkprops r3 -s 0.0577468
+checkprops r4 -s 0.0658619
+
+checkshape r
+checknbshapes r -face 18
+
+checkview -display r -2d -path ${imagedir}/${test_image}.png
diff --git a/tests/bugs/modalg_7/bug32447_2 b/tests/bugs/modalg_7/bug32447_2
new file mode 100644 (file)
index 0000000..5726f9e
--- /dev/null
@@ -0,0 +1,33 @@
+puts "============================================"
+puts "0032447: BRepOffsetAPI_MakePipeShell result in inaccurate shape when using -DT mode and DT_ShapeDivide on the spine"
+puts "============================================"
+puts ""
+
+restore [locate_data_file bug32447-spine.brep] s
+restore [locate_data_file bug32447-profile.brep] p
+
+mksweep s -C 1 0.1
+
+explode s e
+savehistory cor_hist
+modified sc_1 cor_hist s_1
+modified sc_2 cor_hist s_2
+
+checkprops sc_1 -l 0.1816
+checkprops sc_2 -l 0.779758
+
+setsweep -DT
+addsweep p
+buildsweep r -C -S
+
+savehistory sweep_hist
+generated r1 sweep_hist sc_1
+generated r2 sweep_hist sc_2
+
+checkprops r1 -s 0.0483501
+checkprops r2 -s 0.184231
+
+checkshape r
+checknbshapes r -face 10
+
+checkview -display r -2d -path ${imagedir}/${test_image}.png
diff --git a/tests/bugs/modalg_7/bug32447_3 b/tests/bugs/modalg_7/bug32447_3
new file mode 100644 (file)
index 0000000..ba5a110
--- /dev/null
@@ -0,0 +1,42 @@
+puts "============================================"
+puts "0032447: BRepOffsetAPI_MakePipeShell result in inaccurate shape when using -DT mode and DT_ShapeDivide on the spine"
+puts "============================================"
+puts ""
+
+circle c 0 0 0  1
+trim c c 0 1
+convert c c
+mkedge c c
+
+line l 1 0 0  0 1 0
+trim l l -1 0
+convert l l
+mkedge l l 
+
+wire s l c
+
+circle c 0.9 0 0  0 1 0  0.1
+mkedge p c
+wire p p
+
+mksweep s -C 5 0.001
+
+explode s e
+savehistory cor_hist
+modified sc cor_hist s_1
+
+checkprops sc -l 2
+
+setsweep -DT
+addsweep p
+buildsweep r -C -S
+
+savehistory sweep_hist
+generated r1 sweep_hist sc
+
+checkprops r1 -s 1.19393
+
+checkshape r
+checknbshapes r -face 3
+
+checkview -display r -2d -path ${imagedir}/${test_image}.png
diff --git a/tests/bugs/modalg_7/bug32447_4 b/tests/bugs/modalg_7/bug32447_4
new file mode 100644 (file)
index 0000000..f6aaa62
--- /dev/null
@@ -0,0 +1,42 @@
+puts "============================================"
+puts "0032447: BRepOffsetAPI_MakePipeShell result in inaccurate shape when using -DT mode and DT_ShapeDivide on the spine"
+puts "============================================"
+puts ""
+
+circle c1 0 0 0  10
+trim c1 c1 0 1
+convert c1 c1
+mkedge c1 c1
+
+circle c2 -1000 0 0  1010
+trim c2 c2 -0.1 0
+convert c2 c2
+mkedge c2 c2
+
+wire s c2 c1
+
+circle c 9 0 0  0 1 0  1
+mkedge p c
+wire p p
+
+mksweep s -C 5 0.1
+
+explode s e
+savehistory cor_hist
+modified sc cor_hist s_1
+
+checkprops sc -l 111
+
+setsweep -DT
+addsweep p
+buildsweep r -C -S
+
+savehistory sweep_hist
+generated r1 sweep_hist sc
+
+checkprops r1 -s 691.348
+
+checkshape r
+checknbshapes r -face 3
+
+checkview -display r -2d -path ${imagedir}/${test_image}.png