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

13 files changed:
src/FeaturesAPI/FeaturesAPI_BooleanCommon.cpp
src/FeaturesAPI/FeaturesAPI_BooleanCommon.h
src/FeaturesPlugin/CMakeLists.txt
src/FeaturesPlugin/FeaturesPlugin_Boolean.cpp
src/FeaturesPlugin/FeaturesPlugin_Boolean.h
src/FeaturesPlugin/FeaturesPlugin_BooleanCommon.cpp
src/FeaturesPlugin/FeaturesPlugin_BooleanFuse.cpp
src/FeaturesPlugin/FeaturesPlugin_BooleanFuse.h
src/FeaturesPlugin/Test/TestBooleanCommon_MultiLevelCompound0.py [deleted file]
src/FeaturesPlugin/Test/TestBooleanCommon_MultiLevelCompound_v0_1.py [new file with mode: 0644]
src/FeaturesPlugin/Test/TestBooleanCommon_MultiLevelCompound_v0_2.py [new file with mode: 0644]
src/FeaturesPlugin/Test/TestBooleanCommon_MultiLevelCompound_v20190506_1.py [new file with mode: 0644]
src/FeaturesPlugin/Test/TestBooleanCommon_MultiLevelCompound_v20190506_2.py [new file with mode: 0644]

