]> OCCT Git - occt.git/commitdiff
0033298: Modeling Algorithm - Offset operation gives wrong result CR0-WEEK-1 IR-2023-01-06
authorakaftasev <akaftasev@opencascade.com>
Wed, 21 Dec 2022 19:11:49 +0000 (22:11 +0300)
committerVadim Glukhikh <vadim.glukhikh@opencascade.com>
Tue, 3 Jan 2023 18:01:14 +0000 (18:01 +0000)
Process only those images of the faces, if one if them has anInsideEdges/anInsideVertices and the other is not.

src/BRepOffset/BRepOffset_MakeOffset_1.cxx
tests/offset/shape_type_i_c/WA1 [new file with mode: 0644]
tests/offset/shape_type_i_c/WA2 [new file with mode: 0644]
tests/offset/shape_type_i_c/XZ3

index 04359001d29f66bced7f8933d6d248d77a33fe8e..758ed4a7130d0089e0e14a5281a12e896efe6b9d 100644 (file)
@@ -5225,7 +5225,6 @@ void BRepOffset_BuildOffsetFaces::FilterInvalidEdges (const BRepOffset_DataMapOf
     const TopTools_ListOfShape* pEOrigins = myOEOrigins.Seek (aE);
     if (!pEOrigins)
     {
-      theMEUseInRebuild.Add (aE);
       continue;
     }
 
@@ -5393,6 +5392,29 @@ void BRepOffset_BuildOffsetFaces::FindFacesToRebuild()
   }
 }
 
+
+namespace
+{
+//=======================================================================
+//function : mapShapes
+//purpose  : Collect theVecShapes into theMap with setted theType
+//=======================================================================
+  template<class Container>
+  static void mapShapes (const Container& theVecShapes, 
+                         const TopAbs_ShapeEnum theType,
+                         TopTools_MapOfShape& theMap)
+  {
+    for (const auto& aShape : theVecShapes)
+    {
+      for (TopExp_Explorer anExp(aShape, theType); anExp.More(); anExp.Next())
+      {
+        theMap.Add(anExp.Current());
+      }
+    }
+  }
+}
+
+
 //=======================================================================
 //function : IntersectFaces
 //purpose  : Intersection of the faces that should be rebuild to resolve all invalidities
