0024491: Partition algorithm history bug (faces).
[occt.git] / src / BOPAlgo / BOPAlgo_Builder_4.cxx
index f22482b..ca706f2 100644 (file)
 //function : Generated
 //purpose  : 
 //=======================================================================
-  const TopTools_ListOfShape& BOPAlgo_Builder::Generated(const TopoDS_Shape& theS)
+  const TopTools_ListOfShape& BOPAlgo_Builder::Generated(const TopoDS_Shape&)
 {
-  Standard_Boolean bHasImage, bToReverse;
-  TopAbs_ShapeEnum aType;
-  BOPCol_ListIteratorOfListOfShape aIt;
-  //
   myHistShapes.Clear();
-  //
-  if (theS.IsNull()) {
-    return myHistShapes;
-  }
-  //
-  bHasImage=myImages.IsBound(theS);
-  if (!bHasImage) {
-    return myHistShapes;
-  }
-  //
-  aType=theS.ShapeType();
-  //
-  if (!(aType==TopAbs_EDGE   || aType==TopAbs_FACE || 
-      aType==TopAbs_VERTEX || aType==TopAbs_SOLID)) {
-    return myHistShapes;
-  } 
-  //
-  //PrepareHistory();
-  //
-  const BOPCol_ListOfShape& aLSp=myImages.Find(theS);
-  aIt.Initialize(aLSp);
-  for (; aIt.More(); aIt.Next()) {
-    const TopoDS_Shape& aSp=aIt.Value();
-    if (myShapesSD.IsBound(aSp)) {
-      if (myMapShape.Contains(aSp)) {
-       TopoDS_Shape aSpR=myShapesSD.Find(aSp);
-       //
-       if (aType==TopAbs_VERTEX || aType==TopAbs_SOLID) {
-         aSpR.Orientation(theS.Orientation());
-       }
-       else {
-         bToReverse=BOPTools_AlgoTools::IsSplitToReverse(aSpR, theS, myContext);
-         if (bToReverse) {
-           aSpR.Reverse();
-         }
-       }
-       //
-         myHistShapes.Append(aSpR);
-      }
-    }
-  }
-  //
   return myHistShapes;
 }
 //=======================================================================
   aIt.Initialize(aLSp);
   for (; aIt.More(); aIt.Next()) {
     TopoDS_Shape aSp=aIt.Value();
-    if (!myShapesSD.IsBound(aSp)) {
-      if (myMapShape.Contains(aSp)) {
-       //
-       if (aType==TopAbs_VERTEX || aType==TopAbs_SOLID) {
-         aSp.Orientation(theS.Orientation());
-       }
-       else {
-         bToReverse=BOPTools_AlgoTools::IsSplitToReverse(aSp, theS, myContext);
-         if (bToReverse) {
-           aSp.Reverse();
-         }
-       }
-       //
-       myHistShapes.Append(aSp);
+    if (myShapesSD.IsBound(aSp)) {
+      aSp = myShapesSD.Find(aSp);
+    }
+    //
+    if (myMapShape.Contains(aSp)) {
+      //
+      if (aType==TopAbs_VERTEX || aType==TopAbs_SOLID) {
+        aSp.Orientation(theS.Orientation());
+      }
+      else {
+        bToReverse=BOPTools_AlgoTools::IsSplitToReverse(aSp, theS, myContext);
+        if (bToReverse) {
+          aSp.Reverse();
+        }
       }
+      //
+      myHistShapes.Append(aSp);
     }
   }
   //
     //
     if (!myShapesSD.IsBound(aSp)) {
       if (myMapShape.Contains(aSp)) {
-       return bRet; //false
+        return bRet; //false
       }
     }
     else {
       TopoDS_Shape aSpR=myShapesSD.Find(aSp);
       if (myMapShape.Contains(aSpR)) {
-       return bRet; //false
+        return bRet; //false
       }
     }
   }
     return;
   }
   //
-  Standard_Boolean bHasImage, bContainsSD;
+  Standard_Boolean bHasImage;
   TopAbs_ShapeEnum aType;
   BOPCol_MapOfShape aMS;
   BOPCol_ListIteratorOfListOfShape aIt;
     BOPCol_ListOfShape aLSx;
     if (!bHasImage) {
       if (myMapShape.Contains(aSx)) {
-       aLSx.Append(aSx);
-       myImagesResult.Add(aSx, aLSx);
+        aLSx.Append(aSx);
+        myImagesResult.Add(aSx, aLSx);
       }
     }
     else {
       const BOPCol_ListOfShape& aLSp=myImages.Find(aSx);
       aIt.Initialize(aLSp);
       for (; aIt.More(); aIt.Next()) {
-       const TopoDS_Shape& aSp=aIt.Value();
-       if (myMapShape.Contains(aSp)) {
-         aLSx.Append(aSp);
-       }
+        const TopoDS_Shape& aSp=aIt.Value();
+        if (myMapShape.Contains(aSp)) {
+          aLSx.Append(aSp);
+        }
       }
       myImagesResult.Add(aSx, aLSx);
     }
       myHasDeleted=IsDeleted(aSx);
     }
     //
-    if (!myHasGenerated || !myHasModified) {
+    if (!myHasModified && bHasImage) {
       if (aType==TopAbs_EDGE   || aType==TopAbs_FACE || 
-         aType==TopAbs_VERTEX || aType==TopAbs_SOLID) {
-       if (bHasImage) {
-         const BOPCol_ListOfShape& aLSp=myImages.Find(aSx);
-         aIt.Initialize(aLSp);
-         for (; aIt.More(); aIt.Next()) {
-           const TopoDS_Shape& aSp=aIt.Value();
-           //
-           if (myMapShape.Contains(aSp)) {
-             bContainsSD=myShapesSD.IsBound(aSp);
-             //
-             if (!myHasGenerated) {
-               if (bContainsSD) {
-                 myHasGenerated=Standard_True;
-               }
-             }
-             if (!myHasModified) {
-               if (!bContainsSD) {
-                 myHasModified=Standard_True;
-               }
-             }
-           } // if (myMapShape.Contains(aSp))
-         }
-       }
+          aType==TopAbs_VERTEX || aType==TopAbs_SOLID) {
+        myHasModified = Standard_True;
       } 
     }
+    //
+    if (!myHasGenerated) {
+      if (aType==TopAbs_FACE) {
+        const TopTools_ListOfShape& aLG = Generated(aSx);
+        myHasGenerated = aLG.Extent() > 0;
+      }
+    }
   }
   myFlagHistory=Standard_True;
 }
-
-// <- A
-    /*
-    BOPCol_ListOfShape aLSx;
-    if (!bHasImage) {
-      if (myMapShape.Contains(aSx)) {
-       aLSx.Append(aSx);
-       myImagesResult.Add(aSx, aLSx);
-      }
-    }
-    else {
-      const BOPCol_ListOfShape& aLSp=myImages.Find(aSx);
-      aIt.Initialize(aLSp);
-      for (; aIt.More(); aIt.Next()) {
-       const TopoDS_Shape& aSp=aIt.Value();
-       if (myMapShape.Contains(aSp)) {
-         aLSx.Append(aSp);
-       }
-      }
-      myImagesResult.Add(aSx, aLSx);
-    }
-    */