]> OCCT Git - occt-copy.git/commitdiff
0028776: Extend the field BOPAlgo_Builder::myOrigins so that the shape could have...
authoremv <emv@opencascade.com>
Wed, 3 May 2017 12:42:53 +0000 (15:42 +0300)
committeremv <emv@opencascade.com>
Fri, 7 Jul 2017 07:03:47 +0000 (10:03 +0300)
Change the type of the field BOPAlgo_Builder::myOrigins so that the new shape could have multiple origins in case of overlapping.

dox/dev_guides/upgrade/upgrade.md
src/BOPAlgo/BOPAlgo_Builder.cxx
src/BOPAlgo/BOPAlgo_Builder.hxx
src/BOPAlgo/BOPAlgo_Builder_1.cxx
src/BOPAlgo/BOPAlgo_Builder_2.cxx
src/BOPAlgo/BOPAlgo_Builder_3.cxx
src/BOPTest/BOPTest_DebugCommands.cxx
src/BRepFeat/BRepFeat_Builder.cxx
tests/bugs/modalg_6/bug28776 [new file with mode: 0644]

index 84d1db80a21c683359e932c17bfe68b42d948601..7d025d9bf1fac75393c71005e19138877ad49d5f 100644 (file)
@@ -1114,6 +1114,10 @@ The following obsolete features have been removed:
 
 * The result of Boolean operations on arguments of collection types (WIRE/SHELL/COMPSOLID) is now filtered from duplicating containers.
 
+@subsection upgrade_720_changes_methods Other changes
+
+* The method BOPAlgo_Builder::Origins() returns BOPCol_DataMapOfShapeListOfShape instead of BOPCol_DataMapOfShapeShape.
+
 @subsection upgrade_720_BOP_DataStructure BOP - Pairs of interfering indices
 
 * The classes *BOPDS_PassKey* and *BOPDS_PassKeyBoolean* are too excessive and not used any more in Boolean Operations. To replace them the new *BOPDS_Pair* class has been implemented. Thus:
index 598c5c905e25100f36b69a5d05d6f5da2e6a6c68..533fddcffbff3396bf8aad68c97834d19121861d 100644 (file)
@@ -148,7 +148,7 @@ const BOPCol_DataMapOfShapeListOfShape& BOPAlgo_Builder::Images()const
 //function : Origins
 //purpose  : 
 //=======================================================================
-const BOPCol_DataMapOfShapeShape& BOPAlgo_Builder::Origins()const
+const BOPCol_DataMapOfShapeListOfShape& BOPAlgo_Builder::Origins()const
 {
   return myOrigins;
 }
index 0323b854a1f4457ccccd6903a40c2f8291c234d2..2938917fbb155b113b37ccef393ea96fc4b38368 100644 (file)
@@ -86,7 +86,7 @@ Standard_EXPORT virtual ~BOPAlgo_Builder();
   Standard_EXPORT Standard_Boolean IsInterferred (const TopoDS_Shape& theS) const;
   
   //! Returns myOrigins.
-  Standard_EXPORT const BOPCol_DataMapOfShapeShape& Origins() const;
+  Standard_EXPORT const BOPCol_DataMapOfShapeListOfShape& Origins() const;
   
   //! Returns myShapesSD.
   Standard_EXPORT const BOPCol_DataMapOfShapeShape& ShapesSD() const;
@@ -171,7 +171,7 @@ protected:
   BOPCol_DataMapOfShapeListOfShape myImages;
   BOPCol_DataMapOfShapeShape myShapesSD;
   BOPCol_DataMapOfShapeListOfShape mySplits;
-  BOPCol_DataMapOfShapeShape myOrigins;
+  BOPCol_DataMapOfShapeListOfShape myOrigins;
   Standard_Boolean myNonDestructive;
   BOPAlgo_GlueEnum myGlue;
 
index 99ddca309fd232c22ade62c0308d17ea3de12cd5..7541264b1face571b340c542e6c803ed5c14ad2d 100644 (file)
@@ -38,7 +38,7 @@
 //function : FillImagesVertices
 //purpose  : 
 //=======================================================================