@@ -5715,7 +5737,10 @@ void BRepOffset_BuildOffsetFaces::IntersectFaces (TopTools_MapOfShape& theVertsT
       TopoDS_Compound aCBE;
       aBB.MakeCompound (aCBE);
       //
-      TopExp_Explorer aExp (aCBInv, TopAbs_EDGE);
+      // remember inside edges and vertices to further check
+      TopTools_MapOfShape anInsideEdges;
+      TopTools_MapOfShape anInsideVertices;
+      TopExp_Explorer aExp(aCBInv, TopAbs_EDGE);
       for (; aExp.More(); aExp.Next())
       {
         const TopoDS_Shape& aE = aExp.Current();
@@ -5724,6 +5749,15 @@ void BRepOffset_BuildOffsetFaces::IntersectFaces (TopTools_MapOfShape& theVertsT
           if (aMEFence.Add (aE))
           {
             aBB.Add (aCBE, aE);
+            if (!myEdgesToAvoid.Contains(aE) && myInvalidEdges.Contains(aE))
+            {
+              anInsideEdges.Add(aE);
+              TopoDS_Iterator anIt(aE);
+              for (; anIt.More(); anIt.Next())
+              {
+                anInsideVertices.Add(anIt.Value());
+              }
+            }
           }
         }
       }
@@ -5749,10 +5783,6 @@ void BRepOffset_BuildOffsetFaces::IntersectFaces (TopTools_MapOfShape& theVertsT
         TopExp::MapShapes (aCBELoc, TopAbs_EDGE, aME);
         aMECV = aME;
         TopExp::MapShapes (aCBELoc, TopAbs_VERTEX, aME);
-        //
-        // Using the map <aME> find chain of faces to be intersected;
-        //
-        // faces for intersection
         TopTools_IndexedMapOfShape aMFInt;
         // additional faces for intersection
         TopTools_IndexedMapOfShape aMFIntExt;
@@ -5801,6 +5831,14 @@ void BRepOffset_BuildOffsetFaces::IntersectFaces (TopTools_MapOfShape& theVertsT
           if (pMFInter && !pInterFi)
             continue;
 
+          // create map of edges and vertices for aLFImi
+          TopTools_MapOfShape  aMEVIm;
+          mapShapes(*aLFImi, TopAbs_EDGE, aMEVIm);
+          mapShapes(*aLFImi, TopAbs_VERTEX, aMEVIm);
+
+          Standard_Boolean isIContainsE = aMEVIm.HasIntersection(anInsideEdges);
+          Standard_Boolean isIContainsV = aMEVIm.HasIntersection(anInsideVertices);
+
           for (j = i + 1; j <= aNb; ++j)
           {
             const TopoDS_Face& aFj = TopoDS::Face (aMFInt (j));
@@ -5820,6 +5858,28 @@ void BRepOffset_BuildOffsetFaces::IntersectFaces (TopTools_MapOfShape& theVertsT
             if (!aLFEj)
               continue;
 
+            // create map of edges and vertices for aLFImi
+            aMEVIm.Clear();
+            mapShapes(*aLFImj, TopAbs_EDGE, aMEVIm);
+            mapShapes(*aLFImj, TopAbs_VERTEX, aMEVIm);
+            // check images of both faces contain anInsideEdges and anInsideVertices
+            // not process if false and true 
+            Standard_Boolean isJContainsE = aMEVIm.HasIntersection(anInsideEdges);
+            Standard_Boolean isJContainsV = aMEVIm.HasIntersection(anInsideVertices);
+
+            // Check if one face is connected to inside edge then
+            // the other must be also connected
+            if ((isIContainsE && !isJContainsV) ||
+                (isJContainsE && !isIContainsV))
+            {
+              TopTools_ListOfShape aLVC;
+              // it is necessary to process the images if they already have 
+              // common vertices
+              FindCommonParts(*aLFImi, *aLFImj, aLVC, TopAbs_VERTEX);
+
+              if (aLVC.IsEmpty())
+                continue;
+            }
             //
             // if there are some common edges between faces
             // we should use these edges and do not intersect again.
diff --git a/tests/offset/shape_type_i_c/WA1 b/tests/offset/shape_type_i_c/WA1
new file mode 100644 (file)
index 0000000..41532fb
--- /dev/null
@@ -0,0 +1,8 @@
+restore [locate_data_file bug33298.brep] s
+
+OFFSETSHAPE 35 {} $calcul $type
+
+checkprops result -v 1.20105e+08
+
+checknbshapes result -shell 1
+
diff --git a/tests/offset/shape_type_i_c/WA2 b/tests/offset/shape_type_i_c/WA2
new file mode 100644 (file)
index 0000000..9026f12
--- /dev/null
@@ -0,0 +1,8 @@
+restore [locate_data_file bug33298_trimmed.brep] s
+
+OFFSETSHAPE 35 {} $calcul $type
+
+checkprops result -v 7.3756e+07
+
+checknbshapes result -shell 1
+
index 263dde8f44b056ba3d4a8d4ac2ad0eee6ae84730..33bbd3c833e40d0de7e43da4983ec0f6aa3fe58c 100644 (file)
@@ -1,8 +1,7 @@
 puts "TODO CR27414 ALL: Error: number of wire entities in the result"
 puts "TODO CR27414 ALL: Error: number of face entities in the result"
-puts "TODO CR27414 ALL: Error: operation with offset value 9 has failed"
 puts "TODO CR27414 ALL: Error: operation with offset value 10 has failed"
-puts "TODO CR27414 ALL: Operations with following offset values have failed: 10"
+puts "TODO CR27414 ALL: Operations with following offset values have failed: 10"
 
 puts "============================================================================================="
 puts "0032333: Modeling Algorithms - Empty(wrong) result of offset operation in mode \"Complete\" join type \"Intersection\""