Salome HOME
Task 3.2. Concealment into multi-level Compounds
authorazv <azv@opencascade.com>
Mon, 13 May 2019 10:23:58 +0000 (13:23 +0300)
committervsv <vsv@opencascade.com>
Mon, 3 Jun 2019 10:32:04 +0000 (13:32 +0300)
Update behavior of SMASH operation to keep hierarchy of compounds.

src/FeaturesAPI/FeaturesAPI_BooleanSmash.cpp
src/FeaturesAPI/FeaturesAPI_BooleanSmash.h
src/FeaturesPlugin/CMakeLists.txt
src/FeaturesPlugin/FeaturesPlugin_BooleanSmash.cpp
src/FeaturesPlugin/Test/TestBooleanSmash_MultiLevelCompound0.py [deleted file]
src/FeaturesPlugin/Test/TestBooleanSmash_MultiLevelCompound_v0_1.py [new file with mode: 0644]
src/FeaturesPlugin/Test/TestBooleanSmash_MultiLevelCompound_v0_2.py [new file with mode: 0644]
src/FeaturesPlugin/Test/TestBooleanSmash_MultiLevelCompound_v20190506_1.py [new file with mode: 0644]
src/FeaturesPlugin/Test/TestBooleanSmash_MultiLevelCompound_v20190506_2.py [new file with mode: 0644]

index 9c22e3bd34a632af326690dc06babf9138d26a9d..c23f639678f937da2fa8d0d135ea598798eb9c10 100644 (file)
@@ -35,10 +35,12 @@ FeaturesAPI_BooleanSmash::FeaturesAPI_BooleanSmash(
 FeaturesAPI_BooleanSmash::FeaturesAPI_BooleanSmash(
   const std::shared_ptr<ModelAPI_Feature>& theFeature,
   const std::list<ModelHighAPI_Selection>& theMainObjects,
-  const std::list<ModelHighAPI_Selection>& theToolObjects)
+  const std::list<ModelHighAPI_Selection>& theToolObjects,
+  const int theVersion)
 : ModelHighAPI_Interface(theFeature)
 {
   if(initialize()) {
+    fillAttribute(theVersion, theFeature->integer(FeaturesPlugin_Boolean::VERSION_ID()));
     fillAttribute(theMainObjects, mymainObjects);
     fillAttribute(theToolObjects, mytoolObjects);
 
@@ -82,17 +84,26 @@ void FeaturesAPI_BooleanSmash::dump(ModelHighAPI_Dumper& theDumper) const
     aBase->selectionList(FeaturesPlugin_BooleanSmash::OBJECT_LIST_ID());
   AttributeSelectionListPtr aTools =
     aBase->selectionList(FeaturesPlugin_BooleanSmash::TOOL_LIST_ID());
+  AttributeIntegerPtr aVersion =
+    aBase->integer(FeaturesPlugin_BooleanSmash::VERSION_ID());
+
+  theDumper << "(" << aDocName << ", " << anObjects << ", " << aTools;
+
+  if (aVersion && aVersion->isInitialized())
+    theDumper << ", " << aVersion->value();
 
-  theDumper << "(" << aDocName << ", " << anObjects << ", " << aTools << ")" << std::endl;
+  theDumper << ")" << std::endl;
 }
 
 //==================================================================================================
 BooleanSmashPtr addSmash(const std::shared_ptr<ModelAPI_Document>& thePart,
                          const std::list<ModelHighAPI_Selection>& theMainObjects,
-                         const std::list<ModelHighAPI_Selection>& theToolObjects)
+                         const std::list<ModelHighAPI_Selection>& theToolObjects,
+                         const int theVersion)
 {
   std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(FeaturesAPI_BooleanSmash::ID());
   return BooleanSmashPtr(new FeaturesAPI_BooleanSmash(aFeature,
                                                       theMainObjects,
-                                                      theToolObjects));
+                                                      theToolObjects,
+                                                      theVersion));
 }
index f9cadd6edfdbed06549ea6f95339dbbdf1d33eb9..a6e1bbc52e557b133932bf8cbd8fb5a9646bf737 100644 (file)
@@ -44,7 +44,8 @@ public:
   FEATURESAPI_EXPORT
   FeaturesAPI_BooleanSmash(const std::shared_ptr<ModelAPI_Feature>& theFeature,
                            const std::list<ModelHighAPI_Selection>& theMainObjects,
-                           const std::list<ModelHighAPI_Selection>& theToolObjects);
+                           const std::list<ModelHighAPI_Selection>& theToolObjects,
+                           const int theVersion = 0);
 
   /// Destructor.
   FEATURESAPI_EXPORT
@@ -77,6 +78,7 @@ typedef std::shared_ptr<FeaturesAPI_BooleanSmash> BooleanSmashPtr;
 FEATURESAPI_EXPORT
 BooleanSmashPtr addSmash(const std::shared_ptr<ModelAPI_Document>& thePart,
                          const std::list<ModelHighAPI_Selection>& theMainObjects,
-                         const std::list<ModelHighAPI_Selection>& theToolObjects);
+                         const std::list<ModelHighAPI_Selection>& theToolObjects,
+                         const int theVersion = 0);
 
 #endif // FeaturesAPI_BooleanSmash_H_
index 3d99fb44628b1774a704675a1a951b211ae0d39b..ac313d386e877b63242662f88e41f19efa5d17ba 100644 (file)
@@ -476,7 +476,10 @@ ADD_UNIT_TESTS(TestExtrusion.py
                TestBooleanFuse_MultiLevelCompound_v20190506_2.py
                TestBooleanFuse_MultiLevelCompound_v20190506_3.py
                TestBooleanFuse_MultiLevelCompound_v20190506_4.py
-               TestBooleanSmash_MultiLevelCompound0.py
+               TestBooleanSmash_MultiLevelCompound_v0_1.py
+               TestBooleanSmash_MultiLevelCompound_v0_2.py
+               TestBooleanSmash_MultiLevelCompound_v20190506_1.py
+               TestBooleanSmash_MultiLevelCompound_v20190506_2.py
                TestBooleanSplit_MultiLevelCompound0.py
                TestPartition_MultiLevelCompound0.py
 )
index c3b8243ae9267babc74c279e7f9102eec1f3641e..a46ed7409b6ca664fb177e54f286f4cd2f55565c 100644 (file)
@@ -35,6 +35,8 @@
 #include <GeomAPI_ShapeExplorer.h>
 #include <GeomAPI_ShapeIterator.h>
 
+static const int THE_SMASH_VERSION_1 = 20190506;
+
 //==================================================================================================
 FeaturesPlugin_BooleanSmash::FeaturesPlugin_BooleanSmash()
 : FeaturesPlugin_Boolean(FeaturesPlugin_Boolean::BOOL_SMASH)
