From c6f14a5213cbb74286f671f38882abc36b294b4d Mon Sep 17 00:00:00 2001
From: jgv <jgv@opencascade.com>
Date: Mon, 18 May 2020 16:27:55 +0300
Subject: [PATCH] 0031558: BRepOffsetAPI_MakeFilling algorithm makes turned
 inside out face

1. Modification in method BRepFill_Filling::Build - correction of building the wire.
2. Create new subgroup "filling" in the group "bugs".
---
 src/BRepFill/BRepFill_Filling.cxx          |  5 ++--
 tests/bugs/filling/begin                   |  4 +++
 tests/bugs/{moddata_1 => filling}/bug13904 |  0
 tests/bugs/{moddata_1 => filling}/bug16119 |  0
 tests/bugs/{moddata_1 => filling}/bug16833 |  0
 tests/bugs/{modalg_2 => filling}/bug22783  |  0
 tests/bugs/{modalg_2 => filling}/bug22786  |  0
 tests/bugs/{modalg_7 => filling}/bug23343  |  0
 tests/bugs/{modalg_7 => filling}/bug23380  |  0
 tests/bugs/{modalg_6 => filling}/bug27775  |  0
 tests/bugs/{modalg_6 => filling}/bug27873  |  0
 tests/bugs/{modalg_7 => filling}/bug31464  |  0
 tests/bugs/filling/bug31558                | 29 ++++++++++++++++++++++
 tests/bugs/grids.list                      |  1 +
 tests/bugs/{modalg_6 => heal}/bug26466     |  0
 tests/bugs/{modalg_7 => heal}/bug27004     |  0
 tests/bugs/{modalg_6 => heal}/bug27082_1   |  0
 tests/bugs/{modalg_6 => heal}/bug27082_1i  |  0
 tests/bugs/{modalg_6 => heal}/bug27082_2   |  0
 tests/bugs/{modalg_6 => heal}/bug27082_2i  |  0
 tests/bugs/{modalg_6 => heal}/bug27082_3   |  0
 tests/bugs/{modalg_6 => heal}/bug27082_3i  |  0
 tests/bugs/{modalg_6 => heal}/bug27199     |  0
 tests/bugs/{modalg_6 => heal}/bug27271     |  0
 tests/bugs/{modalg_6 => heal}/bug27309     |  0
 tests/bugs/{modalg_6 => heal}/bug27315     |  0
 tests/bugs/{modalg_6 => heal}/bug27521_1   |  0
 tests/bugs/{modalg_6 => heal}/bug27521_2   |  0
 tests/bugs/{modalg_6 => heal}/bug28207     |  0
 tests/bugs/{modalg_6 => heal}/bug28343_1   |  0
 tests/bugs/{modalg_6 => heal}/bug28343_2   |  0
 tests/bugs/{modalg_7 => heal}/bug28995     |  0
 tests/bugs/{modalg_7 => heal}/bug29382     |  0
 tests/bugs/{modalg_7 => heal}/bug29502     |  0
 tests/bugs/{modalg_7 => heal}/bug29504_1   |  0
 tests/bugs/{modalg_7 => heal}/bug29504_2   |  0
 tests/bugs/{modalg_7 => heal}/bug29544_1   |  0
 tests/bugs/{modalg_7 => heal}/bug29544_2   |  0
 tests/bugs/{modalg_7 => heal}/bug29845     |  0
 tests/bugs/{modalg_7 => heal}/bug30099     |  0
 tests/bugs/{modalg_7 => heal}/bug30100_1   |  0
 tests/bugs/{modalg_7 => heal}/bug30158_1   |  0
 tests/bugs/{modalg_7 => heal}/bug30158_2   |  0
 tests/bugs/{modalg_7 => heal}/bug30174     |  0
 tests/bugs/{modalg_7 => heal}/bug30534     |  0
 tests/bugs/{modalg_7 => heal}/bug30714     |  0
 tests/bugs/{modalg_7 => heal}/bug30897     |  0
 tests/bugs/{modalg_7 => heal}/bug30905     |  0
 tests/bugs/{modalg_7 => heal}/bug30927     |  0
 tests/bugs/{modalg_7 => heal}/bug31066     |  0
 tests/bugs/{modalg_7 => heal}/bug31187     |  0
 tests/bugs/{modalg_7 => heal}/bug31441     |  0
 52 files changed, 36 insertions(+), 3 deletions(-)
 create mode 100644 tests/bugs/filling/begin
 rename tests/bugs/{moddata_1 => filling}/bug13904 (100%)
 mode change 100755 => 100644
 rename tests/bugs/{moddata_1 => filling}/bug16119 (100%)
 mode change 100755 => 100644
 rename tests/bugs/{moddata_1 => filling}/bug16833 (100%)
 mode change 100755 => 100644
 rename tests/bugs/{modalg_2 => filling}/bug22783 (100%)
 mode change 100755 => 100644
 rename tests/bugs/{modalg_2 => filling}/bug22786 (100%)
 mode change 100755 => 100644
 rename tests/bugs/{modalg_7 => filling}/bug23343 (100%)
 mode change 100755 => 100644
 rename tests/bugs/{modalg_7 => filling}/bug23380 (100%)
 rename tests/bugs/{modalg_6 => filling}/bug27775 (100%)
 rename tests/bugs/{modalg_6 => filling}/bug27873 (100%)
 rename tests/bugs/{modalg_7 => filling}/bug31464 (100%)
 create mode 100644 tests/bugs/filling/bug31558
 rename tests/bugs/{modalg_6 => heal}/bug26466 (100%)
 rename tests/bugs/{modalg_7 => heal}/bug27004 (100%)
 rename tests/bugs/{modalg_6 => heal}/bug27082_1 (100%)
 rename tests/bugs/{modalg_6 => heal}/bug27082_1i (100%)
 rename tests/bugs/{modalg_6 => heal}/bug27082_2 (100%)
 rename tests/bugs/{modalg_6 => heal}/bug27082_2i (100%)
 rename tests/bugs/{modalg_6 => heal}/bug27082_3 (100%)
 rename tests/bugs/{modalg_6 => heal}/bug27082_3i (100%)
 rename tests/bugs/{modalg_6 => heal}/bug27199 (100%)
 rename tests/bugs/{modalg_6 => heal}/bug27271 (100%)
 rename tests/bugs/{modalg_6 => heal}/bug27309 (100%)
 rename tests/bugs/{modalg_6 => heal}/bug27315 (100%)
 rename tests/bugs/{modalg_6 => heal}/bug27521_1 (100%)
 rename tests/bugs/{modalg_6 => heal}/bug27521_2 (100%)
 rename tests/bugs/{modalg_6 => heal}/bug28207 (100%)
 rename tests/bugs/{modalg_6 => heal}/bug28343_1 (100%)
 rename tests/bugs/{modalg_6 => heal}/bug28343_2 (100%)
 rename tests/bugs/{modalg_7 => heal}/bug28995 (100%)
 rename tests/bugs/{modalg_7 => heal}/bug29382 (100%)
 rename tests/bugs/{modalg_7 => heal}/bug29502 (100%)
 rename tests/bugs/{modalg_7 => heal}/bug29504_1 (100%)
 rename tests/bugs/{modalg_7 => heal}/bug29504_2 (100%)
 rename tests/bugs/{modalg_7 => heal}/bug29544_1 (100%)
 rename tests/bugs/{modalg_7 => heal}/bug29544_2 (100%)
 rename tests/bugs/{modalg_7 => heal}/bug29845 (100%)
 rename tests/bugs/{modalg_7 => heal}/bug30099 (100%)
 rename tests/bugs/{modalg_7 => heal}/bug30100_1 (100%)
 rename tests/bugs/{modalg_7 => heal}/bug30158_1 (100%)
 rename tests/bugs/{modalg_7 => heal}/bug30158_2 (100%)
 rename tests/bugs/{modalg_7 => heal}/bug30174 (100%)
 rename tests/bugs/{modalg_7 => heal}/bug30534 (100%)
 rename tests/bugs/{modalg_7 => heal}/bug30714 (100%)
 rename tests/bugs/{modalg_7 => heal}/bug30897 (100%)
 rename tests/bugs/{modalg_7 => heal}/bug30905 (100%)
 rename tests/bugs/{modalg_7 => heal}/bug30927 (100%)
 rename tests/bugs/{modalg_7 => heal}/bug31066 (100%)
 rename tests/bugs/{modalg_7 => heal}/bug31187 (100%)
 rename tests/bugs/{modalg_7 => heal}/bug31441 (100%)

