]> OCCT Git - occt.git/commitdiff
0031992: Modeling Algorithms - Offset of closed B-spline edge fails
authorjgv <jgv@opencascade.com>
Thu, 22 Sep 2022 09:51:18 +0000 (12:51 +0300)
committersmoskvin <smoskvin@opencascade.com>
Fri, 23 Sep 2022 15:31:02 +0000 (18:31 +0300)
1. Increase the tolerance of approximation.
2. Update auxiliary Draw command "topoload" for usage of option "-approx".

Add missing comment

src/BRepOffsetAPI/BRepOffsetAPI_MakeOffset.cxx
src/BRepOffsetAPI/BRepOffsetAPI_MakeOffset.hxx
src/BRepTest/BRepTest_MatCommands.cxx
src/MAT2d/MAT2d_Tool2d.cxx
src/TKDraw/EXTERNLIB
tests/bugs/modalg_8/bug31992 [new file with mode: 0644]
tests/bugs/modalg_8/bug32214_4
tests/bugs/modalg_8/bug32214_5
tests/bugs/modalg_8/bug32214_6

index fda3234e48c515c52af72d036d11aa3caa7f4f9b..806ae4aa71c1cefa7de46a77492a02cadda3467b 100644 (file)
@@ -60,8 +60,8 @@ static Standard_Boolean NeedsConvertion (const TopoDS_Wire& theWire)
   return Standard_False;
 }
 