@@ -46,105 +48,59 @@ void FeaturesPlugin_BooleanSmash::initAttributes()
 {
   data()->addAttribute(OBJECT_LIST_ID(), ModelAPI_AttributeSelectionList::typeId());
   data()->addAttribute(TOOL_LIST_ID(), ModelAPI_AttributeSelectionList::typeId());
+
+  initVersion(THE_SMASH_VERSION_1);
 }
 
 //==================================================================================================
 void FeaturesPlugin_BooleanSmash::execute()
 {
   std::string anError;
-  ListOfShape anObjects, aTools;
-  std::map<std::shared_ptr<GeomAPI_Shape>, ListOfShape> aCompSolidsObjects;
-
-  // Getting objects.
-  AttributeSelectionListPtr anObjectsSelList = selectionList(OBJECT_LIST_ID());
-  for(int anObjectsIndex = 0; anObjectsIndex < anObjectsSelList->size(); anObjectsIndex++) {
-    AttributeSelectionPtr anObjectAttr = anObjectsSelList->value(anObjectsIndex);
-    std::shared_ptr<GeomAPI_Shape> anObject = anObjectAttr->value();
-    if(!anObject.get()) {
-      return;
-    }
-    ResultPtr aContext = anObjectAttr->context();
-    ResultBodyPtr aResCompSolidPtr = ModelAPI_Tools::bodyOwner(aContext);
-    if (aResCompSolidPtr.get())
-    {
-      std::shared_ptr<GeomAPI_Shape> aContextShape = aResCompSolidPtr->shape();
-
-      std::map<std::shared_ptr<GeomAPI_Shape>, ListOfShape>::iterator
-        anIt = aCompSolidsObjects.begin();
-      for (; anIt != aCompSolidsObjects.end(); anIt++) {
-        if (anIt->first->isEqual(aContextShape)) {
-          aCompSolidsObjects[anIt->first].push_back(anObject);
-          break;
-        }
-      }
-      if (anIt == aCompSolidsObjects.end()) {
-        aCompSolidsObjects[aContextShape].push_back(anObject);
-      }
-
-    } else {
-      anObjects.push_back(anObject);
-    }
-  }
+  ObjectHierarchy anObjectsHistory, aToolsHistory;
+  ListOfShape aPlanes;
 
-  // Getting tools.
-  AttributeSelectionListPtr aToolsSelList = selectionList(TOOL_LIST_ID());
-  for(int aToolsIndex = 0; aToolsIndex < aToolsSelList->size(); aToolsIndex++) {
-    AttributeSelectionPtr aToolAttr = aToolsSelList->value(aToolsIndex);
-    GeomShapePtr aTool = aToolAttr->value();
-    if(!aTool.get()) {
-      return;
-    }
-    aTools.push_back(aTool);
-  }
+  // Getting objects and tools.
+  if (!processAttribute(OBJECT_LIST_ID(), anObjectsHistory, aPlanes) ||
+      !processAttribute(TOOL_LIST_ID(), aToolsHistory, aPlanes))
+    return;
 
   int aResultIndex = 0;
 
-  if((anObjects.empty() && aCompSolidsObjects.empty())
-     || aTools.empty()) {
+  if (anObjectsHistory.IsEmpty() || aToolsHistory.IsEmpty()) {
     std::string aFeatureError = "Error: Not enough objects for boolean operation.";
     setError(aFeatureError);
     return;
   }
 
+  // Collecting all shapes which will be smashed.
+  ListOfShape aShapesToSmash = anObjectsHistory.Objects();
+
   // List of original shapes for naming.
   ListOfShape anOriginalShapes;
-  anOriginalShapes.insert(anOriginalShapes.end(), anObjects.begin(), anObjects.end());
+  anOriginalShapes.insert(anOriginalShapes.end(), aShapesToSmash.begin(), aShapesToSmash.end());
+  ListOfShape aTools = aToolsHistory.Objects();
   anOriginalShapes.insert(anOriginalShapes.end(), aTools.begin(), aTools.end());
 
-  // Collecting all shapes which will be smashed.
-  ListOfShape aShapesToSmash;
-  aShapesToSmash.insert(aShapesToSmash.end(), anObjects.begin(), anObjects.end());
-
   // Collecting solids from compsolids which will not be modified in
   // boolean operation and will be added to result.
   ListOfShape aShapesToAdd;
-  for (std::map<std::shared_ptr<GeomAPI_Shape>, ListOfShape>::iterator
-       anIt = aCompSolidsObjects.begin();
-       anIt != aCompSolidsObjects.end();
+  for (ObjectHierarchy::Iterator anIt = anObjectsHistory.Begin();
+       anIt != anObjectsHistory.End();
        ++anIt)
   {
-    std::shared_ptr<GeomAPI_Shape> aCompSolid = anIt->first;
-    ListOfShape& aUsedInOperationSolids = anIt->second;
-    anOriginalShapes.push_back(aCompSolid);
-    aShapesToSmash.insert(aShapesToSmash.end(),
-                          aUsedInOperationSolids.begin(),
-                          aUsedInOperationSolids.end());
-
-    // Collect solids from compsolid which will not be modified in boolean operation.
-    for (GeomAPI_ShapeExplorer anExp(aCompSolid, GeomAPI_Shape::SOLID);
-         anExp.more();
-         anExp.next())
-    {
-      std::shared_ptr<GeomAPI_Shape> aSolidInCompSolid = anExp.current();
-      ListOfShape::iterator anIt = aUsedInOperationSolids.begin();
-      for (; anIt != aUsedInOperationSolids.end(); anIt++) {
-        if (aSolidInCompSolid->isEqual(*anIt)) {
-          break;
-        }
-      }
-      if (anIt == aUsedInOperationSolids.end()) {
-        aShapesToAdd.push_back(aSolidInCompSolid);
-      }
+    GeomShapePtr aParent = anObjectsHistory.Parent(*anIt, false);
+    if (aParent) {
+      anOriginalShapes.push_back(aParent);
+
+      ListOfShape aUsed, aNotUsed;
+      anObjectsHistory.SplitCompound(aParent, aUsed, aNotUsed);
+      aShapesToAdd.insert(aShapesToAdd.end(), aNotUsed.begin(), aNotUsed.end());
+
+      // add unused shapes of compounds/compsolids to the history,
+      // to avoid treating them as unused later when constructing a compound containing
+      // the result of Smash and all unused sub-shapes of multi-level compounds
+      for (ListOfShape::iterator anIt = aNotUsed.begin(); anIt != aNotUsed.end(); ++anIt)
+        anObjectsHistory.AddObject(*anIt);
     }
   }
 
@@ -212,6 +168,14 @@ void FeaturesPlugin_BooleanSmash::execute()
     aMakeShapeList->appendAlgo(aFillerAlgo);
   }
 
+  // take into account a version of SMASH feature
+  int aSmashVersion = version();
+  if (aSmashVersion == THE_SMASH_VERSION_1) {
+    // merge hierarchies of compounds containing objects and tools
+    // and append the result of the FUSE operation
+    aShape = keepUnusedSubsOfCompound(aShape, anObjectsHistory, aToolsHistory, aMakeShapeList);
+  }
+
   std::shared_ptr<ModelAPI_ResultBody> aResultBody = document()->createBody(data(), aResultIndex);
 
   FeaturesPlugin_Tools::loadModifiedShapes(aResultBody,
diff --git a/src/FeaturesPlugin/Test/TestBooleanSmash_MultiLevelCompound0.py b/src/FeaturesPlugin/Test/TestBooleanSmash_MultiLevelCompound0.py
deleted file mode 100644 (file)
index 0c4525e..0000000
+++ /dev/null
@@ -1,92 +0,0 @@
-# Copyright (C) 2014-2019  CEA/DEN, EDF R&D
-#
-# This library is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public
-# License as published by the Free Software Foundation; either
-# version 2.1 of the License, or (at your option) any later version.
-#
-# This library is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-# Lesser General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public
-# License along with this library; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
-#
-# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-#
-
-from SketchAPI import *
-
-from salome.shaper import model
-
-model.begin()
-partSet = model.moduleDocument()
-Part_1 = model.addPart(partSet)
-Part_1_doc = Part_1.document()
-Cylinder_1 = model.addCylinder(Part_1_doc, model.selection("VERTEX", "PartSet/Origin"), model.selection("EDGE", "PartSet/OZ"), 10, 20)
-LinearCopy_1 = model.addMultiTranslation(Part_1_doc, [model.selection("SOLID", "Cylinder_1_1")], model.selection("EDGE", "PartSet/OX"), 40, 2)
-LinearCopy_2 = model.addMultiTranslation(Part_1_doc, [model.selection("COMPOUND", "LinearCopy_1_1")], model.selection("EDGE", "PartSet/OY"), 40, 2)
-LinearCopy_2.result().subResult(0).subResult(0).setColor(255, 170, 0)
-LinearCopy_2.result().subResult(0).subResult(1).setColor(255, 170, 0)
-LinearCopy_2.result().subResult(1).subResult(0).setColor(0, 0, 255)
-LinearCopy_2.result().subResult(1).subResult(1).setColor(0, 0, 255)
-Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("YOZ"))
-SketchLine_1 = Sketch_1.addLine(7, 0, -7, 0)
-SketchLine_2 = Sketch_1.addLine(-7, 0, -7, 5)
-SketchLine_3 = Sketch_1.addLine(-7, 5, 7, 5)
-SketchLine_4 = Sketch_1.addLine(7, 5, 7, 0)
-SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchLine_4.endPoint(), SketchLine_1.startPoint())
-SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_2.startPoint())
-SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchLine_2.endPoint(), SketchLine_3.startPoint())
-SketchConstraintCoincidence_4 = Sketch_1.setCoincident(SketchLine_3.endPoint(), SketchLine_4.startPoint())
-SketchConstraintHorizontal_1 = Sketch_1.setHorizontal(SketchLine_1.result())
-SketchConstraintVertical_1 = Sketch_1.setVertical(SketchLine_2.result())
-SketchConstraintHorizontal_2 = Sketch_1.setHorizontal(SketchLine_3.result())
-SketchConstraintVertical_2 = Sketch_1.setVertical(SketchLine_4.result())
-SketchProjection_1 = Sketch_1.addProjection(model.selection("EDGE", "PartSet/OZ"), False)
-SketchLine_5 = SketchProjection_1.createdFeature()
-SketchConstraintDistance_1 = Sketch_1.setDistance(SketchLine_3.endPoint(), SketchLine_5.result(), 7, True)
-SketchConstraintCoincidence_5 = Sketch_1.setCoincident(SketchAPI_Line(SketchLine_5).startPoint(), SketchLine_1.result())
-SketchConstraintLength_1 = Sketch_1.setLength(SketchLine_1.result(), 14)
-SketchConstraintLength_2 = Sketch_1.setLength(SketchLine_2.result(), 5)
-SketchLine_6 = Sketch_1.addLine(5, 12, -5, 12)
-SketchLine_7 = Sketch_1.addLine(-5, 12, -5, 15)
-SketchLine_8 = Sketch_1.addLine(-5, 15, 5, 15)
-SketchLine_9 = Sketch_1.addLine(5, 15, 5, 12)
-SketchConstraintCoincidence_6 = Sketch_1.setCoincident(SketchLine_9.endPoint(), SketchLine_6.startPoint())
-SketchConstraintCoincidence_7 = Sketch_1.setCoincident(SketchLine_6.endPoint(), SketchLine_7.startPoint())
-SketchConstraintCoincidence_8 = Sketch_1.setCoincident(SketchLine_7.endPoint(), SketchLine_8.startPoint())
-SketchConstraintCoincidence_9 = Sketch_1.setCoincident(SketchLine_8.endPoint(), SketchLine_9.startPoint())
-SketchConstraintHorizontal_3 = Sketch_1.setHorizontal(SketchLine_6.result())
-SketchConstraintVertical_3 = Sketch_1.setVertical(SketchLine_7.result())
-SketchConstraintHorizontal_4 = Sketch_1.setHorizontal(SketchLine_8.result())
-SketchConstraintVertical_4 = Sketch_1.setVertical(SketchLine_9.result())
-SketchConstraintLength_3 = Sketch_1.setLength(SketchLine_7.result(), 3)
-SketchConstraintLength_4 = Sketch_1.setLength(SketchLine_8.result(), 10)
-SketchConstraintDistance_2 = Sketch_1.setDistance(SketchLine_8.endPoint(), SketchLine_5.result(), 5, True)
-SketchConstraintDistance_3 = Sketch_1.setDistance(SketchLine_6.startPoint(), SketchLine_3.result(), 7, True)
-model.do()
-Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_4r-SketchLine_3r-SketchLine_2r-SketchLine_1r")], model.selection(), 60, 20)
-Extrusion_2 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_9r-SketchLine_8r-SketchLine_7r-SketchLine_6r")], model.selection(), 55, 15)
-LinearCopy_3 = model.addMultiTranslation(Part_1_doc, [model.selection("SOLID", "Extrusion_1_1")], model.selection("EDGE", "PartSet/OY"), 40, 2)
-AngularCopy_1 = model.addMultiRotation(Part_1_doc, [model.selection("SOLID", "Extrusion_2_1")], model.selection("EDGE", "PartSet/OZ"), 90, 2)
-Compound_1 = model.addCompound(Part_1_doc, [model.selection("COMPOUND", "LinearCopy_3_1"), model.selection("COMPOUND", "AngularCopy_1_1")])
-Compound_1.result().subResult(0).subResult(0).setColor(0, 170, 0)
-Compound_1.result().subResult(0).subResult(1).setColor(0, 170, 0)
-Compound_1.result().subResult(1).subResult(0).setColor(0, 255, 0)
-Compound_1.result().subResult(1).subResult(1).setColor(0, 255, 0)
-Smash_1 = model.addSmash(Part_1_doc, [model.selection("SOLID", "LinearCopy_2_1_1_1")], [model.selection("SOLID", "Compound_1_1_2_1"), model.selection("SOLID", "Compound_1_1_2_2")])
-model.do()
-model.end()
-
-from GeomAPI import GeomAPI_Shape
-
-model.testNbResults(Smash_1, 1)
-model.testNbSubResults(Smash_1, [8])
-model.testNbSubShapes(Smash_1, GeomAPI_Shape.SOLID, [8])
-model.testNbSubShapes(Smash_1, GeomAPI_Shape.FACE, [80])
-model.testNbSubShapes(Smash_1, GeomAPI_Shape.EDGE, [348])
-model.testNbSubShapes(Smash_1, GeomAPI_Shape.VERTEX, [696])
-model.testResultsVolumes(Smash_1, [15044.469954918753501260653138161])
diff --git a/src/FeaturesPlugin/Test/TestBooleanSmash_MultiLevelCompound_v0_1.py b/src/FeaturesPlugin/Test/TestBooleanSmash_MultiLevelCompound_v0_1.py
new file mode 100644 (file)
index 0000000..25fffab
--- /dev/null
@@ -0,0 +1,96 @@
+# Copyright (C) 2014-2019  CEA/DEN, EDF R&D
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+#
+# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+#
+
+from SketchAPI import *
+
+from salome.shaper import model
+
+model.begin()
+partSet = model.moduleDocument()
+Part_1 = model.addPart(partSet)
+Part_1_doc = Part_1.document()
+Cylinder_1 = model.addCylinder(Part_1_doc, model.selection("VERTEX", "PartSet/Origin"), model.selection("EDGE", "PartSet/OZ"), 10, 20)
+LinearCopy_1 = model.addMultiTranslation(Part_1_doc, [model.selection("SOLID", "Cylinder_1_1")], model.selection("EDGE", "PartSet/OX"), 40, 2)
+LinearCopy_2 = model.addMultiTranslation(Part_1_doc, [model.selection("COMPOUND", "LinearCopy_1_1")], model.selection("EDGE", "PartSet/OY"), 40, 2)
+LinearCopy_2.result().subResult(0).subResult(0).setColor(255, 170, 0)
+LinearCopy_2.result().subResult(0).subResult(1).setColor(255, 170, 0)
+LinearCopy_2.result().subResult(1).subResult(0).setColor(0, 0, 255)
+LinearCopy_2.result().subResult(1).subResult(1).setColor(0, 0, 255)
+Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("YOZ"))
+SketchLine_1 = Sketch_1.addLine(7, 0, -7, 0)
+SketchLine_2 = Sketch_1.addLine(-7, 0, -7, 5)
+SketchLine_3 = Sketch_1.addLine(-7, 5, 7, 5)
+SketchLine_4 = Sketch_1.addLine(7, 5, 7, 0)
+SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchLine_4.endPoint(), SketchLine_1.startPoint())
+SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_2.startPoint())
+SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchLine_2.endPoint(), SketchLine_3.startPoint())
+SketchConstraintCoincidence_4 = Sketch_1.setCoincident(SketchLine_3.endPoint(), SketchLine_4.startPoint())
+SketchConstraintHorizontal_1 = Sketch_1.setHorizontal(SketchLine_1.result())
+SketchConstraintVertical_1 = Sketch_1.setVertical(SketchLine_2.result())
+SketchConstraintHorizontal_2 = Sketch_1.setHorizontal(SketchLine_3.result())
+SketchConstraintVertical_2 = Sketch_1.setVertical(SketchLine_4.result())
+SketchProjection_1 = Sketch_1.addProjection(model.selection("EDGE", "PartSet/OZ"), False)
+SketchLine_5 = SketchProjection_1.createdFeature()
+SketchConstraintDistance_1 = Sketch_1.setDistance(SketchLine_3.endPoint(), SketchLine_5.result(), 7, True)
+SketchConstraintCoincidence_5 = Sketch_1.setCoincident(SketchAPI_Line(SketchLine_5).startPoint(), SketchLine_1.result())
+SketchConstraintLength_1 = Sketch_1.setLength(SketchLine_1.result(), 14)
+SketchConstraintLength_2 = Sketch_1.setLength(SketchLine_2.result(), 5)
+SketchLine_6 = Sketch_1.addLine(5, 12, -5, 12)
+SketchLine_7 = Sketch_1.addLine(-5, 12, -5, 15)
+SketchLine_8 = Sketch_1.addLine(-5, 15, 5, 15)
+SketchLine_9 = Sketch_1.addLine(5, 15, 5, 12)
+SketchConstraintCoincidence_6 = Sketch_1.setCoincident(SketchLine_9.endPoint(), SketchLine_6.startPoint())
+SketchConstraintCoincidence_7 = Sketch_1.setCoincident(SketchLine_6.endPoint(), SketchLine_7.startPoint())
+SketchConstraintCoincidence_8 = Sketch_1.setCoincident(SketchLine_7.endPoint(), SketchLine_8.startPoint())
+SketchConstraintCoincidence_9 = Sketch_1.setCoincident(SketchLine_8.endPoint(), SketchLine_9.startPoint())
+SketchConstraintHorizontal_3 = Sketch_1.setHorizontal(SketchLine_6.result())
+SketchConstraintVertical_3 = Sketch_1.setVertical(SketchLine_7.result())
+SketchConstraintHorizontal_4 = Sketch_1.setHorizontal(SketchLine_8.result())
+SketchConstraintVertical_4 = Sketch_1.setVertical(SketchLine_9.result())
+SketchConstraintLength_3 = Sketch_1.setLength(SketchLine_7.result(), 3)
+SketchConstraintLength_4 = Sketch_1.setLength(SketchLine_8.result(), 10)
+SketchConstraintDistance_2 = Sketch_1.setDistance(SketchLine_8.endPoint(), SketchLine_5.result(), 5, True)
+SketchConstraintDistance_3 = Sketch_1.setDistance(SketchLine_6.startPoint(), SketchLine_3.result(), 7, True)
+model.do()
+Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_4r-SketchLine_3r-SketchLine_2r-SketchLine_1r")], model.selection(), 60, 20)
+Extrusion_2 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_9r-SketchLine_8r-SketchLine_7r-SketchLine_6r")], model.selection(), 55, 15)
+LinearCopy_3 = model.addMultiTranslation(Part_1_doc, [model.selection("SOLID", "Extrusion_1_1")], model.selection("EDGE", "PartSet/OY"), 40, 2)
+AngularCopy_1 = model.addMultiRotation(Part_1_doc, [model.selection("SOLID", "Extrusion_2_1")], model.selection("EDGE", "PartSet/OZ"), 90, 2)
+Compound_1 = model.addCompound(Part_1_doc, [model.selection("COMPOUND", "LinearCopy_3_1"), model.selection("COMPOUND", "AngularCopy_1_1")])
+Compound_1.result().subResult(0).subResult(0).setColor(0, 170, 0)
+Compound_1.result().subResult(0).subResult(1).setColor(0, 170, 0)
+Compound_1.result().subResult(1).subResult(0).setColor(0, 255, 0)
+Compound_1.result().subResult(1).subResult(1).setColor(0, 255, 0)
+Smash_1 = model.addSmash(Part_1_doc, [model.selection("SOLID", "LinearCopy_2_1_1_1")], [model.selection("SOLID", "Compound_1_1_2_1"), model.selection("SOLID", "Compound_1_1_2_2")])
+
+model.testHaveNamingSubshapes(Smash_1, model, Part_1_doc)
+
+model.end()
+
+from GeomAPI import GeomAPI_Shape
+
+model.testNbResults(Smash_1, 1)
+model.testNbSubResults(Smash_1, [8])
+model.testNbSubShapes(Smash_1, GeomAPI_Shape.SOLID, [8])
+model.testNbSubShapes(Smash_1, GeomAPI_Shape.FACE, [80])
+model.testNbSubShapes(Smash_1, GeomAPI_Shape.EDGE, [348])
+model.testNbSubShapes(Smash_1, GeomAPI_Shape.VERTEX, [696])
+model.testResultsVolumes(Smash_1, [15044.469954918753501260653138161])
+
+assert(model.checkPythonDump())
diff --git a/src/FeaturesPlugin/Test/TestBooleanSmash_MultiLevelCompound_v0_2.py b/src/FeaturesPlugin/Test/TestBooleanSmash_MultiLevelCompound_v0_2.py
new file mode 100644 (file)
index 0000000..f3e5810
--- /dev/null
@@ -0,0 +1,121 @@
+# Copyright (C) 2014-2019  CEA/DEN, EDF R&D
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+#
+# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+#
+
+from SketchAPI import *
+
+from salome.shaper import model
+
+model.begin()
+partSet = model.moduleDocument()
+Part_1 = model.addPart(partSet)
+Part_1_doc = Part_1.document()
+Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY"))
+SketchProjection_1 = Sketch_1.addProjection(model.selection("EDGE", "PartSet/OX"), False)
+SketchLine_1 = SketchProjection_1.createdFeature()
+SketchCircle_1 = Sketch_1.addCircle(0, 0, 10)
+SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchAPI_Line(SketchLine_1).startPoint(), SketchCircle_1.center())
+SketchConstraintRadius_1 = Sketch_1.setRadius(SketchCircle_1.results()[1], 10)
+SketchCircle_2 = Sketch_1.addCircle(10, 0, 10)
+SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchLine_1.result(), SketchCircle_2.center())
+SketchConstraintEqual_1 = Sketch_1.setEqual(SketchCircle_1.results()[1], SketchCircle_2.results()[1])
+SketchConstraintDistanceHorizontal_1 = Sketch_1.setHorizontalDistance(SketchAPI_Line(SketchLine_1).startPoint(), SketchCircle_2.center(), 10)
+model.do()
+Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("COMPOUND", "Sketch_1")], model.selection(), 20, 0)
+Sketch_2 = model.addSketch(Part_1_doc, model.defaultPlane("XOY"))
+SketchProjection_2 = Sketch_2.addProjection(model.selection("EDGE", "PartSet/OY"), False)
+SketchLine_2 = SketchProjection_2.createdFeature()
+SketchCircle_3 = Sketch_2.addCircle(0, -7, 10)
+SketchConstraintCoincidence_3 = Sketch_2.setCoincident(SketchLine_2.result(), SketchCircle_3.center())
+SketchConstraintRadius_2 = Sketch_2.setRadius(SketchCircle_3.results()[1], 10)
+SketchConstraintDistanceVertical_1 = Sketch_2.setVerticalDistance(SketchCircle_3.center(), SketchAPI_Line(SketchLine_2).startPoint(), 7)
+SketchCircle_4 = Sketch_2.addCircle(40, -27, 10)
+SketchConstraintEqual_2 = Sketch_2.setEqual(SketchCircle_4.results()[1], SketchCircle_3.results()[1])
+SketchConstraintDistanceHorizontal_2 = Sketch_2.setHorizontalDistance(SketchCircle_3.center(), SketchCircle_4.center(), 40)
+SketchConstraintDistanceVertical_2 = Sketch_2.setVerticalDistance(SketchCircle_4.center(), SketchCircle_3.center(), 20)
+model.do()
+Extrusion_2 = model.addExtrusion(Part_1_doc, [model.selection("COMPOUND", "Sketch_2")], model.selection(), 20, 0)
+Compound_1 = model.addCompound(Part_1_doc, [model.selection("SOLID", "Extrusion_2_1"), model.selection("SOLID", "Extrusion_2_2")])
+Compound_2 = model.addCompound(Part_1_doc, [model.selection("COMPOUND", "Compound_1_1"), model.selection("COMPSOLID", "Extrusion_1_1")])
+Compound_2.result().subResult(0).setColor(255, 170, 0)
+Compound_2.result().subResult(0).subResult(0).setColor(255, 170, 0)
+Compound_2.result().subResult(0).subResult(1).setColor(255, 170, 0)
+Compound_2.result().subResult(1).setColor(0, 85, 255)
+Compound_2.result().subResult(1).subResult(0).setColor(0, 85, 255)
+Compound_2.result().subResult(1).subResult(1).setColor(0, 85, 255)
+Compound_2.result().subResult(1).subResult(2).setColor(0, 85, 255)
+Sketch_3 = model.addSketch(Part_1_doc, model.defaultPlane("YOZ"))
+SketchLine_3 = Sketch_3.addLine(7, 0, -7, 0)
+SketchLine_4 = Sketch_3.addLine(-7, 0, -7, 5)
+SketchLine_5 = Sketch_3.addLine(-7, 5, 7, 5)
+SketchLine_6 = Sketch_3.addLine(7, 5, 7, 0)
+SketchConstraintCoincidence_4 = Sketch_3.setCoincident(SketchLine_6.endPoint(), SketchLine_3.startPoint())
+SketchConstraintCoincidence_5 = Sketch_3.setCoincident(SketchLine_3.endPoint(), SketchLine_4.startPoint())
+SketchConstraintCoincidence_6 = Sketch_3.setCoincident(SketchLine_4.endPoint(), SketchLine_5.startPoint())
+SketchConstraintCoincidence_7 = Sketch_3.setCoincident(SketchLine_5.endPoint(), SketchLine_6.startPoint())
+SketchConstraintHorizontal_1 = Sketch_3.setHorizontal(SketchLine_3.result())
+SketchConstraintVertical_1 = Sketch_3.setVertical(SketchLine_4.result())
+SketchConstraintHorizontal_2 = Sketch_3.setHorizontal(SketchLine_5.result())
+SketchConstraintVertical_2 = Sketch_3.setVertical(SketchLine_6.result())
+SketchProjection_3 = Sketch_3.addProjection(model.selection("EDGE", "PartSet/OZ"), False)
+SketchLine_7 = SketchProjection_3.createdFeature()
+SketchConstraintDistance_1 = Sketch_3.setDistance(SketchLine_5.endPoint(), SketchLine_7.result(), 7, True)
+SketchConstraintMiddle_1 = Sketch_3.setMiddlePoint(SketchAPI_Line(SketchLine_7).startPoint(), SketchLine_3.result())
+SketchConstraintLength_1 = Sketch_3.setLength(SketchLine_4.result(), 5)
+SketchLine_8 = Sketch_3.addLine(7, 7, -7.000000000000001, 7)
+SketchLine_9 = Sketch_3.addLine(-7.000000000000001, 7, -7.000000000000001, 10)
+SketchLine_10 = Sketch_3.addLine(-7.000000000000001, 10, 7, 10)
+SketchLine_11 = Sketch_3.addLine(7, 10, 7, 7)
+SketchConstraintCoincidence_8 = Sketch_3.setCoincident(SketchLine_11.endPoint(), SketchLine_8.startPoint())
+SketchConstraintCoincidence_9 = Sketch_3.setCoincident(SketchLine_8.endPoint(), SketchLine_9.startPoint())
+SketchConstraintCoincidence_10 = Sketch_3.setCoincident(SketchLine_9.endPoint(), SketchLine_10.startPoint())
+SketchConstraintCoincidence_11 = Sketch_3.setCoincident(SketchLine_10.endPoint(), SketchLine_11.startPoint())
+SketchConstraintHorizontal_3 = Sketch_3.setHorizontal(SketchLine_8.result())
+SketchConstraintVertical_3 = Sketch_3.setVertical(SketchLine_9.result())
+SketchConstraintHorizontal_4 = Sketch_3.setHorizontal(SketchLine_10.result())
+SketchConstraintVertical_4 = Sketch_3.setVertical(SketchLine_11.result())
+SketchConstraintCoincidence_12 = Sketch_3.setCoincident(SketchLine_9.startPoint(), SketchLine_4.result())
+SketchConstraintCoincidence_13 = Sketch_3.setCoincident(SketchLine_8.startPoint(), SketchLine_6.result())
+SketchConstraintLength_2 = Sketch_3.setLength(SketchLine_9.result(), 3)
+SketchConstraintDistance_2 = Sketch_3.setDistance(SketchLine_9.startPoint(), SketchLine_5.result(), 2, True)
+model.do()
+Extrusion_3 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_3/Face-SketchLine_6r-SketchLine_5r-SketchLine_4r-SketchLine_3r")], model.selection(), 50, -10)
+Extrusion_4 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_3/Face-SketchLine_11r-SketchLine_10r-SketchLine_9r-SketchLine_8r")], model.selection(), 60, 20)
+AngularCopy_1 = model.addMultiRotation(Part_1_doc, [model.selection("SOLID", "Extrusion_4_1")], model.selection("EDGE", "PartSet/OZ"), 90, 2)
+Compound_3 = model.addCompound(Part_1_doc, [model.selection("SOLID", "Extrusion_3_1"), model.selection("COMPOUND", "AngularCopy_1_1")])
+Compound_3.result().subResult(0).setColor(0, 170, 0)
+Compound_3.result().subResult(1).setColor(0, 255, 0)
+Compound_3.result().subResult(1).subResult(0).setColor(0, 255, 0)
+Compound_3.result().subResult(1).subResult(1).setColor(0, 255, 0)
+Smash_1 = model.addSmash(Part_1_doc, [model.selection("SOLID", "Compound_2_1_1_1"), model.selection("SOLID", "Compound_2_1_2_3")], [model.selection("SOLID", "Compound_3_1_2_2")])
+
+model.testHaveNamingSubshapes(Smash_1, model, Part_1_doc)
+
+model.end()
+
+from GeomAPI import GeomAPI_Shape
+
+model.testNbResults(Smash_1, 1)
+model.testNbSubResults(Smash_1, [2])
+model.testNbSubShapes(Smash_1, GeomAPI_Shape.SOLID, [7])
+model.testNbSubShapes(Smash_1, GeomAPI_Shape.FACE, [71])
+model.testNbSubShapes(Smash_1, GeomAPI_Shape.EDGE, [328])
+model.testNbSubShapes(Smash_1, GeomAPI_Shape.VERTEX, [656])
+model.testResultsVolumes(Smash_1, [21124.1140931756599457])
+
+assert(model.checkPythonDump())
diff --git a/src/FeaturesPlugin/Test/TestBooleanSmash_MultiLevelCompound_v20190506_1.py b/src/FeaturesPlugin/Test/TestBooleanSmash_MultiLevelCompound_v20190506_1.py
new file mode 100644 (file)
index 0000000..e0b1e5c
--- /dev/null
@@ -0,0 +1,96 @@
+# Copyright (C) 2014-2019  CEA/DEN, EDF R&D
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+#
+# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+#
+
+from SketchAPI import *
+
+from salome.shaper import model
+
+model.begin()
+partSet = model.moduleDocument()
+Part_1 = model.addPart(partSet)
+Part_1_doc = Part_1.document()
+Cylinder_1 = model.addCylinder(Part_1_doc, model.selection("VERTEX", "PartSet/Origin"), model.selection("EDGE", "PartSet/OZ"), 10, 20)
+LinearCopy_1 = model.addMultiTranslation(Part_1_doc, [model.selection("SOLID", "Cylinder_1_1")], model.selection("EDGE", "PartSet/OX"), 40, 2)
+LinearCopy_2 = model.addMultiTranslation(Part_1_doc, [model.selection("COMPOUND", "LinearCopy_1_1")], model.selection("EDGE", "PartSet/OY"), 40, 2)
+LinearCopy_2.result().subResult(0).subResult(0).setColor(255, 170, 0)
+LinearCopy_2.result().subResult(0).subResult(1).setColor(255, 170, 0)
+LinearCopy_2.result().subResult(1).subResult(0).setColor(0, 0, 255)
+LinearCopy_2.result().subResult(1).subResult(1).setColor(0, 0, 255)
+Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("YOZ"))
+SketchLine_1 = Sketch_1.addLine(7, 0, -7, 0)
+SketchLine_2 = Sketch_1.addLine(-7, 0, -7, 5)
+SketchLine_3 = Sketch_1.addLine(-7, 5, 7, 5)
+SketchLine_4 = Sketch_1.addLine(7, 5, 7, 0)
+SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchLine_4.endPoint(), SketchLine_1.startPoint())
+SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_2.startPoint())
+SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchLine_2.endPoint(), SketchLine_3.startPoint())
+SketchConstraintCoincidence_4 = Sketch_1.setCoincident(SketchLine_3.endPoint(), SketchLine_4.startPoint())
+SketchConstraintHorizontal_1 = Sketch_1.setHorizontal(SketchLine_1.result())
+SketchConstraintVertical_1 = Sketch_1.setVertical(SketchLine_2.result())
+SketchConstraintHorizontal_2 = Sketch_1.setHorizontal(SketchLine_3.result())
+SketchConstraintVertical_2 = Sketch_1.setVertical(SketchLine_4.result())
+SketchProjection_1 = Sketch_1.addProjection(model.selection("EDGE", "PartSet/OZ"), False)
+SketchLine_5 = SketchProjection_1.createdFeature()
+SketchConstraintDistance_1 = Sketch_1.setDistance(SketchLine_3.endPoint(), SketchLine_5.result(), 7, True)
+SketchConstraintCoincidence_5 = Sketch_1.setCoincident(SketchAPI_Line(SketchLine_5).startPoint(), SketchLine_1.result())
+SketchConstraintLength_1 = Sketch_1.setLength(SketchLine_1.result(), 14)
+SketchConstraintLength_2 = Sketch_1.setLength(SketchLine_2.result(), 5)
+SketchLine_6 = Sketch_1.addLine(5, 12, -5, 12)
+SketchLine_7 = Sketch_1.addLine(-5, 12, -5, 15)
+SketchLine_8 = Sketch_1.addLine(-5, 15, 5, 15)
+SketchLine_9 = Sketch_1.addLine(5, 15, 5, 12)
+SketchConstraintCoincidence_6 = Sketch_1.setCoincident(SketchLine_9.endPoint(), SketchLine_6.startPoint())
+SketchConstraintCoincidence_7 = Sketch_1.setCoincident(SketchLine_6.endPoint(), SketchLine_7.startPoint())
+SketchConstraintCoincidence_8 = Sketch_1.setCoincident(SketchLine_7.endPoint(), SketchLine_8.startPoint())
+SketchConstraintCoincidence_9 = Sketch_1.setCoincident(SketchLine_8.endPoint(), SketchLine_9.startPoint())
+SketchConstraintHorizontal_3 = Sketch_1.setHorizontal(SketchLine_6.result())
+SketchConstraintVertical_3 = Sketch_1.setVertical(SketchLine_7.result())
+SketchConstraintHorizontal_4 = Sketch_1.setHorizontal(SketchLine_8.result())
+SketchConstraintVertical_4 = Sketch_1.setVertical(SketchLine_9.result())
+SketchConstraintLength_3 = Sketch_1.setLength(SketchLine_7.result(), 3)
+SketchConstraintLength_4 = Sketch_1.setLength(SketchLine_8.result(), 10)
+SketchConstraintDistance_2 = Sketch_1.setDistance(SketchLine_8.endPoint(), SketchLine_5.result(), 5, True)
+SketchConstraintDistance_3 = Sketch_1.setDistance(SketchLine_6.startPoint(), SketchLine_3.result(), 7, True)
+model.do()
+Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_4r-SketchLine_3r-SketchLine_2r-SketchLine_1r")], model.selection(), 60, 20)
+Extrusion_2 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_9r-SketchLine_8r-SketchLine_7r-SketchLine_6r")], model.selection(), 55, 15)
+LinearCopy_3 = model.addMultiTranslation(Part_1_doc, [model.selection("SOLID", "Extrusion_1_1")], model.selection("EDGE", "PartSet/OY"), 40, 2)
+AngularCopy_1 = model.addMultiRotation(Part_1_doc, [model.selection("SOLID", "Extrusion_2_1")], model.selection("EDGE", "PartSet/OZ"), 90, 2)
+Compound_1 = model.addCompound(Part_1_doc, [model.selection("COMPOUND", "LinearCopy_3_1"), model.selection("COMPOUND", "AngularCopy_1_1")])
+Compound_1.result().subResult(0).subResult(0).setColor(0, 170, 0)
+Compound_1.result().subResult(0).subResult(1).setColor(0, 170, 0)
+Compound_1.result().subResult(1).subResult(0).setColor(0, 255, 0)
+Compound_1.result().subResult(1).subResult(1).setColor(0, 255, 0)
+Smash_1 = model.addSmash(Part_1_doc, [model.selection("SOLID", "LinearCopy_2_1_1_1")], [model.selection("SOLID", "Compound_1_1_2_1"), model.selection("SOLID", "Compound_1_1_2_2")], 20190506)
+
+model.testHaveNamingSubshapes(Smash_1, model, Part_1_doc)
+
+model.end()
+
+from GeomAPI import GeomAPI_Shape
+
+model.testNbResults(Smash_1, 1)
+model.testNbSubResults(Smash_1, [3])
+model.testNbSubShapes(Smash_1, GeomAPI_Shape.SOLID, [12])
+model.testNbSubShapes(Smash_1, GeomAPI_Shape.FACE, [98])
+model.testNbSubShapes(Smash_1, GeomAPI_Shape.EDGE, [408])
+model.testNbSubShapes(Smash_1, GeomAPI_Shape.VERTEX, [816])
+model.testResultsVolumes(Smash_1, [38810.840569277926988])
+
+assert(model.checkPythonDump())
diff --git a/src/FeaturesPlugin/Test/TestBooleanSmash_MultiLevelCompound_v20190506_2.py b/src/FeaturesPlugin/Test/TestBooleanSmash_MultiLevelCompound_v20190506_2.py
new file mode 100644 (file)
index 0000000..5bb3790
--- /dev/null
@@ -0,0 +1,121 @@
+# Copyright (C) 2014-2019  CEA/DEN, EDF R&D
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+#
+# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+#
+
+from SketchAPI import *
+
+from salome.shaper import model
+
+model.begin()
+partSet = model.moduleDocument()
+Part_1 = model.addPart(partSet)
+Part_1_doc = Part_1.document()
+Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY"))
+SketchProjection_1 = Sketch_1.addProjection(model.selection("EDGE", "PartSet/OX"), False)
+SketchLine_1 = SketchProjection_1.createdFeature()
+SketchCircle_1 = Sketch_1.addCircle(0, 0, 10)
+SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchAPI_Line(SketchLine_1).startPoint(), SketchCircle_1.center())
+SketchConstraintRadius_1 = Sketch_1.setRadius(SketchCircle_1.results()[1], 10)
+SketchCircle_2 = Sketch_1.addCircle(10, 0, 10)
+SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchLine_1.result(), SketchCircle_2.center())
+SketchConstraintEqual_1 = Sketch_1.setEqual(SketchCircle_1.results()[1], SketchCircle_2.results()[1])
+SketchConstraintDistanceHorizontal_1 = Sketch_1.setHorizontalDistance(SketchAPI_Line(SketchLine_1).startPoint(), SketchCircle_2.center(), 10)
+model.do()
+Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("COMPOUND", "Sketch_1")], model.selection(), 20, 0)
+Sketch_2 = model.addSketch(Part_1_doc, model.defaultPlane("XOY"))
+SketchProjection_2 = Sketch_2.addProjection(model.selection("EDGE", "PartSet/OY"), False)
+SketchLine_2 = SketchProjection_2.createdFeature()
+SketchCircle_3 = Sketch_2.addCircle(0, -7, 10)
+SketchConstraintCoincidence_3 = Sketch_2.setCoincident(SketchLine_2.result(), SketchCircle_3.center())
+SketchConstraintRadius_2 = Sketch_2.setRadius(SketchCircle_3.results()[1], 10)
+SketchConstraintDistanceVertical_1 = Sketch_2.setVerticalDistance(SketchCircle_3.center(), SketchAPI_Line(SketchLine_2).startPoint(), 7)
+SketchCircle_4 = Sketch_2.addCircle(40, -27, 10)
+SketchConstraintEqual_2 = Sketch_2.setEqual(SketchCircle_4.results()[1], SketchCircle_3.results()[1])
+SketchConstraintDistanceHorizontal_2 = Sketch_2.setHorizontalDistance(SketchCircle_3.center(), SketchCircle_4.center(), 40)
+SketchConstraintDistanceVertical_2 = Sketch_2.setVerticalDistance(SketchCircle_4.center(), SketchCircle_3.center(), 20)
+model.do()
+Extrusion_2 = model.addExtrusion(Part_1_doc, [model.selection("COMPOUND", "Sketch_2")], model.selection(), 20, 0)
+Compound_1 = model.addCompound(Part_1_doc, [model.selection("SOLID", "Extrusion_2_1"), model.selection("SOLID", "Extrusion_2_2")])
+Compound_2 = model.addCompound(Part_1_doc, [model.selection("COMPOUND", "Compound_1_1"), model.selection("COMPSOLID", "Extrusion_1_1")])
+Compound_2.result().subResult(0).setColor(255, 170, 0)
+Compound_2.result().subResult(0).subResult(0).setColor(255, 170, 0)
+Compound_2.result().subResult(0).subResult(1).setColor(255, 170, 0)
+Compound_2.result().subResult(1).setColor(0, 85, 255)
+Compound_2.result().subResult(1).subResult(0).setColor(0, 85, 255)
+Compound_2.result().subResult(1).subResult(1).setColor(0, 85, 255)
+Compound_2.result().subResult(1).subResult(2).setColor(0, 85, 255)
+Sketch_3 = model.addSketch(Part_1_doc, model.defaultPlane("YOZ"))
+SketchLine_3 = Sketch_3.addLine(7, 0, -7, 0)
+SketchLine_4 = Sketch_3.addLine(-7, 0, -7, 5)
+SketchLine_5 = Sketch_3.addLine(-7, 5, 7, 5)
+SketchLine_6 = Sketch_3.addLine(7, 5, 7, 0)
+SketchConstraintCoincidence_4 = Sketch_3.setCoincident(SketchLine_6.endPoint(), SketchLine_3.startPoint())
+SketchConstraintCoincidence_5 = Sketch_3.setCoincident(SketchLine_3.endPoint(), SketchLine_4.startPoint())
+SketchConstraintCoincidence_6 = Sketch_3.setCoincident(SketchLine_4.endPoint(), SketchLine_5.startPoint())
+SketchConstraintCoincidence_7 = Sketch_3.setCoincident(SketchLine_5.endPoint(), SketchLine_6.startPoint())
+SketchConstraintHorizontal_1 = Sketch_3.setHorizontal(SketchLine_3.result())
+SketchConstraintVertical_1 = Sketch_3.setVertical(SketchLine_4.result())
+SketchConstraintHorizontal_2 = Sketch_3.setHorizontal(SketchLine_5.result())
+SketchConstraintVertical_2 = Sketch_3.setVertical(SketchLine_6.result())
+SketchProjection_3 = Sketch_3.addProjection(model.selection("EDGE", "PartSet/OZ"), False)
+SketchLine_7 = SketchProjection_3.createdFeature()
+SketchConstraintDistance_1 = Sketch_3.setDistance(SketchLine_5.endPoint(), SketchLine_7.result(), 7, True)
+SketchConstraintMiddle_1 = Sketch_3.setMiddlePoint(SketchAPI_Line(SketchLine_7).startPoint(), SketchLine_3.result())
+SketchConstraintLength_1 = Sketch_3.setLength(SketchLine_4.result(), 5)
+SketchLine_8 = Sketch_3.addLine(7, 7, -7.000000000000001, 7)
+SketchLine_9 = Sketch_3.addLine(-7.000000000000001, 7, -7.000000000000001, 10)
+SketchLine_10 = Sketch_3.addLine(-7.000000000000001, 10, 7, 10)
+SketchLine_11 = Sketch_3.addLine(7, 10, 7, 7)
+SketchConstraintCoincidence_8 = Sketch_3.setCoincident(SketchLine_11.endPoint(), SketchLine_8.startPoint())
+SketchConstraintCoincidence_9 = Sketch_3.setCoincident(SketchLine_8.endPoint(), SketchLine_9.startPoint())
+SketchConstraintCoincidence_10 = Sketch_3.setCoincident(SketchLine_9.endPoint(), SketchLine_10.startPoint())
+SketchConstraintCoincidence_11 = Sketch_3.setCoincident(SketchLine_10.endPoint(), SketchLine_11.startPoint())
+SketchConstraintHorizontal_3 = Sketch_3.setHorizontal(SketchLine_8.result())
+SketchConstraintVertical_3 = Sketch_3.setVertical(SketchLine_9.result())
+SketchConstraintHorizontal_4 = Sketch_3.setHorizontal(SketchLine_10.result())
+SketchConstraintVertical_4 = Sketch_3.setVertical(SketchLine_11.result())
+SketchConstraintCoincidence_12 = Sketch_3.setCoincident(SketchLine_9.startPoint(), SketchLine_4.result())
+SketchConstraintCoincidence_13 = Sketch_3.setCoincident(SketchLine_8.startPoint(), SketchLine_6.result())
+SketchConstraintLength_2 = Sketch_3.setLength(SketchLine_9.result(), 3)
+SketchConstraintDistance_2 = Sketch_3.setDistance(SketchLine_9.startPoint(), SketchLine_5.result(), 2, True)
+model.do()
+Extrusion_3 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_3/Face-SketchLine_6r-SketchLine_5r-SketchLine_4r-SketchLine_3r")], model.selection(), 50, -10)
+Extrusion_4 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_3/Face-SketchLine_11r-SketchLine_10r-SketchLine_9r-SketchLine_8r")], model.selection(), 60, 20)
+AngularCopy_1 = model.addMultiRotation(Part_1_doc, [model.selection("SOLID", "Extrusion_4_1")], model.selection("EDGE", "PartSet/OZ"), 90, 2)
+Compound_3 = model.addCompound(Part_1_doc, [model.selection("SOLID", "Extrusion_3_1"), model.selection("COMPOUND", "AngularCopy_1_1")])
+Compound_3.result().subResult(0).setColor(0, 170, 0)
+Compound_3.result().subResult(1).setColor(0, 255, 0)
+Compound_3.result().subResult(1).subResult(0).setColor(0, 255, 0)
+Compound_3.result().subResult(1).subResult(1).setColor(0, 255, 0)
+Smash_1 = model.addSmash(Part_1_doc, [model.selection("SOLID", "Compound_2_1_1_1"), model.selection("SOLID", "Compound_2_1_2_3")], [model.selection("SOLID", "Compound_3_1_2_2")], 20190506)
+
+model.testHaveNamingSubshapes(Smash_1, model, Part_1_doc)
+
+model.end()
+
+from GeomAPI import GeomAPI_Shape
+
+model.testNbResults(Smash_1, 1)
+model.testNbSubResults(Smash_1, [3])
+model.testNbSubShapes(Smash_1, GeomAPI_Shape.SOLID, [9])
+model.testNbSubShapes(Smash_1, GeomAPI_Shape.FACE, [83])
+model.testNbSubShapes(Smash_1, GeomAPI_Shape.EDGE, [376])
+model.testNbSubShapes(Smash_1, GeomAPI_Shape.VERTEX, [752])
+model.testResultsVolumes(Smash_1, [27284.1140931756599457])
+
+assert(model.checkPythonDump())