diff --git a/src/BRepFill/BRepFill_Filling.cxx b/src/BRepFill/BRepFill_Filling.cxx
index fedf0c307f..d45e19c3f9 100644
--- a/src/BRepFill/BRepFill_Filling.cxx
+++ b/src/BRepFill/BRepFill_Filling.cxx
@@ -721,6 +721,7 @@ void BRepFill_Filling::Build()
       gp_Pnt aPnt = BRep_Tool::Pnt(V1);
       NewV1 = BRepLib_MakeVertex(aPnt);
       BB.UpdateVertex(NewV1, dmax);
+      myOldNewMap.Bind(V1.Oriented(TopAbs_FORWARD), NewV1);
     }
 
     if (myOldNewMap.IsBound(V2))
@@ -730,6 +731,7 @@ void BRepFill_Filling::Build()
       gp_Pnt aPnt = BRep_Tool::Pnt(V2);
       NewV2 = BRepLib_MakeVertex(aPnt);
       BB.UpdateVertex(NewV2, dmax);
+      myOldNewMap.Bind(V2.Oriented(TopAbs_FORWARD), NewV2);
     }
 
     NewV1.Orientation(TopAbs_FORWARD);
@@ -742,9 +744,6 @@ void BRepFill_Filling::Build()
     BRepLib::SameParameter(NewEdge, dmax, Standard_True);
     FinalEdges.Append(NewEdge);
     myOldNewMap.Bind(InitEdge.Oriented(TopAbs_FORWARD), NewEdge.Oriented(TopAbs_FORWARD));
