Salome HOME
Issue #2611: Partition of a solid belonging to a Compsolid
authorazv <azv@opencascade.com>
Sat, 29 Sep 2018 09:25:41 +0000 (12:25 +0300)
committerazv <azv@opencascade.com>
Sat, 29 Sep 2018 09:25:41 +0000 (12:25 +0300)
Unused solids of the first compsolid are kept untoushed now.

src/FeaturesPlugin/FeaturesPlugin_Partition.cpp
src/FeaturesPlugin/Test/TestPartitionSubCompsolidWithCompSolid1.py
src/FeaturesPlugin/Test/TestPartitionSubCompsolidWithCompSolid2.py
src/FeaturesPlugin/Test/TestPartitionSubCompsolidWithCompSolid3.py
src/FeaturesPlugin/Test/TestPartitionSubCompsolidWithSolid5.py

index 3ef472216f53143c2598369fd6724ab0dc04e991..cd4f34cd33a915148c3ba1fc8ebf5da5774cd3fb 100755 (executable)
@@ -366,40 +366,60 @@ void unusedSubsOfComposolid(const CompsolidSubs& theObjects, CompsolidSubs& theN
   }
 }
 
-bool cutUnusedSubs(CompsolidSubs& theObjects, CompsolidSubs& theNotUsed,
-                   std::shared_ptr<GeomAlgoAPI_MakeShapeList>& theMakeShapeList,
-                   std::string& theError)
+static bool cutSubs(const GeomShapePtr& theFirstArgument,
+                    CompsolidSubs& theSubsToCut,
+                    const ListOfShape& theTools,
+                    std::shared_ptr<GeomAlgoAPI_MakeShapeList>& theMakeShapeList,
+                    std::string& theError)
 {
+  if (theTools.empty())
+    return true;
+
   std::shared_ptr<GeomAlgoAPI_MakeShape> aCutAlgo;
 
-  for (CompsolidSubs::iterator anObjIt = theObjects.begin();
-       anObjIt != theObjects.end(); ++anObjIt) {
-    // get list of unused subs of composolids except the current
-    ListOfShape aTools;
-    for (CompsolidSubs::const_iterator aUIt = theNotUsed.begin();
-         aUIt != theNotUsed.end(); ++aUIt) {
-      if (aUIt->first != anObjIt->first)
-        aTools.insert(aTools.end(), aUIt->second.begin(), aUIt->second.end());
-    }
-    if (aTools.empty())
-      continue;
+  for (CompsolidSubs::iterator aUIt= theSubsToCut.begin(); aUIt != theSubsToCut.end(); ++aUIt) {
+    if (aUIt->first == theFirstArgument)
+      continue; // no need to split unused subs of the first compsolid
 
     // cut from current list of solids
     aCutAlgo.reset(
-        new GeomAlgoAPI_Boolean(anObjIt->second, aTools, GeomAlgoAPI_Boolean::BOOL_CUT));
+        new GeomAlgoAPI_Boolean(aUIt->second, theTools, GeomAlgoAPI_Boolean::BOOL_CUT));
     if (isAlgoFailed(aCutAlgo, theError))
       return false;
     theMakeShapeList->appendAlgo(aCutAlgo);
 
-    // update list of objects of the partition
-    GeomAPI_Shape::ShapeType aType = anObjIt->second.front()->shapeType();
-    anObjIt->second.clear();
+    // update list of un-selected objects of the partition
+    GeomAPI_Shape::ShapeType aType = aUIt->second.front()->shapeType();
+    aUIt->second.clear();
     for (GeomAPI_ShapeExplorer anExp(aCutAlgo->shape(), aType); anExp.more(); anExp.next())
-      anObjIt->second.push_back(anExp.current());
+      aUIt->second.push_back(anExp.current());
   }
   return true;
 }
 