-  void BOPAlgo_Builder::FillImagesVertices()
+void BOPAlgo_Builder::FillImagesVertices()
 {
   myErrorStatus=0;
   //
     myImages.Bind(aV, aLVSD);
     //
     myShapesSD.Bind(aV, aVSD);
+    //
+    BOPCol_ListOfShape* pLOr = myOrigins.ChangeSeek(aVSD);
+    if (!pLOr) {
+      pLOr = myOrigins.Bound(aVSD, BOPCol_ListOfShape());
+    }
+    pLOr->Append(aV);
   }
 }
 //=======================================================================
       Standard_Integer nSpR = aPBR->Edge();
       const TopoDS_Shape& aSpR = myDS->Shape(nSpR);
       pLS->Append(aSpR);
-      myOrigins.Bind(aSpR, aE);
+      //
+      BOPCol_ListOfShape* pLOr = myOrigins.ChangeSeek(aSpR);
+      if (!pLOr) {
+        pLOr = myOrigins.Bound(aSpR, BOPCol_ListOfShape());
+      }
+      pLOr->Append(aE);
       //
       if (myDS->IsCommonBlockOnEdge(aPB)) {
         Standard_Integer nSp = aPB->Edge();
index f5d86322d0917db72aa22af19814ba7cb0ce4de7..54ed0833867226b302598df847e325353adeecbc 100644 (file)
@@ -696,7 +696,12 @@ void BOPAlgo_Builder::FillImagesFaces1()
     aItLS.Initialize(aLFIm);
     for (; aItLS.More(); aItLS.Next()) {
       const TopoDS_Face& aFSp=(*(TopoDS_Face*)(&aItLS.Value()));
-      myOrigins.Bind(aFSp, aF);
+      //
+      BOPCol_ListOfShape* pLOr = myOrigins.ChangeSeek(aFSp);
+      if (!pLOr) {
+        pLOr = myOrigins.Bound(aFSp, BOPCol_ListOfShape());
+      }
+      pLOr->Append(aF);
     }
     //
     // 3.
index 536afb91dadec80ecd9320fe4d33b1d19240b25d..040de792fce06f3084ce3dbfb2e3fa5d6e3797dd 100644 (file)
@@ -894,10 +894,7 @@ void BOPAlgo_Builder::BuildSplitSolids
     const BOPCol_ListOfShape& aLSR=aBS.Areas();
     //
     if (!myImages.IsBound(aS)) {
-      BOPCol_ListOfShape aLSx;
-      //
-      myImages.Bind(aS, aLSx);
-      BOPCol_ListOfShape& aLSIm=myImages.ChangeFind(aS);
+      BOPCol_ListOfShape* pLSx = myImages.Bound(aS, BOPCol_ListOfShape());
       //
       aIt.Initialize(aLSR);
       for (; aIt.More(); aIt.Next()) {
@@ -910,7 +907,13 @@ void BOPAlgo_Builder::BuildSplitSolids
         //
         const BOPTools_Set& aSTx=aMST.Added(aST);
         const TopoDS_Shape& aSx=aSTx.Shape();
-        aLSIm.Append(aSx);
+        pLSx->Append(aSx);
+        //
+        BOPCol_ListOfShape* pLOr = myOrigins.ChangeSeek(aSx);
+        if (!pLOr) {
+          pLOr = myOrigins.Bound(aSx, BOPCol_ListOfShape());
+        }
+        pLOr->Append(aS);
         //
         if (bFlagSD) {
           myShapesSD.Bind(aSR, aSx);
@@ -1105,8 +1108,8 @@ void BOPAlgo_Builder::FillInternalShapes()
         continue;
       }
       //
-      if(aMSOr.Contains(aSd)) {
-        //
+      if (aMSOr.Contains(aSd)) {
+        // make new solid
         TopoDS_Solid aSdx;
         //
         aBB.MakeSolid(aSdx);
@@ -1118,15 +1121,12 @@ void BOPAlgo_Builder::FillInternalShapes()
         //
         aBB.Add(aSdx, aSI);
         //
-        if (myImages.IsBound(aSdx)) {
-          BOPCol_ListOfShape& aLS=myImages.ChangeFind(aSdx);
-          aLS.Append(aSdx);
-        } 
-        else {
-          BOPCol_ListOfShape aLS;
-          aLS.Append(aSdx);
-          myImages.Bind(aSd, aLS);
-        }
+        // no need to check for images of aSd as aMSOr contains only original solids
+        BOPCol_ListOfShape* pLS = myImages.Bound(aSd, BOPCol_ListOfShape());
+        pLS->Append(aSdx);
+        //
+        BOPCol_ListOfShape* pLOr = myOrigins.Bound(aSdx, BOPCol_ListOfShape());
+        pLOr->Append(aSd);
         //
         aMSOr.Remove(aSd);
         aSd=aSdx;
index 9e94ea4b459109ffd6bd3817b8009ec8137903cc..28e91cca8c98f65985d14b7d27d85f794a06d162 100644 (file)
@@ -1200,20 +1200,34 @@ Standard_Integer boporigin(Draw_Interpretor& di,
     return 0;
   }
   //
-  char buf[32];
-  //
   BOPAlgo_Builder& aBuilder = BOPTest_Objects::Builder();
-  const BOPCol_DataMapOfShapeShape& aDMI = aBuilder.Origins();
+  const BOPCol_DataMapOfShapeListOfShape& aDMI = aBuilder.Origins();
   if (!aDMI.IsBound(aS)) {
     di << " no origins found\n"; 
     return 0;
   }
   //
-  const TopoDS_Shape& aSx = aDMI.Find(aS);
-  //
+  char buf[32];
   sprintf(buf, "%s_or", a[1]);
-  DBRep::Set(buf, aSx);
   //
+  const BOPCol_ListOfShape& aLSx = aDMI.Find(aS);
+  if (aLSx.Extent() == 1) {
+    DBRep::Set(buf, aLSx.First());
+    di << "1 origin found\n" << buf << "\n";
+    return 0;
+  }
+  //
+  TopoDS_Compound aCOr;
+  BRep_Builder().MakeCompound(aCOr);
+  //
+  BOPCol_ListIteratorOfListOfShape aItLSx(aLSx);
+  for (; aItLSx.More(); aItLSx.Next()) {
+    BRep_Builder().Add(aCOr, aItLSx.Value());
+  }
+  //
+  DBRep::Set(buf, aCOr);
+  //
+  di << aLSx.Extent() << " origins found\n";
   di << buf << "\n";
   //
   return 0;
index 36f766ce93e415b9dd0999cd6a599f77d7f5d184..e1d3de572204bb40de27c6e421549bc5fec68d18 100644 (file)
       aSx=aSTx.Shape();
       aSx.Orientation(anOriF);
       aLFIm.Append(aSx);
-      myOrigins.Bind(aSx, aF);
+      //
+      BOPCol_ListOfShape* pLOr = myOrigins.ChangeSeek(aSx);
+      if (!pLOr) {
+        pLOr = myOrigins.Bound(aSx, BOPCol_ListOfShape());
+      }
+      pLOr->Append(aF);
       //
       if (bFlagSD) {
         myShapesSD.Bind(aFR, aSx);
diff --git a/tests/bugs/modalg_6/bug28776 b/tests/bugs/modalg_6/bug28776
new file mode 100644 (file)
index 0000000..606ccb8
--- /dev/null
@@ -0,0 +1,34 @@
+puts "========"
+puts "OCC28776"
+puts "========"
+puts ""
+####################################################################
+# Extend the field BOPAlgo_Builder::myOrigins so that the shape could have multiple origins
+####################################################################
+
+box b1 10 10 10
+box b2 10 10 10
+box b3 10 10 10
+
+bclearobjects
+bcleartools
+baddobjects b1 b2 b3
+bfillds
+bbuild r
+
+explode r v
+boporigin r_1
+checknbshapes r_1_or -vertex 3
+
+explode r e
+boporigin r_1
+checknbshapes r_1_or -edge 3
+
+explode r f
+boporigin r_1
+checknbshapes r_1_or -face 3
+
+explode r so
+boporigin r_1
+checknbshapes r_1_or -solid 3
+