-    myOldNewMap.Bind(V1.Oriented(TopAbs_FORWARD), NewV1.Oriented(TopAbs_FORWARD));
-    if (!V1.IsSame(V2))
-      myOldNewMap.Bind(V2.Oriented(TopAbs_FORWARD), NewV2.Oriented(TopAbs_FORWARD));
   }
   
   TopoDS_Wire FinalWire = WireFromList(FinalEdges);
diff --git a/tests/bugs/filling/begin b/tests/bugs/filling/begin
new file mode 100644
index 0000000000..e18313fb61
--- /dev/null
+++ b/tests/bugs/filling/begin
@@ -0,0 +1,4 @@
+set subgroup filling
+
+
+
diff --git a/tests/bugs/moddata_1/bug13904 b/tests/bugs/filling/bug13904
old mode 100755
new mode 100644
similarity index 100%
rename from tests/bugs/moddata_1/bug13904
rename to tests/bugs/filling/bug13904
diff --git a/tests/bugs/moddata_1/bug16119 b/tests/bugs/filling/bug16119
old mode 100755
new mode 100644
similarity index 100%
rename from tests/bugs/moddata_1/bug16119
rename to tests/bugs/filling/bug16119
diff --git a/tests/bugs/moddata_1/bug16833 b/tests/bugs/filling/bug16833
old mode 100755
new mode 100644
similarity index 100%
rename from tests/bugs/moddata_1/bug16833
rename to tests/bugs/filling/bug16833
diff --git a/tests/bugs/modalg_2/bug22783 b/tests/bugs/filling/bug22783
old mode 100755
new mode 100644
similarity index 100%
rename from tests/bugs/modalg_2/bug22783
rename to tests/bugs/filling/bug22783
diff --git a/tests/bugs/modalg_2/bug22786 b/tests/bugs/filling/bug22786
old mode 100755
new mode 100644
similarity index 100%
rename from tests/bugs/modalg_2/bug22786
rename to tests/bugs/filling/bug22786
diff --git a/tests/bugs/modalg_7/bug23343 b/tests/bugs/filling/bug23343
old mode 100755
new mode 100644
similarity index 100%
rename from tests/bugs/modalg_7/bug23343
rename to tests/bugs/filling/bug23343
diff --git a/tests/bugs/modalg_7/bug23380 b/tests/bugs/filling/bug23380
similarity index 100%
rename from tests/bugs/modalg_7/bug23380
rename to tests/bugs/filling/bug23380
diff --git a/tests/bugs/modalg_6/bug27775 b/tests/bugs/filling/bug27775
similarity index 100%
rename from tests/bugs/modalg_6/bug27775
rename to tests/bugs/filling/bug27775
diff --git a/tests/bugs/modalg_6/bug27873 b/tests/bugs/filling/bug27873
similarity index 100%
rename from tests/bugs/modalg_6/bug27873
rename to tests/bugs/filling/bug27873
diff --git a/tests/bugs/modalg_7/bug31464 b/tests/bugs/filling/bug31464
similarity index 100%
rename from tests/bugs/modalg_7/bug31464
rename to tests/bugs/filling/bug31464
diff --git a/tests/bugs/filling/bug31558 b/tests/bugs/filling/bug31558
new file mode 100644
index 0000000000..f00454846d
--- /dev/null
+++ b/tests/bugs/filling/bug31558
@@ -0,0 +1,29 @@
+puts "=========================================================================="
+puts "OCC31558: BRepOffsetAPI_MakeFilling algorithm makes turned inside out face"
+puts "=========================================================================="
+puts ""
+
+brestore [locate_data_file bug31558.brep] a
+
+explode a e
+
+filling result 1 0 9  a_2 0  3.5000410449283663 0.62831853071795896 a 1  3.5000410449283663 1.2566370614359179 a 1  3.5000410449283663 1.8849555921538768 a 1  3.5000410449283663 2.5132741228718358 a 1  3.5000410449283663 3.1415926535897949 a 1  3.5000410449283663 3.7699111843077535 a 1  3.5000410449283663 4.3982297150257130 a 1  3.5000410449283663 5.0265482457436717 a 1  3.5000410449283663 5.6548667764616303 a 1
+
+checkshape result
+
+checknbshapes result -face 1 -wire 1 -edge 1 -vertex 1
+
+set tolres [checkmaxtol result]
+
+if { ${tolres} > 2.e-5} {
+   puts "Error: bad tolerance of result"
+}
+
+checkprops result -s 153.938
+
+smallview
+isos result 10
+donly result
+fit
+
+checkview -screenshot -2d -path ${imagedir}/${test_image}.png
diff --git a/tests/bugs/grids.list b/tests/bugs/grids.list
index 1dbf87494d..98f0679746 100755
--- a/tests/bugs/grids.list
+++ b/tests/bugs/grids.list
@@ -20,3 +20,4 @@
 020 stlvrml
 021 splitshape
 022 splitshape_1