+bool cutUnusedSubs(CompsolidSubs& theObjects, CompsolidSubs& theNotUsed,
+                   std::shared_ptr<GeomAlgoAPI_MakeShapeList>& theMakeShapeList,
+                   std::string& theError)
+{
+  GeomShapePtr aFirstArgument = theObjects.front().first;
+
+  // compose a set of tools for the CUT operation:
+  // find the list of unused subs of the first argument or use itself
+  ListOfShape aToolsForUsed;
+  CompsolidSubs::iterator aUIt = theNotUsed.begin();
+  for (; aUIt != theNotUsed.end(); ++aUIt)
+    if (aUIt->first == aFirstArgument) {
+      aToolsForUsed.insert(aToolsForUsed.end(), aUIt->second.begin(), aUIt->second.end());
+      break;
+    }
+  ListOfShape aToolsForUnused;
+  aToolsForUnused.push_back(aFirstArgument);
+
+  // cut subs
+  return cutSubs(aFirstArgument, theObjects, aToolsForUsed, theMakeShapeList, theError)
+      && cutSubs(aFirstArgument, theNotUsed, aToolsForUnused, theMakeShapeList, theError);
+}
+
 bool isAlgoFailed(const std::shared_ptr<GeomAlgoAPI_MakeShape>& theAlgo, std::string& theError)
 {
   if (!theAlgo->isDone()) {
index 9b428d6b59a90d3b292214a2be5498ac675d4f1c..689fdb07eb284e49420f4f1f463d62b019824c05 100644 (file)
@@ -45,9 +45,9 @@ model.do()
 
 # check partition
 model.testNbResults(Partition_2, 1)
-model.testNbSubResults(Partition_2, [9])
-model.testNbSubShapes(Partition_2, GeomAPI_Shape.SOLID, [9])
-model.testNbSubShapes(Partition_2, GeomAPI_Shape.FACE, [61])
+model.testNbSubResults(Partition_2, [7])
+model.testNbSubShapes(Partition_2, GeomAPI_Shape.SOLID, [7])
+model.testNbSubShapes(Partition_2, GeomAPI_Shape.FACE, [53])
 model.testResultsVolumes(Partition_2, [82157.197962046673637814819812775])
 
 # change box height and check partition
@@ -55,8 +55,8 @@ Param_BoxH.setValue(20)
 model.do()
 
 model.testNbResults(Partition_2, 1)
-model.testNbSubResults(Partition_2, [10])
-model.testNbSubShapes(Partition_2, GeomAPI_Shape.SOLID, [10])
+model.testNbSubResults(Partition_2, [8])
+model.testNbSubShapes(Partition_2, GeomAPI_Shape.SOLID, [8])
 model.testNbSubShapes(Partition_2, GeomAPI_Shape.FACE, [73])
 model.testResultsVolumes(Partition_2, [146157.197962002450367435812950134])
 
@@ -66,9 +66,9 @@ Param_ExtrusionMax.setValue(15)
 model.do()
 
 model.testNbResults(Partition_2, 1)
-model.testNbSubResults(Partition_2, [11])
-model.testNbSubShapes(Partition_2, GeomAPI_Shape.SOLID, [11])
-model.testNbSubShapes(Partition_2, GeomAPI_Shape.FACE, [85])
+model.testNbSubResults(Partition_2, [9])
+model.testNbSubShapes(Partition_2, GeomAPI_Shape.SOLID, [9])
+model.testNbSubShapes(Partition_2, GeomAPI_Shape.FACE, [93])
 model.testResultsVolumes(Partition_2, [146157.197961971396580338478088379])
 
 # change radius of a circle and check partition
@@ -76,9 +76,9 @@ Param_Radius.setValue(50)
 model.do()
 
 model.testNbResults(Partition_2, 1)
-model.testNbSubResults(Partition_2, [11])
-model.testNbSubShapes(Partition_2, GeomAPI_Shape.SOLID, [11])
-model.testNbSubShapes(Partition_2, GeomAPI_Shape.FACE, [82])
+model.testNbSubResults(Partition_2, [9])
+model.testNbSubShapes(Partition_2, GeomAPI_Shape.SOLID, [9])
+model.testNbSubShapes(Partition_2, GeomAPI_Shape.FACE, [92])
 model.testResultsVolumes(Partition_2, [156418.581829168775584548711776733])
 
 # check naming
index 38b4094d2b79b0a91f0aecb9801949963c4407bd..48e09d554587d348fb38f36f912ec3ca427b6e70 100644 (file)
@@ -47,7 +47,7 @@ model.do()
 model.testNbResults(Partition_2, 1)
 model.testNbSubResults(Partition_2, [8])
 model.testNbSubShapes(Partition_2, GeomAPI_Shape.SOLID, [8])
-model.testNbSubShapes(Partition_2, GeomAPI_Shape.FACE, [55])
+model.testNbSubShapes(Partition_2, GeomAPI_Shape.FACE, [57])
 model.testResultsVolumes(Partition_2, [82157.197962275837198831140995026])
 
 # change box height and check partition
@@ -57,7 +57,7 @@ model.do()
 model.testNbResults(Partition_2, 1)
 model.testNbSubResults(Partition_2, [9])
 model.testNbSubShapes(Partition_2, GeomAPI_Shape.SOLID, [9])
-model.testNbSubShapes(Partition_2, GeomAPI_Shape.FACE, [70])
+model.testNbSubShapes(Partition_2, GeomAPI_Shape.FACE, [76])
 model.testResultsVolumes(Partition_2, [146157.197962169535458087921142578])
 
 # update extrusion and check partition
@@ -68,7 +68,7 @@ model.do()
 model.testNbResults(Partition_2, 1)
 model.testNbSubResults(Partition_2, [10])
 model.testNbSubShapes(Partition_2, GeomAPI_Shape.SOLID, [10])
-model.testNbSubShapes(Partition_2, GeomAPI_Shape.FACE, [85])
+model.testNbSubShapes(Partition_2, GeomAPI_Shape.FACE, [95])
 model.testResultsVolumes(Partition_2, [146157.197962103120516985654830933])
 
 # change radius of a circle and check partition
@@ -78,7 +78,7 @@ model.do()
 model.testNbResults(Partition_2, 1)
 model.testNbSubResults(Partition_2, [11])
 model.testNbSubShapes(Partition_2, GeomAPI_Shape.SOLID, [11])
-model.testNbSubShapes(Partition_2, GeomAPI_Shape.FACE, [86])
+model.testNbSubShapes(Partition_2, GeomAPI_Shape.FACE, [98])
 model.testResultsVolumes(Partition_2, [156418.58182917608064599335193634])
 
 # check naming
index a466e5e96d26a32e37802d564cad9bcdd929c1c6..c6673117d30384dfc7b02def66722b2bddbeabca 100644 (file)
@@ -47,7 +47,7 @@ model.do()
 model.testNbResults(Partition_2, 1)
 model.testNbSubResults(Partition_2, [9])
 model.testNbSubShapes(Partition_2, GeomAPI_Shape.SOLID, [9])
-model.testNbSubShapes(Partition_2, GeomAPI_Shape.FACE, [61])
+model.testNbSubShapes(Partition_2, GeomAPI_Shape.FACE, [63])
 model.testResultsVolumes(Partition_2, [82157.197962205173098482191562653])
 
 # change box height and check partition
@@ -57,7 +57,7 @@ model.do()
 model.testNbResults(Partition_2, 1)
 model.testNbSubResults(Partition_2, [10])
 model.testNbSubShapes(Partition_2, GeomAPI_Shape.SOLID, [10])
-model.testNbSubShapes(Partition_2, GeomAPI_Shape.FACE, [75])
+model.testNbSubShapes(Partition_2, GeomAPI_Shape.FACE, [81])
 model.testResultsVolumes(Partition_2, [146157.197962133242981508374214172])
 
 # update extrusion and check partition
@@ -68,7 +68,7 @@ model.do()
 model.testNbResults(Partition_2, 1)
 model.testNbSubResults(Partition_2, [11])
 model.testNbSubShapes(Partition_2, GeomAPI_Shape.SOLID, [11])
-model.testNbSubShapes(Partition_2, GeomAPI_Shape.FACE, [89])
+model.testNbSubShapes(Partition_2, GeomAPI_Shape.FACE, [99])
 model.testResultsVolumes(Partition_2, [146157.197962085192557424306869507])
 
 # change radius of a circle and check partition
@@ -78,7 +78,7 @@ model.do()
 model.testNbResults(Partition_2, 1)
 model.testNbSubResults(Partition_2, [11])
 model.testNbSubShapes(Partition_2, GeomAPI_Shape.SOLID, [11])
-model.testNbSubShapes(Partition_2, GeomAPI_Shape.FACE, [86])
+model.testNbSubShapes(Partition_2, GeomAPI_Shape.FACE, [98])
 model.testResultsVolumes(Partition_2, [156418.581829176022438332438468933])
 
 # check naming
index 9ecd4ed69543b90b62bc933102df7022d46d87d4..df68837afabd3e7b0e450a0e8a4bdc776a2f6e06 100644 (file)
@@ -53,7 +53,7 @@ model.do()
 model.testNbResults(Partition_1, 1)
 model.testNbSubResults(Partition_1, [6])
 model.testNbSubShapes(Partition_1, GeomAPI_Shape.SOLID, [6])
-model.testNbSubShapes(Partition_1, GeomAPI_Shape.FACE, [43])
+model.testNbSubShapes(Partition_1, GeomAPI_Shape.FACE, [41])
 model.testResultsVolumes(Partition_1, [138456.153365848527755588293075562])
 
 # update extrusion and check partition
@@ -64,7 +64,7 @@ model.do()
 model.testNbResults(Partition_1, 1)
 model.testNbSubResults(Partition_1, [6])
 model.testNbSubShapes(Partition_1, GeomAPI_Shape.SOLID, [6])
-model.testNbSubShapes(Partition_1, GeomAPI_Shape.FACE, [47])
+model.testNbSubShapes(Partition_1, GeomAPI_Shape.FACE, [43])
 model.testResultsVolumes(Partition_1, [138456.153365848527755588293075562])
 
 # change radius of a circle and check partition