index b036ab38e90e865d4dec2d05d982b1d974537400..d928b89da6b789ba63c4e0b4b19cc41344f80222 100644 (file)
@@ -34,11 +34,13 @@ FeaturesAPI_BooleanCommon::FeaturesAPI_BooleanCommon(
 //==================================================================================================
 FeaturesAPI_BooleanCommon::FeaturesAPI_BooleanCommon(
   const std::shared_ptr<ModelAPI_Feature>& theFeature,
 //==================================================================================================
 FeaturesAPI_BooleanCommon::FeaturesAPI_BooleanCommon(
   const std::shared_ptr<ModelAPI_Feature>& theFeature,
-  const std::list<ModelHighAPI_Selection>& theMainObjects)
+  const std::list<ModelHighAPI_Selection>& theMainObjects,
+  const int theVersion)
 : ModelHighAPI_Interface(theFeature)
 {
   if(initialize()) {
     fillAttribute(FeaturesPlugin_BooleanCommon::CREATION_METHOD_SIMPLE(), mycreationMethod);
 : ModelHighAPI_Interface(theFeature)
 {
   if(initialize()) {
     fillAttribute(FeaturesPlugin_BooleanCommon::CREATION_METHOD_SIMPLE(), mycreationMethod);
+    fillAttribute(theVersion, theFeature->integer(FeaturesPlugin_Boolean::VERSION_ID()));
     fillAttribute(theMainObjects, mymainObjects);
 
     execute(false);
     fillAttribute(theMainObjects, mymainObjects);
 
     execute(false);
@@ -49,11 +51,13 @@ FeaturesAPI_BooleanCommon::FeaturesAPI_BooleanCommon(
 FeaturesAPI_BooleanCommon::FeaturesAPI_BooleanCommon(
   const std::shared_ptr<ModelAPI_Feature>& theFeature,
   const std::list<ModelHighAPI_Selection>& theMainObjects,
 FeaturesAPI_BooleanCommon::FeaturesAPI_BooleanCommon(
   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(FeaturesPlugin_BooleanCommon::CREATION_METHOD_ADVANCED(), mycreationMethod);
 : ModelHighAPI_Interface(theFeature)
 {
   if(initialize()) {
     fillAttribute(FeaturesPlugin_BooleanCommon::CREATION_METHOD_ADVANCED(), mycreationMethod);
+    fillAttribute(theVersion, theFeature->integer(FeaturesPlugin_Boolean::VERSION_ID()));
     fillAttribute(theMainObjects, mymainObjects);
     fillAttribute(theToolObjects, mytoolObjects);
 
     fillAttribute(theMainObjects, mymainObjects);
     fillAttribute(theToolObjects, mytoolObjects);
 
@@ -111,6 +115,8 @@ void FeaturesAPI_BooleanCommon::dump(ModelHighAPI_Dumper& theDumper) const
     aBase->selectionList(FeaturesPlugin_BooleanCommon::OBJECT_LIST_ID());
   AttributeSelectionListPtr aTools =
     aBase->selectionList(FeaturesPlugin_BooleanCommon::TOOL_LIST_ID());
     aBase->selectionList(FeaturesPlugin_BooleanCommon::OBJECT_LIST_ID());
   AttributeSelectionListPtr aTools =
     aBase->selectionList(FeaturesPlugin_BooleanCommon::TOOL_LIST_ID());
+  AttributeIntegerPtr aVersion =
+    aBase->integer(FeaturesPlugin_BooleanCommon::VERSION_ID());
 
   theDumper << "(" << aDocName << ", " << anObjects;
 
 
   theDumper << "(" << aDocName << ", " << anObjects;
 
@@ -118,24 +124,31 @@ void FeaturesAPI_BooleanCommon::dump(ModelHighAPI_Dumper& theDumper) const
     theDumper << ", " << aTools;
   }
 
     theDumper << ", " << aTools;
   }
 
+  if (aVersion && aVersion->isInitialized()) {
+    theDumper << ", " << aVersion->value();
+  }
+
   theDumper << ")" << std::endl;
 }
 
 //==================================================================================================
 BooleanCommonPtr addCommon(const std::shared_ptr<ModelAPI_Document>& thePart,
   theDumper << ")" << std::endl;
 }
 
 //==================================================================================================
 BooleanCommonPtr addCommon(const std::shared_ptr<ModelAPI_Document>& thePart,
-                           const std::list<ModelHighAPI_Selection>& theMainObjects)
+                           const std::list<ModelHighAPI_Selection>& theMainObjects,
+                           const int theVersion)
 {
   std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(FeaturesAPI_BooleanCommon::ID());
 {
   std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(FeaturesAPI_BooleanCommon::ID());
-  return BooleanCommonPtr(new FeaturesAPI_BooleanCommon(aFeature, theMainObjects));
+  return BooleanCommonPtr(new FeaturesAPI_BooleanCommon(aFeature, theMainObjects, theVersion));
 }
 
 //==================================================================================================
 BooleanCommonPtr addCommon(const std::shared_ptr<ModelAPI_Document>& thePart,
                            const std::list<ModelHighAPI_Selection>& theMainObjects,
 }
 
 //==================================================================================================
 BooleanCommonPtr addCommon(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_BooleanCommon::ID());
   return BooleanCommonPtr(new FeaturesAPI_BooleanCommon(aFeature,
                                                         theMainObjects,
 {
   std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(FeaturesAPI_BooleanCommon::ID());
   return BooleanCommonPtr(new FeaturesAPI_BooleanCommon(aFeature,
                                                         theMainObjects,
-                                                        theToolObjects));
+                                                        theToolObjects,
+                                                        theVersion));
 }
 }
index 9005aed2b8ebb8a3aca65e4083d5407136e4ca5c..3470276b7eea79ac5d15fd3c41d519bbe0bda269 100644 (file)
@@ -43,13 +43,15 @@ public:
     /// Constructor with values.
   FEATURESAPI_EXPORT
   FeaturesAPI_BooleanCommon(const std::shared_ptr<ModelAPI_Feature>& theFeature,
     /// Constructor with values.
   FEATURESAPI_EXPORT
   FeaturesAPI_BooleanCommon(const std::shared_ptr<ModelAPI_Feature>& theFeature,
-                            const std::list<ModelHighAPI_Selection>& theMainObjects);
+                            const std::list<ModelHighAPI_Selection>& theMainObjects,
+                            const int theVersion = 0);
 
   /// Constructor with values.
   FEATURESAPI_EXPORT
   FeaturesAPI_BooleanCommon(const std::shared_ptr<ModelAPI_Feature>& theFeature,
                             const std::list<ModelHighAPI_Selection>& theMainObjects,
 
   /// Constructor with values.
   FEATURESAPI_EXPORT
   FeaturesAPI_BooleanCommon(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
 
   /// Destructor.
   FEATURESAPI_EXPORT
@@ -87,13 +89,15 @@ typedef std::shared_ptr<FeaturesAPI_BooleanCommon> BooleanCommonPtr;
 /// \brief Create Boolean Common feature.
 FEATURESAPI_EXPORT
 BooleanCommonPtr addCommon(const std::shared_ptr<ModelAPI_Document>& thePart,
 /// \brief Create Boolean Common feature.
 FEATURESAPI_EXPORT
 BooleanCommonPtr addCommon(const std::shared_ptr<ModelAPI_Document>& thePart,
-                           const std::list<ModelHighAPI_Selection>& theMainObjects);
+                           const std::list<ModelHighAPI_Selection>& theMainObjects,
+                           const int theVersion = 0);
 
 /// \ingroup CPPHighAPI
 /// \brief Create Boolean Common feature.
 FEATURESAPI_EXPORT
 BooleanCommonPtr addCommon(const std::shared_ptr<ModelAPI_Document>& thePart,
                            const std::list<ModelHighAPI_Selection>& theMainObjects,
 
 /// \ingroup CPPHighAPI
 /// \brief Create Boolean Common feature.
 FEATURESAPI_EXPORT
 BooleanCommonPtr addCommon(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_BooleanCommon_H_
 
 #endif // FeaturesAPI_BooleanCommon_H_
index 82fd74586c1a27a89a5b4d6f7f08c955a306f923..8fbf6f07676cc4f4ebfed7b9204390e9b046f392 100644 (file)
@@ -460,7 +460,10 @@ ADD_UNIT_TESTS(TestExtrusion.py
                Test2826.py
                Test2854.py
                Test2878.py
                Test2826.py
                Test2854.py
                Test2878.py
-               TestBooleanCommon_MultiLevelCompound0.py
+               TestBooleanCommon_MultiLevelCompound_v0_1.py
+               TestBooleanCommon_MultiLevelCompound_v0_2.py
+               TestBooleanCommon_MultiLevelCompound_v20190506_1.py
+               TestBooleanCommon_MultiLevelCompound_v20190506_2.py
                TestBooleanCut_MultiLevelCompound0.py
                TestBooleanFuse_MultiLevelCompound_v0_1.py
                TestBooleanFuse_MultiLevelCompound_v0_2.py
                TestBooleanCut_MultiLevelCompound0.py
                TestBooleanFuse_MultiLevelCompound_v0_1.py
                TestBooleanFuse_MultiLevelCompound_v0_2.py
index 856d8d4679fdc586284e21de592f2f006e08e6eb..ec55ff5e303f685cdc742988a7a24c24fe851afc 100644 (file)
@@ -154,7 +154,8 @@ bool FeaturesPlugin_Boolean::processObject(
     const ListOfShape& thePlanes,
     int& theResultIndex,
     std::vector<FeaturesPlugin_Tools::ResultBaseAlgo>& theResultBaseAlgoList,
     const ListOfShape& thePlanes,
     int& theResultIndex,
     std::vector<FeaturesPlugin_Tools::ResultBaseAlgo>& theResultBaseAlgoList,
-    ListOfShape& theResultShapesList)
+    ListOfShape& theResultShapesList,
+    GeomShapePtr theResultCompound)
 {
   ListOfShape aListWithObject;
   aListWithObject.push_back(theObject);
 {
   ListOfShape aListWithObject;
   aListWithObject.push_back(theObject);
@@ -209,22 +210,31 @@ bool FeaturesPlugin_Boolean::processObject(
 
   GeomAPI_ShapeIterator aShapeIt(aResShape);
   if (aShapeIt.more() || aResShape->shapeType() == GeomAPI_Shape::VERTEX) {
 
   GeomAPI_ShapeIterator aShapeIt(aResShape);
   if (aShapeIt.more() || aResShape->shapeType() == GeomAPI_Shape::VERTEX) {
-    std::shared_ptr<ModelAPI_ResultBody> aResultBody =
-        document()->createBody(data(), theResultIndex);
+    std::shared_ptr<ModelAPI_ResultBody> aResultBody;
 
 
-    // tools should be added to the list to fulfill the correct history of modification
-    aListWithObject.insert(aListWithObject.end(), theTools.begin(), theTools.end());
-
-    ListOfShape aUsedTools = theTools;
-    aUsedTools.insert(aUsedTools.end(), thePlanes.begin(), thePlanes.end());
+    if (theResultCompound) { // store BOP result to the compound
+      std::shared_ptr<GeomAlgoAPI_ShapeBuilder> aBuilder(new GeomAlgoAPI_ShapeBuilder);
+      aBuilder->add(theResultCompound, aResShape);
+      aMakeShapeList->appendAlgo(aBuilder);
+    }
+    else { // create a separate ResultBody
+      aResultBody = document()->createBody(data(), theResultIndex);
+
+      // tools should be added to the list to fulfill the correct history of modification
+      aListWithObject.insert(aListWithObject.end(), theTools.begin(), theTools.end());
+
+      ListOfShape aUsedTools = theTools;
+      aUsedTools.insert(aUsedTools.end(), thePlanes.begin(), thePlanes.end());
+
+      FeaturesPlugin_Tools::loadModifiedShapes(aResultBody,
+                                               aListWithObject,
+                                               aUsedTools,
+                                               aMakeShapeList,
+                                               aResShape);
+      setResult(aResultBody, theResultIndex);
+      ++theResultIndex;
+    }
 
 
-    FeaturesPlugin_Tools::loadModifiedShapes(aResultBody,
-                                             aListWithObject,
-                                             aUsedTools,
-                                             aMakeShapeList,
-                                             aResShape);
-    setResult(aResultBody, theResultIndex);
-    ++theResultIndex;
 
     FeaturesPlugin_Tools::ResultBaseAlgo aRBA;
     aRBA.resultBody = aResultBody;
 
     FeaturesPlugin_Tools::ResultBaseAlgo aRBA;
     aRBA.resultBody = aResultBody;
@@ -245,7 +255,8 @@ bool FeaturesPlugin_Boolean::processCompsolid(
     const ListOfShape& thePlanes,
     int& theResultIndex,
     std::vector<FeaturesPlugin_Tools::ResultBaseAlgo>& theResultBaseAlgoList,
     const ListOfShape& thePlanes,
     int& theResultIndex,
     std::vector<FeaturesPlugin_Tools::ResultBaseAlgo>& theResultBaseAlgoList,
-    ListOfShape& theResultShapesList)
+    ListOfShape& theResultShapesList,
+    GeomShapePtr theResultCompound)
 {
   ListOfShape aUsedInOperationSolids;
   ListOfShape aNotUsedSolids;
 {
   ListOfShape aUsedInOperationSolids;
   ListOfShape aNotUsedSolids;
@@ -306,24 +317,32 @@ bool FeaturesPlugin_Boolean::processCompsolid(
   GeomAPI_ShapeIterator aShapeIt(aResultShape);
   if (aShapeIt.more() || aResultShape->shapeType() == GeomAPI_Shape::VERTEX)
   {
   GeomAPI_ShapeIterator aShapeIt(aResultShape);
   if (aShapeIt.more() || aResultShape->shapeType() == GeomAPI_Shape::VERTEX)
   {
-    std::shared_ptr<ModelAPI_ResultBody> aResultBody =
-        document()->createBody(data(), theResultIndex);
+    std::shared_ptr<ModelAPI_ResultBody> aResultBody;
 
 
-    ListOfShape aCompSolidList;
-    aCompSolidList.push_back(theCompsolid);
-    // tools should be added to the list to fulfill the correct history of modification
-    aCompSolidList.insert(aCompSolidList.end(), theTools.begin(), theTools.end());
-
-    ListOfShape aUsedTools = theTools;
-    aUsedTools.insert(aUsedTools.end(), thePlanes.begin(), thePlanes.end());
-
-    FeaturesPlugin_Tools::loadModifiedShapes(aResultBody,
-                                             aCompSolidList,
-                                             aUsedTools,
-                                             aMakeShapeList,
-                                             aResultShape);
-    setResult(aResultBody, theResultIndex);
-    ++theResultIndex;
+    if (theResultCompound) { // store BOP result to the compound
+      std::shared_ptr<GeomAlgoAPI_ShapeBuilder> aBuilder(new GeomAlgoAPI_ShapeBuilder);
+      aBuilder->add(theResultCompound, aResultShape);
+      aMakeShapeList->appendAlgo(aBuilder);
+    }
+    else { // create a separate ResultBody
+      aResultBody = document()->createBody(data(), theResultIndex);
+
+      ListOfShape aCompSolidList;
+      aCompSolidList.push_back(theCompsolid);
+      // tools should be added to the list to fulfill the correct history of modification
+      aCompSolidList.insert(aCompSolidList.end(), theTools.begin(), theTools.end());
+
+      ListOfShape aUsedTools = theTools;
+      aUsedTools.insert(aUsedTools.end(), thePlanes.begin(), thePlanes.end());
+
+      FeaturesPlugin_Tools::loadModifiedShapes(aResultBody,
+                                               aCompSolidList,
+                                               aUsedTools,
+                                               aMakeShapeList,
+                                               aResultShape);
+      setResult(aResultBody, theResultIndex);
+      ++theResultIndex;
+    }
 
     FeaturesPlugin_Tools::ResultBaseAlgo aRBA;
     aRBA.resultBody = aResultBody;
 
     FeaturesPlugin_Tools::ResultBaseAlgo aRBA;
     aRBA.resultBody = aResultBody;
@@ -343,7 +362,8 @@ bool FeaturesPlugin_Boolean::processCompound(
     const ListOfShape& theTools,
     int& theResultIndex,
     std::vector<FeaturesPlugin_Tools::ResultBaseAlgo>& theResultBaseAlgoList,
     const ListOfShape& theTools,
     int& theResultIndex,
     std::vector<FeaturesPlugin_Tools::ResultBaseAlgo>& theResultBaseAlgoList,
-    ListOfShape& theResultShapesList)
+    ListOfShape& theResultShapesList,
+    GeomShapePtr theResultCompound)
 {
   ListOfShape aUsedInOperationShapes;
   ListOfShape aNotUsedShapes;
 {
   ListOfShape aUsedInOperationShapes;
   ListOfShape aNotUsedShapes;
@@ -387,18 +407,26 @@ bool FeaturesPlugin_Boolean::processCompound(
 
   GeomAPI_ShapeIterator aShapeIt(aResultShape);
   if (aShapeIt.more() || aResultShape->shapeType() == GeomAPI_Shape::VERTEX) {
 
   GeomAPI_ShapeIterator aShapeIt(aResultShape);
   if (aShapeIt.more() || aResultShape->shapeType() == GeomAPI_Shape::VERTEX) {
-    std::shared_ptr<ModelAPI_ResultBody> aResultBody =
-        document()->createBody(data(), theResultIndex);
-
-    ListOfShape aCompoundList;
-    aCompoundList.push_back(theCompound);
-    FeaturesPlugin_Tools::loadModifiedShapes(aResultBody,
-                                             aCompoundList,
-                                             theTools,
-                                             aMakeShapeList,
-                                             aResultShape);
-    setResult(aResultBody, theResultIndex);
-    ++theResultIndex;
+    std::shared_ptr<ModelAPI_ResultBody> aResultBody;
+
+    if (theResultCompound) { // store BOP result to the compound
+      std::shared_ptr<GeomAlgoAPI_ShapeBuilder> aBuilder(new GeomAlgoAPI_ShapeBuilder);
+      aBuilder->add(theResultCompound, aResultShape);
+      aMakeShapeList->appendAlgo(aBuilder);
+    }
+    else { // create a separate ResultBody
+      aResultBody = document()->createBody(data(), theResultIndex);
+
+      ListOfShape aCompoundList;
+      aCompoundList.push_back(theCompound);
+      FeaturesPlugin_Tools::loadModifiedShapes(aResultBody,
+                                               aCompoundList,
+                                               theTools,
+                                               aMakeShapeList,
+                                               aResultShape);
+      setResult(aResultBody, theResultIndex);
+      ++theResultIndex;
+    }
 
     FeaturesPlugin_Tools::ResultBaseAlgo aRBA;
     aRBA.resultBody = aResultBody;
 
     FeaturesPlugin_Tools::ResultBaseAlgo aRBA;
     aRBA.resultBody = aResultBody;
@@ -410,6 +438,46 @@ bool FeaturesPlugin_Boolean::processCompound(
   return true;
 }
 
   return true;
 }
 
+//==================================================================================================
+GeomShapePtr FeaturesPlugin_Boolean::keepUnusedSubsOfCompound(
+    const GeomShapePtr& theResult,
+    const ObjectHierarchy& theObjectsHierarchy,
+    const ObjectHierarchy& theToolsHierarchy,
+    std::shared_ptr<GeomAlgoAPI_MakeShapeList> theMakeShapeList)
+{
+  ListOfShape aCompounds;
+  theObjectsHierarchy.CompoundsOfUnusedObjects(aCompounds);
+  theToolsHierarchy.CompoundsOfUnusedObjects(aCompounds);
+
+  GeomShapePtr aResultShape = theResult;
+  if (!aCompounds.empty()) {
+    aResultShape = aCompounds.front();
+    aCompounds.pop_front();
+
+    std::shared_ptr<GeomAlgoAPI_ShapeBuilder> aBuilder(new GeomAlgoAPI_ShapeBuilder);
+    for (ListOfShape::iterator anIt = aCompounds.begin(); anIt != aCompounds.end(); ++anIt) {
+      for (GeomAPI_ShapeIterator aSub(*anIt); aSub.more(); aSub.next())
+        aBuilder->add(aResultShape, aSub.current());
+    }
+
+    if (theResult)
+      aBuilder->add(aResultShape, theResult);
+
+    theMakeShapeList->appendAlgo(aBuilder);
+  }
+  return aResultShape;
+}
+
+//=================================================================================================
+int FeaturesPlugin_Boolean::version()
+{
+  AttributeIntegerPtr aVersionAttr = integer(VERSION_ID());
+  int aVersion = 0;
+  if (aVersionAttr && aVersionAttr->isInitialized())
+    aVersion = aVersionAttr->value();
+  return aVersion;
+}
+
 //=================================================================================================
 
 void FeaturesPlugin_Boolean::ObjectHierarchy::AddObject(const GeomShapePtr& theObject)
 //=================================================================================================
 
 void FeaturesPlugin_Boolean::ObjectHierarchy::AddObject(const GeomShapePtr& theObject)
index 9f6f216285ea624660bd9a67bc21555f709b2f52..f2f11b3541115a2e4453bf7ce0bf097dc4c35a2c 100644 (file)
@@ -29,6 +29,7 @@
 #include <ModelAPI_Feature.h>
 
 class ModelAPI_Result;
 #include <ModelAPI_Feature.h>
 
 class ModelAPI_Result;
+class GeomAlgoAPI_MakeShapeList;
 
 /// \class FeaturesPlugin_Boolean
 /// \ingroup Plugins
 
 /// \class FeaturesPlugin_Boolean
 /// \ingroup Plugins
@@ -168,7 +169,9 @@ protected:
                         ObjectHierarchy& theObjects,
                         ListOfShape& thePlanesList);
 
                         ObjectHierarchy& theObjects,
                         ListOfShape& thePlanesList);
 
-  /// Perform Boolean operation of the object with the tools
+  /// Perform Boolean operation of the object with the tools.
+  /// In case of theResultCompound is not empty, the result of Boolean operation
+  /// is added to this compound, and corresponding ResultBody is not generated.
   /// \return \c false if something went wrong
   bool processObject(const GeomAlgoAPI_Tools::BOPType theBooleanType,
                      const GeomShapePtr& theObject,
   /// \return \c false if something went wrong
   bool processObject(const GeomAlgoAPI_Tools::BOPType theBooleanType,
                      const GeomShapePtr& theObject,
@@ -176,9 +179,12 @@ protected:
                      const ListOfShape& thePlanes,
                      int& theResultIndex,
                      std::vector<FeaturesPlugin_Tools::ResultBaseAlgo>& theResultBaseAlgoList,
                      const ListOfShape& thePlanes,
                      int& theResultIndex,
                      std::vector<FeaturesPlugin_Tools::ResultBaseAlgo>& theResultBaseAlgoList,
-                     ListOfShape& theResultShapesList);
+                     ListOfShape& theResultShapesList,
+                     GeomShapePtr theResulCompound = GeomShapePtr());
 
   /// Perform Boolean operation of the Compsolid with the tools
 
   /// Perform Boolean operation of the Compsolid with the tools
+  /// In case of theResultCompound is not empty, the result of Boolean operation
+  /// is added to this compound, and corresponding ResultBody is not generated.
   /// \return \c false if something went wrong
   bool processCompsolid(const GeomAlgoAPI_Tools::BOPType theBooleanType,
                         const ObjectHierarchy& theCompsolidHierarchy,
   /// \return \c false if something went wrong
   bool processCompsolid(const GeomAlgoAPI_Tools::BOPType theBooleanType,
                         const ObjectHierarchy& theCompsolidHierarchy,
@@ -187,9 +193,12 @@ protected:
                         const ListOfShape& thePlanes,
                         int& theResultIndex,
                         std::vector<FeaturesPlugin_Tools::ResultBaseAlgo>& theResultBaseAlgoList,
                         const ListOfShape& thePlanes,
                         int& theResultIndex,
                         std::vector<FeaturesPlugin_Tools::ResultBaseAlgo>& theResultBaseAlgoList,
-                        ListOfShape& theResultShapesList);
+                        ListOfShape& theResultShapesList,
+                        GeomShapePtr theResulCompound = GeomShapePtr());
 
   /// Perform Boolean operation of the Compound with the tools
 
   /// Perform Boolean operation of the Compound with the tools
+  /// In case of theResultCompound is not empty, the result of Boolean operation
+  /// is added to this compound, and corresponding ResultBody is not generated.
   /// \return \c false if something went wrong
   bool processCompound(const GeomAlgoAPI_Tools::BOPType theBooleanType,
                        const ObjectHierarchy& theCompoundHierarchy,
   /// \return \c false if something went wrong
   bool processCompound(const GeomAlgoAPI_Tools::BOPType theBooleanType,
                        const ObjectHierarchy& theCompoundHierarchy,
@@ -197,7 +206,20 @@ protected:
                        const ListOfShape& theTools,
                        int& theResultIndex,
                        std::vector<FeaturesPlugin_Tools::ResultBaseAlgo>& theResultBaseAlgoList,
                        const ListOfShape& theTools,
                        int& theResultIndex,
                        std::vector<FeaturesPlugin_Tools::ResultBaseAlgo>& theResultBaseAlgoList,
-                       ListOfShape& theResultShapesList);
+                       ListOfShape& theResultShapesList,
+                       GeomShapePtr theResulCompound = GeomShapePtr());
+
+  /// Process unused sub-shapes of compounds.
+  /// Keep the compound hierarchy, but merge top-level compounds
+  /// into a single compound and add the result of the FUSE operation.
+  GeomShapePtr keepUnusedSubsOfCompound(
+      const GeomShapePtr& theResult,
+      const ObjectHierarchy& theObjectsHierarchy,
+      const ObjectHierarchy& theToolsHierarchy,
+      std::shared_ptr<GeomAlgoAPI_MakeShapeList> theMakeShapeList);
+
+  /// Return version of the feature
+  int version();
 
 private:
   void parentForShape(const GeomShapePtr& theShape,
 
 private:
   void parentForShape(const GeomShapePtr& theShape,
index af2d556f18afdd568e4375bac1c22b7cf6850ffe..c5b28fbafa792cc1b2f9908ea92135e45701a018 100644 (file)
 #include "FeaturesPlugin_BooleanCommon.h"
 
 #include <ModelAPI_ResultBody.h>
 #include "FeaturesPlugin_BooleanCommon.h"
 
 #include <ModelAPI_ResultBody.h>
+#include <ModelAPI_AttributeInteger.h>
 #include <ModelAPI_AttributeSelectionList.h>
 #include <ModelAPI_AttributeString.h>
 #include <ModelAPI_AttributeSelectionList.h>
 #include <ModelAPI_AttributeString.h>
+#include <ModelAPI_Session.h>
 #include <ModelAPI_Tools.h>
 #include <ModelAPI_Tools.h>
+#include <ModelAPI_Validator.h>
 
 #include <GeomAlgoAPI_Boolean.h>
 #include <GeomAlgoAPI_MakeShapeCustom.h>
 
 #include <GeomAlgoAPI_Boolean.h>
 #include <GeomAlgoAPI_MakeShapeCustom.h>
@@ -35,6 +38,7 @@
 #include <GeomAlgoAPI_CompoundBuilder.h>
 #include <GeomAlgoAPI_Tools.h>
 
 #include <GeomAlgoAPI_CompoundBuilder.h>
 #include <GeomAlgoAPI_Tools.h>
 
+static const int THE_COMMON_VERSION_1 = 20190506;
 
 //==================================================================================================
 FeaturesPlugin_BooleanCommon::FeaturesPlugin_BooleanCommon()
 
 //==================================================================================================
 FeaturesPlugin_BooleanCommon::FeaturesPlugin_BooleanCommon()
@@ -49,6 +53,17 @@ void FeaturesPlugin_BooleanCommon::initAttributes()
 
   data()->addAttribute(OBJECT_LIST_ID(), ModelAPI_AttributeSelectionList::typeId());
   data()->addAttribute(TOOL_LIST_ID(), ModelAPI_AttributeSelectionList::typeId());
 
   data()->addAttribute(OBJECT_LIST_ID(), ModelAPI_AttributeSelectionList::typeId());
   data()->addAttribute(TOOL_LIST_ID(), ModelAPI_AttributeSelectionList::typeId());
+
+  AttributePtr aVerAttr = data()->addAttribute(VERSION_ID(), ModelAPI_AttributeInteger::typeId());
+  aVerAttr->setIsArgument(false);
+  ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), VERSION_ID());
+  if (!integer(VERSION_ID())->isInitialized() &&
+      !selectionList(OBJECT_LIST_ID())->isInitialized() &&
+      !selectionList(TOOL_LIST_ID())->isInitialized()) {
+    // this is a newly created feature (not read from file),
+    // so, initialize the latest version
+    integer(VERSION_ID())->setValue(THE_COMMON_VERSION_1);
+  }
 }
 
 //==================================================================================================
 }
 
 //==================================================================================================
@@ -82,7 +97,12 @@ void FeaturesPlugin_BooleanCommon::execute()
     return;
   }
 
     return;
   }
 
+  // version of COMMON feature
+  int aCommonVersion = version();
+
   int aResultIndex = 0;
   int aResultIndex = 0;
+  GeomShapePtr aResultCompound;
+
   std::string anError;
   std::shared_ptr<GeomAlgoAPI_MakeShapeList> aMakeShapeList(new GeomAlgoAPI_MakeShapeList());
   std::vector<FeaturesPlugin_Tools::ResultBaseAlgo> aResultBaseAlgoList;
   std::string anError;
   std::shared_ptr<GeomAlgoAPI_MakeShapeList> aMakeShapeList(new GeomAlgoAPI_MakeShapeList());
   std::vector<FeaturesPlugin_Tools::ResultBaseAlgo> aResultBaseAlgoList;
@@ -106,6 +126,12 @@ void FeaturesPlugin_BooleanCommon::execute()
       aMakeShapeList->appendAlgo(aCommonAlgo);
     }
 
       aMakeShapeList->appendAlgo(aCommonAlgo);
     }
 
+    if (aCommonVersion == THE_COMMON_VERSION_1) {
+      // merge hierarchies of compounds containing objects and tools
+      // and append the result of the FUSE operation
+      aShape = keepUnusedSubsOfCompound(aShape, anObjects, aTools, aMakeShapeList);
+    }
+
     GeomAPI_ShapeIterator aShapeIt(aShape);
     if (aShapeIt.more() || aShape->shapeType() == GeomAPI_Shape::VERTEX) {
       std::shared_ptr<ModelAPI_ResultBody> aResultBody =
     GeomAPI_ShapeIterator aShapeIt(aShape);
     if (aShapeIt.more() || aShape->shapeType() == GeomAPI_Shape::VERTEX) {
       std::shared_ptr<ModelAPI_ResultBody> aResultBody =
@@ -132,6 +158,12 @@ void FeaturesPlugin_BooleanCommon::execute()
       aResultShapesList.push_back(aShape);
     }
   } else {
       aResultShapesList.push_back(aShape);
     }
   } else {
+    if (aCommonVersion == THE_COMMON_VERSION_1) {
+      // merge hierarchies of compounds containing objects and tools
+      aResultCompound =
+          keepUnusedSubsOfCompound(GeomShapePtr(), anObjects, aTools, aMakeShapeList);
+    }
+
     bool isOk = true;
     for (ObjectHierarchy::Iterator anObjectsIt = anObjects.Begin();
          anObjectsIt != anObjects.End() && isOk;
     bool isOk = true;
     for (ObjectHierarchy::Iterator anObjectsIt = anObjects.Begin();
          anObjectsIt != anObjects.End() && isOk;
@@ -146,29 +178,60 @@ void FeaturesPlugin_BooleanCommon::execute()
           // Compound handling
           isOk = processCompound(GeomAlgoAPI_Tools::BOOL_COMMON,
                                  anObjects, aParent, aTools.Objects(),
           // Compound handling
           isOk = processCompound(GeomAlgoAPI_Tools::BOOL_COMMON,
                                  anObjects, aParent, aTools.Objects(),
-                                 aResultIndex, aResultBaseAlgoList, aResultShapesList);
+                                 aResultIndex, aResultBaseAlgoList, aResultShapesList,
+                                 aResultCompound);
         }
         else if (aShapeType == GeomAPI_Shape::COMPSOLID) {
           // Compsolid handling
           isOk = processCompsolid(GeomAlgoAPI_Tools::BOOL_COMMON,
                                   anObjects, aParent, aTools.Objects(), ListOfShape(),
         }
         else if (aShapeType == GeomAPI_Shape::COMPSOLID) {
           // Compsolid handling
           isOk = processCompsolid(GeomAlgoAPI_Tools::BOOL_COMMON,
                                   anObjects, aParent, aTools.Objects(), ListOfShape(),
-                                  aResultIndex, aResultBaseAlgoList, aResultShapesList);
+                                  aResultIndex, aResultBaseAlgoList, aResultShapesList,
+                                  aResultCompound);
         }
       } else {
         // process object as is
         isOk = processObject(GeomAlgoAPI_Tools::BOOL_COMMON,
                              anObject, aTools.Objects(), aPlanes,
         }
       } else {
         // process object as is
         isOk = processObject(GeomAlgoAPI_Tools::BOOL_COMMON,
                              anObject, aTools.Objects(), aPlanes,
-                             aResultIndex, aResultBaseAlgoList, aResultShapesList);
+                             aResultIndex, aResultBaseAlgoList, aResultShapesList,
+                             aResultCompound);
       }
     }
       }
     }
+
+    GeomAPI_ShapeIterator aShapeIt(aResultCompound);
+    if (aShapeIt.more()) {
+      std::shared_ptr<ModelAPI_ResultBody> aResultBody =
+          document()->createBody(data(), aResultIndex);
+
+      ListOfShape anObjectList = anObjects.Objects();
+      ListOfShape aToolsList = aTools.Objects();
+      FeaturesPlugin_Tools::loadModifiedShapes(aResultBody,
+                                               anObjectList,
+                                               aToolsList,
+                                               aMakeShapeList,
+                                               aResultCompound);
+      setResult(aResultBody, aResultIndex++);
+
+      // merge algorithms
+      FeaturesPlugin_Tools::ResultBaseAlgo aRBA;
+      aRBA.resultBody = aResultBody;
+      aRBA.baseShape = anObjectList.front();
+      for (std::vector<FeaturesPlugin_Tools::ResultBaseAlgo>::iterator aRBAIt = aResultBaseAlgoList.begin();
+           aRBAIt != aResultBaseAlgoList.end(); ++aRBAIt) {
+        aMakeShapeList->appendAlgo(aRBAIt->makeShape);
+      }
+      aRBA.makeShape = aMakeShapeList;
+      aResultBaseAlgoList.clear();
+      aResultBaseAlgoList.push_back(aRBA);
+    }
   }
 
   // Store deleted shapes after all results has been proceeded. This is to avoid issue when in one
   // result shape has been deleted, but in another it was modified or stayed.
   }
 
   // Store deleted shapes after all results has been proceeded. This is to avoid issue when in one
   // result shape has been deleted, but in another it was modified or stayed.
-  GeomShapePtr aResultShapesCompound = GeomAlgoAPI_CompoundBuilder::compound(aResultShapesList);
+  if (!aResultCompound)
+    aResultCompound = GeomAlgoAPI_CompoundBuilder::compound(aResultShapesList);
   FeaturesPlugin_Tools::loadDeletedShapes(aResultBaseAlgoList,
                                           aTools.Objects(),
   FeaturesPlugin_Tools::loadDeletedShapes(aResultBaseAlgoList,
                                           aTools.Objects(),
-                                          aResultShapesCompound);
+                                          aResultCompound);
 
   // remove the rest results if there were produced in the previous pass
   removeResults(aResultIndex);
 
   // remove the rest results if there were produced in the previous pass
   removeResults(aResultIndex);
index 65e5c0f4cb6e7a95578489b57de9c6cb48a30d9f..84df36d061a8ef547e4d8daed7d064d5ee205a78 100644 (file)
@@ -113,12 +113,7 @@ void FeaturesPlugin_BooleanFuse::execute()
   }
 
   // version of FUSE feature
   }
 
   // version of FUSE feature
-  AttributeIntegerPtr aVersionAttr = integer(VERSION_ID());
-  int aFuseVersion = 0;
-  if (aVersionAttr && aVersionAttr->isInitialized())
-    aFuseVersion = aVersionAttr->value();
-
-////  isSimpleCreation = isSimpleCreation && aFuseVersion < THE_FUSE_VERSION_1;
+  int aFuseVersion = version();
 
   // Collecting all solids which will be fused.
   ListOfShape aSolidsToFuse;
 
   // Collecting all solids which will be fused.
   ListOfShape aSolidsToFuse;
@@ -274,32 +269,3 @@ void FeaturesPlugin_BooleanFuse::execute()
   // remove the rest results if there were produced in the previous pass
   removeResults(aResultIndex);
 }
   // remove the rest results if there were produced in the previous pass
   removeResults(aResultIndex);
 }
-
-//==================================================================================================
-GeomShapePtr FeaturesPlugin_BooleanFuse::keepUnusedSubsOfCompound(
-    const GeomShapePtr& theFuseResult,
-    const ObjectHierarchy& theObjectsHierarchy,
-    const ObjectHierarchy& theToolsHierarchy,
-    std::shared_ptr<GeomAlgoAPI_MakeShapeList> theMakeShapeList)
-{
-  ListOfShape aCompounds;
-  theObjectsHierarchy.CompoundsOfUnusedObjects(aCompounds);
-  theToolsHierarchy.CompoundsOfUnusedObjects(aCompounds);
-
-  GeomShapePtr aResultShape = theFuseResult;
-  if (!aCompounds.empty()) {
-    aResultShape = aCompounds.front();
-    aCompounds.pop_front();
-
-    std::shared_ptr<GeomAlgoAPI_ShapeBuilder> aBuilder(new GeomAlgoAPI_ShapeBuilder);
-    for (ListOfShape::iterator anIt = aCompounds.begin(); anIt != aCompounds.end(); ++anIt) {
-      for (GeomAPI_ShapeIterator aSub(*anIt); aSub.more(); aSub.next())
-        aBuilder->add(aResultShape, aSub.current());
-    }
-
-    aBuilder->add(aResultShape, theFuseResult);
-
-    theMakeShapeList->appendAlgo(aBuilder);
-  }
-  return aResultShape;
-}
index f94498406a0326a669de4763ce10164e6e330e00..a16c8781ae07eff63d923f11bfb36a3af5422998 100644 (file)
@@ -22,8 +22,6 @@
 
 #include "FeaturesPlugin_Boolean.h"
 
 
 #include "FeaturesPlugin_Boolean.h"
 
-class GeomAlgoAPI_MakeShapeList;
-
 /// \class FeaturesPlugin_BooleanFuse
 /// \ingroup Plugins
 /// \brief Feature for applying of Boolean Fuse operation.
 /// \class FeaturesPlugin_BooleanFuse
 /// \ingroup Plugins
 /// \brief Feature for applying of Boolean Fuse operation.
@@ -97,16 +95,6 @@ public:
 
   /// Use plugin manager for features creation.
   FeaturesPlugin_BooleanFuse();
 
   /// Use plugin manager for features creation.
   FeaturesPlugin_BooleanFuse();
-
-private:
-  /// Process unused sub-shapes of compounds.
-  /// Keep the compound hierarchy, but merge top-level compounds
-  /// into a single compound and add the result of the FUSE operation.
-  GeomShapePtr keepUnusedSubsOfCompound(
-      const GeomShapePtr& theFuseResult,
-      const ObjectHierarchy& theObjectsHierarchy,
-      const ObjectHierarchy& theToolsHierarchy,
-      std::shared_ptr<GeomAlgoAPI_MakeShapeList> theMakeShapeList);
 };
 
 #endif
 };
 
 #endif
diff --git a/src/FeaturesPlugin/Test/TestBooleanCommon_MultiLevelCompound0.py b/src/FeaturesPlugin/Test/TestBooleanCommon_MultiLevelCompound0.py
deleted file mode 100644 (file)
index 705125a..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, -6.999999999999999, 0)
-SketchLine_2 = Sketch_1.addLine(-6.999999999999999, 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)
-Common_1 = model.addCommon(Part_1_doc, [model.selection("SOLID", "LinearCopy_2_1_1_1"), model.selection("COMPOUND", "Compound_1_1_2")])
-model.do()
-model.end()
-
-from GeomAPI import GeomAPI_Shape
-
-model.testNbResults(Common_1, 1)
-model.testNbSubResults(Common_1, [2])
-model.testNbSubShapes(Common_1, GeomAPI_Shape.SOLID, [2])
-model.testNbSubShapes(Common_1, GeomAPI_Shape.FACE, [13])
-model.testNbSubShapes(Common_1, GeomAPI_Shape.EDGE, [54])
-model.testNbSubShapes(Common_1, GeomAPI_Shape.VERTEX, [108])
-model.testResultsVolumes(Common_1, [1147.933772988635155343217775226])
diff --git a/src/FeaturesPlugin/Test/TestBooleanCommon_MultiLevelCompound_v0_1.py b/src/FeaturesPlugin/Test/TestBooleanCommon_MultiLevelCompound_v0_1.py
new file mode 100644 (file)
index 0000000..3869c13
--- /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)
+Common_1 = model.addCommon(Part_1_doc, [model.selection("SOLID", "LinearCopy_2_1_1_1"), model.selection("COMPOUND", "Compound_1_1_2")])
+
+model.testHaveNamingSubshapes(Common_1, model, Part_1_doc)
+
+model.end()
+
+from GeomAPI import GeomAPI_Shape
+
+model.testNbResults(Common_1, 1)
+model.testNbSubResults(Common_1, [2])
+model.testNbSubShapes(Common_1, GeomAPI_Shape.SOLID, [2])
+model.testNbSubShapes(Common_1, GeomAPI_Shape.FACE, [13])
+model.testNbSubShapes(Common_1, GeomAPI_Shape.EDGE, [54])
+model.testNbSubShapes(Common_1, GeomAPI_Shape.VERTEX, [108])
+model.testResultsVolumes(Common_1, [1147.933772988635155343217775226])
+
+assert(model.checkPythonDump())
diff --git a/src/FeaturesPlugin/Test/TestBooleanCommon_MultiLevelCompound_v0_2.py b/src/FeaturesPlugin/Test/TestBooleanCommon_MultiLevelCompound_v0_2.py
new file mode 100644 (file)
index 0000000..87c31b6
--- /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)
+Common_1 = model.addCommon(Part_1_doc, [model.selection("SOLID", "Compound_2_1_1_1"), model.selection("SOLID", "Compound_2_1_2_3")], [model.selection("COMPOUND", "Compound_3_1_2")])
+
+model.testHaveNamingSubshapes(Common_1, model, Part_1_doc)
+
+model.end()
+
+from GeomAPI import GeomAPI_Shape
+
+model.testNbResults(Common_1, 2)
+model.testNbSubResults(Common_1, [2, 3])
+model.testNbSubShapes(Common_1, GeomAPI_Shape.SOLID, [2, 3])
+model.testNbSubShapes(Common_1, GeomAPI_Shape.FACE, [9, 18])
+model.testNbSubShapes(Common_1, GeomAPI_Shape.EDGE, [30, 74])
+model.testNbSubShapes(Common_1, GeomAPI_Shape.VERTEX, [60, 148])
+model.testResultsVolumes(Common_1, [7048.363799144838594, 6703.185306801399747])
+
+assert(model.checkPythonDump())
diff --git a/src/FeaturesPlugin/Test/TestBooleanCommon_MultiLevelCompound_v20190506_1.py b/src/FeaturesPlugin/Test/TestBooleanCommon_MultiLevelCompound_v20190506_1.py
new file mode 100644 (file)
index 0000000..ddbbf6f
--- /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)
+Common_1 = model.addCommon(Part_1_doc, [model.selection("SOLID", "LinearCopy_2_1_1_1"), model.selection("COMPOUND", "Compound_1_1_2")], 20190506)
+
+model.testHaveNamingSubshapes(Common_1, model, Part_1_doc)
+
+model.end()
+
+from GeomAPI import GeomAPI_Shape
+
+model.testNbResults(Common_1, 1)
+model.testNbSubResults(Common_1, [4])
+model.testNbSubShapes(Common_1, GeomAPI_Shape.SOLID, [7])
+model.testNbSubShapes(Common_1, GeomAPI_Shape.FACE, [34])
+model.testNbSubShapes(Common_1, GeomAPI_Shape.EDGE, [120])
+model.testNbSubShapes(Common_1, GeomAPI_Shape.VERTEX, [240])
+model.testResultsVolumes(Common_1, [31197.48969452739765984])
+
+assert(model.checkPythonDump())
diff --git a/src/FeaturesPlugin/Test/TestBooleanCommon_MultiLevelCompound_v20190506_2.py b/src/FeaturesPlugin/Test/TestBooleanCommon_MultiLevelCompound_v20190506_2.py
new file mode 100644 (file)
index 0000000..e95f88f
--- /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)
+Common_1 = model.addCommon(Part_1_doc, [model.selection("SOLID", "Compound_2_1_1_1"), model.selection("SOLID", "Compound_2_1_2_3")], [model.selection("COMPOUND", "Compound_3_1_2")], 20190506)
+
+model.testHaveNamingSubshapes(Common_1, model, Part_1_doc)
+
+model.end()
+
+from GeomAPI import GeomAPI_Shape
+
+model.testNbResults(Common_1, 1)
+model.testNbSubResults(Common_1, [4])
+model.testNbSubShapes(Common_1, GeomAPI_Shape.SOLID, [7])
+model.testNbSubShapes(Common_1, GeomAPI_Shape.FACE, [36])
+model.testNbSubShapes(Common_1, GeomAPI_Shape.EDGE, [134])
+model.testNbSubShapes(Common_1, GeomAPI_Shape.VERTEX, [268])
+model.testResultsVolumes(Common_1, [22834.734413125825])
+
+assert(model.checkPythonDump())