+023 filling
\ No newline at end of file
diff --git a/tests/bugs/modalg_6/bug26466 b/tests/bugs/heal/bug26466
similarity index 100%
rename from tests/bugs/modalg_6/bug26466
rename to tests/bugs/heal/bug26466
diff --git a/tests/bugs/modalg_7/bug27004 b/tests/bugs/heal/bug27004
similarity index 100%
rename from tests/bugs/modalg_7/bug27004
rename to tests/bugs/heal/bug27004
diff --git a/tests/bugs/modalg_6/bug27082_1 b/tests/bugs/heal/bug27082_1
similarity index 100%
rename from tests/bugs/modalg_6/bug27082_1
rename to tests/bugs/heal/bug27082_1
diff --git a/tests/bugs/modalg_6/bug27082_1i b/tests/bugs/heal/bug27082_1i
similarity index 100%
rename from tests/bugs/modalg_6/bug27082_1i
rename to tests/bugs/heal/bug27082_1i
diff --git a/tests/bugs/modalg_6/bug27082_2 b/tests/bugs/heal/bug27082_2
similarity index 100%
rename from tests/bugs/modalg_6/bug27082_2
rename to tests/bugs/heal/bug27082_2
diff --git a/tests/bugs/modalg_6/bug27082_2i b/tests/bugs/heal/bug27082_2i
similarity index 100%
rename from tests/bugs/modalg_6/bug27082_2i
rename to tests/bugs/heal/bug27082_2i
diff --git a/tests/bugs/modalg_6/bug27082_3 b/tests/bugs/heal/bug27082_3
similarity index 100%
rename from tests/bugs/modalg_6/bug27082_3
rename to tests/bugs/heal/bug27082_3
diff --git a/tests/bugs/modalg_6/bug27082_3i b/tests/bugs/heal/bug27082_3i
similarity index 100%
rename from tests/bugs/modalg_6/bug27082_3i
rename to tests/bugs/heal/bug27082_3i
diff --git a/tests/bugs/modalg_6/bug27199 b/tests/bugs/heal/bug27199
similarity index 100%
rename from tests/bugs/modalg_6/bug27199
rename to tests/bugs/heal/bug27199
diff --git a/tests/bugs/modalg_6/bug27271 b/tests/bugs/heal/bug27271
similarity index 100%
rename from tests/bugs/modalg_6/bug27271
rename to tests/bugs/heal/bug27271
diff --git a/tests/bugs/modalg_6/bug27309 b/tests/bugs/heal/bug27309
similarity index 100%
rename from tests/bugs/modalg_6/bug27309
rename to tests/bugs/heal/bug27309
diff --git a/tests/bugs/modalg_6/bug27315 b/tests/bugs/heal/bug27315
similarity index 100%
rename from tests/bugs/modalg_6/bug27315
rename to tests/bugs/heal/bug27315
diff --git a/tests/bugs/modalg_6/bug27521_1 b/tests/bugs/heal/bug27521_1
similarity index 100%
rename from tests/bugs/modalg_6/bug27521_1
rename to tests/bugs/heal/bug27521_1
diff --git a/tests/bugs/modalg_6/bug27521_2 b/tests/bugs/heal/bug27521_2
similarity index 100%
rename from tests/bugs/modalg_6/bug27521_2
rename to tests/bugs/heal/bug27521_2
diff --git a/tests/bugs/modalg_6/bug28207 b/tests/bugs/heal/bug28207
similarity index 100%
rename from tests/bugs/modalg_6/bug28207
rename to tests/bugs/heal/bug28207
diff --git a/tests/bugs/modalg_6/bug28343_1 b/tests/bugs/heal/bug28343_1
similarity index 100%
rename from tests/bugs/modalg_6/bug28343_1
rename to tests/bugs/heal/bug28343_1
diff --git a/tests/bugs/modalg_6/bug28343_2 b/tests/bugs/heal/bug28343_2
similarity index 100%
rename from tests/bugs/modalg_6/bug28343_2
rename to tests/bugs/heal/bug28343_2
diff --git a/tests/bugs/modalg_7/bug28995 b/tests/bugs/heal/bug28995
similarity index 100%
rename from tests/bugs/modalg_7/bug28995
rename to tests/bugs/heal/bug28995
diff --git a/tests/bugs/modalg_7/bug29382 b/tests/bugs/heal/bug29382
similarity index 100%
rename from tests/bugs/modalg_7/bug29382
rename to tests/bugs/heal/bug29382
diff --git a/tests/bugs/modalg_7/bug29502 b/tests/bugs/heal/bug29502
similarity index 100%
rename from tests/bugs/modalg_7/bug29502
rename to tests/bugs/heal/bug29502
diff --git a/tests/bugs/modalg_7/bug29504_1 b/tests/bugs/heal/bug29504_1
similarity index 100%
rename from tests/bugs/modalg_7/bug29504_1
rename to tests/bugs/heal/bug29504_1
diff --git a/tests/bugs/modalg_7/bug29504_2 b/tests/bugs/heal/bug29504_2
similarity index 100%
rename from tests/bugs/modalg_7/bug29504_2
rename to tests/bugs/heal/bug29504_2
diff --git a/tests/bugs/modalg_7/bug29544_1 b/tests/bugs/heal/bug29544_1
similarity index 100%
rename from tests/bugs/modalg_7/bug29544_1
rename to tests/bugs/heal/bug29544_1
diff --git a/tests/bugs/modalg_7/bug29544_2 b/tests/bugs/heal/bug29544_2
similarity index 100%
rename from tests/bugs/modalg_7/bug29544_2
rename to tests/bugs/heal/bug29544_2
diff --git a/tests/bugs/modalg_7/bug29845 b/tests/bugs/heal/bug29845
similarity index 100%
rename from tests/bugs/modalg_7/bug29845
rename to tests/bugs/heal/bug29845
diff --git a/tests/bugs/modalg_7/bug30099 b/tests/bugs/heal/bug30099
similarity index 100%
rename from tests/bugs/modalg_7/bug30099
rename to tests/bugs/heal/bug30099
diff --git a/tests/bugs/modalg_7/bug30100_1 b/tests/bugs/heal/bug30100_1
similarity index 100%
rename from tests/bugs/modalg_7/bug30100_1
rename to tests/bugs/heal/bug30100_1
diff --git a/tests/bugs/modalg_7/bug30158_1 b/tests/bugs/heal/bug30158_1
similarity index 100%
rename from tests/bugs/modalg_7/bug30158_1
rename to tests/bugs/heal/bug30158_1
diff --git a/tests/bugs/modalg_7/bug30158_2 b/tests/bugs/heal/bug30158_2
similarity index 100%
rename from tests/bugs/modalg_7/bug30158_2
rename to tests/bugs/heal/bug30158_2
diff --git a/tests/bugs/modalg_7/bug30174 b/tests/bugs/heal/bug30174
similarity index 100%
rename from tests/bugs/modalg_7/bug30174
rename to tests/bugs/heal/bug30174
diff --git a/tests/bugs/modalg_7/bug30534 b/tests/bugs/heal/bug30534
similarity index 100%
rename from tests/bugs/modalg_7/bug30534
rename to tests/bugs/heal/bug30534
diff --git a/tests/bugs/modalg_7/bug30714 b/tests/bugs/heal/bug30714
similarity index 100%
rename from tests/bugs/modalg_7/bug30714
rename to tests/bugs/heal/bug30714
diff --git a/tests/bugs/modalg_7/bug30897 b/tests/bugs/heal/bug30897
similarity index 100%
rename from tests/bugs/modalg_7/bug30897
rename to tests/bugs/heal/bug30897
diff --git a/tests/bugs/modalg_7/bug30905 b/tests/bugs/heal/bug30905
similarity index 100%
rename from tests/bugs/modalg_7/bug30905
rename to tests/bugs/heal/bug30905
diff --git a/tests/bugs/modalg_7/bug30927 b/tests/bugs/heal/bug30927
similarity index 100%
rename from tests/bugs/modalg_7/bug30927
rename to tests/bugs/heal/bug30927
diff --git a/tests/bugs/modalg_7/bug31066 b/tests/bugs/heal/bug31066
similarity index 100%
rename from tests/bugs/modalg_7/bug31066
rename to tests/bugs/heal/bug31066
diff --git a/tests/bugs/modalg_7/bug31187 b/tests/bugs/heal/bug31187
similarity index 100%
rename from tests/bugs/modalg_7/bug31187
rename to tests/bugs/heal/bug31187
diff --git a/tests/bugs/modalg_7/bug31441 b/tests/bugs/heal/bug31441
similarity index 100%
rename from tests/bugs/modalg_7/bug31441
rename to tests/bugs/heal/bug31441