-static TopoDS_Face ConvertFace (const TopoDS_Face&  theFace,
-                                const Standard_Real theAngleTolerance)
+TopoDS_Face BRepOffsetAPI_MakeOffset::ConvertFace (const TopoDS_Face&  theFace,
+                                                   const Standard_Real theAngleTolerance)
 {
   TopAbs_Orientation anOr = theFace.Orientation();
   TopoDS_Face aFace = theFace;
@@ -76,6 +76,7 @@ static TopoDS_Face ConvertFace (const TopoDS_Face&  theFace,
     if (NeedsConvertion (aWire))
     {
       TopAbs_Orientation anOrOfWire = aWire.Orientation();
+      aWire.Orientation (TopAbs_FORWARD);
       aWire = BRepAlgo::ConvertWire (aWire, theAngleTolerance, aFace);
       BRepLib::BuildCurves3d (aWire);
       aWire.Orientation (anOrOfWire);
@@ -352,7 +353,7 @@ void BRepOffsetAPI_MakeOffset::Perform(const Standard_Real Offset,
   {
     if (myIsToApprox)
     {
-      Standard_Real aTol = 0.01;
+      Standard_Real aTol = 0.1;
       if (myFace.IsNull())
       {
         TopoDS_Face aFace;
index 43fd383af0c4027c9533b94452c678a58968d443..42907bdcc639e1f730295b1113482dcdc40e2c56 100644 (file)
@@ -84,7 +84,10 @@ public:
   //! from the shape <S>.
   Standard_EXPORT virtual const TopTools_ListOfShape& Generated (const TopoDS_Shape& S) Standard_OVERRIDE;
 
-
+  //! Converts each wire of the face into contour consisting only of
+  //! arcs and segments. New 3D curves are built too.
+  Standard_EXPORT static TopoDS_Face ConvertFace (const TopoDS_Face& theFace,
+                                                  const Standard_Real theAngleTolerance);
 
 
 protected:
index 04255f2aff221641bc2ef10ec9d4a49bb9e071d0..cbde7fe112a96478d7fef204d2d1c8c6e4163c0f 100644 (file)
@@ -35,6 +35,7 @@
 #include <Bisector_BisecAna.hxx>
 #include <Precision.hxx>
 
+#include <BRepOffsetAPI_MakeOffset.hxx>
 #include <BRepMAT2d_Explorer.hxx>
 #include <BRepMAT2d_BisectingLocus.hxx>
 #include <BRepMAT2d_LinkTopoBilo.hxx>
@@ -44,6 +45,7 @@
 
 #include <DBRep.hxx>
 #include <TopoDS.hxx>
+#include <TopoDS_Face.hxx>
 
 #ifdef _WIN32
 Standard_IMPORT Draw_Viewer dout;
@@ -70,7 +72,16 @@ static Standard_Integer topoload (Draw_Interpretor& , Standard_Integer argc, con
 
   if (C1.IsNull()) return 1;
 
-  anExplo.Perform (TopoDS::Face(C1));
+  TopoDS_Face aFace = TopoDS::Face(C1);
+  
+  if (argc >= 3 &&
+      (strcmp(argv[2], "-approx") == 0))
+  {
+    Standard_Real aTol = 0.1;
+    aFace = BRepOffsetAPI_MakeOffset::ConvertFace (aFace, aTol);
+  }
+
+  anExplo.Perform (aFace);
   return 0;
 }
 
@@ -267,7 +278,7 @@ void DrawCurve(const Handle(Geom2d_Curve)& aCurve,
 
 void BRepTest::MatCommands (Draw_Interpretor& theCommands)
 {
-  theCommands.Add("topoload","load face",__FILE__,topoload);
+  theCommands.Add("topoload","load face: topoload face [-approx]",__FILE__,topoload);
   theCommands.Add("drawcont","display current contour",__FILE__,drawcont);
   theCommands.Add("mat","computes the mat: mat [a/i [o]]",__FILE__,mat);
   theCommands.Add("side","side left/right",__FILE__,side);
index c2b73d844127b4880a9fc7d62908f5249a105e47..9c772597590e4cd436dfa7061d233a7ce16851b6 100644 (file)
 #include <Draw_Appli.hxx>
 #include <DrawTrSurf_Curve2d.hxx>
 #include <GCE2d_MakeSegment.hxx>
-#include <DrawTrSurf.hxx>
 #endif
 
-
 #include <Bisector_Bisec.hxx>
 #include <Bisector_BisecAna.hxx>
 #include <Bisector_BisecCC.hxx>
@@ -229,10 +227,22 @@ Standard_Integer MAT2d_Tool2d::TangentBefore(const Standard_Integer anitem,
   type = theCircuit->Value(anitem)->DynamicType();
   if ( type != STANDARD_TYPE(Geom2d_CartesianPoint)){
     curve = Handle(Geom2d_Curve)::DownCast(theCircuit->Value(anitem));
+#ifdef DRAW
+    char  *name = new char[100];
+    sprintf(name, "c%d", anitem);
+    DrawTrSurf::Set(name, curve);
+    delete [] name;
+#endif
     theGeomVecs.Bind(theNumberOfVecs,curve->DN(curve->LastParameter(),1));
   }
   else {
     curve = Handle(Geom2d_Curve)::DownCast(theCircuit->Value(item));
+#ifdef DRAW
+    char  *name = new char[100];
+    sprintf(name, "c%d", item);
+    DrawTrSurf::Set(name, curve);
+    delete [] name;
+#endif
     Standard_Real param = (IsOpenResult && anitem == theCircuit->NumberOfItems())?
       curve->LastParameter() : curve->FirstParameter();
     theGeomVecs.Bind(theNumberOfVecs,curve->DN(param,1));
@@ -265,6 +275,12 @@ Standard_Integer MAT2d_Tool2d::TangentAfter(const Standard_Integer anitem,
   type = theCircuit->Value(anitem)->DynamicType();
   if ( type != STANDARD_TYPE(Geom2d_CartesianPoint)){
     curve     = Handle(Geom2d_Curve)::DownCast(theCircuit->Value(anitem));
+#ifdef DRAW
+    char  *name = new char[100];
+    sprintf(name, "c%d", anitem);
+    DrawTrSurf::Set(name, curve);
+    delete [] name;
+#endif
     thevector = curve->DN(curve->FirstParameter(),1);
   }
   else {
@@ -272,7 +288,14 @@ Standard_Integer MAT2d_Tool2d::TangentAfter(const Standard_Integer anitem,
     item      = (anitem == 1) ? theCircuit->NumberOfItems() : (anitem - 1);
     else
       item = (anitem == 1) ? 2 : (anitem - 1);
+    
     curve     = Handle(Geom2d_Curve)::DownCast(theCircuit->Value(item));
+#ifdef DRAW
+    char  *name = new char[100];
+    sprintf(name, "c%d", item);
+    DrawTrSurf::Set(name, curve);
+    delete [] name;
+#endif
     Standard_Real param = (IsOpenResult && anitem == 1)?
       curve->FirstParameter() : curve->LastParameter();
     thevector = curve->DN(param,1);
@@ -397,6 +420,14 @@ void MAT2d_Tool2d::CreateBisector(const Handle(MAT_Bisector)& abisector)
   abisector->BisectorNumber(theNumberOfBisectors);
   abisector->Sense(1);
 
+#ifdef DRAW
+  char  *name = new char[100];
+  sprintf(name, "b%d", theNumberOfBisectors);
+  DrawTrSurf::Set(name, bisector.Value());
+  Dump(abisector->BisectorNumber(),1);
+  delete [] name;
+#endif
+
 #ifdef OCCT_DEBUG
   Standard_Boolean AffichDraw = Standard_False;
   if (AffichDraw) Dump(abisector->BisectorNumber(),1);
index 46fa6c978b7f49984c49fae1fa7a85585bb3fd0d..7afca519afe26bf9810c976bca8bebcc92195564 100755 (executable)
@@ -5,7 +5,6 @@ TKG3d
 TKMath
 TKBRep
 TKGeomAlgo
-TKTopAlgo
 TKShHealing
 TKMesh
 TKService
diff --git a/tests/bugs/modalg_8/bug31992 b/tests/bugs/modalg_8/bug31992
new file mode 100644 (file)
index 0000000..7e74c4d
--- /dev/null
@@ -0,0 +1,64 @@
+puts "=============================================="
+puts "OCC31992: Offset of closed B-spline edge fails"
+puts "=============================================="
+puts ""
+
+restore [locate_data_file bug31992.brep] a
+wire a a
+mkplane a a
+
+mkoffset result a 20 0.1 -approx
+
+top
+fit
+
+checkview -screenshot -2d -path ${imagedir}/${test_image}.png
+
+for {set i 1} {$i<=20} {incr i} {
+       checkshape result_${i}
+       set tolres [checkmaxtol result_${i}]
+       if { ${tolres} > 1.001e-7} {
+               puts "Error: bad tolerance of result"
+       }
+}
+
+checknbshapes result_1 -t -vertex 175 -edge 175 -wire 1
+checkprops result_1 -l 9.16454
+checknbshapes result_2 -t -vertex 175 -edge 175 -wire 1
+checkprops result_2 -l 9.79285
+checknbshapes result_3 -t -vertex 175 -edge 175 -wire 1
+checkprops result_3 -l 10.4212
+checknbshapes result_4 -t -vertex 175 -edge 175 -wire 1
+checkprops result_4 -l 11.0495
+checknbshapes result_5 -t -vertex 175 -edge 175 -wire 1
+checkprops result_5 -l 11.6778
+checknbshapes result_6 -t -vertex 173 -edge 173 -wire 1
+checkprops result_6 -l 12.3061
+checknbshapes result_7 -t -vertex 169 -edge 169 -wire 1
+checkprops result_7 -l 12.9344
+checknbshapes result_8 -t -vertex 167 -edge 167 -wire 1
+checkprops result_8 -l 13.5626
+checknbshapes result_9 -t -vertex 165 -edge 165 -wire 1
+checkprops result_9 -l 14.1907
+checknbshapes result_10 -t -vertex 162 -edge 162 -wire 1
+checkprops result_10 -l 14.8189
+checknbshapes result_11 -t -vertex 158 -edge 158 -wire 1
+checkprops result_11 -l 15.447
+checknbshapes result_12 -t -vertex 155 -edge 155 -wire 1
+checkprops result_12 -l 16.0748
+checknbshapes result_13 -t -vertex 154 -edge 154 -wire 1
+checkprops result_13 -l 16.7025
+checknbshapes result_14 -t -vertex 152 -edge 152 -wire 1
+checkprops result_14 -l 17.3303
+checknbshapes result_15 -t -vertex 150 -edge 150 -wire 1
+checkprops result_15 -l 17.958
+checknbshapes result_16 -t -vertex 148 -edge 148 -wire 1
+checkprops result_16 -l 18.5855
+checknbshapes result_17 -t -vertex 147 -edge 147 -wire 1
+checkprops result_17 -l 19.213
+checknbshapes result_18 -t -vertex 147 -edge 147 -wire 1
+checkprops result_18 -l 19.8405
+checknbshapes result_19 -t -vertex 146 -edge 146 -wire 1
+checkprops result_19 -l 20.4681
+checknbshapes result_20 -t -vertex 145 -edge 145 -wire 1
+checkprops result_20 -l 21.0957
index 31d1217a4091d3f3826325016e8953dc94d95cc4..ae71ced38f30c29eefb15fd66f967afaad522c95 100644 (file)
@@ -22,31 +22,31 @@ for {set i 1} {$i<=14} {incr i} {
        }
 }
 
-checknbshapes result_1 -t -vertex 114 -edge 114 -wire 1
+checknbshapes result_1 -t -vertex 83 -edge 83 -wire 1
 checkprops result_1 -l 4.39365
-checknbshapes result_2 -t -vertex 110 -edge 110 -wire 1
+checknbshapes result_2 -t -vertex 79 -edge 79 -wire 1
 checkprops result_2 -l 5.02084
-checknbshapes result_3 -t -vertex 104 -edge 104 -wire 1
+checknbshapes result_3 -t -vertex 76 -edge 76 -wire 1
 checkprops result_3 -l 5.64778
-checknbshapes result_4 -t -vertex 101 -edge 101 -wire 1
+checknbshapes result_4 -t -vertex 74 -edge 74 -wire 1
 checkprops result_4 -l 6.27443
-checknbshapes result_5 -t -vertex 95 -edge 95 -wire 1
+checknbshapes result_5 -t -vertex 70 -edge 70 -wire 1
 checkprops result_5 -l 6.89816
-checknbshapes result_6 -t -vertex 92 -edge 92 -wire 1
+checknbshapes result_6 -t -vertex 66 -edge 66 -wire 1
 checkprops result_6 -l 7.51255
-checknbshapes result_7 -t -vertex 88 -edge 88 -wire 1
+checknbshapes result_7 -t -vertex 65 -edge 65 -wire 1
 checkprops result_7 -l 8.12807
-checknbshapes result_8 -t -vertex 81 -edge 81 -wire 1
+checknbshapes result_8 -t -vertex 59 -edge 59 -wire 1
 checkprops result_8 -l 8.74586
-checknbshapes result_9 -t -vertex 72 -edge 72 -wire 1
+checknbshapes result_9 -t -vertex 53 -edge 53 -wire 1
 checkprops result_9 -l 9.36292
-checknbshapes result_10 -t -vertex 65 -edge 65 -wire 1
+checknbshapes result_10 -t -vertex 51 -edge 51 -wire 1
 checkprops result_10 -l 9.97455
-checknbshapes result_11 -t -vertex 60 -edge 60 -wire 1
+checknbshapes result_11 -t -vertex 50 -edge 50 -wire 1
 checkprops result_11 -l 10.5864
-checknbshapes result_12 -t -vertex 59 -edge 59 -wire 1
+checknbshapes result_12 -t -vertex 49 -edge 49 -wire 1
 checkprops result_12 -l 11.2017
-checknbshapes result_13 -t -vertex 57 -edge 57 -wire 1
+checknbshapes result_13 -t -vertex 49 -edge 49 -wire 1
 checkprops result_13 -l 11.8196
-checknbshapes result_14 -t -vertex 55 -edge 55 -wire 1
+checknbshapes result_14 -t -vertex 47 -edge 47 -wire 1
 checkprops result_14 -l 12.4395
index fa6eb5c7c6cc3fee3e92aa555ca6ff82e3f213e0..47b83e43e56683cb32a807b397696601fe359e9a 100644 (file)
@@ -22,31 +22,31 @@ for {set i 1} {$i<=14} {incr i} {
        }
 }
 
-checknbshapes result_1 -t -vertex 61 -edge 60 -wire 1
+checknbshapes result_1 -t -vertex 47 -edge 46 -wire 1
 checkprops result_1 -l 2.04858
-checknbshapes result_2 -t -vertex 61 -edge 60 -wire 1
+checknbshapes result_2 -t -vertex 47 -edge 46 -wire 1
 checkprops result_2 -l 2.21414
-checknbshapes result_3 -t -vertex 61 -edge 60 -wire 1
+checknbshapes result_3 -t -vertex 47 -edge 46 -wire 1
 checkprops result_3 -l 2.37971
-checknbshapes result_4 -t -vertex 61 -edge 60 -wire 1
+checknbshapes result_4 -t -vertex 47 -edge 46 -wire 1
 checkprops result_4 -l 2.54528
-checknbshapes result_5 -t -vertex 61 -edge 60 -wire 1
+checknbshapes result_5 -t -vertex 47 -edge 46 -wire 1
 checkprops result_5 -l 2.71084
-checknbshapes result_6 -t -vertex 61 -edge 60 -wire 1
+checknbshapes result_6 -t -vertex 47 -edge 46 -wire 1
 checkprops result_6 -l 2.87641
-checknbshapes result_7 -t -vertex 61 -edge 60 -wire 1
+checknbshapes result_7 -t -vertex 47 -edge 46 -wire 1
 checkprops result_7 -l 3.04198
-checknbshapes result_8 -t -vertex 56 -edge 55 -wire 1
+checknbshapes result_8 -t -vertex 43 -edge 42 -wire 1
 checkprops result_8 -l 3.20723
-checknbshapes result_9 -t -vertex 50 -edge 49 -wire 1
-checkprops result_9 -l 3.38587
-checknbshapes result_10 -t -vertex 48 -edge 47 -wire 1
+checknbshapes result_9 -t -vertex 38 -edge 37 -wire 1
+checkprops result_9 -l 3.32866
+checknbshapes result_10 -t -vertex 38 -edge 37 -wire 1
 checkprops result_10 -l 3.58204
-checknbshapes result_11 -t -vertex 45 -edge 44 -wire 1
-checkprops result_11 -l 3.73715
-checknbshapes result_12 -t -vertex 45 -edge 44 -wire 1
-checkprops result_12 -l 3.97323
-checknbshapes result_13 -t -vertex 43 -edge 42 -wire 1
+checknbshapes result_11 -t -vertex 37 -edge 36 -wire 1
+checkprops result_11 -l 3.67639
+checknbshapes result_12 -t -vertex 37 -edge 36 -wire 1
+checkprops result_12 -l 3.90941
+checknbshapes result_13 -t -vertex 37 -edge 36 -wire 1
 checkprops result_13 -l 4.14242
-checknbshapes result_14 -t -vertex 43 -edge 42 -wire 1
+checknbshapes result_14 -t -vertex 37 -edge 36 -wire 1
 checkprops result_14 -l 4.37544
index 732073bbeff2247cd8501567d6c149ec4357fc8b..251dd8e097a4f16eb4d6a49299327b1f39350261 100644 (file)
@@ -22,31 +22,31 @@ for {set i 1} {$i<=14} {incr i} {
        }
 }
 
-checknbshapes result_1 -t -vertex 50 -edge 49 -wire 1
+checknbshapes result_1 -t -vertex 33 -edge 32 -wire 1
 checkprops result_1 -l 1.66475
-checknbshapes result_2 -t -vertex 46 -edge 45 -wire 1
-checkprops result_2 -l 1.57655
-checknbshapes result_3 -t -vertex 40 -edge 39 -wire 1
-checkprops result_3 -l 1.48755
-checknbshapes result_4 -t -vertex 37 -edge 36 -wire 1
+checknbshapes result_2 -t -vertex 29 -edge 28 -wire 1
+checkprops result_2 -l 1.56032
+checknbshapes result_3 -t -vertex 26 -edge 25 -wire 1
+checkprops result_3 -l 1.45922
+checknbshapes result_4 -t -vertex 24 -edge 23 -wire 1
 checkprops result_4 -l 1.39682
-checknbshapes result_5 -t -vertex 31 -edge 30 -wire 1
+checknbshapes result_5 -t -vertex 20 -edge 19 -wire 1
 checkprops result_5 -l 1.30715
-checknbshapes result_6 -t -vertex 28 -edge 27 -wire 1
+checknbshapes result_6 -t -vertex 16 -edge 15 -wire 1
 checkprops result_6 -l 1.27033
-checknbshapes result_7 -t -vertex 24 -edge 23 -wire 1
+checknbshapes result_7 -t -vertex 15 -edge 14 -wire 1
 checkprops result_7 -l 1.1996
-checknbshapes result_8 -t -vertex 22 -edge 21 -wire 1
+checknbshapes result_8 -t -vertex 13 -edge 12 -wire 1
 checkprops result_8 -l 1.1737
-checknbshapes result_9 -t -vertex 18 -edge 17 -wire 1
+checknbshapes result_9 -t -vertex 11 -edge 10 -wire 1
 checkprops result_9 -l 1.17713
-checknbshapes result_10 -t -vertex 17 -edge 16 -wire 1
-checkprops result_10 -l 1.22711
-checknbshapes result_11 -t -vertex 14 -edge 13 -wire 1
-checkprops result_11 -l 1.2663
-checknbshapes result_12 -t -vertex 14 -edge 13 -wire 1
-checkprops result_12 -l 1.33108
-checknbshapes result_13 -t -vertex 14 -edge 13 -wire 1
-checkprops result_13 -l 1.39586
-checknbshapes result_14 -t -vertex 14 -edge 13 -wire 1
-checkprops result_14 -l 1.46064
+checknbshapes result_10 -t -vertex 9 -edge 8 -wire 1
+checkprops result_10 -l 1.11521
+checknbshapes result_11 -t -vertex 9 -edge 8 -wire 1
+checkprops result_11 -l 1.17655
+checknbshapes result_12 -t -vertex 8 -edge 7 -wire 1
+checkprops result_12 -l 1.10597
+checknbshapes result_13 -t -vertex 8 -edge 7 -wire 1
+checkprops result_13 -l 1.16139
+checknbshapes result_14 -t -vertex 6 -edge 5 -wire 1
+checkprops result_14 -l 1.06775