Salome HOME
Task 3.2. To keep compounds’ sub-shapes for all operations (issue #3139)
authorazv <azv@opencascade.com>
Sun, 23 Feb 2020 11:10:48 +0000 (14:10 +0300)
committerazv <azv@opencascade.com>
Sun, 23 Feb 2020 14:50:25 +0000 (17:50 +0300)
Refactor the Linear Copy and the Angular Copy features.

31 files changed:
src/FeaturesAPI/FeaturesAPI.i
src/FeaturesAPI/FeaturesAPI_MultiRotation.cpp
src/FeaturesAPI/FeaturesAPI_MultiRotation.h
src/FeaturesAPI/FeaturesAPI_MultiTranslation.cpp
src/FeaturesAPI/FeaturesAPI_MultiTranslation.h
src/FeaturesPlugin/CMakeLists.txt
src/FeaturesPlugin/FeaturesPlugin_MultiRotation.cpp
src/FeaturesPlugin/FeaturesPlugin_MultiRotation.h
src/FeaturesPlugin/FeaturesPlugin_MultiTranslation.cpp
src/FeaturesPlugin/FeaturesPlugin_MultiTranslation.h
src/FeaturesPlugin/Test/TestMultiRotation_MultiLevelCompound_v0_1.py [new file with mode: 0644]
src/FeaturesPlugin/Test/TestMultiRotation_MultiLevelCompound_v0_2.py [new file with mode: 0644]
src/FeaturesPlugin/Test/TestMultiRotation_MultiLevelCompound_v0_3.py [new file with mode: 0644]
src/FeaturesPlugin/Test/TestMultiRotation_MultiLevelCompound_v0_4.py [new file with mode: 0644]
src/FeaturesPlugin/Test/TestMultiRotation_MultiLevelCompound_v95_1.py [new file with mode: 0644]
src/FeaturesPlugin/Test/TestMultiRotation_MultiLevelCompound_v95_2.py [new file with mode: 0644]
src/FeaturesPlugin/Test/TestMultiRotation_MultiLevelCompound_v95_3.py [new file with mode: 0644]
src/FeaturesPlugin/Test/TestMultiRotation_MultiLevelCompound_v95_4.py [new file with mode: 0644]
src/FeaturesPlugin/Test/TestMultiTranslation_MultiLevelCompound_v0_1.py [new file with mode: 0644]
src/FeaturesPlugin/Test/TestMultiTranslation_MultiLevelCompound_v0_2.py [new file with mode: 0644]
src/FeaturesPlugin/Test/TestMultiTranslation_MultiLevelCompound_v0_3.py [new file with mode: 0644]
src/FeaturesPlugin/Test/TestMultiTranslation_MultiLevelCompound_v0_4.py [new file with mode: 0644]
src/FeaturesPlugin/Test/TestMultiTranslation_MultiLevelCompound_v95_1.py [new file with mode: 0644]
src/FeaturesPlugin/Test/TestMultiTranslation_MultiLevelCompound_v95_2.py [new file with mode: 0644]
src/FeaturesPlugin/Test/TestMultiTranslation_MultiLevelCompound_v95_3.py [new file with mode: 0644]
src/FeaturesPlugin/Test/TestMultiTranslation_MultiLevelCompound_v95_4.py [new file with mode: 0644]
src/ModelGeomAlgo/ModelGeomAlgo_Shape.cpp
src/ModelHighAPI/ModelHighAPI_Double.cpp
src/ModelHighAPI/ModelHighAPI_Double.h
src/ModelHighAPI/ModelHighAPI_Integer.cpp
src/ModelHighAPI/ModelHighAPI_Integer.h

index 2dfba2c48b98debc6db365d6e774ee0307f17d93..7d1505907d76bc7a72b0ba18bf2f61e93081c679 100644 (file)
@@ -41,6 +41,8 @@
 %feature("kwargs") addCommon;
 %feature("kwargs") addCut;
 %feature("kwargs") addFuse;
+%feature("kwargs") addMultiRotation;
+%feature("kwargs") addMultiTranslation;
 %feature("kwargs") addPartition;
 %feature("kwargs") addPlacement;
 %feature("kwargs") addRotation;
index 8e59da5f22c912ffd96c0f85c3c4e8cf402cf0fa..44bbd0b2babe8148faad268be341162bc94c34f6 100644 (file)
@@ -23,6 +23,7 @@
 
 #include <FeaturesAPI_MultiRotation.h>
 
+#include <ModelHighAPI_Double.h>
 #include <ModelHighAPI_Dumper.h>
 #include <ModelHighAPI_Tools.h>
 
@@ -132,19 +133,10 @@ void FeaturesAPI_MultiRotation::dump(ModelHighAPI_Dumper& theDumper) const
     aBase->integer(FeaturesPlugin_MultiRotation::NB_COPIES_ANGULAR_ID());
   theDumper << ", " << anAttrNumberAngular;
 
-  theDumper << ")" << std::endl;
-}
+  if (!aBase->data()->version().empty())
+    theDumper << ", keepSubResults = True";
 
-//==================================================================================================
-MultiRotationPtr addMultiRotation(const std::shared_ptr<ModelAPI_Document>& thePart,
-                                  const std::list<ModelHighAPI_Selection>& theMainObjects,
-                                  const ModelHighAPI_Selection& theAxis,
-                                  const ModelHighAPI_Integer& theNumber)
-{
-  std::shared_ptr<ModelAPI_Feature> aFeature =
-    thePart->addFeature(FeaturesAPI_MultiRotation::ID());
-  return MultiRotationPtr(new FeaturesAPI_MultiRotation(aFeature, theMainObjects,
-                                                        theAxis, theNumber));
+  theDumper << ")" << std::endl;
 }
 
 //==================================================================================================
@@ -152,10 +144,30 @@ MultiRotationPtr addMultiRotation(const std::shared_ptr<ModelAPI_Document>& theP
                                   const std::list<ModelHighAPI_Selection>& theMainObjects,
                                   const ModelHighAPI_Selection& theAxis,
                                   const ModelHighAPI_Double& theStep,
-                                  const ModelHighAPI_Integer& theNumber)
+                                  const ModelHighAPI_Integer& theNumber,
+                                  const bool keepSubResults)
 {
   std::shared_ptr<ModelAPI_Feature> aFeature =
     thePart->addFeature(FeaturesAPI_MultiRotation::ID());
-  return MultiRotationPtr(new FeaturesAPI_MultiRotation(aFeature, theMainObjects,
-                                                        theAxis, theStep, theNumber));
+  if (!keepSubResults)
+    aFeature->data()->setVersion("");
+
+  MultiRotationPtr aResult;
+  if (theNumber.string().empty()) {
+    // rotate for the whole circle
+    double aStepVal = theStep.value();
+    std::string aStepStr = theStep.string();
+    std::ostringstream aStepValAsStr;
+    aStepValAsStr << aStepVal;
+
+    ModelHighAPI_Integer aNumber = aStepStr == aStepValAsStr.str()
+                                 ? ModelHighAPI_Integer(aStepVal)
+                                 : ModelHighAPI_Integer(aStepStr);
+    aResult.reset(new FeaturesAPI_MultiRotation(aFeature, theMainObjects, theAxis, aNumber));
+  }
+  else {
+    aResult.reset(new FeaturesAPI_MultiRotation(aFeature, theMainObjects,
+                                                theAxis, theStep, theNumber));
+  }
+  return aResult;
 }
index 6c33affb060c6061837f4e7f7495ae94ab28271b..0b87f76f2ab3116aefa65292d7cab1c379f55ea5 100644 (file)
 
 #include <FeaturesPlugin_MultiRotation.h>
 
+#include <ModelHighAPI_Integer.h>
 #include <ModelHighAPI_Interface.h>
 #include <ModelHighAPI_Macro.h>
 
 class ModelHighAPI_Double;
 class ModelHighAPI_Dumper;
-class ModelHighAPI_Integer;
 class ModelHighAPI_Selection;
 
 /// \class FeaturesAPI_MultiRotation
@@ -102,14 +102,6 @@ public:
 /// Pointer on Multirotation object.
 typedef std::shared_ptr<FeaturesAPI_MultiRotation> MultiRotationPtr;
 
-/// \ingroup CPPHighAPI
-/// \brief Create MultiRotation feature.
-FEATURESAPI_EXPORT
-MultiRotationPtr addMultiRotation(const std::shared_ptr<ModelAPI_Document>& thePart,
-                                  const std::list<ModelHighAPI_Selection>& theMainObjects,
-                                  const ModelHighAPI_Selection& theAxis,
-                                  const ModelHighAPI_Integer& theNumber);
-
 /// \ingroup CPPHighAPI
 /// \brief Create MultiRotation feature.
 FEATURESAPI_EXPORT
@@ -117,6 +109,7 @@ MultiRotationPtr addMultiRotation(const std::shared_ptr<ModelAPI_Document>& theP
                                   const std::list<ModelHighAPI_Selection>& theMainObjects,
                                   const ModelHighAPI_Selection& theAxis,
                                   const ModelHighAPI_Double& theStep,
-                                  const ModelHighAPI_Integer& theNumber);
+                                  const ModelHighAPI_Integer& theNumber = ModelHighAPI_Integer(""),
+                                  const bool keepSubResults = false);
 
 #endif // FEATURESAPI_MULTIROTATION_H_
index c5afd844478eb078400a8331a9c188296cde8370..9885ed33e5e494df567c3845262942ddbca840b0 100644 (file)
@@ -155,20 +155,10 @@ void FeaturesAPI_MultiTranslation::dump(ModelHighAPI_Dumper& theDumper) const
     theDumper << ", " << anAttrSecondNumber;
   }
 
-  theDumper << ")" << std::endl;
-}
+  if (!aBase->data()->version().empty())
+    theDumper << ", keepSubResults = True";
 
-//==================================================================================================
-MultiTranslationPtr addMultiTranslation(const std::shared_ptr<ModelAPI_Document>& thePart,
-                                        const std::list<ModelHighAPI_Selection>& theMainObjects,
-                                        const ModelHighAPI_Selection& theAxisObject,
-                                        const ModelHighAPI_Double& theStep,
-                                        const ModelHighAPI_Integer& theNumber)
-{
-  std::shared_ptr<ModelAPI_Feature> aFeature =
-    thePart->addFeature(FeaturesAPI_MultiTranslation::ID());
-  return MultiTranslationPtr(new FeaturesAPI_MultiTranslation(aFeature, theMainObjects,
-                                                              theAxisObject, theStep, theNumber));
+  theDumper << ")" << std::endl;
 }
 
 //==================================================================================================
@@ -179,13 +169,22 @@ MultiTranslationPtr addMultiTranslation(const std::shared_ptr<ModelAPI_Document>
                                         const ModelHighAPI_Integer& theFirstNumber,
                                         const ModelHighAPI_Selection& theSecondAxisObject,
                                         const ModelHighAPI_Double& theSecondStep,
-                                        const ModelHighAPI_Integer& theSecondNumber)
+                                        const ModelHighAPI_Integer& theSecondNumber,
+                                        const bool keepSubResults)
 {
   std::shared_ptr<ModelAPI_Feature> aFeature =
     thePart->addFeature(FeaturesAPI_MultiTranslation::ID());
-  return MultiTranslationPtr(new FeaturesAPI_MultiTranslation(aFeature, theMainObjects,
-                                                              theFirstAxisObject, theFirstStep,
-                                                              theFirstNumber,
-                                                              theSecondAxisObject, theSecondStep,
-                                                              theSecondNumber));
+  if (!keepSubResults)
+    aFeature->data()->setVersion("");
+  MultiTranslationPtr aMT;
+  if (theSecondAxisObject.variantType() == ModelHighAPI_Selection::VT_Empty) {
+    aMT.reset(new FeaturesAPI_MultiTranslation(aFeature, theMainObjects,
+        theFirstAxisObject, theFirstStep, theFirstNumber));
+  }
+  else {
+    aMT.reset(new FeaturesAPI_MultiTranslation(aFeature, theMainObjects,
+        theFirstAxisObject, theFirstStep, theFirstNumber,
+        theSecondAxisObject, theSecondStep, theSecondNumber));
+  }
+  return aMT;
 }
index d62314116fc99abe9dff40cfbfedbff8aad42991..489f66d7e704c91d2f209a4380b80543742ef9f3 100644 (file)
 
 #include <FeaturesPlugin_MultiTranslation.h>
 
+#include <ModelHighAPI_Double.h>
+#include <ModelHighAPI_Integer.h>
 #include <ModelHighAPI_Interface.h>
 #include <ModelHighAPI_Macro.h>
+#include <ModelHighAPI_Selection.h>
 
-class ModelHighAPI_Double;
 class ModelHighAPI_Dumper;
-class ModelHighAPI_Integer;
-class ModelHighAPI_Selection;
 
 /// \class FeaturesAPI_MultiTranslation
 /// \ingroup CPPHighAPI
@@ -116,23 +116,15 @@ typedef std::shared_ptr<FeaturesAPI_MultiTranslation> MultiTranslationPtr;
 
 /// \ingroup CPPHighAPI
 /// \brief Create MultiTranslation feature.
-FEATURESAPI_EXPORT
-MultiTranslationPtr addMultiTranslation(const std::shared_ptr<ModelAPI_Document>& thePart,
-                                        const std::list<ModelHighAPI_Selection>& theMainObjects,
-                                        const ModelHighAPI_Selection& theAxisObject,
-                                        const ModelHighAPI_Double& theStep,
-                                        const ModelHighAPI_Integer& theNumber);
-
-/// \ingroup CPPHighAPI
-/// \brief Create MultiTranslation feature.
-FEATURESAPI_EXPORT
-MultiTranslationPtr addMultiTranslation(const std::shared_ptr<ModelAPI_Document>& thePart,
-                                        const std::list<ModelHighAPI_Selection>& theMainObjects,
-                                        const ModelHighAPI_Selection& theFirstAxisObject,
-                                        const ModelHighAPI_Double& theFirstStep,
-                                        const ModelHighAPI_Integer& theFirstNumber,
-                                        const ModelHighAPI_Selection& theSecondAxisObject,
-                                        const ModelHighAPI_Double& theSecondStep,
-                                        const ModelHighAPI_Integer& theSecondNumber);
+FEATURESAPI_EXPORT MultiTranslationPtr addMultiTranslation(
+    const std::shared_ptr<ModelAPI_Document>& thePart,
+    const std::list<ModelHighAPI_Selection>& theMainObjects,
+    const ModelHighAPI_Selection& theFirstAxisObject,
+    const ModelHighAPI_Double& theFirstStep,
+    const ModelHighAPI_Integer& theFirstNumber,
+    const ModelHighAPI_Selection& theSecondAxisObject = ModelHighAPI_Selection(),
+    const ModelHighAPI_Double& theSecondStep = ModelHighAPI_Double(),
+    const ModelHighAPI_Integer& theSecondNumber = ModelHighAPI_Integer(),
+    const bool keepSubResults = false);
 
 #endif // FEATURESAPI_MULTITRANSLATION_H_
index 1b06f51f8ba3dccfb963e87150f895196c4c86b8..4aff68961120763743b3d9bd5c8de73793972f71 100644 (file)
@@ -617,4 +617,20 @@ ADD_UNIT_TESTS(TestExtrusion.py
                TestScale_MultiLevelCompound_v95_2.py
                TestScale_MultiLevelCompound_v95_3.py
                TestScale_MultiLevelCompound_v95_4.py
+               TestMultiTranslation_MultiLevelCompound_v0_1.py
+               TestMultiTranslation_MultiLevelCompound_v0_2.py
+               TestMultiTranslation_MultiLevelCompound_v0_3.py
+               TestMultiTranslation_MultiLevelCompound_v0_4.py
+               TestMultiTranslation_MultiLevelCompound_v95_1.py
+               TestMultiTranslation_MultiLevelCompound_v95_2.py
+               TestMultiTranslation_MultiLevelCompound_v95_3.py
+               TestMultiTranslation_MultiLevelCompound_v95_4.py
+               TestMultiRotation_MultiLevelCompound_v0_1.py
+               TestMultiRotation_MultiLevelCompound_v0_2.py
+               TestMultiRotation_MultiLevelCompound_v0_3.py
+               TestMultiRotation_MultiLevelCompound_v0_4.py
+               TestMultiRotation_MultiLevelCompound_v95_1.py
+               TestMultiRotation_MultiLevelCompound_v95_2.py
+               TestMultiRotation_MultiLevelCompound_v95_3.py
+               TestMultiRotation_MultiLevelCompound_v95_4.py
 )
index 68151d9c6af07e6328f6e6a75b1b9b9cfa1d7763..07cdcd7a9fb0904635ede1cc2d09f793883a6639 100644 (file)
@@ -48,6 +48,8 @@
 #include <math.h>
 #include <iostream>
 
+static const std::string MULTIROTATION_VERSION_1("v9.5");
+
 //=================================================================================================
 FeaturesPlugin_MultiRotation::FeaturesPlugin_MultiRotation()
 {
@@ -78,6 +80,11 @@ void FeaturesPlugin_MultiRotation::initAttributes()
   data()->addAttribute(FeaturesPlugin_MultiRotation::NB_COPIES_RADIAL_ID(),
                        ModelAPI_AttributeInteger::typeId());
 #endif
+
+  if (!aSelection->isInitialized()) {
+    // new feature, not read from file
+    data()->setVersion(MULTIROTATION_VERSION_1);
+  }
 }
 
 //=================================================================================================
@@ -96,132 +103,128 @@ void FeaturesPlugin_MultiRotation::execute()
 }
 
 //=================================================================================================
-void FeaturesPlugin_MultiRotation::performRotation1D()
+bool FeaturesPlugin_MultiRotation::paramsOfRotation(std::shared_ptr<GeomAPI_Ax1>& theAxis,
+                                                    double& theAngle,
+                                                    int& theQuantity)
 {
-  // Getting objects.
-  ListOfShape anObjects;
-  std::list<ResultPtr> aContextes;
-  AttributeSelectionListPtr anObjectsSelList =
-    selectionList(FeaturesPlugin_MultiRotation::OBJECTS_LIST_ID());
-  if (anObjectsSelList->size() == 0) {
-    setError("Error: empty selection list");
-    return;
-  }
-  for(int anObjectsIndex = 0; anObjectsIndex < anObjectsSelList->size(); anObjectsIndex++) {
-    std::shared_ptr<ModelAPI_AttributeSelection> anObjectAttr =
-      anObjectsSelList->value(anObjectsIndex);
-    std::shared_ptr<GeomAPI_Shape> anObject = anObjectAttr->value();
-    if(!anObject.get()) { // may be for not-activated parts
-      return;
-    }
-    anObjects.push_back(anObject);
-    aContextes.push_back(anObjectAttr->context());
-  }
-
   //Getting axis.
   static const std::string aSelectionError = "Error: The axis shape selection is bad.";
   AttributeSelectionPtr anObjRef = selection(AXIS_ANGULAR_ID());
   GeomShapePtr aShape = anObjRef->value();
-  if (!aShape.get()) {
-    if (anObjRef->context().get()) {
-      aShape = anObjRef->context()->shape();
-    }
-  }
+  if (!aShape.get() && anObjRef->context().get())
+    aShape = anObjRef->context()->shape();
   if (!aShape.get()) {
     setError(aSelectionError);
-    return;
+    return false;
   }
 
   GeomEdgePtr anEdge;
   if (aShape->isEdge())
-  {
     anEdge = aShape->edge();
-  }
-  else if (aShape->isCompound())
-  {
+  else if (aShape->isCompound()) {
     GeomAPI_ShapeIterator anIt(aShape);
     anEdge = anIt.current()->edge();
   }
 
-  if (!anEdge.get())
-  {
+  if (!anEdge.get()) {
     setError(aSelectionError);
-    return;
+    return false;
   }
 
-  std::shared_ptr<GeomAPI_Ax1> anAxis(new GeomAPI_Ax1(anEdge->line()->location(),
-                                                      anEdge->line()->direction()));
+  theAxis.reset(new GeomAPI_Ax1(anEdge->line()->location(), anEdge->line()->direction()));
 
   // Getting number of copies.
-  int nbCopies =
-    integer(FeaturesPlugin_MultiRotation::NB_COPIES_ANGULAR_ID())->value();
-
-  if (nbCopies <=0) {
+  theQuantity = integer(FeaturesPlugin_MultiRotation::NB_COPIES_ANGULAR_ID())->value();
+  if (theQuantity <= 0) {
     std::string aFeatureError = "Multirotation builder ";
-    aFeatureError+=":: the number of copies for the angular direction is null or negative.";
+    aFeatureError += ":: the number of copies for the angular direction is null or negative.";
     setError(aFeatureError);
-    return;
+    return false;
   }
 
   // Getting angle
-  double anAngle;
   std::string useAngularStep =
     string(FeaturesPlugin_MultiRotation::USE_ANGULAR_STEP_ID())->value();
-  if (!useAngularStep.empty()) {
-    anAngle = real(FeaturesPlugin_MultiRotation::STEP_ANGULAR_ID())->value();
-  } else {
-    anAngle = 360./nbCopies;
+  if (!useAngularStep.empty())
+    theAngle = real(FeaturesPlugin_MultiRotation::STEP_ANGULAR_ID())->value();
+  else
+    theAngle = 360. / theQuantity;
+  return true;
+}
+
+//=================================================================================================
+void FeaturesPlugin_MultiRotation::performRotation1D()
+{
+  bool isKeepSubShapes = data()->version() == MULTIROTATION_VERSION_1;
+
+  // Getting objects.
+  AttributeSelectionListPtr anObjectsSelList = selectionList(OBJECTS_LIST_ID());
+  if (anObjectsSelList->size() == 0) {
+    setError("Error: empty selection list");
+    return;
   }
 
-  // Moving each object.
+  GeomAPI_ShapeHierarchy anObjects;
+  std::list<ResultPtr> aParts;
+  if (!FeaturesPlugin_Tools::shapesFromSelectionList(
+       anObjectsSelList, isKeepSubShapes, anObjects, aParts))
+    return;
+
+  // Parameters of rotation.
+  std::shared_ptr<GeomAPI_Ax1> anAxis;
+  double anAngle = 0.0;
+  int nbCopies = 0;
+  if (!paramsOfRotation(anAxis, anAngle, nbCopies))
+    return;
+
+
+  std::string anError;
   int aResultIndex = 0;
-  std::list<ResultPtr>::iterator aContext = aContextes.begin();
-  for(ListOfShape::iterator anObjectsIt = anObjects.begin(); anObjectsIt != anObjects.end();
-        anObjectsIt++, aContext++) {
-    std::shared_ptr<GeomAPI_Shape> aBaseShape = *anObjectsIt;
-    bool isPart = aContext->get() && (*aContext)->groupName() == ModelAPI_ResultPart::group();
+  // Moving each part.
+  for (std::list<ResultPtr>::iterator aPRes = aParts.begin(); aPRes != aParts.end(); ++aPRes) {
+    ResultPartPtr anOrigin = std::dynamic_pointer_cast<ModelAPI_ResultPart>(*aPRes);
+    std::shared_ptr<GeomAPI_Trsf> aTrsf(new GeomAPI_Trsf());
+    for (int i = 0; i < nbCopies; ++i) {
+      aTrsf->setRotation(anAxis, i * anAngle);
+      ResultPartPtr aResultPart = document()->copyPart(anOrigin, data(), aResultIndex);
+      aResultPart->setTrsf(anOrigin, aTrsf);
+      setResult(aResultPart, aResultIndex++);
+    }
+  }
 
-    // Setting result.
-    if (isPart) {
-      ResultPartPtr anOrigin = std::dynamic_pointer_cast<ModelAPI_ResultPart>(*aContext);
-      std::shared_ptr<GeomAPI_Trsf> aTrsf(new GeomAPI_Trsf());
-      for (int i=0; i<nbCopies; i++) {
-        aTrsf->setRotation(anAxis, i*anAngle);
-        ResultPartPtr aResultPart = document()->copyPart(anOrigin, data(), aResultIndex);
-        aResultPart->setTrsf(*aContext, aTrsf);
-        setResult(aResultPart, aResultIndex);
-        aResultIndex++;
-      }
-    } else {
-      std::string anError;
-      ListOfShape aListOfShape;
-      std::shared_ptr<GeomAlgoAPI_MakeShapeList>
-          aListOfRotationAlgo(new GeomAlgoAPI_MakeShapeList);
+  // Collect transformations for each object in a part.
+  std::shared_ptr<GeomAlgoAPI_MakeShapeList> aMakeShapeList(new GeomAlgoAPI_MakeShapeList);
+  for (GeomAPI_ShapeHierarchy::iterator anObjectsIt = anObjects.begin();
+       anObjectsIt != anObjects.end(); anObjectsIt++) {
+    std::shared_ptr<GeomAPI_Shape> aBaseShape = *anObjectsIt;
+    ListOfShape aListOfShape;
 
-      for (int i=0; i<nbCopies; i++) {
-        std::shared_ptr<GeomAlgoAPI_Rotation> aRotationnAlgo(
-          new GeomAlgoAPI_Rotation(aBaseShape, anAxis, i*anAngle));
+    for (int i = 0; i < nbCopies; i++) {
+      std::shared_ptr<GeomAlgoAPI_Rotation> aRotationnAlgo(
+          new GeomAlgoAPI_Rotation(aBaseShape, anAxis, i * anAngle));
 
-        // Checking that the algorithm worked properly.
-        if (GeomAlgoAPI_Tools::AlgoError::isAlgorithmFailed(aRotationnAlgo, getKind(), anError)) {
-          setError(anError);
-          break;
-        }
-        aListOfShape.push_back(aRotationnAlgo->shape());
-        aListOfRotationAlgo->appendAlgo(aRotationnAlgo);
+      // Checking that the algorithm worked properly.
+      if (GeomAlgoAPI_Tools::AlgoError::isAlgorithmFailed(aRotationnAlgo, getKind(), anError)) {
+        setError(anError);
+        break;
       }
-      std::shared_ptr<GeomAPI_Shape> aCompound =
-        GeomAlgoAPI_CompoundBuilder::compound(aListOfShape);
-      ResultBodyPtr aResultBody = document()->createBody(data(), aResultIndex);
+      aListOfShape.push_back(aRotationnAlgo->shape());
+      aMakeShapeList->appendAlgo(aRotationnAlgo);
+    }
 
-      ListOfShape aBaseShapes;
-      aBaseShapes.push_back(aBaseShape);
-      FeaturesPlugin_Tools::loadModifiedShapes(aResultBody, aBaseShapes, ListOfShape(),
-                                               aListOfRotationAlgo, aCompound, "Rotated");
+    GeomShapePtr aCompound = GeomAlgoAPI_CompoundBuilder::compound(aListOfShape);
+    anObjects.markModified(aBaseShape, aCompound);
+  }
 
-      setResult(aResultBody, aResultIndex);
-      aResultIndex++;
-    }
+  // Build results of the operation.
+  const ListOfShape& anOriginalShapes = anObjects.objects();
+  ListOfShape aTopLevel;
+  anObjects.topLevelObjects(aTopLevel);
+  for (ListOfShape::iterator anIt = aTopLevel.begin(); anIt != aTopLevel.end(); ++anIt) {
+    ResultBodyPtr aResultBody = document()->createBody(data(), aResultIndex);
+    FeaturesPlugin_Tools::loadModifiedShapes(aResultBody, anOriginalShapes, ListOfShape(),
+                                             aMakeShapeList, *anIt, "Rotated");
+    setResult(aResultBody, aResultIndex++);
   }
 
   // Remove the rest results if there were produced in the previous pass.
@@ -251,32 +254,13 @@ void FeaturesPlugin_MultiRotation::performRotation2D()
     aContextes.push_back(anObjectAttr->context());
   }
 
-  //Getting axis.
+  // Parameters of rotation.
   std::shared_ptr<GeomAPI_Ax1> anAxis;
-  std::shared_ptr<GeomAPI_Edge> anEdge;
-  std::shared_ptr<ModelAPI_AttributeSelection> anObjRef =
-    selection(FeaturesPlugin_MultiRotation::AXIS_ANGULAR_ID());
-  if(anObjRef && anObjRef->value() && anObjRef->value()->isEdge()) {
-    anEdge = std::shared_ptr<GeomAPI_Edge>(new GeomAPI_Edge(anObjRef->value()));
-  } else if (anObjRef && !anObjRef->value() && anObjRef->context() &&
-             anObjRef->context()->shape() && anObjRef->context()->shape()->isEdge()) {
-    anEdge = std::shared_ptr<GeomAPI_Edge>(new GeomAPI_Edge(anObjRef->context()->shape()));
-  }
-  if(anEdge) {
-    anAxis = std::shared_ptr<GeomAPI_Ax1>(new GeomAPI_Ax1(anEdge->line()->location(),
-                                                          anEdge->line()->direction()));
-  }
-
-  // Getting number of copies int he angular direction.
-  int nbAngular =
-    integer(FeaturesPlugin_MultiRotation::NB_COPIES_ANGULAR_ID())->value();
-
-  if (nbAngular <=0) {
-    std::string aFeatureError = "Multirotation builder ";
-    aFeatureError+=":: the number of copies for the angular direction is null or negative.";
-    setError(aFeatureError);
+  double anAngle = 0.0;
+  int nbCopies = 0;
+  if (!paramsOfRotation(anAxis, anAngle, nbCopies))
     return;
-  }
+
 
   // Getting number of copies int he radial direction.
   int nbRadial =
@@ -289,16 +273,6 @@ void FeaturesPlugin_MultiRotation::performRotation2D()
     return;
   }
 
-  // Getting angle
-  double anAngle;
-  std::string useAngularStep =
-    string(FeaturesPlugin_MultiRotation::USE_ANGULAR_STEP_ID())->value();
-  if (!useAngularStep.empty()) {
-    anAngle = real(FeaturesPlugin_MultiRotation::STEP_ANGULAR_ID())->value();
-  } else {
-    anAngle = 360./nbAngular;
-  }
-
   // Getting step
   double aStep = real(FeaturesPlugin_MultiRotation::STEP_RADIAL_ID())->value();
 
index 4b3cb965d80beb166b3aca07b69bdeb00797e7bb..6c81a130b20c53dfd407fd3c1bd5da6f8e5243c4 100644 (file)
@@ -120,6 +120,10 @@ class FeaturesPlugin_MultiRotation : public ModelAPI_Feature
   FeaturesPlugin_MultiRotation();
 
 private:
+  /// Fill axis, number of copies and angle of the rotation.
+  /// \returns \c false in case of errors.
+  bool paramsOfRotation(std::shared_ptr<GeomAPI_Ax1>& theAxis, double& theAngle, int& theQuantity);
+
   /// Perform the multi rotation in one direction.
   void performRotation1D();
 
index 51e96cd4a5aea9b1150d85ef45ca806d01719ba2..d8b030f14c58d4df11a5d7232ab295c234e036af 100644 (file)
@@ -23,6 +23,7 @@
 #include <GeomAlgoAPI_CompoundBuilder.h>
 #include <GeomAlgoAPI_MakeShapeList.h>
 #include <GeomAlgoAPI_Tools.h>
+#include <GeomAlgoAPI_Translation.h>
 
 #include <GeomAPI_Ax1.h>
 #include <GeomAPI_Edge.h>
@@ -39,6 +40,8 @@
 
 #include <math.h>
 
+static const std::string MULTITRANSLATION_VERSION_1("v9.5");
+
 //=================================================================================================
 FeaturesPlugin_MultiTranslation::FeaturesPlugin_MultiTranslation()
 {
@@ -67,117 +70,83 @@ void FeaturesPlugin_MultiTranslation::initAttributes()
                        ModelAPI_AttributeDouble::typeId());
   data()->addAttribute(FeaturesPlugin_MultiTranslation::NB_COPIES_SECOND_DIR_ID(),
                        ModelAPI_AttributeInteger::typeId());
-}
 
-//=================================================================================================
-void FeaturesPlugin_MultiTranslation::execute()
-{
-  std::string useSecondDir = string(FeaturesPlugin_MultiTranslation::USE_SECOND_DIR_ID())->value();
-  if(!useSecondDir.empty()) {
-    performTwoDirection();
-  } else {
-    performOneDirection();
+  if (!aSelection->isInitialized()) {
+    // new feature, not read from file
+    data()->setVersion(MULTITRANSLATION_VERSION_1);
   }
 }
 
 //=================================================================================================
-void FeaturesPlugin_MultiTranslation::performOneDirection()
+void FeaturesPlugin_MultiTranslation::execute()
 {
+  bool isKeepSubShapes = data()->version() == MULTITRANSLATION_VERSION_1;
+
   // Getting objects.
-  ListOfShape anObjects;
-  std::list<ResultPtr> aContextes;
-  AttributeSelectionListPtr anObjectsSelList =
-    selectionList(FeaturesPlugin_MultiTranslation::OBJECTS_LIST_ID());
+  AttributeSelectionListPtr anObjectsSelList = selectionList(OBJECTS_LIST_ID());
   if (anObjectsSelList->size() == 0) {
     setError("Error: empty selection list");
     return;
   }
-  for(int anObjectsIndex = 0; anObjectsIndex < anObjectsSelList->size(); anObjectsIndex++) {
-    std::shared_ptr<ModelAPI_AttributeSelection> anObjectAttr =
-      anObjectsSelList->value(anObjectsIndex);
-    std::shared_ptr<GeomAPI_Shape> anObject = anObjectAttr->value();
-    if(!anObject.get()) { // may be for not-activated parts
-      return;
-    }
-    anObjects.push_back(anObject);
-    aContextes.push_back(anObjectAttr->context());
-  }
 
-  //Getting axis.
-  static const std::string aSelectionError = "Error: The axis shape selection is bad.";
-  AttributeSelectionPtr anObjRef = selection(AXIS_FIRST_DIR_ID());
-  GeomShapePtr aShape = anObjRef->value();
-  if (!aShape.get()) {
-    if (anObjRef->context().get()) {
-      aShape = anObjRef->context()->shape();
-    }
-  }
-  if (!aShape.get()) {
-    setError(aSelectionError);
+  GeomAPI_ShapeHierarchy anObjects;
+  std::list<ResultPtr> aParts;
+  if (!FeaturesPlugin_Tools::shapesFromSelectionList(
+       anObjectsSelList, isKeepSubShapes, anObjects, aParts))
     return;
-  }
-
-  GeomEdgePtr anEdge;
-  if (aShape->isEdge())
-  {
-    anEdge = aShape->edge();
-  }
-  else if (aShape->isCompound())
-  {
-    GeomAPI_ShapeIterator anIt(aShape);
-    anEdge = anIt.current()->edge();
-  }
 
-  if (!anEdge.get())
-  {
-    setError(aSelectionError);
+  std::shared_ptr<GeomAPI_Dir> aFirstDir, aSecondDir;
+  double aFirstStep, aSecondStep;
+  int aFirstNbCopies, aSecondNbCopies;
+  if (!paramsAlongDirection(0, aFirstDir, aFirstStep, aFirstNbCopies))
     return;
-  }
 
-  std::shared_ptr<GeomAPI_Ax1> anAxis (new GeomAPI_Ax1(anEdge->line()->location(),
-                                                       anEdge->line()->direction()));
-
-  // Getting step.
-  double aStep = real(FeaturesPlugin_MultiTranslation::STEP_FIRST_DIR_ID())->value();
-
-  // Getting number of copies.
-  int nbCopies =
-    integer(FeaturesPlugin_MultiTranslation::NB_COPIES_FIRST_DIR_ID())->value();
-
-  if (nbCopies <=0) {
-    std::string aFeatureError = "Multitranslation builder ";
-    aFeatureError+=":: the number of copies for the first direction is null or negative.";
-    setError(aFeatureError);
-    return;
+  bool useSecondDir = !string(USE_SECOND_DIR_ID())->value().empty();
+  if (useSecondDir) {
+    if (!paramsAlongDirection(1, aSecondDir, aSecondStep, aSecondNbCopies))
+      return;
+  }
+  else {
+    aSecondDir = aFirstDir; // direction does not matter
+    aSecondStep = 0.0;
+    aSecondNbCopies = 1;
   }
 
-  // Moving each object.
+  std::string anError;
   int aResultIndex = 0;
-  std::list<ResultPtr>::iterator aContext = aContextes.begin();
-  for(ListOfShape::iterator anObjectsIt = anObjects.begin(); anObjectsIt != anObjects.end();
-        anObjectsIt++, aContext++) {
-    std::shared_ptr<GeomAPI_Shape> aBaseShape = *anObjectsIt;
-    bool isPart = aContext->get() && (*aContext)->groupName() == ModelAPI_ResultPart::group();
+  // Moving each part.
+  for (std::list<ResultPtr>::iterator aPRes = aParts.begin(); aPRes != aParts.end(); ++aPRes) {
+    ResultPartPtr anOrigin = std::dynamic_pointer_cast<ModelAPI_ResultPart>(*aPRes);
+    std::shared_ptr<GeomAPI_Trsf> aTrsf(new GeomAPI_Trsf());
+    for (int j = 0; j < aSecondNbCopies; j++) {
+      for (int i = 0; i < aFirstNbCopies; i++) {
+        double dx = i * aFirstStep * aFirstDir->x() + j * aSecondStep * aSecondDir->x();
+        double dy = i * aFirstStep * aFirstDir->y() + j * aSecondStep * aSecondDir->y();
+        double dz = i * aFirstStep * aFirstDir->z() + j * aSecondStep * aSecondDir->z();
+        aTrsf->setTranslation(dx, dy, dz);
 
-    // Setting result.
-    if (isPart) {
-      ResultPartPtr anOrigin = std::dynamic_pointer_cast<ModelAPI_ResultPart>(*aContext);
-      std::shared_ptr<GeomAPI_Trsf> aTrsf(new GeomAPI_Trsf());
-      for (int i=0; i<nbCopies; i++) {
-        aTrsf->setTranslation(anAxis, i*aStep);
         ResultPartPtr aResultPart = document()->copyPart(anOrigin, data(), aResultIndex);
-        aResultPart->setTrsf(*aContext, aTrsf);
+        aResultPart->setTrsf(anOrigin, aTrsf);
         setResult(aResultPart, aResultIndex);
         aResultIndex++;
       }
-    } else {
-      std::string anError;
-      ListOfShape aListOfShape;
-      ListOfMakeShape aMakeShapeList;
+    }
+  }
 
-      for (int i=0; i<nbCopies; i++) {
+  // Collect transformations for each object in a part.
+  std::shared_ptr<GeomAlgoAPI_MakeShapeList> aMakeShapeList(new GeomAlgoAPI_MakeShapeList);
+  for (GeomAPI_ShapeHierarchy::iterator anObjectsIt = anObjects.begin();
+       anObjectsIt != anObjects.end(); anObjectsIt++) {
+    std::shared_ptr<GeomAPI_Shape> aBaseShape = *anObjectsIt;
+    ListOfShape aListOfShape;
+
+    for (int j = 0; j < aSecondNbCopies; j++) {
+      for (int i = 0; i < aFirstNbCopies; i++) {
+        double dx = i * aFirstStep * aFirstDir->x() + j * aSecondStep * aSecondDir->x();
+        double dy = i * aFirstStep * aFirstDir->y() + j * aSecondStep * aSecondDir->y();
+        double dz = i * aFirstStep * aFirstDir->z() + j * aSecondStep * aSecondDir->z();
         std::shared_ptr<GeomAlgoAPI_Translation> aTranslationAlgo(
-          new GeomAlgoAPI_Translation(aBaseShape, anAxis, i*aStep));
+            new GeomAlgoAPI_Translation(aBaseShape, dx, dy, dz));
 
         // Checking that the algorithm worked properly.
         if (GeomAlgoAPI_Tools::AlgoError::isAlgorithmFailed(
@@ -186,24 +155,22 @@ void FeaturesPlugin_MultiTranslation::performOneDirection()
           break;
         }
         aListOfShape.push_back(aTranslationAlgo->shape());
-        aMakeShapeList.push_back(aTranslationAlgo);
+        aMakeShapeList->appendAlgo(aTranslationAlgo);
       }
-
-      std::shared_ptr<GeomAlgoAPI_MakeShapeList>
-          aListOfTranslationAlgo(new GeomAlgoAPI_MakeShapeList(aMakeShapeList));
-
-      std::shared_ptr<GeomAPI_Shape> aCompound =
-        GeomAlgoAPI_CompoundBuilder::compound(aListOfShape);
-      ResultBodyPtr aResultBody = document()->createBody(data(), aResultIndex);
-
-      ListOfShape aBaseShapes;
-      aBaseShapes.push_back(aBaseShape);
-      FeaturesPlugin_Tools::loadModifiedShapes(aResultBody, aBaseShapes, ListOfShape(),
-                                               aListOfTranslationAlgo, aCompound, "Translated");
-
-      setResult(aResultBody, aResultIndex);
-      aResultIndex++;
     }
+    GeomShapePtr aCompound = GeomAlgoAPI_CompoundBuilder::compound(aListOfShape);
+    anObjects.markModified(aBaseShape, aCompound);
+  }
+
+  // Build results of the operation.
+  const ListOfShape& anOriginalShapes = anObjects.objects();
+  ListOfShape aTopLevel;
+  anObjects.topLevelObjects(aTopLevel);
+  for (ListOfShape::iterator anIt = aTopLevel.begin(); anIt != aTopLevel.end(); ++anIt) {
+    ResultBodyPtr aResultBody = document()->createBody(data(), aResultIndex);
+    FeaturesPlugin_Tools::loadModifiedShapes(aResultBody, anOriginalShapes, ListOfShape(),
+                                             aMakeShapeList, *anIt, "Translated");
+    setResult(aResultBody, aResultIndex++);
   }
 
   // Remove the rest results if there were produced in the previous pass.
@@ -211,195 +178,48 @@ void FeaturesPlugin_MultiTranslation::performOneDirection()
 }
 
 //=================================================================================================
-void FeaturesPlugin_MultiTranslation::performTwoDirection()
+bool FeaturesPlugin_MultiTranslation::paramsAlongDirection(const int theIndex,
+                                                           std::shared_ptr<GeomAPI_Dir>& theDir,
+                                                           double& theDistance,
+                                                           int& theQuantity)
 {
-  // Getting objects.
-  ListOfShape anObjects;
-  std::list<ResultPtr> aContextes;
-  AttributeSelectionListPtr anObjectsSelList =
-    selectionList(FeaturesPlugin_MultiTranslation::OBJECTS_LIST_ID());
-  if (anObjectsSelList->size() == 0) {
-    setError("Error: empty selection list");
-    return;
-  }
-  for(int anObjectsIndex = 0; anObjectsIndex < anObjectsSelList->size(); anObjectsIndex++) {
-    std::shared_ptr<ModelAPI_AttributeSelection> anObjectAttr =
-      anObjectsSelList->value(anObjectsIndex);
-    std::shared_ptr<GeomAPI_Shape> anObject = anObjectAttr->value();
-    if(!anObject.get()) { // may be for not-activated parts
-      return;
-    }
-    anObjects.push_back(anObject);
-    aContextes.push_back(anObjectAttr->context());
-  }
+  static std::string THE_AXIS_DIR[2] = { AXIS_FIRST_DIR_ID(), AXIS_SECOND_DIR_ID() };
+  static std::string THE_STEP[2] = { STEP_FIRST_DIR_ID(), STEP_SECOND_DIR_ID() };
+  static std::string THE_COPIES[2] = { NB_COPIES_FIRST_DIR_ID(), NB_COPIES_SECOND_DIR_ID() };
+  static std::string THE_INDEX_ID[2] = { "first", "second" };
 
   //Getting axis.
   static const std::string aSelectionError = "Error: The axis shape selection is bad.";
-  AttributeSelectionPtr anObjRef = selection(AXIS_FIRST_DIR_ID());
+  AttributeSelectionPtr anObjRef = selection(THE_AXIS_DIR[theIndex]);
   GeomShapePtr aShape = anObjRef->value();
-  if (!aShape.get()) {
-    if (anObjRef->context().get()) {
-      aShape = anObjRef->context()->shape();
-    }
-  }
+  if (!aShape.get() && anObjRef->context().get())
+    aShape = anObjRef->context()->shape();
   if (!aShape.get()) {
     setError(aSelectionError);
-    return;
+    return false;
   }
 
   GeomEdgePtr anEdge;
   if (aShape->isEdge())
-  {
-    anEdge = aShape->edge();
-  }
-  else if (aShape->isCompound())
-  {
-    GeomAPI_ShapeIterator anIt(aShape);
-    anEdge = anIt.current()->edge();
-  }
-
-  if (!anEdge.get())
-  {
-    setError(aSelectionError);
-    return;
-  }
-
-  std::shared_ptr<GeomAPI_Ax1> aFirstAxis(new GeomAPI_Ax1(anEdge->line()->location(),
-                                                          anEdge->line()->direction()));
-
-  //Getting axis.
-  anObjRef = selection(AXIS_SECOND_DIR_ID());
-  aShape = anObjRef->value();
-  if (!aShape.get()) {
-    if (anObjRef->context().get()) {
-      aShape = anObjRef->context()->shape();
-    }
-  }
-  if (!aShape.get()) {
-    setError(aSelectionError);
-    return;
-  }
-
-  if (aShape->isEdge())
-  {
     anEdge = aShape->edge();
-  }
-  else if (aShape->isCompound())
-  {
+  else if (aShape->isCompound()) {
     GeomAPI_ShapeIterator anIt(aShape);
     anEdge = anIt.current()->edge();
   }
 
-  if (!anEdge.get())
-  {
+  if (!anEdge.get()) {
     setError(aSelectionError);
-    return;
-  }
-
-  std::shared_ptr<GeomAPI_Ax1> aSecondAxis(new GeomAPI_Ax1(anEdge->line()->location(),
-                                                           anEdge->line()->direction()));
-
-  // Getting step.
-  double aFirstStep = real(FeaturesPlugin_MultiTranslation::STEP_FIRST_DIR_ID())->value();
-  double aSecondStep = real(FeaturesPlugin_MultiTranslation::STEP_SECOND_DIR_ID())->value();
-
-  // Getting number of copies.
-  int aFirstNbCopies =
-    integer(FeaturesPlugin_MultiTranslation::NB_COPIES_FIRST_DIR_ID())->value();
-  int aSecondNbCopies =
-    integer(FeaturesPlugin_MultiTranslation::NB_COPIES_SECOND_DIR_ID())->value();
-
-  if (aFirstNbCopies <=0) {
-    std::string aFeatureError = "Multitranslation builder ";
-    aFeatureError+=":: the number of copies for the first direction is null or negative.";
-    setError(aFeatureError);
-    return;
+    return false;
   }
 
-  if (aSecondNbCopies <=0) {
-    std::string aFeatureError = "Multitranslation builder ";
-    aFeatureError+=":: the number of copies for the second direction is null or negative.";
+  theDir = anEdge->line()->direction();
+  theDistance = real(THE_STEP[theIndex])->value();
+  theQuantity = integer(THE_COPIES[theIndex])->value();
+  if (theQuantity <= 0) {
+    std::string aFeatureError = "Multitranslation builder :: the number of copies for the ";
+    aFeatureError += THE_INDEX_ID[theIndex] + " direction is null or negative.";
     setError(aFeatureError);
-    return;
-  }
-
-  // Coord aFirstAxis
-  double x1 = aFirstAxis->dir()->x();
-  double y1 = aFirstAxis->dir()->y();
-  double z1 = aFirstAxis->dir()->z();
-  double norm1 = sqrt(x1*x1 + y1*y1 + z1*z1);
-
-  // Coord aSecondAxis
-  double x2 = aSecondAxis->dir()->x();
-  double y2 = aSecondAxis->dir()->y();
-  double z2 = aSecondAxis->dir()->z();
-  double norm2 = sqrt(x2*x2 + y2*y2 + z2*z2);
-
-  // Moving each object.
-  int aResultIndex = 0;
-  std::list<ResultPtr>::iterator aContext = aContextes.begin();
-  for(ListOfShape::iterator anObjectsIt = anObjects.begin(); anObjectsIt != anObjects.end();
-        anObjectsIt++, aContext++) {
-    std::shared_ptr<GeomAPI_Shape> aBaseShape = *anObjectsIt;
-    bool isPart = aContext->get() && (*aContext)->groupName() == ModelAPI_ResultPart::group();
-
-    // Setting result.
-    if (isPart) {
-      ResultPartPtr anOrigin = std::dynamic_pointer_cast<ModelAPI_ResultPart>(*aContext);
-      std::shared_ptr<GeomAPI_Trsf> aTrsf(new GeomAPI_Trsf());
-      for (int j=0; j<aSecondNbCopies; j++) {
-        for (int i=0; i<aFirstNbCopies; i++) {
-          double dx = i*aFirstStep*x1/norm1+j*aSecondStep*x2/norm2;
-          double dy = i*aFirstStep*y1/norm1+j*aSecondStep*y2/norm2;
-          double dz = i*aFirstStep*z1/norm1+j*aSecondStep*z2/norm2;
-          aTrsf->setTranslation(dx, dy, dz);
-          ResultPartPtr aResultPart = document()->copyPart(anOrigin, data(), aResultIndex);
-          aResultPart->setTrsf(*aContext, aTrsf);
-          setResult(aResultPart, aResultIndex);
-          aResultIndex++;
-        }
-      }
-    } else {
-      std::string anError;
-      ListOfShape aListOfShape;
-      ListOfMakeShape aMakeShapeList;
-
-      for (int j=0; j<aSecondNbCopies; j++) {
-        for (int i=0; i<aFirstNbCopies; i++) {
-          double dx = i*aFirstStep*x1/norm1+j*aSecondStep*x2/norm2;
-          double dy = i*aFirstStep*y1/norm1+j*aSecondStep*y2/norm2;
-          double dz = i*aFirstStep*z1/norm1+j*aSecondStep*z2/norm2;
-          std::shared_ptr<GeomAlgoAPI_Translation> aTranslationAlgo(
-            new GeomAlgoAPI_Translation(aBaseShape, dx, dy, dz));
-
-          // Checking that the algorithm worked properly.
-          if (GeomAlgoAPI_Tools::AlgoError::isAlgorithmFailed(
-              aTranslationAlgo, getKind(), anError)) {
-            setError(anError);
-            break;
-          }
-          aListOfShape.push_back(aTranslationAlgo->shape());
-          aMakeShapeList.push_back(aTranslationAlgo);
-        }
-      }
-
-      std::shared_ptr<GeomAlgoAPI_MakeShapeList>
-          aListOfTranslationAlgo(new GeomAlgoAPI_MakeShapeList(aMakeShapeList));
-
-      std::shared_ptr<GeomAPI_Shape> aCompound =
-        GeomAlgoAPI_CompoundBuilder::compound(aListOfShape);
-      ResultBodyPtr aResultBody = document()->createBody(data(), aResultIndex);
-
-      ListOfShape aBaseShapes;
-      aBaseShapes.push_back(aBaseShape);
-      FeaturesPlugin_Tools::loadModifiedShapes(aResultBody, aBaseShapes, ListOfShape(),
-                                               aListOfTranslationAlgo, aCompound, "Translated");
-
-      setResult(aResultBody, aResultIndex);
-      aResultIndex++;
-    }
+    return false;
   }
-
-  // Remove the rest results if there were produced in the previous pass.
-  removeResults(aResultIndex);
+  return true;
 }
index 6f817ce41f82351ee654dcb1e0c9a0069fefaf04..be232988027556447327f6ed0991e2bf00ca88dd 100644 (file)
 
 #include <FeaturesPlugin.h>
 
-#include <GeomAlgoAPI_Translation.h>
-
 #include <ModelAPI_Feature.h>
 
+class GeomAPI_Dir;
+
 /** \class FeaturesPlugin_MultiTranslation
  *  \ingroup Plugins
  *  \brief Feature for movement objects along one or two axes an arbitary number of times,
@@ -114,11 +114,12 @@ class FeaturesPlugin_MultiTranslation : public ModelAPI_Feature
   FeaturesPlugin_MultiTranslation();
 
 private:
-  /// Perform the multi translation in one direction.
-  void performOneDirection();
-
-  /// Perform the multi translation in two directions.
-  void performTwoDirection();
+  /// Fill axis, number of copies and distance for the given direction.
+  /// \returns \c false in case of errors.
+  bool paramsAlongDirection(const int theIndex,
+                            std::shared_ptr<GeomAPI_Dir>& theDir,
+                            double& theDistance,
+                            int& theQuantity);
 };
 
 #endif // FEATURESPLUGIN_MULTITRANSLATION_H_
\ No newline at end of file
diff --git a/src/FeaturesPlugin/Test/TestMultiRotation_MultiLevelCompound_v0_1.py b/src/FeaturesPlugin/Test/TestMultiRotation_MultiLevelCompound_v0_1.py
new file mode 100644 (file)
index 0000000..674650d
--- /dev/null
@@ -0,0 +1,134 @@
+# Copyright (C) 2020  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 salome.shaper import model
+
+from GeomAPI import *
+from GeomAlgoAPI import *
+from SketchAPI import *
+
+model.begin()
+partSet = model.moduleDocument()
+Part_1 = model.addPart(partSet)
+Part_1_doc = Part_1.document()
+Sketch_1 = model.addSketch(Part_1_doc, model.standardPlane("XOY"))
+SketchEllipse_1 = Sketch_1.addEllipse(11.18033988749894, -50, 22.36067977499789, -50, 10)
+[SketchPoint_1, SketchPoint_2, SketchPoint_3, SketchPoint_4, SketchPoint_5, SketchPoint_6, SketchPoint_7, SketchLine_1, SketchLine_2] = SketchEllipse_1.construction(center = "aux", firstFocus = "aux", secondFocus = "aux", majorAxisStart = "aux", majorAxisEnd = "aux", minorAxisStart = "aux", minorAxisEnd = "aux", majorAxis = "aux", minorAxis = "aux")
+SketchConstraintHorizontal_1 = Sketch_1.setHorizontal(SketchLine_1.result())
+SketchConstraintLength_1 = Sketch_1.setLength(SketchLine_1.result(), 30)
+SketchConstraintLength_2 = Sketch_1.setLength(SketchLine_2.result(), 20)
+SketchProjection_1 = Sketch_1.addProjection(model.selection("EDGE", "PartSet/OY"), False)
+SketchLine_3 = SketchProjection_1.createdFeature()
+SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchAPI_Point(SketchPoint_3).coordinates(), SketchLine_3.result())
+SketchConstraintDistance_1 = Sketch_1.setDistance(SketchAPI_Line(SketchLine_3).startPoint(), SketchAPI_Point(SketchPoint_3).coordinates(), 50, True)
+SketchCircle_1 = Sketch_1.addCircle(41.18033988749897, -50, 5)
+SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchCircle_1.center(), SketchLine_1.result())
+SketchConstraintDistance_2 = Sketch_1.setDistance(SketchEllipse_1.majorAxisPositive(), SketchCircle_1.center(), 15, True)
+SketchConstraintRadius_1 = Sketch_1.setRadius(SketchCircle_1.results()[1], 5)
+SketchMultiRotation_1 = Sketch_1.addRotation([SketchEllipse_1.result(), SketchCircle_1.results()[1]], SketchAPI_Point(SketchPoint_3).coordinates(), 360, 3, True)
+[SketchEllipse_2, SketchEllipse_3, SketchCircle_2, SketchCircle_3] = SketchMultiRotation_1.rotated()
+model.do()
+Sketch_1.changeFacesOrder([[SketchEllipse_1.result(), SketchEllipse_1.result(), SketchEllipse_2.result(), SketchEllipse_3.result()],
+                           [SketchCircle_1.results()[1]],
+                           [SketchEllipse_2.result(), SketchEllipse_2.result(), SketchEllipse_3.result(), SketchEllipse_1.result()],
+                           [SketchEllipse_1.result(), SketchEllipse_3.result(), SketchEllipse_2.result()],
+                           [SketchEllipse_3.result(), SketchEllipse_2.result(), SketchEllipse_1.result()],
+                           [SketchEllipse_1.result(), SketchEllipse_2.result(), SketchEllipse_3.result()],
+                           [SketchEllipse_1.result(), SketchEllipse_3.result(), SketchEllipse_2.result()],
+                           [SketchEllipse_2.result(), SketchEllipse_3.result(), SketchEllipse_3.result(), SketchEllipse_1.result()],
+                           [SketchCircle_2.results()[1]],
+                           [SketchCircle_3.results()[1]]
+                          ])
+model.do()
+Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("COMPOUND", "Sketch_1")], model.selection(), 10, 0)
+Compound_1 = model.addCompound(Part_1_doc, [model.selection("SOLID", "Extrusion_1_2"), model.selection("SOLID", "Extrusion_1_3")])
+Compound_2_objects = [model.selection("COMPSOLID", "Extrusion_1_1"), model.selection("COMPOUND", "Compound_1_1"), model.selection("SOLID", "Extrusion_1_4")]
+Compound_2 = model.addCompound(Part_1_doc, Compound_2_objects)
+model.end()
+
+ANGLE = 60
+COPIES = 3
+TOLERANCE = 1.e-7
+
+
+model.begin()
+MultiRotation_1 = model.addMultiRotation(Part_1_doc, [model.selection("SOLID", "Compound_2_1_1_5")], model.selection("EDGE", "PartSet/OZ"), ANGLE, COPIES)
+model.testNbResults(MultiRotation_1, 1)
+model.testNbSubResults(MultiRotation_1, [COPIES])
+model.testNbSubShapes(MultiRotation_1, GeomAPI_Shape.SOLID, [1 * COPIES])
+model.testNbSubShapes(MultiRotation_1, GeomAPI_Shape.FACE, [5 * COPIES])
+model.testNbSubShapes(MultiRotation_1, GeomAPI_Shape.EDGE, [18 * COPIES])
+model.testNbSubShapes(MultiRotation_1, GeomAPI_Shape.VERTEX, [36 * COPIES])
+model.testResultsVolumes(MultiRotation_1, [542.746463956 * COPIES])
+
+refPoint = GeomAPI_Pnt(22.16914827868, -12.5, 5)
+midPoint = MultiRotation_1.defaultResult().shape().middlePoint()
+assert(midPoint.distance(refPoint) < TOLERANCE)
+
+
+Recover_1 = model.addRecover(Part_1_doc, MultiRotation_1, [Compound_2.result()], True)
+MultiRotation_2 = model.addMultiRotation(Part_1_doc, [model.selection("SOLID", "Recover_1_1_2_1")], model.selection("EDGE", "PartSet/OZ"), ANGLE, COPIES)
+model.testNbResults(MultiRotation_2, 1)
+model.testNbSubResults(MultiRotation_2, [COPIES])
+model.testNbSubShapes(MultiRotation_2, GeomAPI_Shape.SOLID, [1 * COPIES])
+model.testNbSubShapes(MultiRotation_2, GeomAPI_Shape.FACE, [3 * COPIES])
+model.testNbSubShapes(MultiRotation_2, GeomAPI_Shape.EDGE, [6 * COPIES])
+model.testNbSubShapes(MultiRotation_2, GeomAPI_Shape.VERTEX, [12 * COPIES])
+model.testResultsVolumes(MultiRotation_2, [785.39816339745 * COPIES])
+
+refPoint = GeomAPI_Pnt(43.301270189, 5.3316102395, 5)
+midPoint = MultiRotation_2.defaultResult().shape().middlePoint()
+assert(midPoint.distance(refPoint) < TOLERANCE)
+
+
+Recover_2 = model.addRecover(Part_1_doc, MultiRotation_2, [Recover_1.result()], True)
+MultiRotation_3 = model.addMultiRotation(Part_1_doc, [model.selection("SOLID", "Recover_2_1_3")], model.selection("EDGE", "PartSet/OZ"), ANGLE, COPIES)
+model.testNbResults(MultiRotation_3, 1)
+model.testNbSubResults(MultiRotation_3, [COPIES])
+model.testNbSubShapes(MultiRotation_3, GeomAPI_Shape.SOLID, [1 * COPIES])
+model.testNbSubShapes(MultiRotation_3, GeomAPI_Shape.FACE, [3 * COPIES])
+model.testNbSubShapes(MultiRotation_3, GeomAPI_Shape.EDGE, [6 * COPIES])
+model.testNbSubShapes(MultiRotation_3, GeomAPI_Shape.VERTEX, [12 * COPIES])
+model.testResultsVolumes(MultiRotation_3, [785.39816339745 * COPIES])
+
+refPoint = GeomAPI_Pnt(31.94572, -30.33161024, 5)
+midPoint = MultiRotation_3.defaultResult().shape().middlePoint()
+assert(midPoint.distance(refPoint) < TOLERANCE)
+
+
+Recover_3 = model.addRecover(Part_1_doc, MultiRotation_3, [Recover_2.result()], True)
+MultiRotation_4 = model.addMultiRotation(Part_1_doc, [model.selection("SOLID", "Recover_3_1_1_1"), model.selection("SOLID", "Recover_3_1_2_2"), model.selection("SOLID", "Recover_3_1_3")], model.selection("EDGE", "PartSet/OZ"), ANGLE, COPIES)
+model.testNbResults(MultiRotation_4, 3)
+model.testNbSubResults(MultiRotation_4, [COPIES, COPIES, COPIES])
+model.testNbSubShapes(MultiRotation_4, GeomAPI_Shape.SOLID, [1 * COPIES, 1 * COPIES, 1 * COPIES])
+model.testNbSubShapes(MultiRotation_4, GeomAPI_Shape.FACE, [6 * COPIES, 3 * COPIES, 3 * COPIES])
+model.testNbSubShapes(MultiRotation_4, GeomAPI_Shape.EDGE, [24 * COPIES, 6 * COPIES, 6 * COPIES])
+model.testNbSubShapes(MultiRotation_4, GeomAPI_Shape.VERTEX, [48 * COPIES, 12 * COPIES, 12 * COPIES])
+model.testResultsVolumes(MultiRotation_4, [3444.394198615 * COPIES, 785.39816339745 * COPIES, 785.39816339745 * COPIES])
+
+REFERENCE = [GeomAPI_Pnt(32.6022829255, -5.6990653637, 5),
+             GeomAPI_Pnt(1.06046515086, -17.8316102395, 5),
+             GeomAPI_Pnt(31.945720066, -30.3316102395, 5)]
+for res, ref in zip(MultiRotation_4.results(), REFERENCE):
+    midPoint = res.resultSubShapePair()[0].shape().middlePoint()
+    assert(midPoint.distance(ref) < TOLERANCE)
+
+model.end()
+
+assert(model.checkPythonDump())
diff --git a/src/FeaturesPlugin/Test/TestMultiRotation_MultiLevelCompound_v0_2.py b/src/FeaturesPlugin/Test/TestMultiRotation_MultiLevelCompound_v0_2.py
new file mode 100644 (file)
index 0000000..5779ece
--- /dev/null
@@ -0,0 +1,133 @@
+# Copyright (C) 2020  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 salome.shaper import model
+
+from GeomAPI import *
+from GeomAlgoAPI import *
+from SketchAPI import *
+
+model.begin()
+partSet = model.moduleDocument()
+Part_1 = model.addPart(partSet)
+Part_1_doc = Part_1.document()
+Sketch_1 = model.addSketch(Part_1_doc, model.standardPlane("XOY"))
+SketchEllipse_1 = Sketch_1.addEllipse(11.18033988749894, -50, 22.36067977499789, -50, 10)
+[SketchPoint_1, SketchPoint_2, SketchPoint_3, SketchPoint_4, SketchPoint_5, SketchPoint_6, SketchPoint_7, SketchLine_1, SketchLine_2] = SketchEllipse_1.construction(center = "aux", firstFocus = "aux", secondFocus = "aux", majorAxisStart = "aux", majorAxisEnd = "aux", minorAxisStart = "aux", minorAxisEnd = "aux", majorAxis = "aux", minorAxis = "aux")
+SketchConstraintHorizontal_1 = Sketch_1.setHorizontal(SketchLine_1.result())
+SketchConstraintLength_1 = Sketch_1.setLength(SketchLine_1.result(), 30)
+SketchConstraintLength_2 = Sketch_1.setLength(SketchLine_2.result(), 20)
+SketchProjection_1 = Sketch_1.addProjection(model.selection("EDGE", "PartSet/OY"), False)
+SketchLine_3 = SketchProjection_1.createdFeature()
+SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchAPI_Point(SketchPoint_3).coordinates(), SketchLine_3.result())
+SketchConstraintDistance_1 = Sketch_1.setDistance(SketchAPI_Line(SketchLine_3).startPoint(), SketchAPI_Point(SketchPoint_3).coordinates(), 50, True)
+SketchCircle_1 = Sketch_1.addCircle(41.18033988749897, -50, 5)
+SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchCircle_1.center(), SketchLine_1.result())
+SketchConstraintDistance_2 = Sketch_1.setDistance(SketchEllipse_1.majorAxisPositive(), SketchCircle_1.center(), 15, True)
+SketchConstraintRadius_1 = Sketch_1.setRadius(SketchCircle_1.results()[1], 5)
+SketchMultiRotation_1 = Sketch_1.addRotation([SketchEllipse_1.result(), SketchCircle_1.results()[1]], SketchAPI_Point(SketchPoint_3).coordinates(), 360, 3, True)
+[SketchEllipse_2, SketchEllipse_3, SketchCircle_2, SketchCircle_3] = SketchMultiRotation_1.rotated()
+model.do()
+Sketch_1.changeFacesOrder([[SketchEllipse_1.result(), SketchEllipse_1.result(), SketchEllipse_2.result(), SketchEllipse_3.result()],
+                           [SketchCircle_1.results()[1]],
+                           [SketchEllipse_2.result(), SketchEllipse_2.result(), SketchEllipse_3.result(), SketchEllipse_1.result()],
+                           [SketchEllipse_1.result(), SketchEllipse_3.result(), SketchEllipse_2.result()],
+                           [SketchEllipse_3.result(), SketchEllipse_2.result(), SketchEllipse_1.result()],
+                           [SketchEllipse_1.result(), SketchEllipse_2.result(), SketchEllipse_3.result()],
+                           [SketchEllipse_1.result(), SketchEllipse_3.result(), SketchEllipse_2.result()],
+                           [SketchEllipse_2.result(), SketchEllipse_3.result(), SketchEllipse_3.result(), SketchEllipse_1.result()],
+                           [SketchCircle_2.results()[1]],
+                           [SketchCircle_3.results()[1]]
+                          ])
+model.do()
+Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("COMPOUND", "Sketch_1")], model.selection(), 10, 0)
+Compound_1 = model.addCompound(Part_1_doc, [model.selection("SOLID", "Extrusion_1_2"), model.selection("SOLID", "Extrusion_1_3")])
+Compound_2_objects = [model.selection("COMPSOLID", "Extrusion_1_1"), model.selection("COMPOUND", "Compound_1_1"), model.selection("SOLID", "Extrusion_1_4")]
+Compound_2 = model.addCompound(Part_1_doc, Compound_2_objects)
+model.end()
+
+COPIES = 3
+TOLERANCE = 1.e-7
+
+
+model.begin()
+MultiRotation_1 = model.addMultiRotation(Part_1_doc, [model.selection("SOLID", "Compound_2_1_1_5")], model.selection("EDGE", "PartSet/OZ"), COPIES)
+model.testNbResults(MultiRotation_1, 1)
+model.testNbSubResults(MultiRotation_1, [COPIES])
+model.testNbSubShapes(MultiRotation_1, GeomAPI_Shape.SOLID, [1 * COPIES])
+model.testNbSubShapes(MultiRotation_1, GeomAPI_Shape.FACE, [5 * COPIES])
+model.testNbSubShapes(MultiRotation_1, GeomAPI_Shape.EDGE, [18 * COPIES])
+model.testNbSubShapes(MultiRotation_1, GeomAPI_Shape.VERTEX, [36 * COPIES])
+model.testResultsVolumes(MultiRotation_1, [542.746463956 * COPIES])
+
+refPoint = GeomAPI_Pnt(0.518513184, -12.5, 5)
+midPoint = MultiRotation_1.defaultResult().shape().middlePoint()
+assert(midPoint.distance(refPoint) < TOLERANCE)
+
+
+Recover_1 = model.addRecover(Part_1_doc, MultiRotation_1, [Compound_2.result()], True)
+MultiRotation_2 = model.addMultiRotation(Part_1_doc, [model.selection("SOLID", "Recover_1_1_2_1")], model.selection("EDGE", "PartSet/OZ"), COPIES)
+model.testNbResults(MultiRotation_2, 1)
+model.testNbSubResults(MultiRotation_2, [COPIES])
+model.testNbSubShapes(MultiRotation_2, GeomAPI_Shape.SOLID, [1 * COPIES])
+model.testNbSubShapes(MultiRotation_2, GeomAPI_Shape.FACE, [3 * COPIES])
+model.testNbSubShapes(MultiRotation_2, GeomAPI_Shape.EDGE, [6 * COPIES])
+model.testNbSubShapes(MultiRotation_2, GeomAPI_Shape.VERTEX, [12 * COPIES])
+model.testResultsVolumes(MultiRotation_2, [785.39816339745 * COPIES])
+
+refPoint = GeomAPI_Pnt(-11.355550122, 5.3316102, 5)
+midPoint = MultiRotation_2.defaultResult().shape().middlePoint()
+assert(midPoint.distance(refPoint) < TOLERANCE)
+
+
+Recover_2 = model.addRecover(Part_1_doc, MultiRotation_2, [Recover_1.result()], True)
+MultiRotation_3 = model.addMultiRotation(Part_1_doc, [model.selection("SOLID", "Recover_2_1_3")], model.selection("EDGE", "PartSet/OZ"), COPIES)
+model.testNbResults(MultiRotation_3, 1)
+model.testNbSubResults(MultiRotation_3, [COPIES])
+model.testNbSubShapes(MultiRotation_3, GeomAPI_Shape.SOLID, [1 * COPIES])
+model.testNbSubShapes(MultiRotation_3, GeomAPI_Shape.FACE, [3 * COPIES])
+model.testNbSubShapes(MultiRotation_3, GeomAPI_Shape.EDGE, [6 * COPIES])
+model.testNbSubShapes(MultiRotation_3, GeomAPI_Shape.VERTEX, [12 * COPIES])
+model.testResultsVolumes(MultiRotation_3, [785.39816339745 * COPIES])
+
+refPoint = GeomAPI_Pnt(10.29508497, -12.5, 5)
+midPoint = MultiRotation_3.defaultResult().shape().middlePoint()
+assert(midPoint.distance(refPoint) < TOLERANCE)
+
+
+Recover_3 = model.addRecover(Part_1_doc, MultiRotation_3, [Recover_2.result()], True)
+MultiRotation_4 = model.addMultiRotation(Part_1_doc, [model.selection("SOLID", "Recover_3_1_1_1"), model.selection("SOLID", "Recover_3_1_2_2"), model.selection("SOLID", "Recover_3_1_3")], model.selection("EDGE", "PartSet/OZ"), COPIES)
+model.testNbResults(MultiRotation_4, 3)
+model.testNbSubResults(MultiRotation_4, [COPIES, COPIES, COPIES])
+model.testNbSubShapes(MultiRotation_4, GeomAPI_Shape.SOLID, [1 * COPIES, 1 * COPIES, 1 * COPIES])
+model.testNbSubShapes(MultiRotation_4, GeomAPI_Shape.FACE, [6 * COPIES, 3 * COPIES, 3 * COPIES])
+model.testNbSubShapes(MultiRotation_4, GeomAPI_Shape.EDGE, [24 * COPIES, 6 * COPIES, 6 * COPIES])
+model.testNbSubShapes(MultiRotation_4, GeomAPI_Shape.VERTEX, [48 * COPIES, 12 * COPIES, 12 * COPIES])
+model.testResultsVolumes(MultiRotation_4, [3444.394198615 * COPIES, 785.39816339745 * COPIES, 785.39816339745 * COPIES])
+
+REFERENCE = [GeomAPI_Pnt(-5.8665084688, -5.6990653637, 5),
+             GeomAPI_Pnt(1.06046515086, 5.3316102395, 5),
+             GeomAPI_Pnt(10.29508497, -12.5, 5)]
+for res, ref in zip(MultiRotation_4.results(), REFERENCE):
+    midPoint = res.resultSubShapePair()[0].shape().middlePoint()
+    assert(midPoint.distance(ref) < TOLERANCE)
+
+model.end()
+
+assert(model.checkPythonDump())
diff --git a/src/FeaturesPlugin/Test/TestMultiRotation_MultiLevelCompound_v0_3.py b/src/FeaturesPlugin/Test/TestMultiRotation_MultiLevelCompound_v0_3.py
new file mode 100644 (file)
index 0000000..7442e96
--- /dev/null
@@ -0,0 +1,199 @@
+# Copyright (C) 2020  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 salome.shaper import model
+from GeomAPI import *
+from GeomAlgoAPI import *
+
+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"))
+SketchPoint_1 = Sketch_1.addPoint(44.29784155360136, 17.09942588468031)
+SketchArc_1 = Sketch_1.addArc(44.29784155360136, 17.09942588468031, 47.1668727423061, 12.27945348765633, 45.38299232715926, 22.60269052200972, False)
+SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchPoint_1.coordinates(), SketchArc_1.center())
+SketchLine_1 = Sketch_1.addLine(42.5764228403785, 22.14892077680068, 39.70739165167375, 16.41085839939117)
+SketchLine_2 = Sketch_1.addLine(39.70739165167375, 16.41085839939117, 43.03546783057126, 12.04993099255995)
+SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_2.startPoint())
+SketchLine_3 = Sketch_1.addLine(28.57555063949931, 12.96802097294547, 15.72229091410204, 12.96802097294547)
+SketchLine_4 = Sketch_1.addLine(15.72229091410204, 12.96802097294547, 15.72229091410204, 21.46035329151154)
+SketchLine_5 = Sketch_1.addLine(15.72229091410204, 21.46035329151154, 28.57555063949931, 21.46035329151154)
+SketchLine_6 = Sketch_1.addLine(28.57555063949931, 21.46035329151154, 28.57555063949931, 12.96802097294547)
+SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchLine_6.endPoint(), SketchLine_3.startPoint())
+SketchConstraintCoincidence_4 = Sketch_1.setCoincident(SketchLine_3.endPoint(), SketchLine_4.startPoint())
+SketchConstraintCoincidence_5 = Sketch_1.setCoincident(SketchLine_4.endPoint(), SketchLine_5.startPoint())
+SketchConstraintCoincidence_6 = Sketch_1.setCoincident(SketchLine_5.endPoint(), SketchLine_6.startPoint())
+SketchConstraintHorizontal_1 = Sketch_1.setHorizontal(SketchLine_3.result())
+SketchConstraintVertical_1 = Sketch_1.setVertical(SketchLine_4.result())
+SketchConstraintHorizontal_2 = Sketch_1.setHorizontal(SketchLine_5.result())
+SketchConstraintVertical_2 = Sketch_1.setVertical(SketchLine_6.result())
+SketchLine_7 = Sketch_1.addLine(-10.67279602198167, 14.78814178154371, -28.34602814440294, 14.78814178154371)
+SketchLine_8 = Sketch_1.addLine(-28.34602814440294, 14.78814178154371, -28.34602814440294, 25.13271321305362)
+SketchLine_9 = Sketch_1.addLine(-28.34602814440294, 25.13271321305362, -10.67279602198167, 25.13271321305362)
+SketchLine_10 = Sketch_1.addLine(-10.67279602198167, 25.13271321305362, -10.67279602198167, 14.78814178154371)
+SketchConstraintCoincidence_7 = Sketch_1.setCoincident(SketchLine_10.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())
+SketchConstraintCoincidence_10 = Sketch_1.setCoincident(SketchLine_9.endPoint(), SketchLine_10.startPoint())
+SketchConstraintHorizontal_3 = Sketch_1.setHorizontal(SketchLine_7.result())
+SketchConstraintVertical_3 = Sketch_1.setVertical(SketchLine_8.result())
+SketchConstraintHorizontal_4 = Sketch_1.setHorizontal(SketchLine_9.result())
+SketchConstraintVertical_4 = Sketch_1.setVertical(SketchLine_10.result())
+SketchLine_11 = Sketch_1.addLine(-17.67323212242127, 25.13271321305362, -21.80463703415611, 14.78814178154371)
+SketchConstraintCoincidence_11 = Sketch_1.setCoincident(SketchLine_11.startPoint(), SketchLine_9.result())
+SketchConstraintCoincidence_12 = Sketch_1.setCoincident(SketchLine_11.endPoint(), SketchLine_7.result())
+model.do()
+Vertex_1 = model.addVertex(Part_1_doc, [model.selection("VERTEX", "Sketch_1/SketchArc_1")], False)
+Edge_1 = model.addEdge(Part_1_doc, [model.selection("EDGE", "Sketch_1/SketchArc_1_2")], False)
+Wire_1 = model.addWire(Part_1_doc, [model.selection("EDGE", "Sketch_1/SketchLine_1"), model.selection("EDGE", "Sketch_1/SketchLine_2")], False)
+Face_1 = model.addFace(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_6r-SketchLine_5r-SketchLine_4r-SketchLine_3r")])
+Shell_1 = model.addShell(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_10r-SketchLine_9r-SketchLine_11f-SketchLine_7r"), model.selection("FACE", "Sketch_1/Face-SketchLine_11r-SketchLine_9r-SketchLine_8r-SketchLine_7r")])
+Box_1 = model.addBox(Part_1_doc, 10, 10, 10)
+Translation_1 = model.addTranslation(Part_1_doc, [model.selection("SOLID", "Box_1_1")], model.selection("EDGE", "PartSet/OX"), 50)
+Box_2 = model.addBox(Part_1_doc, 10, 10, 10)
+Cylinder_1 = model.addCylinder(Part_1_doc, model.selection("VERTEX", "PartSet/Origin"), model.selection("EDGE", "PartSet/OZ"), 5, 10)
+Partition_1 = model.addPartition(Part_1_doc, [model.selection("SOLID", "Box_2_1"), model.selection("SOLID", "Cylinder_1_1")])
+Box_3 = model.addBox(Part_1_doc, 10, 10, 10)
+Translation_2 = model.addTranslation(Part_1_doc, [model.selection("SOLID", "Box_3_1")], model.selection("EDGE", "PartSet/OY"), 50)
+AngularCopy_1 = model.addMultiRotation(Part_1_doc, [model.selection("SOLID", "Translation_2_1")], model.selection("EDGE", "PartSet/OZ"), 30, 3)
+model.end()
+
+TOLERANCE = 1.e-7
+COPIES = 4
+
+
+model.begin()
+MultiRotation_1 = model.addMultiRotation(Part_1_doc, [model.selection("VERTEX", "Vertex_1_1")], model.selection("EDGE", "PartSet/OX"), COPIES)
+model.testNbResults(MultiRotation_1, 1)
+model.testNbSubResults(MultiRotation_1, [COPIES])
+model.testNbSubShapes(MultiRotation_1, GeomAPI_Shape.SOLID, [0])
+model.testNbSubShapes(MultiRotation_1, GeomAPI_Shape.FACE, [0])
+model.testNbSubShapes(MultiRotation_1, GeomAPI_Shape.EDGE, [0])
+model.testNbSubShapes(MultiRotation_1, GeomAPI_Shape.VERTEX, [COPIES])
+model.testResultsVolumes(MultiRotation_1, [0])
+refPoint = Vertex_1.defaultResult().shape().middlePoint()
+refPoint.setY(0)
+refPoint.setZ(0)
+midPoint = MultiRotation_1.defaultResult().shape().middlePoint()
+assert(midPoint.distance(refPoint) < TOLERANCE)
+
+MultiRotation_2 = model.addMultiRotation(Part_1_doc, [model.selection("EDGE", "Edge_1_1")], model.selection("EDGE", "PartSet/OX"), COPIES)
+model.testNbResults(MultiRotation_2, 1)
+model.testNbSubResults(MultiRotation_2, [COPIES])
+model.testNbSubShapes(MultiRotation_2, GeomAPI_Shape.SOLID, [0])
+model.testNbSubShapes(MultiRotation_2, GeomAPI_Shape.FACE, [0])
+model.testNbSubShapes(MultiRotation_2, GeomAPI_Shape.EDGE, [COPIES])
+model.testNbSubShapes(MultiRotation_2, GeomAPI_Shape.VERTEX, [2 * COPIES])
+model.testResultsVolumes(MultiRotation_2, [0])
+comp = GeomAlgoAPI_CompoundBuilder.compound([Edge_1.defaultResult().shape()])
+refPoint = comp.middlePoint()
+refPoint.setY(0)
+refPoint.setZ(0)
+midPoint = MultiRotation_2.defaultResult().shape().middlePoint()
+assert(midPoint.distance(refPoint) < TOLERANCE)
+
+MultiRotation_3 = model.addMultiRotation(Part_1_doc, [model.selection("WIRE", "Wire_1_1")], model.selection("EDGE", "PartSet/OX"), COPIES)
+model.testNbResults(MultiRotation_3, 1)
+model.testNbSubResults(MultiRotation_3, [COPIES])
+model.testNbSubShapes(MultiRotation_3, GeomAPI_Shape.SOLID, [0])
+model.testNbSubShapes(MultiRotation_3, GeomAPI_Shape.FACE, [0])
+model.testNbSubShapes(MultiRotation_3, GeomAPI_Shape.EDGE, [2 * COPIES])
+model.testNbSubShapes(MultiRotation_3, GeomAPI_Shape.VERTEX, [4 * COPIES])
+model.testResultsVolumes(MultiRotation_3, [0])
+comp = GeomAlgoAPI_CompoundBuilder.compound([Wire_1.defaultResult().shape()])
+refPoint = comp.middlePoint()
+refPoint.setY(0)
+refPoint.setZ(0)
+midPoint = MultiRotation_3.defaultResult().shape().middlePoint()
+assert(midPoint.distance(refPoint) < TOLERANCE)
+
+MultiRotation_4 = model.addMultiRotation(Part_1_doc, [model.selection("FACE", "Face_1_1")], model.selection("EDGE", "PartSet/OX"), COPIES)
+model.testNbResults(MultiRotation_4, 1)
+model.testNbSubResults(MultiRotation_4, [COPIES])
+model.testNbSubShapes(MultiRotation_4, GeomAPI_Shape.SOLID, [0])
+model.testNbSubShapes(MultiRotation_4, GeomAPI_Shape.FACE, [COPIES])
+model.testNbSubShapes(MultiRotation_4, GeomAPI_Shape.EDGE, [4 * COPIES])
+model.testNbSubShapes(MultiRotation_4, GeomAPI_Shape.VERTEX, [8 * COPIES])
+model.testResultsVolumes(MultiRotation_4, [109.154152964914914 * COPIES])
+refPoint = Face_1.defaultResult().shape().middlePoint()
+refPoint.setY(0)
+refPoint.setZ(0)
+midPoint = MultiRotation_4.defaultResult().shape().middlePoint()
+assert(midPoint.distance(refPoint) < TOLERANCE)
+
+MultiRotation_5 = model.addMultiRotation(Part_1_doc, [model.selection("SHELL", "Shell_1_1")], model.selection("EDGE", "PartSet/OX"), COPIES)
+model.testNbResults(MultiRotation_5, 1)
+model.testNbSubResults(MultiRotation_5, [COPIES])
+model.testNbSubShapes(MultiRotation_5, GeomAPI_Shape.SOLID, [0])
+model.testNbSubShapes(MultiRotation_5, GeomAPI_Shape.FACE, [2 * COPIES])
+model.testNbSubShapes(MultiRotation_5, GeomAPI_Shape.EDGE, [8 * COPIES])
+model.testNbSubShapes(MultiRotation_5, GeomAPI_Shape.VERTEX, [16 * COPIES])
+model.testResultsVolumes(MultiRotation_5, [182.822012116 * COPIES])
+refPoint = Shell_1.defaultResult().shape().middlePoint()
+refPoint.setY(0)
+refPoint.setZ(0)
+midPoint = MultiRotation_5.defaultResult().shape().middlePoint()
+assert(midPoint.distance(refPoint) < TOLERANCE)
+
+MultiRotation_6 = model.addMultiRotation(Part_1_doc, [model.selection("SOLID", "Translation_1_1")], model.selection("EDGE", "PartSet/OX"), COPIES)
+model.testNbResults(MultiRotation_6, 1)
+model.testNbSubResults(MultiRotation_6, [COPIES])
+model.testNbSubShapes(MultiRotation_6, GeomAPI_Shape.SOLID, [COPIES])
+model.testNbSubShapes(MultiRotation_6, GeomAPI_Shape.FACE, [6 * COPIES])
+model.testNbSubShapes(MultiRotation_6, GeomAPI_Shape.EDGE, [24 * COPIES])
+model.testNbSubShapes(MultiRotation_6, GeomAPI_Shape.VERTEX, [48 * COPIES])
+model.testResultsVolumes(MultiRotation_6, [1000 * COPIES])
+refPoint = Translation_1.defaultResult().shape().middlePoint()
+refPoint.setY(0)
+refPoint.setZ(0)
+midPoint = MultiRotation_6.defaultResult().shape().middlePoint()
+assert(midPoint.distance(refPoint) < TOLERANCE)
+
+MultiRotation_7 = model.addMultiRotation(Part_1_doc, [model.selection("COMPSOLID", "Partition_1_1")], model.selection("EDGE", "PartSet/OX"), COPIES)
+model.testNbResults(MultiRotation_7, 1)
+model.testNbSubResults(MultiRotation_7, [COPIES])
+model.testNbSubShapes(MultiRotation_7, GeomAPI_Shape.SOLID, [3 * COPIES])
+model.testNbSubShapes(MultiRotation_7, GeomAPI_Shape.FACE, [17 * COPIES])
+model.testNbSubShapes(MultiRotation_7, GeomAPI_Shape.EDGE, [66 * COPIES])
+model.testNbSubShapes(MultiRotation_7, GeomAPI_Shape.VERTEX, [132 * COPIES])
+model.testResultsVolumes(MultiRotation_7, [1589.0486226 * COPIES])
+refPoint = Partition_1.defaultResult().shape().middlePoint()
+refPoint.setY(0)
+refPoint.setZ(0)
+midPoint = MultiRotation_7.defaultResult().shape().middlePoint()
+assert(midPoint.distance(refPoint) < TOLERANCE)
+
+MultiRotation_8 = model.addMultiRotation(Part_1_doc, [model.selection("COMPOUND", "AngularCopy_1_1")], model.selection("EDGE", "PartSet/OX"), COPIES)
+model.testNbResults(MultiRotation_8, 1)
+model.testNbSubResults(MultiRotation_8, [COPIES])
+model.testNbSubShapes(MultiRotation_8, GeomAPI_Shape.SOLID, [3 * COPIES])
+model.testNbSubShapes(MultiRotation_8, GeomAPI_Shape.FACE, [18 * COPIES])
+model.testNbSubShapes(MultiRotation_8, GeomAPI_Shape.EDGE, [72 * COPIES])
+model.testNbSubShapes(MultiRotation_8, GeomAPI_Shape.VERTEX, [144 * COPIES])
+model.testResultsVolumes(MultiRotation_8, [3000 * COPIES])
+refPoint = AngularCopy_1.defaultResult().shape().middlePoint()
+refPoint.setY(0)
+refPoint.setZ(0)
+midPoint = MultiRotation_8.defaultResult().shape().middlePoint()
+assert(midPoint.distance(refPoint) < TOLERANCE)
+
+model.end()
+
+assert(model.checkPythonDump())
diff --git a/src/FeaturesPlugin/Test/TestMultiRotation_MultiLevelCompound_v0_4.py b/src/FeaturesPlugin/Test/TestMultiRotation_MultiLevelCompound_v0_4.py
new file mode 100644 (file)
index 0000000..fb3623c
--- /dev/null
@@ -0,0 +1,208 @@
+# Copyright (C) 2020  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 salome.shaper import model
+from GeomAPI import *
+from GeomAlgoAPI import *
+
+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"))
+SketchPoint_1 = Sketch_1.addPoint(44.29784155360136, 17.09942588468031)
+SketchArc_1 = Sketch_1.addArc(44.29784155360136, 17.09942588468031, 47.1668727423061, 12.27945348765633, 45.38299232715926, 22.60269052200972, False)
+SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchPoint_1.coordinates(), SketchArc_1.center())
+SketchLine_1 = Sketch_1.addLine(42.5764228403785, 22.14892077680068, 39.70739165167375, 16.41085839939117)
+SketchLine_2 = Sketch_1.addLine(39.70739165167375, 16.41085839939117, 43.03546783057126, 12.04993099255995)
+SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_2.startPoint())
+SketchLine_3 = Sketch_1.addLine(28.57555063949931, 12.96802097294547, 15.72229091410204, 12.96802097294547)
+SketchLine_4 = Sketch_1.addLine(15.72229091410204, 12.96802097294547, 15.72229091410204, 21.46035329151154)
+SketchLine_5 = Sketch_1.addLine(15.72229091410204, 21.46035329151154, 28.57555063949931, 21.46035329151154)
+SketchLine_6 = Sketch_1.addLine(28.57555063949931, 21.46035329151154, 28.57555063949931, 12.96802097294547)
+SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchLine_6.endPoint(), SketchLine_3.startPoint())
+SketchConstraintCoincidence_4 = Sketch_1.setCoincident(SketchLine_3.endPoint(), SketchLine_4.startPoint())
+SketchConstraintCoincidence_5 = Sketch_1.setCoincident(SketchLine_4.endPoint(), SketchLine_5.startPoint())
+SketchConstraintCoincidence_6 = Sketch_1.setCoincident(SketchLine_5.endPoint(), SketchLine_6.startPoint())
+SketchConstraintHorizontal_1 = Sketch_1.setHorizontal(SketchLine_3.result())
+SketchConstraintVertical_1 = Sketch_1.setVertical(SketchLine_4.result())
+SketchConstraintHorizontal_2 = Sketch_1.setHorizontal(SketchLine_5.result())
+SketchConstraintVertical_2 = Sketch_1.setVertical(SketchLine_6.result())
+SketchLine_7 = Sketch_1.addLine(-10.67279602198167, 14.78814178154371, -28.34602814440294, 14.78814178154371)
+SketchLine_8 = Sketch_1.addLine(-28.34602814440294, 14.78814178154371, -28.34602814440294, 25.13271321305362)
+SketchLine_9 = Sketch_1.addLine(-28.34602814440294, 25.13271321305362, -10.67279602198167, 25.13271321305362)
+SketchLine_10 = Sketch_1.addLine(-10.67279602198167, 25.13271321305362, -10.67279602198167, 14.78814178154371)
+SketchConstraintCoincidence_7 = Sketch_1.setCoincident(SketchLine_10.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())
+SketchConstraintCoincidence_10 = Sketch_1.setCoincident(SketchLine_9.endPoint(), SketchLine_10.startPoint())
+SketchConstraintHorizontal_3 = Sketch_1.setHorizontal(SketchLine_7.result())
+SketchConstraintVertical_3 = Sketch_1.setVertical(SketchLine_8.result())
+SketchConstraintHorizontal_4 = Sketch_1.setHorizontal(SketchLine_9.result())
+SketchConstraintVertical_4 = Sketch_1.setVertical(SketchLine_10.result())
+SketchLine_11 = Sketch_1.addLine(-17.67323212242127, 25.13271321305362, -21.80463703415611, 14.78814178154371)
+SketchConstraintCoincidence_11 = Sketch_1.setCoincident(SketchLine_11.startPoint(), SketchLine_9.result())
+SketchConstraintCoincidence_12 = Sketch_1.setCoincident(SketchLine_11.endPoint(), SketchLine_7.result())
+model.do()
+Vertex_1 = model.addVertex(Part_1_doc, [model.selection("VERTEX", "Sketch_1/SketchArc_1")], False)
+Edge_1 = model.addEdge(Part_1_doc, [model.selection("EDGE", "Sketch_1/SketchArc_1_2")], False)
+Wire_1 = model.addWire(Part_1_doc, [model.selection("EDGE", "Sketch_1/SketchLine_1"), model.selection("EDGE", "Sketch_1/SketchLine_2")], False)
+Face_1 = model.addFace(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_6r-SketchLine_5r-SketchLine_4r-SketchLine_3r")])
+Shell_1 = model.addShell(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_10r-SketchLine_9r-SketchLine_11f-SketchLine_7r"), model.selection("FACE", "Sketch_1/Face-SketchLine_11r-SketchLine_9r-SketchLine_8r-SketchLine_7r")])
+Box_1 = model.addBox(Part_1_doc, 10, 10, 10)
+Translation_1 = model.addTranslation(Part_1_doc, [model.selection("SOLID", "Box_1_1")], model.selection("EDGE", "PartSet/OX"), 50)
+Box_2 = model.addBox(Part_1_doc, 10, 10, 10)
+Cylinder_1 = model.addCylinder(Part_1_doc, model.selection("VERTEX", "PartSet/Origin"), model.selection("EDGE", "PartSet/OZ"), 5, 10)
+Partition_1 = model.addPartition(Part_1_doc, [model.selection("SOLID", "Box_2_1"), model.selection("SOLID", "Cylinder_1_1")])
+Box_3 = model.addBox(Part_1_doc, 10, 10, 10)
+Translation_2 = model.addTranslation(Part_1_doc, [model.selection("SOLID", "Box_3_1")], model.selection("EDGE", "PartSet/OY"), 50)
+AngularCopy_1 = model.addMultiRotation(Part_1_doc, [model.selection("SOLID", "Translation_2_1")], model.selection("EDGE", "PartSet/OZ"), 30, 3)
+Compound_1_objects = [model.selection("VERTEX", "Vertex_1_1"), model.selection("EDGE", "Edge_1_1"), model.selection("WIRE", "Wire_1_1"), model.selection("FACE", "Face_1_1"), model.selection("SHELL", "Shell_1_1"), model.selection("SOLID", "Translation_1_1"), model.selection("COMPSOLID", "Partition_1_1"), model.selection("COMPOUND", "AngularCopy_1_1")]
+Compound_1 = model.addCompound(Part_1_doc, Compound_1_objects)
+model.end()
+
+TOLERANCE = 1.e-7
+COPIES = 4
+
+
+model.begin()
+MultiRotation_1 = model.addMultiRotation(Part_1_doc, [model.selection("VERTEX", "Compound_1_1_1")], model.selection("EDGE", "PartSet/OX"), COPIES)
+model.testNbResults(MultiRotation_1, 1)
+model.testNbSubResults(MultiRotation_1, [COPIES])
+model.testNbSubShapes(MultiRotation_1, GeomAPI_Shape.SOLID, [0])
+model.testNbSubShapes(MultiRotation_1, GeomAPI_Shape.FACE, [0])
+model.testNbSubShapes(MultiRotation_1, GeomAPI_Shape.EDGE, [0])
+model.testNbSubShapes(MultiRotation_1, GeomAPI_Shape.VERTEX, [COPIES])
+model.testResultsVolumes(MultiRotation_1, [0])
+refPoint = Vertex_1.defaultResult().shape().middlePoint()
+refPoint.setY(0)
+refPoint.setZ(0)
+midPoint = MultiRotation_1.defaultResult().shape().middlePoint()
+assert(midPoint.distance(refPoint) < TOLERANCE)
+
+Recover_1 = model.addRecover(Part_1_doc, MultiRotation_1, [Compound_1.result()], True)
+MultiRotation_2 = model.addMultiRotation(Part_1_doc, [model.selection("EDGE", "Recover_1_1_2")], model.selection("EDGE", "PartSet/OX"), COPIES)
+model.testNbResults(MultiRotation_2, 1)
+model.testNbSubResults(MultiRotation_2, [COPIES])
+model.testNbSubShapes(MultiRotation_2, GeomAPI_Shape.SOLID, [0])
+model.testNbSubShapes(MultiRotation_2, GeomAPI_Shape.FACE, [0])
+model.testNbSubShapes(MultiRotation_2, GeomAPI_Shape.EDGE, [COPIES])
+model.testNbSubShapes(MultiRotation_2, GeomAPI_Shape.VERTEX, [2 * COPIES])
+model.testResultsVolumes(MultiRotation_2, [0])
+comp = GeomAlgoAPI_CompoundBuilder.compound([Edge_1.defaultResult().shape()])
+refPoint = comp.middlePoint()
+refPoint.setY(0)
+refPoint.setZ(0)
+midPoint = MultiRotation_2.defaultResult().shape().middlePoint()
+assert(midPoint.distance(refPoint) < TOLERANCE)
+
+Recover_2 = model.addRecover(Part_1_doc, MultiRotation_2, [Recover_1.result()])
+MultiRotation_3 = model.addMultiRotation(Part_1_doc, [model.selection("WIRE", "Recover_2_1_3")], model.selection("EDGE", "PartSet/OX"), COPIES)
+model.testNbResults(MultiRotation_3, 1)
+model.testNbSubResults(MultiRotation_3, [COPIES])
+model.testNbSubShapes(MultiRotation_3, GeomAPI_Shape.SOLID, [0])
+model.testNbSubShapes(MultiRotation_3, GeomAPI_Shape.FACE, [0])
+model.testNbSubShapes(MultiRotation_3, GeomAPI_Shape.EDGE, [2 * COPIES])
+model.testNbSubShapes(MultiRotation_3, GeomAPI_Shape.VERTEX, [4 * COPIES])
+model.testResultsVolumes(MultiRotation_3, [0])
+comp = GeomAlgoAPI_CompoundBuilder.compound([Wire_1.defaultResult().shape()])
+refPoint = comp.middlePoint()
+refPoint.setY(0)
+refPoint.setZ(0)
+midPoint = MultiRotation_3.defaultResult().shape().middlePoint()
+assert(midPoint.distance(refPoint) < TOLERANCE)
+
+Recover_3 = model.addRecover(Part_1_doc, MultiRotation_3, [Recover_2.result()])
+MultiRotation_4 = model.addMultiRotation(Part_1_doc, [model.selection("FACE", "Recover_3_1_4")], model.selection("EDGE", "PartSet/OX"), COPIES)
+model.testNbResults(MultiRotation_4, 1)
+model.testNbSubResults(MultiRotation_4, [COPIES])
+model.testNbSubShapes(MultiRotation_4, GeomAPI_Shape.SOLID, [0])
+model.testNbSubShapes(MultiRotation_4, GeomAPI_Shape.FACE, [COPIES])
+model.testNbSubShapes(MultiRotation_4, GeomAPI_Shape.EDGE, [4 * COPIES])
+model.testNbSubShapes(MultiRotation_4, GeomAPI_Shape.VERTEX, [8 * COPIES])
+model.testResultsVolumes(MultiRotation_4, [109.154152964914914 * COPIES])
+refPoint = Face_1.defaultResult().shape().middlePoint()
+refPoint.setY(0)
+refPoint.setZ(0)
+midPoint = MultiRotation_4.defaultResult().shape().middlePoint()
+assert(midPoint.distance(refPoint) < TOLERANCE)
+
+Recover_4 = model.addRecover(Part_1_doc, MultiRotation_4, [Recover_3.result()])
+MultiRotation_5 = model.addMultiRotation(Part_1_doc, [model.selection("SHELL", "Recover_4_1_5")], model.selection("EDGE", "PartSet/OX"), COPIES)
+model.testNbResults(MultiRotation_5, 1)
+model.testNbSubResults(MultiRotation_5, [COPIES])
+model.testNbSubShapes(MultiRotation_5, GeomAPI_Shape.SOLID, [0])
+model.testNbSubShapes(MultiRotation_5, GeomAPI_Shape.FACE, [2 * COPIES])
+model.testNbSubShapes(MultiRotation_5, GeomAPI_Shape.EDGE, [8 * COPIES])
+model.testNbSubShapes(MultiRotation_5, GeomAPI_Shape.VERTEX, [16 * COPIES])
+model.testResultsVolumes(MultiRotation_5, [182.822012116 * COPIES])
+refPoint = Shell_1.defaultResult().shape().middlePoint()
+refPoint.setY(0)
+refPoint.setZ(0)
+midPoint = MultiRotation_5.defaultResult().shape().middlePoint()
+assert(midPoint.distance(refPoint) < TOLERANCE)
+
+Recover_5 = model.addRecover(Part_1_doc, MultiRotation_5, [Recover_4.result()])
+MultiRotation_6 = model.addMultiRotation(Part_1_doc, [model.selection("SOLID", "Recover_5_1_6")], model.selection("EDGE", "PartSet/OX"), COPIES)
+model.testNbResults(MultiRotation_6, 1)
+model.testNbSubResults(MultiRotation_6, [COPIES])
+model.testNbSubShapes(MultiRotation_6, GeomAPI_Shape.SOLID, [COPIES])
+model.testNbSubShapes(MultiRotation_6, GeomAPI_Shape.FACE, [6 * COPIES])
+model.testNbSubShapes(MultiRotation_6, GeomAPI_Shape.EDGE, [24 * COPIES])
+model.testNbSubShapes(MultiRotation_6, GeomAPI_Shape.VERTEX, [48 * COPIES])
+model.testResultsVolumes(MultiRotation_6, [1000 * COPIES])
+refPoint = Translation_1.defaultResult().shape().middlePoint()
+refPoint.setY(0)
+refPoint.setZ(0)
+midPoint = MultiRotation_6.defaultResult().shape().middlePoint()
+assert(midPoint.distance(refPoint) < TOLERANCE)
+
+Recover_6 = model.addRecover(Part_1_doc, MultiRotation_6, [Recover_5.result()])
+MultiRotation_7 = model.addMultiRotation(Part_1_doc, [model.selection("COMPSOLID", "Recover_6_1_7")], model.selection("EDGE", "PartSet/OX"), COPIES)
+model.testNbResults(MultiRotation_7, 1)
+model.testNbSubResults(MultiRotation_7, [COPIES])
+model.testNbSubShapes(MultiRotation_7, GeomAPI_Shape.SOLID, [3 * COPIES])
+model.testNbSubShapes(MultiRotation_7, GeomAPI_Shape.FACE, [17 * COPIES])
+model.testNbSubShapes(MultiRotation_7, GeomAPI_Shape.EDGE, [66 * COPIES])
+model.testNbSubShapes(MultiRotation_7, GeomAPI_Shape.VERTEX, [132 * COPIES])
+model.testResultsVolumes(MultiRotation_7, [1589.0486226 * COPIES])
+refPoint = Partition_1.defaultResult().shape().middlePoint()
+refPoint.setY(0)
+refPoint.setZ(0)
+midPoint = MultiRotation_7.defaultResult().shape().middlePoint()
+assert(midPoint.distance(refPoint) < TOLERANCE)
+
+Recover_7 = model.addRecover(Part_1_doc, MultiRotation_7, [Recover_6.result()])
+MultiRotation_8 = model.addMultiRotation(Part_1_doc, [model.selection("COMPOUND", "Recover_7_1_8")], model.selection("EDGE", "PartSet/OX"), COPIES)
+model.testNbResults(MultiRotation_8, 1)
+model.testNbSubResults(MultiRotation_8, [COPIES])
+model.testNbSubShapes(MultiRotation_8, GeomAPI_Shape.SOLID, [3 * COPIES])
+model.testNbSubShapes(MultiRotation_8, GeomAPI_Shape.FACE, [18 * COPIES])
+model.testNbSubShapes(MultiRotation_8, GeomAPI_Shape.EDGE, [72 * COPIES])
+model.testNbSubShapes(MultiRotation_8, GeomAPI_Shape.VERTEX, [144 * COPIES])
+model.testResultsVolumes(MultiRotation_8, [3000 * COPIES])
+refPoint = AngularCopy_1.defaultResult().shape().middlePoint()
+refPoint.setY(0)
+refPoint.setZ(0)
+midPoint = MultiRotation_8.defaultResult().shape().middlePoint()
+assert(midPoint.distance(refPoint) < TOLERANCE)
+
+model.end()
+
+assert(model.checkPythonDump())
diff --git a/src/FeaturesPlugin/Test/TestMultiRotation_MultiLevelCompound_v95_1.py b/src/FeaturesPlugin/Test/TestMultiRotation_MultiLevelCompound_v95_1.py
new file mode 100644 (file)
index 0000000..0b47113
--- /dev/null
@@ -0,0 +1,118 @@
+# Copyright (C) 2020  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 salome.shaper import model
+
+from GeomAPI import *
+from SketchAPI import *
+
+model.begin()
+partSet = model.moduleDocument()
+Part_1 = model.addPart(partSet)
+Part_1_doc = Part_1.document()
+Sketch_1 = model.addSketch(Part_1_doc, model.standardPlane("XOY"))
+SketchEllipse_1 = Sketch_1.addEllipse(11.18033988749894, -50, 22.36067977499789, -50, 10)
+[SketchPoint_1, SketchPoint_2, SketchPoint_3, SketchPoint_4, SketchPoint_5, SketchPoint_6, SketchPoint_7, SketchLine_1, SketchLine_2] = SketchEllipse_1.construction(center = "aux", firstFocus = "aux", secondFocus = "aux", majorAxisStart = "aux", majorAxisEnd = "aux", minorAxisStart = "aux", minorAxisEnd = "aux", majorAxis = "aux", minorAxis = "aux")
+SketchConstraintHorizontal_1 = Sketch_1.setHorizontal(SketchLine_1.result())
+SketchConstraintLength_1 = Sketch_1.setLength(SketchLine_1.result(), 30)
+SketchConstraintLength_2 = Sketch_1.setLength(SketchLine_2.result(), 20)
+SketchProjection_1 = Sketch_1.addProjection(model.selection("EDGE", "PartSet/OY"), False)
+SketchLine_3 = SketchProjection_1.createdFeature()
+SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchAPI_Point(SketchPoint_3).coordinates(), SketchLine_3.result())
+SketchConstraintDistance_1 = Sketch_1.setDistance(SketchAPI_Line(SketchLine_3).startPoint(), SketchAPI_Point(SketchPoint_3).coordinates(), 50, True)
+SketchCircle_1 = Sketch_1.addCircle(41.18033988749897, -50, 5)
+SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchCircle_1.center(), SketchLine_1.result())
+SketchConstraintDistance_2 = Sketch_1.setDistance(SketchEllipse_1.majorAxisPositive(), SketchCircle_1.center(), 15, True)
+SketchConstraintRadius_1 = Sketch_1.setRadius(SketchCircle_1.results()[1], 5)
+SketchMultiRotation_1 = Sketch_1.addRotation([SketchEllipse_1.result(), SketchCircle_1.results()[1]], SketchAPI_Point(SketchPoint_3).coordinates(), 360, 3, True)
+[SketchEllipse_2, SketchEllipse_3, SketchCircle_2, SketchCircle_3] = SketchMultiRotation_1.rotated()
+model.do()
+Sketch_1.changeFacesOrder([[SketchEllipse_1.result(), SketchEllipse_1.result(), SketchEllipse_2.result(), SketchEllipse_3.result()],
+                           [SketchCircle_1.results()[1]],
+                           [SketchEllipse_2.result(), SketchEllipse_2.result(), SketchEllipse_3.result(), SketchEllipse_1.result()],
+                           [SketchEllipse_1.result(), SketchEllipse_3.result(), SketchEllipse_2.result()],
+                           [SketchEllipse_3.result(), SketchEllipse_2.result(), SketchEllipse_1.result()],
+                           [SketchEllipse_1.result(), SketchEllipse_2.result(), SketchEllipse_3.result()],
+                           [SketchEllipse_1.result(), SketchEllipse_3.result(), SketchEllipse_2.result()],
+                           [SketchEllipse_2.result(), SketchEllipse_3.result(), SketchEllipse_3.result(), SketchEllipse_1.result()],
+                           [SketchCircle_2.results()[1]],
+                           [SketchCircle_3.results()[1]]
+                          ])
+model.do()
+Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("COMPOUND", "Sketch_1")], model.selection(), 10, 0)
+Compound_1 = model.addCompound(Part_1_doc, [model.selection("SOLID", "Extrusion_1_2"), model.selection("SOLID", "Extrusion_1_3")])
+Compound_2_objects = [model.selection("COMPSOLID", "Extrusion_1_1"), model.selection("COMPOUND", "Compound_1_1"), model.selection("SOLID", "Extrusion_1_4")]
+Compound_2 = model.addCompound(Part_1_doc, Compound_2_objects)
+model.end()
+
+ANGLE = 60
+COPIES = 3
+TOLERANCE = 1.e-7
+
+def subsRefPoints(theResult):
+    res = []
+    for ind in range(0, theResult.numberOfSubs()):
+        res.append( theResult.subResult(ind).resultSubShapePair()[0].shape().middlePoint())
+    return res
+
+REFERENCE = subsRefPoints(Compound_2.result())
+
+def assertResult(theFeature, theNbSolids, theNbFaces, theNbEdges, theNbVertices, theVolume):
+    model.testNbResults(theFeature, 1)
+    model.testNbSubResults(theFeature, [3])
+    model.testNbSubShapes(theFeature, GeomAPI_Shape.SOLID, [theNbSolids])
+    model.testNbSubShapes(theFeature, GeomAPI_Shape.FACE, [theNbFaces])
+    model.testNbSubShapes(theFeature, GeomAPI_Shape.EDGE, [theNbEdges])
+    model.testNbSubShapes(theFeature, GeomAPI_Shape.VERTEX, [theNbVertices])
+    model.testResultsVolumes(theFeature, [theVolume])
+
+    for ind in range(0, theFeature.result().numberOfSubs()):
+        ref = REFERENCE[ind]
+        midPoint = theFeature.result().subResult(ind).resultSubShapePair()[0].shape().middlePoint()
+        assert(midPoint.distance(ref) < TOLERANCE), "Sub-result {}; actual ({}, {}, {}) != expected ({}, {}, {})".format(ind, midPoint.x(), midPoint.y(), midPoint.z(), ref.x(), ref.y(), ref.z())
+
+
+model.begin()
+MultiRotation_1 = model.addMultiRotation(Part_1_doc, [model.selection("SOLID", "Compound_2_1_1_5")], model.selection("EDGE", "PartSet/OZ"), ANGLE, COPIES, keepSubResults = True)
+model.end()
+# selection of a compsolid part is prohibited
+assert(MultiRotation_1.feature().error() != "")
+
+model.begin()
+MultiRotation_1.setMainObjects([model.selection("COMPSOLID", "Compound_2_1_1")])
+REFERENCE[0] = GeomAPI_Pnt(26.21750044779, -12.5, 5)
+assertResult(MultiRotation_1, 24, 123, 450, 900, 38247.599)
+
+MultiRotation_2 = model.addMultiRotation(Part_1_doc, [model.selection("SOLID", "AngularCopy_1_1_2_1")], model.selection("EDGE", "PartSet/OZ"), ANGLE, COPIES, keepSubResults = True)
+REFERENCE[1] = GeomAPI_Pnt(21.6506350946, 5.3316102, 5)
+assertResult(MultiRotation_2, 26, 129, 462, 924, 39818.3954)
+
+MultiRotation_3 = model.addMultiRotation(Part_1_doc, [model.selection("SOLID", "AngularCopy_2_1_3")], model.selection("EDGE", "PartSet/OZ"), ANGLE, COPIES, keepSubResults = True)
+REFERENCE[2] = GeomAPI_Pnt(31.94572, -30.3316102, 5)
+assertResult(MultiRotation_3, 28, 135, 474, 948, 41389.19175)
+
+MultiRotation_4 = model.addMultiRotation(Part_1_doc, [model.selection("COMPSOLID", "AngularCopy_3_1_1_1"), model.selection("SOLID", "AngularCopy_3_1_2_2"), model.selection("COMPOUND", "AngularCopy_3_1_3")], model.selection("EDGE", "PartSet/OZ"), -ANGLE, COPIES, keepSubResults = True)
+REFERENCE[0] = GeomAPI_Pnt(0, -12.5, 5)
+REFERENCE[1] = GeomAPI_Pnt(20.59016994, 5.3316102, 5)
+REFERENCE[2] = GeomAPI_Pnt(0, -12.5, 5)
+assertResult(MultiRotation_4, 50, 235, 810, 1620, 71599.98)
+
+model.end()
+
+assert(model.checkPythonDump())
diff --git a/src/FeaturesPlugin/Test/TestMultiRotation_MultiLevelCompound_v95_2.py b/src/FeaturesPlugin/Test/TestMultiRotation_MultiLevelCompound_v95_2.py
new file mode 100644 (file)
index 0000000..34d6b00
--- /dev/null
@@ -0,0 +1,114 @@
+# Copyright (C) 2020  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 salome.shaper import model
+
+from GeomAPI import *
+from SketchAPI import *
+
+model.begin()
+partSet = model.moduleDocument()
+Part_1 = model.addPart(partSet)
+Part_1_doc = Part_1.document()
+Sketch_1 = model.addSketch(Part_1_doc, model.standardPlane("XOY"))
+SketchEllipse_1 = Sketch_1.addEllipse(11.18033988749894, -50, 22.36067977499789, -50, 10)
+[SketchPoint_1, SketchPoint_2, SketchPoint_3, SketchPoint_4, SketchPoint_5, SketchPoint_6, SketchPoint_7, SketchLine_1, SketchLine_2] = SketchEllipse_1.construction(center = "aux", firstFocus = "aux", secondFocus = "aux", majorAxisStart = "aux", majorAxisEnd = "aux", minorAxisStart = "aux", minorAxisEnd = "aux", majorAxis = "aux", minorAxis = "aux")
+SketchConstraintHorizontal_1 = Sketch_1.setHorizontal(SketchLine_1.result())
+SketchConstraintLength_1 = Sketch_1.setLength(SketchLine_1.result(), 30)
+SketchConstraintLength_2 = Sketch_1.setLength(SketchLine_2.result(), 20)
+SketchProjection_1 = Sketch_1.addProjection(model.selection("EDGE", "PartSet/OY"), False)
+SketchLine_3 = SketchProjection_1.createdFeature()
+SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchAPI_Point(SketchPoint_3).coordinates(), SketchLine_3.result())
+SketchConstraintDistance_1 = Sketch_1.setDistance(SketchAPI_Line(SketchLine_3).startPoint(), SketchAPI_Point(SketchPoint_3).coordinates(), 50, True)
+SketchCircle_1 = Sketch_1.addCircle(41.18033988749897, -50, 5)
+SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchCircle_1.center(), SketchLine_1.result())
+SketchConstraintDistance_2 = Sketch_1.setDistance(SketchEllipse_1.majorAxisPositive(), SketchCircle_1.center(), 15, True)
+SketchConstraintRadius_1 = Sketch_1.setRadius(SketchCircle_1.results()[1], 5)
+SketchMultiRotation_1 = Sketch_1.addRotation([SketchEllipse_1.result(), SketchCircle_1.results()[1]], SketchAPI_Point(SketchPoint_3).coordinates(), 360, 3, True)
+[SketchEllipse_2, SketchEllipse_3, SketchCircle_2, SketchCircle_3] = SketchMultiRotation_1.rotated()
+model.do()
+Sketch_1.changeFacesOrder([[SketchEllipse_1.result(), SketchEllipse_1.result(), SketchEllipse_2.result(), SketchEllipse_3.result()],
+                           [SketchCircle_1.results()[1]],
+                           [SketchEllipse_2.result(), SketchEllipse_2.result(), SketchEllipse_3.result(), SketchEllipse_1.result()],
+                           [SketchEllipse_1.result(), SketchEllipse_3.result(), SketchEllipse_2.result()],
+                           [SketchEllipse_3.result(), SketchEllipse_2.result(), SketchEllipse_1.result()],
+                           [SketchEllipse_1.result(), SketchEllipse_2.result(), SketchEllipse_3.result()],
+                           [SketchEllipse_1.result(), SketchEllipse_3.result(), SketchEllipse_2.result()],
+                           [SketchEllipse_2.result(), SketchEllipse_3.result(), SketchEllipse_3.result(), SketchEllipse_1.result()],
+                           [SketchCircle_2.results()[1]],
+                           [SketchCircle_3.results()[1]]
+                          ])
+model.do()
+Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("COMPOUND", "Sketch_1")], model.selection(), 10, 0)
+Compound_1 = model.addCompound(Part_1_doc, [model.selection("SOLID", "Extrusion_1_2"), model.selection("SOLID", "Extrusion_1_3")])
+Compound_2_objects = [model.selection("COMPSOLID", "Extrusion_1_1"), model.selection("COMPOUND", "Compound_1_1"), model.selection("SOLID", "Extrusion_1_4")]
+Compound_2 = model.addCompound(Part_1_doc, Compound_2_objects)
+model.end()
+
+COPIES = 3
+TOLERANCE = 1.e-7
+
+def subsRefPoints(theResult):
+    res = []
+    for ind in range(0, theResult.numberOfSubs()):
+        res.append( theResult.subResult(ind).resultSubShapePair()[0].shape().middlePoint())
+    return res
+
+REFERENCE = subsRefPoints(Compound_2.result())
+
+def assertResult(theFeature, theNbSolids, theNbFaces, theNbEdges, theNbVertices, theVolume):
+    model.testNbResults(theFeature, 1)
+    model.testNbSubResults(theFeature, [3])
+    model.testNbSubShapes(theFeature, GeomAPI_Shape.SOLID, [theNbSolids])
+    model.testNbSubShapes(theFeature, GeomAPI_Shape.FACE, [theNbFaces])
+    model.testNbSubShapes(theFeature, GeomAPI_Shape.EDGE, [theNbEdges])
+    model.testNbSubShapes(theFeature, GeomAPI_Shape.VERTEX, [theNbVertices])
+    model.testResultsVolumes(theFeature, [theVolume])
+
+    for ind in range(0, theFeature.result().numberOfSubs()):
+        ref = REFERENCE[ind]
+        midPoint = theFeature.result().subResult(ind).resultSubShapePair()[0].shape().middlePoint()
+        assert(midPoint.distance(ref) < TOLERANCE), "Sub-result {}; actual ({}, {}, {}) != expected ({}, {}, {})".format(ind, midPoint.x(), midPoint.y(), midPoint.z(), ref.x(), ref.y(), ref.z())
+
+
+model.begin()
+MultiRotation_1 = model.addMultiRotation(Part_1_doc, [model.selection("SOLID", "Compound_2_1_1_5")], model.selection("EDGE", "PartSet/OZ"), COPIES, keepSubResults = True)
+model.end()
+# selection of a compsolid part is prohibited
+assert(MultiRotation_1.feature().error() != "")
+
+model.begin()
+MultiRotation_1.setMainObjects([model.selection("COMPSOLID", "Compound_2_1_1")])
+REFERENCE[0] = GeomAPI_Pnt(4.566865353, -12.5, 5)
+assertResult(MultiRotation_1, 24, 123, 450, 900, 38247.599)
+
+MultiRotation_2 = model.addMultiRotation(Part_1_doc, [model.selection("SOLID", "AngularCopy_1_1_2_1")], model.selection("EDGE", "PartSet/OZ"), COPIES, keepSubResults = True)
+REFERENCE[1] = GeomAPI_Pnt(-11.35555012, 5.3316102, 5)
+assertResult(MultiRotation_2, 26, 129, 462, 924, 39818.3954)
+
+MultiRotation_3 = model.addMultiRotation(Part_1_doc, [model.selection("SOLID", "AngularCopy_2_1_3")], model.selection("EDGE", "PartSet/OZ"), COPIES, keepSubResults = True)
+REFERENCE[2] = GeomAPI_Pnt(10.29508497, -12.5, 5)
+assertResult(MultiRotation_3, 28, 135, 474, 948, 41389.19175)
+
+MultiRotation_4 = model.addMultiRotation(Part_1_doc, [model.selection("COMPSOLID", "AngularCopy_3_1_1_1"), model.selection("SOLID", "AngularCopy_3_1_2_2"), model.selection("COMPOUND", "AngularCopy_3_1_3")], model.selection("EDGE", "PartSet/OZ"), COPIES, keepSubResults = True)
+assertResult(MultiRotation_4, 50, 235, 810, 1620, 71599.98)
+
+model.end()
+
+assert(model.checkPythonDump())
diff --git a/src/FeaturesPlugin/Test/TestMultiRotation_MultiLevelCompound_v95_3.py b/src/FeaturesPlugin/Test/TestMultiRotation_MultiLevelCompound_v95_3.py
new file mode 100644 (file)
index 0000000..f416272
--- /dev/null
@@ -0,0 +1,199 @@
+# Copyright (C) 2020  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 salome.shaper import model
+from GeomAPI import *
+from GeomAlgoAPI import *
+
+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"))
+SketchPoint_1 = Sketch_1.addPoint(44.29784155360136, 17.09942588468031)
+SketchArc_1 = Sketch_1.addArc(44.29784155360136, 17.09942588468031, 47.1668727423061, 12.27945348765633, 45.38299232715926, 22.60269052200972, False)
+SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchPoint_1.coordinates(), SketchArc_1.center())
+SketchLine_1 = Sketch_1.addLine(42.5764228403785, 22.14892077680068, 39.70739165167375, 16.41085839939117)
+SketchLine_2 = Sketch_1.addLine(39.70739165167375, 16.41085839939117, 43.03546783057126, 12.04993099255995)
+SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_2.startPoint())
+SketchLine_3 = Sketch_1.addLine(28.57555063949931, 12.96802097294547, 15.72229091410204, 12.96802097294547)
+SketchLine_4 = Sketch_1.addLine(15.72229091410204, 12.96802097294547, 15.72229091410204, 21.46035329151154)
+SketchLine_5 = Sketch_1.addLine(15.72229091410204, 21.46035329151154, 28.57555063949931, 21.46035329151154)
+SketchLine_6 = Sketch_1.addLine(28.57555063949931, 21.46035329151154, 28.57555063949931, 12.96802097294547)
+SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchLine_6.endPoint(), SketchLine_3.startPoint())
+SketchConstraintCoincidence_4 = Sketch_1.setCoincident(SketchLine_3.endPoint(), SketchLine_4.startPoint())
+SketchConstraintCoincidence_5 = Sketch_1.setCoincident(SketchLine_4.endPoint(), SketchLine_5.startPoint())
+SketchConstraintCoincidence_6 = Sketch_1.setCoincident(SketchLine_5.endPoint(), SketchLine_6.startPoint())
+SketchConstraintHorizontal_1 = Sketch_1.setHorizontal(SketchLine_3.result())
+SketchConstraintVertical_1 = Sketch_1.setVertical(SketchLine_4.result())
+SketchConstraintHorizontal_2 = Sketch_1.setHorizontal(SketchLine_5.result())
+SketchConstraintVertical_2 = Sketch_1.setVertical(SketchLine_6.result())
+SketchLine_7 = Sketch_1.addLine(-10.67279602198167, 14.78814178154371, -28.34602814440294, 14.78814178154371)
+SketchLine_8 = Sketch_1.addLine(-28.34602814440294, 14.78814178154371, -28.34602814440294, 25.13271321305362)
+SketchLine_9 = Sketch_1.addLine(-28.34602814440294, 25.13271321305362, -10.67279602198167, 25.13271321305362)
+SketchLine_10 = Sketch_1.addLine(-10.67279602198167, 25.13271321305362, -10.67279602198167, 14.78814178154371)
+SketchConstraintCoincidence_7 = Sketch_1.setCoincident(SketchLine_10.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())
+SketchConstraintCoincidence_10 = Sketch_1.setCoincident(SketchLine_9.endPoint(), SketchLine_10.startPoint())
+SketchConstraintHorizontal_3 = Sketch_1.setHorizontal(SketchLine_7.result())
+SketchConstraintVertical_3 = Sketch_1.setVertical(SketchLine_8.result())
+SketchConstraintHorizontal_4 = Sketch_1.setHorizontal(SketchLine_9.result())
+SketchConstraintVertical_4 = Sketch_1.setVertical(SketchLine_10.result())
+SketchLine_11 = Sketch_1.addLine(-17.67323212242127, 25.13271321305362, -21.80463703415611, 14.78814178154371)
+SketchConstraintCoincidence_11 = Sketch_1.setCoincident(SketchLine_11.startPoint(), SketchLine_9.result())
+SketchConstraintCoincidence_12 = Sketch_1.setCoincident(SketchLine_11.endPoint(), SketchLine_7.result())
+model.do()
+Vertex_1 = model.addVertex(Part_1_doc, [model.selection("VERTEX", "Sketch_1/SketchArc_1")], False)
+Edge_1 = model.addEdge(Part_1_doc, [model.selection("EDGE", "Sketch_1/SketchArc_1_2")], False)
+Wire_1 = model.addWire(Part_1_doc, [model.selection("EDGE", "Sketch_1/SketchLine_1"), model.selection("EDGE", "Sketch_1/SketchLine_2")], False)
+Face_1 = model.addFace(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_6r-SketchLine_5r-SketchLine_4r-SketchLine_3r")])
+Shell_1 = model.addShell(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_10r-SketchLine_9r-SketchLine_11f-SketchLine_7r"), model.selection("FACE", "Sketch_1/Face-SketchLine_11r-SketchLine_9r-SketchLine_8r-SketchLine_7r")])
+Box_1 = model.addBox(Part_1_doc, 10, 10, 10)
+Translation_1 = model.addTranslation(Part_1_doc, [model.selection("SOLID", "Box_1_1")], model.selection("EDGE", "PartSet/OX"), 50)
+Box_2 = model.addBox(Part_1_doc, 10, 10, 10)
+Cylinder_1 = model.addCylinder(Part_1_doc, model.selection("VERTEX", "PartSet/Origin"), model.selection("EDGE", "PartSet/OZ"), 5, 10)
+Partition_1 = model.addPartition(Part_1_doc, [model.selection("SOLID", "Box_2_1"), model.selection("SOLID", "Cylinder_1_1")], keepSubResults = True)
+Box_3 = model.addBox(Part_1_doc, 10, 10, 10)
+Translation_2 = model.addTranslation(Part_1_doc, [model.selection("SOLID", "Box_3_1")], model.selection("EDGE", "PartSet/OY"), 50)
+AngularCopy_1 = model.addMultiRotation(Part_1_doc, [model.selection("SOLID", "Translation_2_1")], model.selection("EDGE", "PartSet/OZ"), 30, 3)
+model.end()
+
+TOLERANCE = 1.e-7
+COPIES = 4
+
+
+model.begin()
+MultiRotation_1 = model.addMultiRotation(Part_1_doc, [model.selection("VERTEX", "Vertex_1_1")], model.selection("EDGE", "PartSet/OX"), COPIES, keepSubResults = True)
+model.testNbResults(MultiRotation_1, 1)
+model.testNbSubResults(MultiRotation_1, [COPIES])
+model.testNbSubShapes(MultiRotation_1, GeomAPI_Shape.SOLID, [0])
+model.testNbSubShapes(MultiRotation_1, GeomAPI_Shape.FACE, [0])
+model.testNbSubShapes(MultiRotation_1, GeomAPI_Shape.EDGE, [0])
+model.testNbSubShapes(MultiRotation_1, GeomAPI_Shape.VERTEX, [COPIES])
+model.testResultsVolumes(MultiRotation_1, [0])
+refPoint = Vertex_1.defaultResult().shape().middlePoint()
+refPoint.setY(0)
+refPoint.setZ(0)
+midPoint = MultiRotation_1.defaultResult().shape().middlePoint()
+assert(midPoint.distance(refPoint) < TOLERANCE)
+
+MultiRotation_2 = model.addMultiRotation(Part_1_doc, [model.selection("EDGE", "Edge_1_1")], model.selection("EDGE", "PartSet/OX"), COPIES, keepSubResults = True)
+model.testNbResults(MultiRotation_2, 1)
+model.testNbSubResults(MultiRotation_2, [COPIES])
+model.testNbSubShapes(MultiRotation_2, GeomAPI_Shape.SOLID, [0])
+model.testNbSubShapes(MultiRotation_2, GeomAPI_Shape.FACE, [0])
+model.testNbSubShapes(MultiRotation_2, GeomAPI_Shape.EDGE, [COPIES])
+model.testNbSubShapes(MultiRotation_2, GeomAPI_Shape.VERTEX, [2 * COPIES])
+model.testResultsVolumes(MultiRotation_2, [0])
+comp = GeomAlgoAPI_CompoundBuilder.compound([Edge_1.defaultResult().shape()])
+refPoint = comp.middlePoint()
+refPoint.setY(0)
+refPoint.setZ(0)
+midPoint = MultiRotation_2.defaultResult().shape().middlePoint()
+assert(midPoint.distance(refPoint) < TOLERANCE)
+
+MultiRotation_3 = model.addMultiRotation(Part_1_doc, [model.selection("WIRE", "Wire_1_1")], model.selection("EDGE", "PartSet/OX"), COPIES, keepSubResults = True)
+model.testNbResults(MultiRotation_3, 1)
+model.testNbSubResults(MultiRotation_3, [COPIES])
+model.testNbSubShapes(MultiRotation_3, GeomAPI_Shape.SOLID, [0])
+model.testNbSubShapes(MultiRotation_3, GeomAPI_Shape.FACE, [0])
+model.testNbSubShapes(MultiRotation_3, GeomAPI_Shape.EDGE, [2 * COPIES])
+model.testNbSubShapes(MultiRotation_3, GeomAPI_Shape.VERTEX, [4 * COPIES])
+model.testResultsVolumes(MultiRotation_3, [0])
+comp = GeomAlgoAPI_CompoundBuilder.compound([Wire_1.defaultResult().shape()])
+refPoint = comp.middlePoint()
+refPoint.setY(0)
+refPoint.setZ(0)
+midPoint = MultiRotation_3.defaultResult().shape().middlePoint()
+assert(midPoint.distance(refPoint) < TOLERANCE)
+
+MultiRotation_4 = model.addMultiRotation(Part_1_doc, [model.selection("FACE", "Face_1_1")], model.selection("EDGE", "PartSet/OX"), COPIES, keepSubResults = True)
+model.testNbResults(MultiRotation_4, 1)
+model.testNbSubResults(MultiRotation_4, [COPIES])
+model.testNbSubShapes(MultiRotation_4, GeomAPI_Shape.SOLID, [0])
+model.testNbSubShapes(MultiRotation_4, GeomAPI_Shape.FACE, [COPIES])
+model.testNbSubShapes(MultiRotation_4, GeomAPI_Shape.EDGE, [4 * COPIES])
+model.testNbSubShapes(MultiRotation_4, GeomAPI_Shape.VERTEX, [8 * COPIES])
+model.testResultsVolumes(MultiRotation_4, [109.154152964914914 * COPIES])
+refPoint = Face_1.defaultResult().shape().middlePoint()
+refPoint.setY(0)
+refPoint.setZ(0)
+midPoint = MultiRotation_4.defaultResult().shape().middlePoint()
+assert(midPoint.distance(refPoint) < TOLERANCE)
+
+MultiRotation_5 = model.addMultiRotation(Part_1_doc, [model.selection("SHELL", "Shell_1_1")], model.selection("EDGE", "PartSet/OX"), COPIES, keepSubResults = True)
+model.testNbResults(MultiRotation_5, 1)
+model.testNbSubResults(MultiRotation_5, [COPIES])
+model.testNbSubShapes(MultiRotation_5, GeomAPI_Shape.SOLID, [0])
+model.testNbSubShapes(MultiRotation_5, GeomAPI_Shape.FACE, [2 * COPIES])
+model.testNbSubShapes(MultiRotation_5, GeomAPI_Shape.EDGE, [8 * COPIES])
+model.testNbSubShapes(MultiRotation_5, GeomAPI_Shape.VERTEX, [16 * COPIES])
+model.testResultsVolumes(MultiRotation_5, [182.822012116 * COPIES])
+refPoint = Shell_1.defaultResult().shape().middlePoint()
+refPoint.setY(0)
+refPoint.setZ(0)
+midPoint = MultiRotation_5.defaultResult().shape().middlePoint()
+assert(midPoint.distance(refPoint) < TOLERANCE)
+
+MultiRotation_6 = model.addMultiRotation(Part_1_doc, [model.selection("SOLID", "Translation_1_1")], model.selection("EDGE", "PartSet/OX"), COPIES, keepSubResults = True)
+model.testNbResults(MultiRotation_6, 1)
+model.testNbSubResults(MultiRotation_6, [COPIES])
+model.testNbSubShapes(MultiRotation_6, GeomAPI_Shape.SOLID, [COPIES])
+model.testNbSubShapes(MultiRotation_6, GeomAPI_Shape.FACE, [6 * COPIES])
+model.testNbSubShapes(MultiRotation_6, GeomAPI_Shape.EDGE, [24 * COPIES])
+model.testNbSubShapes(MultiRotation_6, GeomAPI_Shape.VERTEX, [48 * COPIES])
+model.testResultsVolumes(MultiRotation_6, [1000 * COPIES])
+refPoint = Translation_1.defaultResult().shape().middlePoint()
+refPoint.setY(0)
+refPoint.setZ(0)
+midPoint = MultiRotation_6.defaultResult().shape().middlePoint()
+assert(midPoint.distance(refPoint) < TOLERANCE)
+
+MultiRotation_7 = model.addMultiRotation(Part_1_doc, [model.selection("COMPSOLID", "Partition_1_1")], model.selection("EDGE", "PartSet/OX"), COPIES, keepSubResults = True)
+model.testNbResults(MultiRotation_7, 1)
+model.testNbSubResults(MultiRotation_7, [COPIES])
+model.testNbSubShapes(MultiRotation_7, GeomAPI_Shape.SOLID, [3 * COPIES])
+model.testNbSubShapes(MultiRotation_7, GeomAPI_Shape.FACE, [17 * COPIES])
+model.testNbSubShapes(MultiRotation_7, GeomAPI_Shape.EDGE, [66 * COPIES])
+model.testNbSubShapes(MultiRotation_7, GeomAPI_Shape.VERTEX, [132 * COPIES])
+model.testResultsVolumes(MultiRotation_7, [1589.0486226 * COPIES])
+refPoint = Partition_1.defaultResult().shape().middlePoint()
+refPoint.setY(0)
+refPoint.setZ(0)
+midPoint = MultiRotation_7.defaultResult().shape().middlePoint()
+assert(midPoint.distance(refPoint) < TOLERANCE)
+
+MultiRotation_8 = model.addMultiRotation(Part_1_doc, [model.selection("COMPOUND", "AngularCopy_1_1")], model.selection("EDGE", "PartSet/OX"), COPIES, keepSubResults = True)
+model.testNbResults(MultiRotation_8, 1)
+model.testNbSubResults(MultiRotation_8, [COPIES])
+model.testNbSubShapes(MultiRotation_8, GeomAPI_Shape.SOLID, [3 * COPIES])
+model.testNbSubShapes(MultiRotation_8, GeomAPI_Shape.FACE, [18 * COPIES])
+model.testNbSubShapes(MultiRotation_8, GeomAPI_Shape.EDGE, [72 * COPIES])
+model.testNbSubShapes(MultiRotation_8, GeomAPI_Shape.VERTEX, [144 * COPIES])
+model.testResultsVolumes(MultiRotation_8, [3000 * COPIES])
+refPoint = AngularCopy_1.defaultResult().shape().middlePoint()
+refPoint.setY(0)
+refPoint.setZ(0)
+midPoint = MultiRotation_8.defaultResult().shape().middlePoint()
+assert(midPoint.distance(refPoint) < TOLERANCE)
+
+model.end()
+
+assert(model.checkPythonDump())
diff --git a/src/FeaturesPlugin/Test/TestMultiRotation_MultiLevelCompound_v95_4.py b/src/FeaturesPlugin/Test/TestMultiRotation_MultiLevelCompound_v95_4.py
new file mode 100644 (file)
index 0000000..6f46913
--- /dev/null
@@ -0,0 +1,169 @@
+# Copyright (C) 2020  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 salome.shaper import model
+from GeomAPI import *
+
+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"))
+SketchPoint_1 = Sketch_1.addPoint(44.29784155360136, 17.09942588468031)
+SketchArc_1 = Sketch_1.addArc(44.29784155360136, 17.09942588468031, 47.1668727423061, 12.27945348765633, 45.38299232715926, 22.60269052200972, False)
+SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchPoint_1.coordinates(), SketchArc_1.center())
+SketchLine_1 = Sketch_1.addLine(42.5764228403785, 22.14892077680068, 39.70739165167375, 16.41085839939117)
+SketchLine_2 = Sketch_1.addLine(39.70739165167375, 16.41085839939117, 43.03546783057126, 12.04993099255995)
+SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_2.startPoint())
+SketchLine_3 = Sketch_1.addLine(28.57555063949931, 12.96802097294547, 15.72229091410204, 12.96802097294547)
+SketchLine_4 = Sketch_1.addLine(15.72229091410204, 12.96802097294547, 15.72229091410204, 21.46035329151154)
+SketchLine_5 = Sketch_1.addLine(15.72229091410204, 21.46035329151154, 28.57555063949931, 21.46035329151154)
+SketchLine_6 = Sketch_1.addLine(28.57555063949931, 21.46035329151154, 28.57555063949931, 12.96802097294547)
+SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchLine_6.endPoint(), SketchLine_3.startPoint())
+SketchConstraintCoincidence_4 = Sketch_1.setCoincident(SketchLine_3.endPoint(), SketchLine_4.startPoint())
+SketchConstraintCoincidence_5 = Sketch_1.setCoincident(SketchLine_4.endPoint(), SketchLine_5.startPoint())
+SketchConstraintCoincidence_6 = Sketch_1.setCoincident(SketchLine_5.endPoint(), SketchLine_6.startPoint())
+SketchConstraintHorizontal_1 = Sketch_1.setHorizontal(SketchLine_3.result())
+SketchConstraintVertical_1 = Sketch_1.setVertical(SketchLine_4.result())
+SketchConstraintHorizontal_2 = Sketch_1.setHorizontal(SketchLine_5.result())
+SketchConstraintVertical_2 = Sketch_1.setVertical(SketchLine_6.result())
+SketchLine_7 = Sketch_1.addLine(-10.67279602198167, 14.78814178154371, -28.34602814440294, 14.78814178154371)
+SketchLine_8 = Sketch_1.addLine(-28.34602814440294, 14.78814178154371, -28.34602814440294, 25.13271321305362)
+SketchLine_9 = Sketch_1.addLine(-28.34602814440294, 25.13271321305362, -10.67279602198167, 25.13271321305362)
+SketchLine_10 = Sketch_1.addLine(-10.67279602198167, 25.13271321305362, -10.67279602198167, 14.78814178154371)
+SketchConstraintCoincidence_7 = Sketch_1.setCoincident(SketchLine_10.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())
+SketchConstraintCoincidence_10 = Sketch_1.setCoincident(SketchLine_9.endPoint(), SketchLine_10.startPoint())
+SketchConstraintHorizontal_3 = Sketch_1.setHorizontal(SketchLine_7.result())
+SketchConstraintVertical_3 = Sketch_1.setVertical(SketchLine_8.result())
+SketchConstraintHorizontal_4 = Sketch_1.setHorizontal(SketchLine_9.result())
+SketchConstraintVertical_4 = Sketch_1.setVertical(SketchLine_10.result())
+SketchLine_11 = Sketch_1.addLine(-17.67323212242127, 25.13271321305362, -21.80463703415611, 14.78814178154371)
+SketchConstraintCoincidence_11 = Sketch_1.setCoincident(SketchLine_11.startPoint(), SketchLine_9.result())
+SketchConstraintCoincidence_12 = Sketch_1.setCoincident(SketchLine_11.endPoint(), SketchLine_7.result())
+model.do()
+Vertex_1 = model.addVertex(Part_1_doc, [model.selection("VERTEX", "Sketch_1/SketchArc_1")], False)
+Edge_1 = model.addEdge(Part_1_doc, [model.selection("EDGE", "Sketch_1/SketchArc_1_2")], False)
+Wire_1 = model.addWire(Part_1_doc, [model.selection("EDGE", "Sketch_1/SketchLine_1"), model.selection("EDGE", "Sketch_1/SketchLine_2")], False)
+Face_1 = model.addFace(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_6r-SketchLine_5r-SketchLine_4r-SketchLine_3r")])
+Shell_1 = model.addShell(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_10r-SketchLine_9r-SketchLine_11f-SketchLine_7r"), model.selection("FACE", "Sketch_1/Face-SketchLine_11r-SketchLine_9r-SketchLine_8r-SketchLine_7r")])
+Box_1 = model.addBox(Part_1_doc, 10, 10, 10)
+Translation_1 = model.addTranslation(Part_1_doc, [model.selection("SOLID", "Box_1_1")], model.selection("EDGE", "PartSet/OX"), 50)
+Box_2 = model.addBox(Part_1_doc, 10, 10, 10)
+Cylinder_1 = model.addCylinder(Part_1_doc, model.selection("VERTEX", "PartSet/Origin"), model.selection("EDGE", "PartSet/OZ"), 5, 10)
+Partition_1 = model.addPartition(Part_1_doc, [model.selection("SOLID", "Box_2_1"), model.selection("SOLID", "Cylinder_1_1")], keepSubResults = True)
+Box_3 = model.addBox(Part_1_doc, 10, 10, 10)
+Translation_2 = model.addTranslation(Part_1_doc, [model.selection("SOLID", "Box_3_1")], model.selection("EDGE", "PartSet/OY"), 50)
+AngularCopy_1 = model.addMultiRotation(Part_1_doc, [model.selection("SOLID", "Translation_2_1")], model.selection("EDGE", "PartSet/OZ"), 30, 3)
+Compound_1_objects = [model.selection("VERTEX", "Vertex_1_1"), model.selection("EDGE", "Edge_1_1"), model.selection("WIRE", "Wire_1_1"), model.selection("FACE", "Face_1_1"), model.selection("SHELL", "Shell_1_1"), model.selection("SOLID", "Translation_1_1"), model.selection("COMPSOLID", "Partition_1_1"), model.selection("COMPOUND", "AngularCopy_1_1")]
+Compound_1 = model.addCompound(Part_1_doc, Compound_1_objects)
+model.end()
+
+TOLERANCE = 1.e-7
+COPIES = 4
+
+NB_SOLIDS = 7
+NB_FACES = 44
+NB_EDGES = 177
+NB_VERTICES = 355
+VOLUME = 5589.0486226
+
+# collect reference data
+REFERENCE = []
+for ind in range(0, Compound_1.result().numberOfSubs()):
+    p = Compound_1.result().subResult(ind).resultSubShapePair()[1].middlePoint()
+    REFERENCE.append(p)
+
+def assertResult(theFeature, theNbMoved):
+    model.testNbResults(theFeature, 1)
+    model.testNbSubResults(theFeature, [8])
+    model.testNbSubShapes(theFeature, GeomAPI_Shape.SOLID, [NB_SOLIDS])
+    model.testNbSubShapes(theFeature, GeomAPI_Shape.FACE, [NB_FACES])
+    model.testNbSubShapes(theFeature, GeomAPI_Shape.EDGE, [NB_EDGES])
+    model.testNbSubShapes(theFeature, GeomAPI_Shape.VERTEX, [NB_VERTICES])
+    model.testResultsVolumes(theFeature, [VOLUME])
+
+    for ind in range(0, theFeature.result().numberOfSubs()):
+        ref = GeomAPI_Pnt(REFERENCE[ind].x(), REFERENCE[ind].y(), REFERENCE[ind].z())
+        if ind < theNbMoved:
+            ref.setY(0)
+            ref.setZ(0)
+        midPoint = theFeature.result().subResult(ind).resultSubShapePair()[0].shape().middlePoint()
+        assert(midPoint.distance(ref) < TOLERANCE), "Sub-result {}; actual ({}, {}, {}) != expected ({}, {}, {})".format(ind, midPoint.x(), midPoint.y(), midPoint.z(), ref.x(), ref.y(), ref.z())
+
+
+model.begin()
+MultiRotation_1 = model.addMultiRotation(Part_1_doc, [model.selection("VERTEX", "Compound_1_1_1")], model.selection("EDGE", "PartSet/OX"), COPIES, keepSubResults = True)
+NB_VERTICES += COPIES - 1
+assertResult(MultiRotation_1, 1)
+
+MultiRotation_2 = model.addMultiRotation(Part_1_doc, [model.selection("EDGE", "AngularCopy_2_1_2")], model.selection("EDGE", "PartSet/OX"), COPIES, keepSubResults = True)
+c = GeomAlgoAPI_CompoundBuilder.compound([Edge_1.defaultResult().shape()])
+REFERENCE[1] = c.middlePoint()
+NB_EDGES += COPIES - 1
+NB_VERTICES += 2 * (COPIES - 1)
+assertResult(MultiRotation_2, 2)
+
+MultiRotation_3 = model.addMultiRotation(Part_1_doc, [model.selection("WIRE", "AngularCopy_3_1_3")], model.selection("EDGE", "PartSet/OX"), COPIES, keepSubResults = True)
+c = GeomAlgoAPI_CompoundBuilder.compound([Wire_1.defaultResult().shape()])
+REFERENCE[2] = c.middlePoint()
+NB_EDGES += 2 * (COPIES - 1)
+NB_VERTICES += 4 * (COPIES - 1)
+assertResult(MultiRotation_3, 3)
+
+MultiRotation_4 = model.addMultiRotation(Part_1_doc, [model.selection("FACE", "AngularCopy_4_1_4")], model.selection("EDGE", "PartSet/OX"), COPIES, keepSubResults = True)
+NB_FACES += COPIES - 1
+NB_EDGES += 4 * (COPIES - 1)
+NB_VERTICES += 8 * (COPIES - 1)
+assertResult(MultiRotation_4, 4)
+
+MultiRotation_5 = model.addMultiRotation(Part_1_doc, [model.selection("SHELL", "AngularCopy_5_1_5")], model.selection("EDGE", "PartSet/OX"), COPIES, keepSubResults = True)
+NB_FACES += 2 * (COPIES - 1)
+NB_EDGES += 8 * (COPIES - 1)
+NB_VERTICES += 16 * (COPIES - 1)
+assertResult(MultiRotation_5, 5)
+
+MultiRotation_6 = model.addMultiRotation(Part_1_doc, [model.selection("SOLID", "AngularCopy_6_1_6")], model.selection("EDGE", "PartSet/OX"), COPIES, keepSubResults = True)
+NB_SOLIDS += COPIES - 1
+NB_FACES += 6 * (COPIES - 1)
+NB_EDGES += 24 * (COPIES - 1)
+NB_VERTICES += 48 * (COPIES - 1)
+VOLUME += 1000 * (COPIES - 1)
+assertResult(MultiRotation_6, 6)
+
+MultiRotation_7 = model.addMultiRotation(Part_1_doc, [model.selection("COMPSOLID", "AngularCopy_7_1_7")], model.selection("EDGE", "PartSet/OX"), COPIES, keepSubResults = True)
+NB_SOLIDS += 3 * (COPIES - 1)
+NB_FACES += 17 * (COPIES - 1)
+NB_EDGES += 66 * (COPIES - 1)
+NB_VERTICES += 132 * (COPIES - 1)
+VOLUME += 1589.0486226 * (COPIES - 1)
+assertResult(MultiRotation_7, 7)
+
+MultiRotation_8 = model.addMultiRotation(Part_1_doc, [model.selection("COMPOUND", "AngularCopy_8_1_8")], model.selection("EDGE", "PartSet/OX"), COPIES, keepSubResults = True)
+NB_SOLIDS += 3 * (COPIES - 1)
+NB_FACES += 18 * (COPIES - 1)
+NB_EDGES += 72 * (COPIES - 1)
+NB_VERTICES += 144 * (COPIES - 1)
+VOLUME += 3000 * (COPIES - 1)
+assertResult(MultiRotation_8, 8)
+
+model.end()
+
+assert(model.checkPythonDump())
diff --git a/src/FeaturesPlugin/Test/TestMultiTranslation_MultiLevelCompound_v0_1.py b/src/FeaturesPlugin/Test/TestMultiTranslation_MultiLevelCompound_v0_1.py
new file mode 100644 (file)
index 0000000..08b4fcd
--- /dev/null
@@ -0,0 +1,140 @@
+# Copyright (C) 2020  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 salome.shaper import model
+
+from GeomAPI import *
+from GeomAlgoAPI import *
+from SketchAPI import *
+
+model.begin()
+partSet = model.moduleDocument()
+Part_1 = model.addPart(partSet)
+Part_1_doc = Part_1.document()
+Sketch_1 = model.addSketch(Part_1_doc, model.standardPlane("XOY"))
+SketchEllipse_1 = Sketch_1.addEllipse(11.18033988749894, -50, 22.36067977499789, -50, 10)
+[SketchPoint_1, SketchPoint_2, SketchPoint_3, SketchPoint_4, SketchPoint_5, SketchPoint_6, SketchPoint_7, SketchLine_1, SketchLine_2] = SketchEllipse_1.construction(center = "aux", firstFocus = "aux", secondFocus = "aux", majorAxisStart = "aux", majorAxisEnd = "aux", minorAxisStart = "aux", minorAxisEnd = "aux", majorAxis = "aux", minorAxis = "aux")
+SketchConstraintHorizontal_1 = Sketch_1.setHorizontal(SketchLine_1.result())
+SketchConstraintLength_1 = Sketch_1.setLength(SketchLine_1.result(), 30)
+SketchConstraintLength_2 = Sketch_1.setLength(SketchLine_2.result(), 20)
+SketchProjection_1 = Sketch_1.addProjection(model.selection("EDGE", "PartSet/OY"), False)
+SketchLine_3 = SketchProjection_1.createdFeature()
+SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchAPI_Point(SketchPoint_3).coordinates(), SketchLine_3.result())
+SketchConstraintDistance_1 = Sketch_1.setDistance(SketchAPI_Line(SketchLine_3).startPoint(), SketchAPI_Point(SketchPoint_3).coordinates(), 50, True)
+SketchCircle_1 = Sketch_1.addCircle(41.18033988749897, -50, 5)
+SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchCircle_1.center(), SketchLine_1.result())
+SketchConstraintDistance_2 = Sketch_1.setDistance(SketchEllipse_1.majorAxisPositive(), SketchCircle_1.center(), 15, True)
+SketchConstraintRadius_1 = Sketch_1.setRadius(SketchCircle_1.results()[1], 5)
+SketchMultiRotation_1 = Sketch_1.addRotation([SketchEllipse_1.result(), SketchCircle_1.results()[1]], SketchAPI_Point(SketchPoint_3).coordinates(), 360, 3, True)
+[SketchEllipse_2, SketchEllipse_3, SketchCircle_2, SketchCircle_3] = SketchMultiRotation_1.rotated()
+model.do()
+Sketch_1.changeFacesOrder([[SketchEllipse_1.result(), SketchEllipse_1.result(), SketchEllipse_2.result(), SketchEllipse_3.result()],
+                           [SketchCircle_1.results()[1]],
+                           [SketchEllipse_2.result(), SketchEllipse_2.result(), SketchEllipse_3.result(), SketchEllipse_1.result()],
+                           [SketchEllipse_1.result(), SketchEllipse_3.result(), SketchEllipse_2.result()],
+                           [SketchEllipse_3.result(), SketchEllipse_2.result(), SketchEllipse_1.result()],
+                           [SketchEllipse_1.result(), SketchEllipse_2.result(), SketchEllipse_3.result()],
+                           [SketchEllipse_1.result(), SketchEllipse_3.result(), SketchEllipse_2.result()],
+                           [SketchEllipse_2.result(), SketchEllipse_3.result(), SketchEllipse_3.result(), SketchEllipse_1.result()],
+                           [SketchCircle_2.results()[1]],
+                           [SketchCircle_3.results()[1]]
+                          ])
+model.do()
+Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("COMPOUND", "Sketch_1")], model.selection(), 10, 0)
+Compound_1 = model.addCompound(Part_1_doc, [model.selection("SOLID", "Extrusion_1_2"), model.selection("SOLID", "Extrusion_1_3")])
+Compound_2_objects = [model.selection("COMPSOLID", "Extrusion_1_1"), model.selection("COMPOUND", "Compound_1_1"), model.selection("SOLID", "Extrusion_1_4")]
+Compound_2 = model.addCompound(Part_1_doc, Compound_2_objects)
+model.end()
+
+DISTANCE = 20
+COPIES = 3
+TOLERANCE = 1.e-7
+
+
+model.begin()
+MultiTranslation_1 = model.addMultiTranslation(Part_1_doc, [model.selection("SOLID", "Compound_2_1_1_5")], model.selection("EDGE", "PartSet/OZ"), DISTANCE, COPIES)
+model.testNbResults(MultiTranslation_1, 1)
+model.testNbSubResults(MultiTranslation_1, [COPIES])
+model.testNbSubShapes(MultiTranslation_1, GeomAPI_Shape.SOLID, [1 * COPIES])
+model.testNbSubShapes(MultiTranslation_1, GeomAPI_Shape.FACE, [5 * COPIES])
+model.testNbSubShapes(MultiTranslation_1, GeomAPI_Shape.EDGE, [18 * COPIES])
+model.testNbSubShapes(MultiTranslation_1, GeomAPI_Shape.VERTEX, [36 * COPIES])
+model.testResultsVolumes(MultiTranslation_1, [542.746463956 * COPIES])
+
+comp = GeomAlgoAPI_CompoundBuilder.compound([Extrusion_1.results()[0].subResult(4).resultSubShapePair()[0].shape()])
+refPoint = comp.middlePoint()
+refPoint.setZ(refPoint.z() + DISTANCE / 2 * (COPIES - 1))
+midPoint = MultiTranslation_1.defaultResult().shape().middlePoint()
+assert(midPoint.distance(refPoint) < TOLERANCE)
+
+
+Recover_1 = model.addRecover(Part_1_doc, MultiTranslation_1, [Compound_2.result()], True)
+MultiTranslation_2 = model.addMultiTranslation(Part_1_doc, [model.selection("SOLID", "Recover_1_1_2_1")], model.selection("EDGE", "PartSet/OZ"), DISTANCE, COPIES)
+model.testNbResults(MultiTranslation_2, 1)
+model.testNbSubResults(MultiTranslation_2, [COPIES])
+model.testNbSubShapes(MultiTranslation_2, GeomAPI_Shape.SOLID, [1 * COPIES])
+model.testNbSubShapes(MultiTranslation_2, GeomAPI_Shape.FACE, [3 * COPIES])
+model.testNbSubShapes(MultiTranslation_2, GeomAPI_Shape.EDGE, [6 * COPIES])
+model.testNbSubShapes(MultiTranslation_2, GeomAPI_Shape.VERTEX, [12 * COPIES])
+model.testResultsVolumes(MultiTranslation_2, [785.39816339745 * COPIES])
+
+refPoint = Recover_1.result().subResult(1).subResult(0).resultSubShapePair()[0].shape().middlePoint()
+refPoint.setZ(refPoint.z() + DISTANCE / 2 * (COPIES - 1))
+midPoint = MultiTranslation_2.defaultResult().shape().middlePoint()
+assert(midPoint.distance(refPoint) < TOLERANCE)
+
+
+Recover_2 = model.addRecover(Part_1_doc, MultiTranslation_2, [Recover_1.result()], True)
+MultiTranslation_3 = model.addMultiTranslation(Part_1_doc, [model.selection("SOLID", "Recover_2_1_3")], model.selection("EDGE", "PartSet/OZ"), DISTANCE, COPIES)
+model.testNbResults(MultiTranslation_3, 1)
+model.testNbSubResults(MultiTranslation_3, [COPIES])
+model.testNbSubShapes(MultiTranslation_3, GeomAPI_Shape.SOLID, [1 * COPIES])
+model.testNbSubShapes(MultiTranslation_3, GeomAPI_Shape.FACE, [3 * COPIES])
+model.testNbSubShapes(MultiTranslation_3, GeomAPI_Shape.EDGE, [6 * COPIES])
+model.testNbSubShapes(MultiTranslation_3, GeomAPI_Shape.VERTEX, [12 * COPIES])
+model.testResultsVolumes(MultiTranslation_3, [785.39816339745 * COPIES])
+
+refPoint = Recover_2.result().subResult(2).resultSubShapePair()[0].shape().middlePoint()
+refPoint.setZ(refPoint.z() + DISTANCE / 2 * (COPIES - 1))
+midPoint = MultiTranslation_3.defaultResult().shape().middlePoint()
+assert(midPoint.distance(refPoint) < TOLERANCE)
+
+
+Recover_3 = model.addRecover(Part_1_doc, MultiTranslation_3, [Recover_2.result()], True)
+MultiTranslation_4 = model.addMultiTranslation(Part_1_doc, [model.selection("SOLID", "Recover_3_1_1_1"), model.selection("SOLID", "Recover_3_1_2_2"), model.selection("SOLID", "Recover_3_1_3")], model.selection("EDGE", "PartSet/OZ"), DISTANCE, COPIES)
+model.testNbResults(MultiTranslation_4, 3)
+model.testNbSubResults(MultiTranslation_4, [COPIES, COPIES, COPIES])
+model.testNbSubShapes(MultiTranslation_4, GeomAPI_Shape.SOLID, [1 * COPIES, 1 * COPIES, 1 * COPIES])
+model.testNbSubShapes(MultiTranslation_4, GeomAPI_Shape.FACE, [6 * COPIES, 3 * COPIES, 3 * COPIES])
+model.testNbSubShapes(MultiTranslation_4, GeomAPI_Shape.EDGE, [24 * COPIES, 6 * COPIES, 6 * COPIES])
+model.testNbSubShapes(MultiTranslation_4, GeomAPI_Shape.VERTEX, [48 * COPIES, 12 * COPIES, 12 * COPIES])
+model.testResultsVolumes(MultiTranslation_4, [3444.394198615 * COPIES, 785.39816339745 * COPIES, 785.39816339745 * COPIES])
+
+comp = GeomAlgoAPI_CompoundBuilder.compound([Recover_3.result().subResult(0).subResult(0).resultSubShapePair()[0].shape()])
+REFERENCE = [comp.middlePoint(),
+             Recover_3.result().subResult(1).subResult(1).resultSubShapePair()[0].shape().middlePoint(),
+             Recover_3.result().subResult(2).resultSubShapePair()[0].shape().middlePoint()]
+for res, ref in zip(MultiTranslation_4.results(), REFERENCE):
+    ref.setZ(ref.z() + DISTANCE / 2 * (COPIES - 1))
+    midPoint = res.resultSubShapePair()[0].shape().middlePoint()
+    assert(midPoint.distance(ref) < TOLERANCE)
+
+model.end()
+
+assert(model.checkPythonDump())
diff --git a/src/FeaturesPlugin/Test/TestMultiTranslation_MultiLevelCompound_v0_2.py b/src/FeaturesPlugin/Test/TestMultiTranslation_MultiLevelCompound_v0_2.py
new file mode 100644 (file)
index 0000000..90180fd
--- /dev/null
@@ -0,0 +1,146 @@
+# Copyright (C) 2020  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 salome.shaper import model
+
+from GeomAPI import *
+from GeomAlgoAPI import *
+from SketchAPI import *
+
+model.begin()
+partSet = model.moduleDocument()
+Part_1 = model.addPart(partSet)
+Part_1_doc = Part_1.document()
+Sketch_1 = model.addSketch(Part_1_doc, model.standardPlane("XOY"))
+SketchEllipse_1 = Sketch_1.addEllipse(11.18033988749894, -50, 22.36067977499789, -50, 10)
+[SketchPoint_1, SketchPoint_2, SketchPoint_3, SketchPoint_4, SketchPoint_5, SketchPoint_6, SketchPoint_7, SketchLine_1, SketchLine_2] = SketchEllipse_1.construction(center = "aux", firstFocus = "aux", secondFocus = "aux", majorAxisStart = "aux", majorAxisEnd = "aux", minorAxisStart = "aux", minorAxisEnd = "aux", majorAxis = "aux", minorAxis = "aux")
+SketchConstraintHorizontal_1 = Sketch_1.setHorizontal(SketchLine_1.result())
+SketchConstraintLength_1 = Sketch_1.setLength(SketchLine_1.result(), 30)
+SketchConstraintLength_2 = Sketch_1.setLength(SketchLine_2.result(), 20)
+SketchProjection_1 = Sketch_1.addProjection(model.selection("EDGE", "PartSet/OY"), False)
+SketchLine_3 = SketchProjection_1.createdFeature()
+SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchAPI_Point(SketchPoint_3).coordinates(), SketchLine_3.result())
+SketchConstraintDistance_1 = Sketch_1.setDistance(SketchAPI_Line(SketchLine_3).startPoint(), SketchAPI_Point(SketchPoint_3).coordinates(), 50, True)
+SketchCircle_1 = Sketch_1.addCircle(41.18033988749897, -50, 5)
+SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchCircle_1.center(), SketchLine_1.result())
+SketchConstraintDistance_2 = Sketch_1.setDistance(SketchEllipse_1.majorAxisPositive(), SketchCircle_1.center(), 15, True)
+SketchConstraintRadius_1 = Sketch_1.setRadius(SketchCircle_1.results()[1], 5)
+SketchMultiRotation_1 = Sketch_1.addRotation([SketchEllipse_1.result(), SketchCircle_1.results()[1]], SketchAPI_Point(SketchPoint_3).coordinates(), 360, 3, True)
+[SketchEllipse_2, SketchEllipse_3, SketchCircle_2, SketchCircle_3] = SketchMultiRotation_1.rotated()
+model.do()
+Sketch_1.changeFacesOrder([[SketchEllipse_1.result(), SketchEllipse_1.result(), SketchEllipse_2.result(), SketchEllipse_3.result()],
+                           [SketchCircle_1.results()[1]],
+                           [SketchEllipse_2.result(), SketchEllipse_2.result(), SketchEllipse_3.result(), SketchEllipse_1.result()],
+                           [SketchEllipse_1.result(), SketchEllipse_3.result(), SketchEllipse_2.result()],
+                           [SketchEllipse_3.result(), SketchEllipse_2.result(), SketchEllipse_1.result()],
+                           [SketchEllipse_1.result(), SketchEllipse_2.result(), SketchEllipse_3.result()],
+                           [SketchEllipse_1.result(), SketchEllipse_3.result(), SketchEllipse_2.result()],
+                           [SketchEllipse_2.result(), SketchEllipse_3.result(), SketchEllipse_3.result(), SketchEllipse_1.result()],
+                           [SketchCircle_2.results()[1]],
+                           [SketchCircle_3.results()[1]]
+                          ])
+model.do()
+Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("COMPOUND", "Sketch_1")], model.selection(), 10, 0)
+Compound_1 = model.addCompound(Part_1_doc, [model.selection("SOLID", "Extrusion_1_2"), model.selection("SOLID", "Extrusion_1_3")])
+Compound_2_objects = [model.selection("COMPSOLID", "Extrusion_1_1"), model.selection("COMPOUND", "Compound_1_1"), model.selection("SOLID", "Extrusion_1_4")]
+Compound_2 = model.addCompound(Part_1_doc, Compound_2_objects)
+model.end()
+
+TOLERANCE = 1.e-7
+DISTANCE_1 = 20
+COPIES_1 = 3
+DISTANCE_2 = 100
+COPIES_2 = 2
+COPIES = COPIES_1 * COPIES_2
+
+model.begin()
+MultiTranslation_1 = model.addMultiTranslation(Part_1_doc, [model.selection("SOLID", "Compound_2_1_1_5")], model.selection("EDGE", "PartSet/OZ"), DISTANCE_1, COPIES_1, model.selection("EDGE", "PartSet/OY"), DISTANCE_2, COPIES_2)
+model.testNbResults(MultiTranslation_1, 1)
+model.testNbSubResults(MultiTranslation_1, [COPIES])
+model.testNbSubShapes(MultiTranslation_1, GeomAPI_Shape.SOLID, [1 * COPIES])
+model.testNbSubShapes(MultiTranslation_1, GeomAPI_Shape.FACE, [5 * COPIES])
+model.testNbSubShapes(MultiTranslation_1, GeomAPI_Shape.EDGE, [18 * COPIES])
+model.testNbSubShapes(MultiTranslation_1, GeomAPI_Shape.VERTEX, [36 * COPIES])
+model.testResultsVolumes(MultiTranslation_1, [542.746463956 * COPIES])
+
+comp = GeomAlgoAPI_CompoundBuilder.compound([Extrusion_1.results()[0].subResult(4).resultSubShapePair()[0].shape()])
+refPoint = comp.middlePoint()
+refPoint.setY(refPoint.y() + DISTANCE_2 / 2 * (COPIES_2 - 1))
+refPoint.setZ(refPoint.z() + DISTANCE_1 / 2 * (COPIES_1 - 1))
+midPoint = MultiTranslation_1.defaultResult().shape().middlePoint()
+assert(midPoint.distance(refPoint) < TOLERANCE)
+
+
+Recover_1 = model.addRecover(Part_1_doc, MultiTranslation_1, [Compound_2.result()], True)
+MultiTranslation_2 = model.addMultiTranslation(Part_1_doc, [model.selection("SOLID", "Recover_1_1_2_1")], model.selection("EDGE", "PartSet/OZ"), DISTANCE_1, COPIES_1, model.selection("EDGE", "PartSet/OY"), DISTANCE_2, COPIES_2)
+model.testNbResults(MultiTranslation_2, 1)
+model.testNbSubResults(MultiTranslation_2, [COPIES])
+model.testNbSubShapes(MultiTranslation_2, GeomAPI_Shape.SOLID, [1 * COPIES])
+model.testNbSubShapes(MultiTranslation_2, GeomAPI_Shape.FACE, [3 * COPIES])
+model.testNbSubShapes(MultiTranslation_2, GeomAPI_Shape.EDGE, [6 * COPIES])
+model.testNbSubShapes(MultiTranslation_2, GeomAPI_Shape.VERTEX, [12 * COPIES])
+model.testResultsVolumes(MultiTranslation_2, [785.39816339745 * COPIES])
+
+refPoint = Recover_1.result().subResult(1).subResult(0).resultSubShapePair()[0].shape().middlePoint()
+refPoint.setY(refPoint.y() + DISTANCE_2 / 2 * (COPIES_2 - 1))
+refPoint.setZ(refPoint.z() + DISTANCE_1 / 2 * (COPIES_1 - 1))
+midPoint = MultiTranslation_2.defaultResult().shape().middlePoint()
+assert(midPoint.distance(refPoint) < TOLERANCE)
+
+
+Recover_2 = model.addRecover(Part_1_doc, MultiTranslation_2, [Recover_1.result()], True)
+MultiTranslation_3 = model.addMultiTranslation(Part_1_doc, [model.selection("SOLID", "Recover_2_1_3")], model.selection("EDGE", "PartSet/OZ"), DISTANCE_1, COPIES_1, model.selection("EDGE", "PartSet/OY"), DISTANCE_2, COPIES_2)
+model.testNbResults(MultiTranslation_3, 1)
+model.testNbSubResults(MultiTranslation_3, [COPIES])
+model.testNbSubShapes(MultiTranslation_3, GeomAPI_Shape.SOLID, [1 * COPIES])
+model.testNbSubShapes(MultiTranslation_3, GeomAPI_Shape.FACE, [3 * COPIES])
+model.testNbSubShapes(MultiTranslation_3, GeomAPI_Shape.EDGE, [6 * COPIES])
+model.testNbSubShapes(MultiTranslation_3, GeomAPI_Shape.VERTEX, [12 * COPIES])
+model.testResultsVolumes(MultiTranslation_3, [785.39816339745 * COPIES])
+
+refPoint = Recover_2.result().subResult(2).resultSubShapePair()[0].shape().middlePoint()
+refPoint.setY(refPoint.y() + DISTANCE_2 / 2 * (COPIES_2 - 1))
+refPoint.setZ(refPoint.z() + DISTANCE_1 / 2 * (COPIES_1 - 1))
+midPoint = MultiTranslation_3.defaultResult().shape().middlePoint()
+assert(midPoint.distance(refPoint) < TOLERANCE)
+
+
+Recover_3 = model.addRecover(Part_1_doc, MultiTranslation_3, [Recover_2.result()], True)
+MultiTranslation_4 = model.addMultiTranslation(Part_1_doc, [model.selection("SOLID", "Recover_3_1_1_1"), model.selection("SOLID", "Recover_3_1_2_2"), model.selection("SOLID", "Recover_3_1_3")], model.selection("EDGE", "PartSet/OZ"), DISTANCE_1, COPIES_1, model.selection("EDGE", "PartSet/OY"), DISTANCE_2, COPIES_2)
+model.testNbResults(MultiTranslation_4, 3)
+model.testNbSubResults(MultiTranslation_4, [COPIES, COPIES, COPIES])
+model.testNbSubShapes(MultiTranslation_4, GeomAPI_Shape.SOLID, [1 * COPIES, 1 * COPIES, 1 * COPIES])
+model.testNbSubShapes(MultiTranslation_4, GeomAPI_Shape.FACE, [6 * COPIES, 3 * COPIES, 3 * COPIES])
+model.testNbSubShapes(MultiTranslation_4, GeomAPI_Shape.EDGE, [24 * COPIES, 6 * COPIES, 6 * COPIES])
+model.testNbSubShapes(MultiTranslation_4, GeomAPI_Shape.VERTEX, [48 * COPIES, 12 * COPIES, 12 * COPIES])
+model.testResultsVolumes(MultiTranslation_4, [3444.394198615 * COPIES, 785.39816339745 * COPIES, 785.39816339745 * COPIES])
+
+comp = GeomAlgoAPI_CompoundBuilder.compound([Recover_3.result().subResult(0).subResult(0).resultSubShapePair()[0].shape()])
+REFERENCE = [comp.middlePoint(),
+             Recover_3.result().subResult(1).subResult(1).resultSubShapePair()[0].shape().middlePoint(),
+             Recover_3.result().subResult(2).resultSubShapePair()[0].shape().middlePoint()]
+for res, ref in zip(MultiTranslation_4.results(), REFERENCE):
+    ref.setY(ref.y() + DISTANCE_2 / 2 * (COPIES_2 - 1))
+    ref.setZ(ref.z() + DISTANCE_1 / 2 * (COPIES_1 - 1))
+    midPoint = res.resultSubShapePair()[0].shape().middlePoint()
+    assert(midPoint.distance(ref) < TOLERANCE)
+
+model.end()
+
+assert(model.checkPythonDump())
diff --git a/src/FeaturesPlugin/Test/TestMultiTranslation_MultiLevelCompound_v0_3.py b/src/FeaturesPlugin/Test/TestMultiTranslation_MultiLevelCompound_v0_3.py
new file mode 100644 (file)
index 0000000..199af9d
--- /dev/null
@@ -0,0 +1,192 @@
+# Copyright (C) 2020  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 salome.shaper import model
+from GeomAPI import *
+from GeomAlgoAPI import *
+
+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"))
+SketchPoint_1 = Sketch_1.addPoint(44.29784155360136, 17.09942588468031)
+SketchArc_1 = Sketch_1.addArc(44.29784155360136, 17.09942588468031, 47.1668727423061, 12.27945348765633, 45.38299232715926, 22.60269052200972, False)
+SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchPoint_1.coordinates(), SketchArc_1.center())
+SketchLine_1 = Sketch_1.addLine(42.5764228403785, 22.14892077680068, 39.70739165167375, 16.41085839939117)
+SketchLine_2 = Sketch_1.addLine(39.70739165167375, 16.41085839939117, 43.03546783057126, 12.04993099255995)
+SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_2.startPoint())
+SketchLine_3 = Sketch_1.addLine(28.57555063949931, 12.96802097294547, 15.72229091410204, 12.96802097294547)
+SketchLine_4 = Sketch_1.addLine(15.72229091410204, 12.96802097294547, 15.72229091410204, 21.46035329151154)
+SketchLine_5 = Sketch_1.addLine(15.72229091410204, 21.46035329151154, 28.57555063949931, 21.46035329151154)
+SketchLine_6 = Sketch_1.addLine(28.57555063949931, 21.46035329151154, 28.57555063949931, 12.96802097294547)
+SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchLine_6.endPoint(), SketchLine_3.startPoint())
+SketchConstraintCoincidence_4 = Sketch_1.setCoincident(SketchLine_3.endPoint(), SketchLine_4.startPoint())
+SketchConstraintCoincidence_5 = Sketch_1.setCoincident(SketchLine_4.endPoint(), SketchLine_5.startPoint())
+SketchConstraintCoincidence_6 = Sketch_1.setCoincident(SketchLine_5.endPoint(), SketchLine_6.startPoint())
+SketchConstraintHorizontal_1 = Sketch_1.setHorizontal(SketchLine_3.result())
+SketchConstraintVertical_1 = Sketch_1.setVertical(SketchLine_4.result())
+SketchConstraintHorizontal_2 = Sketch_1.setHorizontal(SketchLine_5.result())
+SketchConstraintVertical_2 = Sketch_1.setVertical(SketchLine_6.result())
+SketchLine_7 = Sketch_1.addLine(-10.67279602198167, 14.78814178154371, -28.34602814440294, 14.78814178154371)
+SketchLine_8 = Sketch_1.addLine(-28.34602814440294, 14.78814178154371, -28.34602814440294, 25.13271321305362)
+SketchLine_9 = Sketch_1.addLine(-28.34602814440294, 25.13271321305362, -10.67279602198167, 25.13271321305362)
+SketchLine_10 = Sketch_1.addLine(-10.67279602198167, 25.13271321305362, -10.67279602198167, 14.78814178154371)
+SketchConstraintCoincidence_7 = Sketch_1.setCoincident(SketchLine_10.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())
+SketchConstraintCoincidence_10 = Sketch_1.setCoincident(SketchLine_9.endPoint(), SketchLine_10.startPoint())
+SketchConstraintHorizontal_3 = Sketch_1.setHorizontal(SketchLine_7.result())
+SketchConstraintVertical_3 = Sketch_1.setVertical(SketchLine_8.result())
+SketchConstraintHorizontal_4 = Sketch_1.setHorizontal(SketchLine_9.result())
+SketchConstraintVertical_4 = Sketch_1.setVertical(SketchLine_10.result())
+SketchLine_11 = Sketch_1.addLine(-17.67323212242127, 25.13271321305362, -21.80463703415611, 14.78814178154371)
+SketchConstraintCoincidence_11 = Sketch_1.setCoincident(SketchLine_11.startPoint(), SketchLine_9.result())
+SketchConstraintCoincidence_12 = Sketch_1.setCoincident(SketchLine_11.endPoint(), SketchLine_7.result())
+model.do()
+Vertex_1 = model.addVertex(Part_1_doc, [model.selection("VERTEX", "Sketch_1/SketchArc_1")], False)
+Edge_1 = model.addEdge(Part_1_doc, [model.selection("EDGE", "Sketch_1/SketchArc_1_2")], False)
+Wire_1 = model.addWire(Part_1_doc, [model.selection("EDGE", "Sketch_1/SketchLine_1"), model.selection("EDGE", "Sketch_1/SketchLine_2")], False)
+Face_1 = model.addFace(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_6r-SketchLine_5r-SketchLine_4r-SketchLine_3r")])
+Shell_1 = model.addShell(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_10r-SketchLine_9r-SketchLine_11f-SketchLine_7r"), model.selection("FACE", "Sketch_1/Face-SketchLine_11r-SketchLine_9r-SketchLine_8r-SketchLine_7r")])
+Box_1 = model.addBox(Part_1_doc, 10, 10, 10)
+Translation_1 = model.addTranslation(Part_1_doc, [model.selection("SOLID", "Box_1_1")], model.selection("EDGE", "PartSet/OX"), 50)
+Box_2 = model.addBox(Part_1_doc, 10, 10, 10)
+Cylinder_1 = model.addCylinder(Part_1_doc, model.selection("VERTEX", "PartSet/Origin"), model.selection("EDGE", "PartSet/OZ"), 5, 10)
+Partition_1 = model.addPartition(Part_1_doc, [model.selection("SOLID", "Box_2_1"), model.selection("SOLID", "Cylinder_1_1")])
+Box_3 = model.addBox(Part_1_doc, 10, 10, 10)
+Translation_2 = model.addTranslation(Part_1_doc, [model.selection("SOLID", "Box_3_1")], model.selection("EDGE", "PartSet/OY"), 50)
+AngularCopy_1 = model.addMultiRotation(Part_1_doc, [model.selection("SOLID", "Translation_2_1")], model.selection("EDGE", "PartSet/OZ"), 30, 3)
+model.end()
+
+TOLERANCE = 1.e-7
+DISTANCE = 20
+COPIES = 2
+
+
+model.begin()
+MultiTranslation_1 = model.addMultiTranslation(Part_1_doc, [model.selection("VERTEX", "Vertex_1_1")], model.selection("EDGE", "PartSet/OZ"), DISTANCE, COPIES)
+model.testNbResults(MultiTranslation_1, 1)
+model.testNbSubResults(MultiTranslation_1, [COPIES])
+model.testNbSubShapes(MultiTranslation_1, GeomAPI_Shape.SOLID, [0])
+model.testNbSubShapes(MultiTranslation_1, GeomAPI_Shape.FACE, [0])
+model.testNbSubShapes(MultiTranslation_1, GeomAPI_Shape.EDGE, [0])
+model.testNbSubShapes(MultiTranslation_1, GeomAPI_Shape.VERTEX, [COPIES])
+model.testResultsVolumes(MultiTranslation_1, [0])
+refPoint = Vertex_1.defaultResult().shape().middlePoint()
+refPoint.setZ(refPoint.z() + DISTANCE / 2 * (COPIES - 1))
+midPoint = MultiTranslation_1.defaultResult().shape().middlePoint()
+assert(midPoint.distance(refPoint) < TOLERANCE)
+
+MultiTranslation_2 = model.addMultiTranslation(Part_1_doc, [model.selection("EDGE", "Edge_1_1")], model.selection("EDGE", "PartSet/OZ"), DISTANCE, COPIES)
+model.testNbResults(MultiTranslation_2, 1)
+model.testNbSubResults(MultiTranslation_2, [COPIES])
+model.testNbSubShapes(MultiTranslation_2, GeomAPI_Shape.SOLID, [0])
+model.testNbSubShapes(MultiTranslation_2, GeomAPI_Shape.FACE, [0])
+model.testNbSubShapes(MultiTranslation_2, GeomAPI_Shape.EDGE, [COPIES])
+model.testNbSubShapes(MultiTranslation_2, GeomAPI_Shape.VERTEX, [2 * COPIES])
+model.testResultsVolumes(MultiTranslation_2, [0])
+comp = GeomAlgoAPI_CompoundBuilder.compound([Edge_1.defaultResult().shape()])
+refPoint = comp.middlePoint()
+refPoint.setZ(refPoint.z() + DISTANCE / 2 * (COPIES - 1))
+midPoint = MultiTranslation_2.defaultResult().shape().middlePoint()
+assert(midPoint.distance(refPoint) < TOLERANCE)
+
+MultiTranslation_3 = model.addMultiTranslation(Part_1_doc, [model.selection("WIRE", "Wire_1_1")], model.selection("EDGE", "PartSet/OZ"), DISTANCE, COPIES)
+model.testNbResults(MultiTranslation_3, 1)
+model.testNbSubResults(MultiTranslation_3, [COPIES])
+model.testNbSubShapes(MultiTranslation_3, GeomAPI_Shape.SOLID, [0])
+model.testNbSubShapes(MultiTranslation_3, GeomAPI_Shape.FACE, [0])
+model.testNbSubShapes(MultiTranslation_3, GeomAPI_Shape.EDGE, [2 * COPIES])
+model.testNbSubShapes(MultiTranslation_3, GeomAPI_Shape.VERTEX, [4 * COPIES])
+model.testResultsVolumes(MultiTranslation_3, [0])
+comp = GeomAlgoAPI_CompoundBuilder.compound([Wire_1.defaultResult().shape()])
+refPoint = comp.middlePoint()
+refPoint.setZ(refPoint.z() + DISTANCE / 2 * (COPIES - 1))
+midPoint = MultiTranslation_3.defaultResult().shape().middlePoint()
+assert(midPoint.distance(refPoint) < TOLERANCE)
+
+MultiTranslation_4 = model.addMultiTranslation(Part_1_doc, [model.selection("FACE", "Face_1_1")], model.selection("EDGE", "PartSet/OZ"), DISTANCE, COPIES)
+model.testNbResults(MultiTranslation_4, 1)
+model.testNbSubResults(MultiTranslation_4, [COPIES])
+model.testNbSubShapes(MultiTranslation_4, GeomAPI_Shape.SOLID, [0])
+model.testNbSubShapes(MultiTranslation_4, GeomAPI_Shape.FACE, [COPIES])
+model.testNbSubShapes(MultiTranslation_4, GeomAPI_Shape.EDGE, [4 * COPIES])
+model.testNbSubShapes(MultiTranslation_4, GeomAPI_Shape.VERTEX, [8 * COPIES])
+model.testResultsVolumes(MultiTranslation_4, [109.154152964914914 * COPIES])
+refPoint = Face_1.defaultResult().shape().middlePoint()
+refPoint.setZ(refPoint.z() + DISTANCE / 2 * (COPIES - 1))
+midPoint = MultiTranslation_4.defaultResult().shape().middlePoint()
+assert(midPoint.distance(refPoint) < TOLERANCE)
+
+MultiTranslation_5 = model.addMultiTranslation(Part_1_doc, [model.selection("SHELL", "Shell_1_1")], model.selection("EDGE", "PartSet/OZ"), DISTANCE, COPIES)
+model.testNbResults(MultiTranslation_5, 1)
+model.testNbSubResults(MultiTranslation_5, [COPIES])
+model.testNbSubShapes(MultiTranslation_5, GeomAPI_Shape.SOLID, [0])
+model.testNbSubShapes(MultiTranslation_5, GeomAPI_Shape.FACE, [2 * COPIES])
+model.testNbSubShapes(MultiTranslation_5, GeomAPI_Shape.EDGE, [8 * COPIES])
+model.testNbSubShapes(MultiTranslation_5, GeomAPI_Shape.VERTEX, [16 * COPIES])
+model.testResultsVolumes(MultiTranslation_5, [182.822012116 * COPIES])
+refPoint = Shell_1.defaultResult().shape().middlePoint()
+refPoint.setZ(refPoint.z() + DISTANCE / 2 * (COPIES - 1))
+midPoint = MultiTranslation_5.defaultResult().shape().middlePoint()
+assert(midPoint.distance(refPoint) < TOLERANCE)
+
+MultiTranslation_6 = model.addMultiTranslation(Part_1_doc, [model.selection("SOLID", "Translation_1_1")], model.selection("EDGE", "PartSet/OZ"), DISTANCE, COPIES)
+model.testNbResults(MultiTranslation_6, 1)
+model.testNbSubResults(MultiTranslation_6, [COPIES])
+model.testNbSubShapes(MultiTranslation_6, GeomAPI_Shape.SOLID, [COPIES])
+model.testNbSubShapes(MultiTranslation_6, GeomAPI_Shape.FACE, [6 * COPIES])
+model.testNbSubShapes(MultiTranslation_6, GeomAPI_Shape.EDGE, [24 * COPIES])
+model.testNbSubShapes(MultiTranslation_6, GeomAPI_Shape.VERTEX, [48 * COPIES])
+model.testResultsVolumes(MultiTranslation_6, [1000 * COPIES])
+refPoint = Translation_1.defaultResult().shape().middlePoint()
+refPoint.setZ(refPoint.z() + DISTANCE / 2 * (COPIES - 1))
+midPoint = MultiTranslation_6.defaultResult().shape().middlePoint()
+assert(midPoint.distance(refPoint) < TOLERANCE)
+
+MultiTranslation_7 = model.addMultiTranslation(Part_1_doc, [model.selection("COMPSOLID", "Partition_1_1")], model.selection("EDGE", "PartSet/OZ"), DISTANCE, COPIES)
+model.testNbResults(MultiTranslation_7, 1)
+model.testNbSubResults(MultiTranslation_7, [COPIES])
+model.testNbSubShapes(MultiTranslation_7, GeomAPI_Shape.SOLID, [3 * COPIES])
+model.testNbSubShapes(MultiTranslation_7, GeomAPI_Shape.FACE, [17 * COPIES])
+model.testNbSubShapes(MultiTranslation_7, GeomAPI_Shape.EDGE, [66 * COPIES])
+model.testNbSubShapes(MultiTranslation_7, GeomAPI_Shape.VERTEX, [132 * COPIES])
+model.testResultsVolumes(MultiTranslation_7, [1589.0486226 * COPIES])
+refPoint = Partition_1.defaultResult().shape().middlePoint()
+refPoint.setZ(refPoint.z() + DISTANCE / 2 * (COPIES - 1))
+midPoint = MultiTranslation_7.defaultResult().shape().middlePoint()
+assert(midPoint.distance(refPoint) < TOLERANCE)
+
+MultiTranslation_8 = model.addMultiTranslation(Part_1_doc, [model.selection("COMPOUND", "AngularCopy_1_1")], model.selection("EDGE", "PartSet/OZ"), DISTANCE, COPIES)
+model.testNbResults(MultiTranslation_8, 1)
+model.testNbSubResults(MultiTranslation_8, [COPIES])
+model.testNbSubShapes(MultiTranslation_8, GeomAPI_Shape.SOLID, [3 * COPIES])
+model.testNbSubShapes(MultiTranslation_8, GeomAPI_Shape.FACE, [18 * COPIES])
+model.testNbSubShapes(MultiTranslation_8, GeomAPI_Shape.EDGE, [72 * COPIES])
+model.testNbSubShapes(MultiTranslation_8, GeomAPI_Shape.VERTEX, [144 * COPIES])
+model.testResultsVolumes(MultiTranslation_8, [3000 * COPIES])
+refPoint = AngularCopy_1.defaultResult().shape().middlePoint()
+refPoint.setZ(refPoint.z() + DISTANCE / 2 * (COPIES - 1))
+midPoint = MultiTranslation_8.defaultResult().shape().middlePoint()
+assert(midPoint.distance(refPoint) < TOLERANCE)
+
+model.end()
+
+assert(model.checkPythonDump())
diff --git a/src/FeaturesPlugin/Test/TestMultiTranslation_MultiLevelCompound_v0_4.py b/src/FeaturesPlugin/Test/TestMultiTranslation_MultiLevelCompound_v0_4.py
new file mode 100644 (file)
index 0000000..2c627b9
--- /dev/null
@@ -0,0 +1,201 @@
+# Copyright (C) 2020  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 salome.shaper import model
+from GeomAPI import *
+from GeomAlgoAPI import *
+
+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"))
+SketchPoint_1 = Sketch_1.addPoint(44.29784155360136, 17.09942588468031)
+SketchArc_1 = Sketch_1.addArc(44.29784155360136, 17.09942588468031, 47.1668727423061, 12.27945348765633, 45.38299232715926, 22.60269052200972, False)
+SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchPoint_1.coordinates(), SketchArc_1.center())
+SketchLine_1 = Sketch_1.addLine(42.5764228403785, 22.14892077680068, 39.70739165167375, 16.41085839939117)
+SketchLine_2 = Sketch_1.addLine(39.70739165167375, 16.41085839939117, 43.03546783057126, 12.04993099255995)
+SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_2.startPoint())
+SketchLine_3 = Sketch_1.addLine(28.57555063949931, 12.96802097294547, 15.72229091410204, 12.96802097294547)
+SketchLine_4 = Sketch_1.addLine(15.72229091410204, 12.96802097294547, 15.72229091410204, 21.46035329151154)
+SketchLine_5 = Sketch_1.addLine(15.72229091410204, 21.46035329151154, 28.57555063949931, 21.46035329151154)
+SketchLine_6 = Sketch_1.addLine(28.57555063949931, 21.46035329151154, 28.57555063949931, 12.96802097294547)
+SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchLine_6.endPoint(), SketchLine_3.startPoint())
+SketchConstraintCoincidence_4 = Sketch_1.setCoincident(SketchLine_3.endPoint(), SketchLine_4.startPoint())
+SketchConstraintCoincidence_5 = Sketch_1.setCoincident(SketchLine_4.endPoint(), SketchLine_5.startPoint())
+SketchConstraintCoincidence_6 = Sketch_1.setCoincident(SketchLine_5.endPoint(), SketchLine_6.startPoint())
+SketchConstraintHorizontal_1 = Sketch_1.setHorizontal(SketchLine_3.result())
+SketchConstraintVertical_1 = Sketch_1.setVertical(SketchLine_4.result())
+SketchConstraintHorizontal_2 = Sketch_1.setHorizontal(SketchLine_5.result())
+SketchConstraintVertical_2 = Sketch_1.setVertical(SketchLine_6.result())
+SketchLine_7 = Sketch_1.addLine(-10.67279602198167, 14.78814178154371, -28.34602814440294, 14.78814178154371)
+SketchLine_8 = Sketch_1.addLine(-28.34602814440294, 14.78814178154371, -28.34602814440294, 25.13271321305362)
+SketchLine_9 = Sketch_1.addLine(-28.34602814440294, 25.13271321305362, -10.67279602198167, 25.13271321305362)
+SketchLine_10 = Sketch_1.addLine(-10.67279602198167, 25.13271321305362, -10.67279602198167, 14.78814178154371)
+SketchConstraintCoincidence_7 = Sketch_1.setCoincident(SketchLine_10.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())
+SketchConstraintCoincidence_10 = Sketch_1.setCoincident(SketchLine_9.endPoint(), SketchLine_10.startPoint())
+SketchConstraintHorizontal_3 = Sketch_1.setHorizontal(SketchLine_7.result())
+SketchConstraintVertical_3 = Sketch_1.setVertical(SketchLine_8.result())
+SketchConstraintHorizontal_4 = Sketch_1.setHorizontal(SketchLine_9.result())
+SketchConstraintVertical_4 = Sketch_1.setVertical(SketchLine_10.result())
+SketchLine_11 = Sketch_1.addLine(-17.67323212242127, 25.13271321305362, -21.80463703415611, 14.78814178154371)
+SketchConstraintCoincidence_11 = Sketch_1.setCoincident(SketchLine_11.startPoint(), SketchLine_9.result())
+SketchConstraintCoincidence_12 = Sketch_1.setCoincident(SketchLine_11.endPoint(), SketchLine_7.result())
+model.do()
+Vertex_1 = model.addVertex(Part_1_doc, [model.selection("VERTEX", "Sketch_1/SketchArc_1")], False)
+Edge_1 = model.addEdge(Part_1_doc, [model.selection("EDGE", "Sketch_1/SketchArc_1_2")], False)
+Wire_1 = model.addWire(Part_1_doc, [model.selection("EDGE", "Sketch_1/SketchLine_1"), model.selection("EDGE", "Sketch_1/SketchLine_2")], False)
+Face_1 = model.addFace(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_6r-SketchLine_5r-SketchLine_4r-SketchLine_3r")])
+Shell_1 = model.addShell(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_10r-SketchLine_9r-SketchLine_11f-SketchLine_7r"), model.selection("FACE", "Sketch_1/Face-SketchLine_11r-SketchLine_9r-SketchLine_8r-SketchLine_7r")])
+Box_1 = model.addBox(Part_1_doc, 10, 10, 10)
+Translation_1 = model.addTranslation(Part_1_doc, [model.selection("SOLID", "Box_1_1")], model.selection("EDGE", "PartSet/OX"), 50)
+Box_2 = model.addBox(Part_1_doc, 10, 10, 10)
+Cylinder_1 = model.addCylinder(Part_1_doc, model.selection("VERTEX", "PartSet/Origin"), model.selection("EDGE", "PartSet/OZ"), 5, 10)
+Partition_1 = model.addPartition(Part_1_doc, [model.selection("SOLID", "Box_2_1"), model.selection("SOLID", "Cylinder_1_1")])
+Box_3 = model.addBox(Part_1_doc, 10, 10, 10)
+Translation_2 = model.addTranslation(Part_1_doc, [model.selection("SOLID", "Box_3_1")], model.selection("EDGE", "PartSet/OY"), 50)
+AngularCopy_1 = model.addMultiRotation(Part_1_doc, [model.selection("SOLID", "Translation_2_1")], model.selection("EDGE", "PartSet/OZ"), 30, 3)
+Compound_1_objects = [model.selection("VERTEX", "Vertex_1_1"), model.selection("EDGE", "Edge_1_1"), model.selection("WIRE", "Wire_1_1"), model.selection("FACE", "Face_1_1"), model.selection("SHELL", "Shell_1_1"), model.selection("SOLID", "Translation_1_1"), model.selection("COMPSOLID", "Partition_1_1"), model.selection("COMPOUND", "AngularCopy_1_1")]
+Compound_1 = model.addCompound(Part_1_doc, Compound_1_objects)
+model.end()
+
+TOLERANCE = 1.e-7
+DISTANCE = 20
+COPIES = 2
+
+
+model.begin()
+MultiTranslation_1 = model.addMultiTranslation(Part_1_doc, [model.selection("VERTEX", "Compound_1_1_1")], model.selection("EDGE", "PartSet/OZ"), DISTANCE, COPIES)
+model.testNbResults(MultiTranslation_1, 1)
+model.testNbSubResults(MultiTranslation_1, [COPIES])
+model.testNbSubShapes(MultiTranslation_1, GeomAPI_Shape.SOLID, [0])
+model.testNbSubShapes(MultiTranslation_1, GeomAPI_Shape.FACE, [0])
+model.testNbSubShapes(MultiTranslation_1, GeomAPI_Shape.EDGE, [0])
+model.testNbSubShapes(MultiTranslation_1, GeomAPI_Shape.VERTEX, [COPIES])
+model.testResultsVolumes(MultiTranslation_1, [0])
+refPoint = Vertex_1.defaultResult().shape().middlePoint()
+refPoint.setZ(refPoint.z() + DISTANCE / 2 * (COPIES - 1))
+midPoint = MultiTranslation_1.defaultResult().shape().middlePoint()
+assert(midPoint.distance(refPoint) < TOLERANCE)
+
+Recover_1 = model.addRecover(Part_1_doc, MultiTranslation_1, [Compound_1.result()], True)
+MultiTranslation_2 = model.addMultiTranslation(Part_1_doc, [model.selection("EDGE", "Recover_1_1_2")], model.selection("EDGE", "PartSet/OZ"), DISTANCE, COPIES)
+model.testNbResults(MultiTranslation_2, 1)
+model.testNbSubResults(MultiTranslation_2, [COPIES])
+model.testNbSubShapes(MultiTranslation_2, GeomAPI_Shape.SOLID, [0])
+model.testNbSubShapes(MultiTranslation_2, GeomAPI_Shape.FACE, [0])
+model.testNbSubShapes(MultiTranslation_2, GeomAPI_Shape.EDGE, [COPIES])
+model.testNbSubShapes(MultiTranslation_2, GeomAPI_Shape.VERTEX, [2 * COPIES])
+model.testResultsVolumes(MultiTranslation_2, [0])
+comp = GeomAlgoAPI_CompoundBuilder.compound([Edge_1.defaultResult().shape()])
+refPoint = comp.middlePoint()
+refPoint.setZ(refPoint.z() + DISTANCE / 2 * (COPIES - 1))
+midPoint = MultiTranslation_2.defaultResult().shape().middlePoint()
+assert(midPoint.distance(refPoint) < TOLERANCE)
+
+Recover_2 = model.addRecover(Part_1_doc, MultiTranslation_2, [Recover_1.result()])
+MultiTranslation_3 = model.addMultiTranslation(Part_1_doc, [model.selection("WIRE", "Recover_2_1_3")], model.selection("EDGE", "PartSet/OZ"), DISTANCE, COPIES)
+model.testNbResults(MultiTranslation_3, 1)
+model.testNbSubResults(MultiTranslation_3, [COPIES])
+model.testNbSubShapes(MultiTranslation_3, GeomAPI_Shape.SOLID, [0])
+model.testNbSubShapes(MultiTranslation_3, GeomAPI_Shape.FACE, [0])
+model.testNbSubShapes(MultiTranslation_3, GeomAPI_Shape.EDGE, [2 * COPIES])
+model.testNbSubShapes(MultiTranslation_3, GeomAPI_Shape.VERTEX, [4 * COPIES])
+model.testResultsVolumes(MultiTranslation_3, [0])
+comp = GeomAlgoAPI_CompoundBuilder.compound([Wire_1.defaultResult().shape()])
+refPoint = comp.middlePoint()
+refPoint.setZ(refPoint.z() + DISTANCE / 2 * (COPIES - 1))
+midPoint = MultiTranslation_3.defaultResult().shape().middlePoint()
+assert(midPoint.distance(refPoint) < TOLERANCE)
+
+Recover_3 = model.addRecover(Part_1_doc, MultiTranslation_3, [Recover_2.result()])
+MultiTranslation_4 = model.addMultiTranslation(Part_1_doc, [model.selection("FACE", "Recover_3_1_4")], model.selection("EDGE", "PartSet/OZ"), DISTANCE, COPIES)
+model.testNbResults(MultiTranslation_4, 1)
+model.testNbSubResults(MultiTranslation_4, [COPIES])
+model.testNbSubShapes(MultiTranslation_4, GeomAPI_Shape.SOLID, [0])
+model.testNbSubShapes(MultiTranslation_4, GeomAPI_Shape.FACE, [COPIES])
+model.testNbSubShapes(MultiTranslation_4, GeomAPI_Shape.EDGE, [4 * COPIES])
+model.testNbSubShapes(MultiTranslation_4, GeomAPI_Shape.VERTEX, [8 * COPIES])
+model.testResultsVolumes(MultiTranslation_4, [109.154152964914914 * COPIES])
+refPoint = Face_1.defaultResult().shape().middlePoint()
+refPoint.setZ(refPoint.z() + DISTANCE / 2 * (COPIES - 1))
+midPoint = MultiTranslation_4.defaultResult().shape().middlePoint()
+assert(midPoint.distance(refPoint) < TOLERANCE)
+
+Recover_4 = model.addRecover(Part_1_doc, MultiTranslation_4, [Recover_3.result()])
+MultiTranslation_5 = model.addMultiTranslation(Part_1_doc, [model.selection("SHELL", "Recover_4_1_5")], model.selection("EDGE", "PartSet/OZ"), DISTANCE, COPIES)
+model.testNbResults(MultiTranslation_5, 1)
+model.testNbSubResults(MultiTranslation_5, [COPIES])
+model.testNbSubShapes(MultiTranslation_5, GeomAPI_Shape.SOLID, [0])
+model.testNbSubShapes(MultiTranslation_5, GeomAPI_Shape.FACE, [2 * COPIES])
+model.testNbSubShapes(MultiTranslation_5, GeomAPI_Shape.EDGE, [8 * COPIES])
+model.testNbSubShapes(MultiTranslation_5, GeomAPI_Shape.VERTEX, [16 * COPIES])
+model.testResultsVolumes(MultiTranslation_5, [182.822012116 * COPIES])
+refPoint = Shell_1.defaultResult().shape().middlePoint()
+refPoint.setZ(refPoint.z() + DISTANCE / 2 * (COPIES - 1))
+midPoint = MultiTranslation_5.defaultResult().shape().middlePoint()
+assert(midPoint.distance(refPoint) < TOLERANCE)
+
+Recover_5 = model.addRecover(Part_1_doc, MultiTranslation_5, [Recover_4.result()])
+MultiTranslation_6 = model.addMultiTranslation(Part_1_doc, [model.selection("SOLID", "Recover_5_1_6")], model.selection("EDGE", "PartSet/OZ"), DISTANCE, COPIES)
+model.testNbResults(MultiTranslation_6, 1)
+model.testNbSubResults(MultiTranslation_6, [COPIES])
+model.testNbSubShapes(MultiTranslation_6, GeomAPI_Shape.SOLID, [COPIES])
+model.testNbSubShapes(MultiTranslation_6, GeomAPI_Shape.FACE, [6 * COPIES])
+model.testNbSubShapes(MultiTranslation_6, GeomAPI_Shape.EDGE, [24 * COPIES])
+model.testNbSubShapes(MultiTranslation_6, GeomAPI_Shape.VERTEX, [48 * COPIES])
+model.testResultsVolumes(MultiTranslation_6, [1000 * COPIES])
+refPoint = Translation_1.defaultResult().shape().middlePoint()
+refPoint.setZ(refPoint.z() + DISTANCE / 2 * (COPIES - 1))
+midPoint = MultiTranslation_6.defaultResult().shape().middlePoint()
+assert(midPoint.distance(refPoint) < TOLERANCE)
+
+Recover_6 = model.addRecover(Part_1_doc, MultiTranslation_6, [Recover_5.result()])
+MultiTranslation_7 = model.addMultiTranslation(Part_1_doc, [model.selection("COMPSOLID", "Recover_6_1_7")], model.selection("EDGE", "PartSet/OZ"), DISTANCE, COPIES)
+model.testNbResults(MultiTranslation_7, 1)
+model.testNbSubResults(MultiTranslation_7, [COPIES])
+model.testNbSubShapes(MultiTranslation_7, GeomAPI_Shape.SOLID, [3 * COPIES])
+model.testNbSubShapes(MultiTranslation_7, GeomAPI_Shape.FACE, [17 * COPIES])
+model.testNbSubShapes(MultiTranslation_7, GeomAPI_Shape.EDGE, [66 * COPIES])
+model.testNbSubShapes(MultiTranslation_7, GeomAPI_Shape.VERTEX, [132 * COPIES])
+model.testResultsVolumes(MultiTranslation_7, [1589.0486226 * COPIES])
+refPoint = Partition_1.defaultResult().shape().middlePoint()
+refPoint.setZ(refPoint.z() + DISTANCE / 2 * (COPIES - 1))
+midPoint = MultiTranslation_7.defaultResult().shape().middlePoint()
+assert(midPoint.distance(refPoint) < TOLERANCE)
+
+Recover_7 = model.addRecover(Part_1_doc, MultiTranslation_7, [Recover_6.result()])
+MultiTranslation_8 = model.addMultiTranslation(Part_1_doc, [model.selection("COMPOUND", "Recover_7_1_8")], model.selection("EDGE", "PartSet/OZ"), DISTANCE, COPIES)
+model.testNbResults(MultiTranslation_8, 1)
+model.testNbSubResults(MultiTranslation_8, [COPIES])
+model.testNbSubShapes(MultiTranslation_8, GeomAPI_Shape.SOLID, [3 * COPIES])
+model.testNbSubShapes(MultiTranslation_8, GeomAPI_Shape.FACE, [18 * COPIES])
+model.testNbSubShapes(MultiTranslation_8, GeomAPI_Shape.EDGE, [72 * COPIES])
+model.testNbSubShapes(MultiTranslation_8, GeomAPI_Shape.VERTEX, [144 * COPIES])
+model.testResultsVolumes(MultiTranslation_8, [3000 * COPIES])
+refPoint = AngularCopy_1.defaultResult().shape().middlePoint()
+refPoint.setZ(refPoint.z() + DISTANCE / 2 * (COPIES - 1))
+midPoint = MultiTranslation_8.defaultResult().shape().middlePoint()
+assert(midPoint.distance(refPoint) < TOLERANCE)
+
+model.end()
+
+assert(model.checkPythonDump())
diff --git a/src/FeaturesPlugin/Test/TestMultiTranslation_MultiLevelCompound_v95_1.py b/src/FeaturesPlugin/Test/TestMultiTranslation_MultiLevelCompound_v95_1.py
new file mode 100644 (file)
index 0000000..f2a808b
--- /dev/null
@@ -0,0 +1,118 @@
+# Copyright (C) 2020  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 salome.shaper import model
+
+from GeomAPI import *
+from SketchAPI import *
+
+model.begin()
+partSet = model.moduleDocument()
+Part_1 = model.addPart(partSet)
+Part_1_doc = Part_1.document()
+Sketch_1 = model.addSketch(Part_1_doc, model.standardPlane("XOY"))
+SketchEllipse_1 = Sketch_1.addEllipse(11.18033988749894, -50, 22.36067977499789, -50, 10)
+[SketchPoint_1, SketchPoint_2, SketchPoint_3, SketchPoint_4, SketchPoint_5, SketchPoint_6, SketchPoint_7, SketchLine_1, SketchLine_2] = SketchEllipse_1.construction(center = "aux", firstFocus = "aux", secondFocus = "aux", majorAxisStart = "aux", majorAxisEnd = "aux", minorAxisStart = "aux", minorAxisEnd = "aux", majorAxis = "aux", minorAxis = "aux")
+SketchConstraintHorizontal_1 = Sketch_1.setHorizontal(SketchLine_1.result())
+SketchConstraintLength_1 = Sketch_1.setLength(SketchLine_1.result(), 30)
+SketchConstraintLength_2 = Sketch_1.setLength(SketchLine_2.result(), 20)
+SketchProjection_1 = Sketch_1.addProjection(model.selection("EDGE", "PartSet/OY"), False)
+SketchLine_3 = SketchProjection_1.createdFeature()
+SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchAPI_Point(SketchPoint_3).coordinates(), SketchLine_3.result())
+SketchConstraintDistance_1 = Sketch_1.setDistance(SketchAPI_Line(SketchLine_3).startPoint(), SketchAPI_Point(SketchPoint_3).coordinates(), 50, True)
+SketchCircle_1 = Sketch_1.addCircle(41.18033988749897, -50, 5)
+SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchCircle_1.center(), SketchLine_1.result())
+SketchConstraintDistance_2 = Sketch_1.setDistance(SketchEllipse_1.majorAxisPositive(), SketchCircle_1.center(), 15, True)
+SketchConstraintRadius_1 = Sketch_1.setRadius(SketchCircle_1.results()[1], 5)
+SketchMultiRotation_1 = Sketch_1.addRotation([SketchEllipse_1.result(), SketchCircle_1.results()[1]], SketchAPI_Point(SketchPoint_3).coordinates(), 360, 3, True)
+[SketchEllipse_2, SketchEllipse_3, SketchCircle_2, SketchCircle_3] = SketchMultiRotation_1.rotated()
+model.do()
+Sketch_1.changeFacesOrder([[SketchEllipse_1.result(), SketchEllipse_1.result(), SketchEllipse_2.result(), SketchEllipse_3.result()],
+                           [SketchCircle_1.results()[1]],
+                           [SketchEllipse_2.result(), SketchEllipse_2.result(), SketchEllipse_3.result(), SketchEllipse_1.result()],
+                           [SketchEllipse_1.result(), SketchEllipse_3.result(), SketchEllipse_2.result()],
+                           [SketchEllipse_3.result(), SketchEllipse_2.result(), SketchEllipse_1.result()],
+                           [SketchEllipse_1.result(), SketchEllipse_2.result(), SketchEllipse_3.result()],
+                           [SketchEllipse_1.result(), SketchEllipse_3.result(), SketchEllipse_2.result()],
+                           [SketchEllipse_2.result(), SketchEllipse_3.result(), SketchEllipse_3.result(), SketchEllipse_1.result()],
+                           [SketchCircle_2.results()[1]],
+                           [SketchCircle_3.results()[1]]
+                          ])
+model.do()
+Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("COMPOUND", "Sketch_1")], model.selection(), 10, 0)
+Compound_1 = model.addCompound(Part_1_doc, [model.selection("SOLID", "Extrusion_1_2"), model.selection("SOLID", "Extrusion_1_3")])
+Compound_2_objects = [model.selection("COMPSOLID", "Extrusion_1_1"), model.selection("COMPOUND", "Compound_1_1"), model.selection("SOLID", "Extrusion_1_4")]
+Compound_2 = model.addCompound(Part_1_doc, Compound_2_objects)
+model.end()
+
+DISTANCE = 50
+COPIES = 3
+TOLERANCE = 1.e-7
+
+def subsRefPoints(theResult):
+    res = []
+    for ind in range(0, theResult.numberOfSubs()):
+        res.append( theResult.subResult(ind).resultSubShapePair()[0].shape().middlePoint())
+    return res
+
+REFERENCE = subsRefPoints(Compound_2.result())
+
+def assertResult(theFeature, theNbSolids, theNbFaces, theNbEdges, theNbVertices, theVolume):
+    model.testNbResults(theFeature, 1)
+    model.testNbSubResults(theFeature, [3])
+    model.testNbSubShapes(theFeature, GeomAPI_Shape.SOLID, [theNbSolids])
+    model.testNbSubShapes(theFeature, GeomAPI_Shape.FACE, [theNbFaces])
+    model.testNbSubShapes(theFeature, GeomAPI_Shape.EDGE, [theNbEdges])
+    model.testNbSubShapes(theFeature, GeomAPI_Shape.VERTEX, [theNbVertices])
+    model.testResultsVolumes(theFeature, [theVolume])
+
+    for ind in range(0, theFeature.result().numberOfSubs()):
+        ref = REFERENCE[ind]
+        midPoint = theFeature.result().subResult(ind).resultSubShapePair()[0].shape().middlePoint()
+        assert(midPoint.distance(ref) < TOLERANCE), "Sub-result {}; actual ({}, {}, {}) != expected ({}, {}, {})".format(ind, midPoint.x(), midPoint.y(), midPoint.z(), ref.x(), ref.y(), ref.z())
+
+
+model.begin()
+MultiTranslation_1 = model.addMultiTranslation(Part_1_doc, [model.selection("SOLID", "Compound_2_1_1_5")], model.selection("EDGE", "PartSet/OZ"), DISTANCE, COPIES, keepSubResults = True)
+model.end()
+# selection of a compsolid part is prohibited
+assert(MultiTranslation_1.feature().error() != "")
+
+model.begin()
+MultiTranslation_1.setMainObjects([model.selection("COMPSOLID", "Compound_2_1_1")])
+REFERENCE[0].setZ(REFERENCE[0].z() + DISTANCE / 2 * (COPIES - 1))
+assertResult(MultiTranslation_1, 24, 123, 450, 900, 38247.599)
+
+MultiTranslation_2 = model.addMultiTranslation(Part_1_doc, [model.selection("SOLID", "LinearCopy_1_1_2_1")], model.selection("EDGE", "PartSet/OZ"), DISTANCE, COPIES, keepSubResults = True)
+REFERENCE[1].setZ(REFERENCE[1].z() + DISTANCE / 2 * (COPIES - 1))
+assertResult(MultiTranslation_2, 26, 129, 462, 924, 39818.3954)
+
+MultiTranslation_3 = model.addMultiTranslation(Part_1_doc, [model.selection("SOLID", "LinearCopy_2_1_3")], model.selection("EDGE", "PartSet/OZ"), DISTANCE, COPIES, keepSubResults = True)
+REFERENCE[2].setZ(REFERENCE[2].z() + DISTANCE / 2 * (COPIES - 1))
+assertResult(MultiTranslation_3, 28, 135, 474, 948, 41389.19175)
+
+MultiTranslation_4 = model.addMultiTranslation(Part_1_doc, [model.selection("COMPSOLID", "LinearCopy_3_1_1_1"), model.selection("SOLID", "LinearCopy_3_1_2_2"), model.selection("COMPOUND", "LinearCopy_3_1_3")], model.selection("EDGE", "PartSet/OY"), DISTANCE, COPIES, keepSubResults = True)
+REFERENCE[0].setY(REFERENCE[0].y() + DISTANCE / 2 * (COPIES - 1))
+REFERENCE[1].setY(REFERENCE[1].y() + DISTANCE / 2 * (COPIES - 1))
+REFERENCE[2].setY(REFERENCE[2].y() + DISTANCE / 2 * (COPIES - 1))
+assertResult(MultiTranslation_4, 50, 235, 810, 1620, 71599.98)
+
+model.end()
+
+assert(model.checkPythonDump())
diff --git a/src/FeaturesPlugin/Test/TestMultiTranslation_MultiLevelCompound_v95_2.py b/src/FeaturesPlugin/Test/TestMultiTranslation_MultiLevelCompound_v95_2.py
new file mode 100644 (file)
index 0000000..42a6853
--- /dev/null
@@ -0,0 +1,129 @@
+# Copyright (C) 2020  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 salome.shaper import model
+
+from GeomAPI import *
+from SketchAPI import *
+
+model.begin()
+partSet = model.moduleDocument()
+Part_1 = model.addPart(partSet)
+Part_1_doc = Part_1.document()
+Sketch_1 = model.addSketch(Part_1_doc, model.standardPlane("XOY"))
+SketchEllipse_1 = Sketch_1.addEllipse(11.18033988749894, -50, 22.36067977499789, -50, 10)
+[SketchPoint_1, SketchPoint_2, SketchPoint_3, SketchPoint_4, SketchPoint_5, SketchPoint_6, SketchPoint_7, SketchLine_1, SketchLine_2] = SketchEllipse_1.construction(center = "aux", firstFocus = "aux", secondFocus = "aux", majorAxisStart = "aux", majorAxisEnd = "aux", minorAxisStart = "aux", minorAxisEnd = "aux", majorAxis = "aux", minorAxis = "aux")
+SketchConstraintHorizontal_1 = Sketch_1.setHorizontal(SketchLine_1.result())
+SketchConstraintLength_1 = Sketch_1.setLength(SketchLine_1.result(), 30)
+SketchConstraintLength_2 = Sketch_1.setLength(SketchLine_2.result(), 20)
+SketchProjection_1 = Sketch_1.addProjection(model.selection("EDGE", "PartSet/OY"), False)
+SketchLine_3 = SketchProjection_1.createdFeature()
+SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchAPI_Point(SketchPoint_3).coordinates(), SketchLine_3.result())
+SketchConstraintDistance_1 = Sketch_1.setDistance(SketchAPI_Line(SketchLine_3).startPoint(), SketchAPI_Point(SketchPoint_3).coordinates(), 50, True)
+SketchCircle_1 = Sketch_1.addCircle(41.18033988749897, -50, 5)
+SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchCircle_1.center(), SketchLine_1.result())
+SketchConstraintDistance_2 = Sketch_1.setDistance(SketchEllipse_1.majorAxisPositive(), SketchCircle_1.center(), 15, True)
+SketchConstraintRadius_1 = Sketch_1.setRadius(SketchCircle_1.results()[1], 5)
+SketchMultiRotation_1 = Sketch_1.addRotation([SketchEllipse_1.result(), SketchCircle_1.results()[1]], SketchAPI_Point(SketchPoint_3).coordinates(), 360, 3, True)
+[SketchEllipse_2, SketchEllipse_3, SketchCircle_2, SketchCircle_3] = SketchMultiRotation_1.rotated()
+model.do()
+Sketch_1.changeFacesOrder([[SketchEllipse_1.result(), SketchEllipse_1.result(), SketchEllipse_2.result(), SketchEllipse_3.result()],
+                           [SketchCircle_1.results()[1]],
+                           [SketchEllipse_2.result(), SketchEllipse_2.result(), SketchEllipse_3.result(), SketchEllipse_1.result()],
+                           [SketchEllipse_1.result(), SketchEllipse_3.result(), SketchEllipse_2.result()],
+                           [SketchEllipse_3.result(), SketchEllipse_2.result(), SketchEllipse_1.result()],
+                           [SketchEllipse_1.result(), SketchEllipse_2.result(), SketchEllipse_3.result()],
+                           [SketchEllipse_1.result(), SketchEllipse_3.result(), SketchEllipse_2.result()],
+                           [SketchEllipse_2.result(), SketchEllipse_3.result(), SketchEllipse_3.result(), SketchEllipse_1.result()],
+                           [SketchCircle_2.results()[1]],
+                           [SketchCircle_3.results()[1]]
+                          ])
+model.do()
+Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("COMPOUND", "Sketch_1")], model.selection(), 10, 0)
+Compound_1 = model.addCompound(Part_1_doc, [model.selection("SOLID", "Extrusion_1_2"), model.selection("SOLID", "Extrusion_1_3")])
+Compound_2_objects = [model.selection("COMPSOLID", "Extrusion_1_1"), model.selection("COMPOUND", "Compound_1_1"), model.selection("SOLID", "Extrusion_1_4")]
+Compound_2 = model.addCompound(Part_1_doc, Compound_2_objects)
+model.end()
+
+TOLERANCE = 1.e-7
+DISTANCE_1 = 100
+COPIES_1 = 2
+DISTANCE_2 = 50
+COPIES_2 = 3
+COPIES = COPIES_1 * COPIES_2
+
+
+def subsRefPoints(theResult):
+    res = []
+    for ind in range(0, theResult.numberOfSubs()):
+        res.append( theResult.subResult(ind).resultSubShapePair()[0].shape().middlePoint())
+    return res
+
+REFERENCE = subsRefPoints(Compound_2.result())
+
+def assertResult(theFeature, theNbSolids, theNbFaces, theNbEdges, theNbVertices, theVolume):
+    model.testNbResults(theFeature, 1)
+    model.testNbSubResults(theFeature, [3])
+    model.testNbSubShapes(theFeature, GeomAPI_Shape.SOLID, [theNbSolids])
+    model.testNbSubShapes(theFeature, GeomAPI_Shape.FACE, [theNbFaces])
+    model.testNbSubShapes(theFeature, GeomAPI_Shape.EDGE, [theNbEdges])
+    model.testNbSubShapes(theFeature, GeomAPI_Shape.VERTEX, [theNbVertices])
+    model.testResultsVolumes(theFeature, [theVolume])
+
+    for ind in range(0, theFeature.result().numberOfSubs()):
+        ref = REFERENCE[ind]
+        midPoint = theFeature.result().subResult(ind).resultSubShapePair()[0].shape().middlePoint()
+        assert(midPoint.distance(ref) < TOLERANCE), "Sub-result {}; actual ({}, {}, {}) != expected ({}, {}, {})".format(ind, midPoint.x(), midPoint.y(), midPoint.z(), ref.x(), ref.y(), ref.z())
+
+
+model.begin()
+MultiTranslation_1 = model.addMultiTranslation(Part_1_doc, [model.selection("SOLID", "Compound_2_1_1_5")], model.selection("EDGE", "PartSet/OY"), DISTANCE_1, COPIES_1, model.selection("EDGE", "PartSet/OZ"), DISTANCE_2, COPIES_2, keepSubResults = True)
+model.end()
+# selection of a compsolid part is prohibited
+assert(MultiTranslation_1.feature().error() != "")
+
+model.begin()
+MultiTranslation_1.setMainObjects([model.selection("COMPSOLID", "Compound_2_1_1")])
+REFERENCE[0].setY(REFERENCE[0].y() + DISTANCE_1 / 2 * (COPIES_1 - 1))
+REFERENCE[0].setZ(REFERENCE[0].z() + DISTANCE_2 / 2 * (COPIES_2 - 1))
+assertResult(MultiTranslation_1, 45, 237, 882, 1764, 74139.0037)
+
+MultiTranslation_2 = model.addMultiTranslation(Part_1_doc, [model.selection("SOLID", "LinearCopy_1_1_2_1")], model.selection("EDGE", "PartSet/OY"), DISTANCE_1, COPIES_1, model.selection("EDGE", "PartSet/OZ"), DISTANCE_2, COPIES_2, keepSubResults = True)
+ref1Ycopy = REFERENCE[1].y()
+REFERENCE[1].setY(0)
+REFERENCE[1].setZ(REFERENCE[1].z() + DISTANCE_2 / 2 * (COPIES_2 - 1))
+assertResult(MultiTranslation_2, 50, 252, 912, 1824, 78065.9945)
+
+MultiTranslation_3 = model.addMultiTranslation(Part_1_doc, [model.selection("SOLID", "LinearCopy_2_1_3")], model.selection("EDGE", "PartSet/OY"), DISTANCE_1, COPIES_1, model.selection("EDGE", "PartSet/OZ"), DISTANCE_2, COPIES_2, keepSubResults = True)
+REFERENCE[2].setY(REFERENCE[2].y() + DISTANCE_1 / 2 * (COPIES_1 - 1))
+REFERENCE[2].setZ(REFERENCE[2].z() + DISTANCE_2 / 2 * (COPIES_2 - 1))
+assertResult(MultiTranslation_3, 55, 267, 942, 1884, 81992.9853)
+
+MultiTranslation_4 = model.addMultiTranslation(Part_1_doc, [model.selection("COMPSOLID", "LinearCopy_3_1_1_5"), model.selection("SOLID", "LinearCopy_3_1_2_2"), model.selection("COMPOUND", "LinearCopy_3_1_3")], model.selection("EDGE", "PartSet/OX"), -DISTANCE_2, COPIES_2, model.selection("EDGE", "PartSet/OY"), -DISTANCE_1, COPIES_1, keepSubResults = True)
+REFERENCE[0].setX(REFERENCE[0].x() - DISTANCE_2 / 2 * (COPIES_2 - 1))
+REFERENCE[0].setY(REFERENCE[0].y() - DISTANCE_1 / 2 * (COPIES_1 - 1))
+REFERENCE[1].setX(REFERENCE[1].x() - DISTANCE_2 / 2 * (COPIES_2 - 1))
+REFERENCE[1].setY(ref1Ycopy)
+REFERENCE[2].setX(REFERENCE[2].x() - DISTANCE_2 / 2 * (COPIES_2 - 1))
+REFERENCE[2].setY(REFERENCE[2].y() - DISTANCE_1 / 2 * (COPIES_1 - 1))
+assertResult(MultiTranslation_4, 125, 562, 1872, 3744, 169300.9287)
+
+model.end()
+
+assert(model.checkPythonDump())
diff --git a/src/FeaturesPlugin/Test/TestMultiTranslation_MultiLevelCompound_v95_3.py b/src/FeaturesPlugin/Test/TestMultiTranslation_MultiLevelCompound_v95_3.py
new file mode 100644 (file)
index 0000000..4b85150
--- /dev/null
@@ -0,0 +1,192 @@
+# Copyright (C) 2020  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 salome.shaper import model
+from GeomAPI import *
+from GeomAlgoAPI import *
+
+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"))
+SketchPoint_1 = Sketch_1.addPoint(44.29784155360136, 17.09942588468031)
+SketchArc_1 = Sketch_1.addArc(44.29784155360136, 17.09942588468031, 47.1668727423061, 12.27945348765633, 45.38299232715926, 22.60269052200972, False)
+SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchPoint_1.coordinates(), SketchArc_1.center())
+SketchLine_1 = Sketch_1.addLine(42.5764228403785, 22.14892077680068, 39.70739165167375, 16.41085839939117)
+SketchLine_2 = Sketch_1.addLine(39.70739165167375, 16.41085839939117, 43.03546783057126, 12.04993099255995)
+SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_2.startPoint())
+SketchLine_3 = Sketch_1.addLine(28.57555063949931, 12.96802097294547, 15.72229091410204, 12.96802097294547)
+SketchLine_4 = Sketch_1.addLine(15.72229091410204, 12.96802097294547, 15.72229091410204, 21.46035329151154)
+SketchLine_5 = Sketch_1.addLine(15.72229091410204, 21.46035329151154, 28.57555063949931, 21.46035329151154)
+SketchLine_6 = Sketch_1.addLine(28.57555063949931, 21.46035329151154, 28.57555063949931, 12.96802097294547)
+SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchLine_6.endPoint(), SketchLine_3.startPoint())
+SketchConstraintCoincidence_4 = Sketch_1.setCoincident(SketchLine_3.endPoint(), SketchLine_4.startPoint())
+SketchConstraintCoincidence_5 = Sketch_1.setCoincident(SketchLine_4.endPoint(), SketchLine_5.startPoint())
+SketchConstraintCoincidence_6 = Sketch_1.setCoincident(SketchLine_5.endPoint(), SketchLine_6.startPoint())
+SketchConstraintHorizontal_1 = Sketch_1.setHorizontal(SketchLine_3.result())
+SketchConstraintVertical_1 = Sketch_1.setVertical(SketchLine_4.result())
+SketchConstraintHorizontal_2 = Sketch_1.setHorizontal(SketchLine_5.result())
+SketchConstraintVertical_2 = Sketch_1.setVertical(SketchLine_6.result())
+SketchLine_7 = Sketch_1.addLine(-10.67279602198167, 14.78814178154371, -28.34602814440294, 14.78814178154371)
+SketchLine_8 = Sketch_1.addLine(-28.34602814440294, 14.78814178154371, -28.34602814440294, 25.13271321305362)
+SketchLine_9 = Sketch_1.addLine(-28.34602814440294, 25.13271321305362, -10.67279602198167, 25.13271321305362)
+SketchLine_10 = Sketch_1.addLine(-10.67279602198167, 25.13271321305362, -10.67279602198167, 14.78814178154371)
+SketchConstraintCoincidence_7 = Sketch_1.setCoincident(SketchLine_10.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())
+SketchConstraintCoincidence_10 = Sketch_1.setCoincident(SketchLine_9.endPoint(), SketchLine_10.startPoint())
+SketchConstraintHorizontal_3 = Sketch_1.setHorizontal(SketchLine_7.result())
+SketchConstraintVertical_3 = Sketch_1.setVertical(SketchLine_8.result())
+SketchConstraintHorizontal_4 = Sketch_1.setHorizontal(SketchLine_9.result())
+SketchConstraintVertical_4 = Sketch_1.setVertical(SketchLine_10.result())
+SketchLine_11 = Sketch_1.addLine(-17.67323212242127, 25.13271321305362, -21.80463703415611, 14.78814178154371)
+SketchConstraintCoincidence_11 = Sketch_1.setCoincident(SketchLine_11.startPoint(), SketchLine_9.result())
+SketchConstraintCoincidence_12 = Sketch_1.setCoincident(SketchLine_11.endPoint(), SketchLine_7.result())
+model.do()
+Vertex_1 = model.addVertex(Part_1_doc, [model.selection("VERTEX", "Sketch_1/SketchArc_1")], False)
+Edge_1 = model.addEdge(Part_1_doc, [model.selection("EDGE", "Sketch_1/SketchArc_1_2")], False)
+Wire_1 = model.addWire(Part_1_doc, [model.selection("EDGE", "Sketch_1/SketchLine_1"), model.selection("EDGE", "Sketch_1/SketchLine_2")], False)
+Face_1 = model.addFace(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_6r-SketchLine_5r-SketchLine_4r-SketchLine_3r")])
+Shell_1 = model.addShell(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_10r-SketchLine_9r-SketchLine_11f-SketchLine_7r"), model.selection("FACE", "Sketch_1/Face-SketchLine_11r-SketchLine_9r-SketchLine_8r-SketchLine_7r")])
+Box_1 = model.addBox(Part_1_doc, 10, 10, 10)
+Translation_1 = model.addTranslation(Part_1_doc, [model.selection("SOLID", "Box_1_1")], model.selection("EDGE", "PartSet/OX"), 50)
+Box_2 = model.addBox(Part_1_doc, 10, 10, 10)
+Cylinder_1 = model.addCylinder(Part_1_doc, model.selection("VERTEX", "PartSet/Origin"), model.selection("EDGE", "PartSet/OZ"), 5, 10)
+Partition_1 = model.addPartition(Part_1_doc, [model.selection("SOLID", "Box_2_1"), model.selection("SOLID", "Cylinder_1_1")], keepSubResults = True)
+Box_3 = model.addBox(Part_1_doc, 10, 10, 10)
+Translation_2 = model.addTranslation(Part_1_doc, [model.selection("SOLID", "Box_3_1")], model.selection("EDGE", "PartSet/OY"), 50)
+AngularCopy_1 = model.addMultiRotation(Part_1_doc, [model.selection("SOLID", "Translation_2_1")], model.selection("EDGE", "PartSet/OZ"), 30, 3)
+model.end()
+
+TOLERANCE = 1.e-7
+DISTANCE = 20
+COPIES = 2
+
+
+model.begin()
+MultiTranslation_1 = model.addMultiTranslation(Part_1_doc, [model.selection("VERTEX", "Vertex_1_1")], model.selection("EDGE", "PartSet/OZ"), DISTANCE, COPIES, keepSubResults = True)
+model.testNbResults(MultiTranslation_1, 1)
+model.testNbSubResults(MultiTranslation_1, [COPIES])
+model.testNbSubShapes(MultiTranslation_1, GeomAPI_Shape.SOLID, [0])
+model.testNbSubShapes(MultiTranslation_1, GeomAPI_Shape.FACE, [0])
+model.testNbSubShapes(MultiTranslation_1, GeomAPI_Shape.EDGE, [0])
+model.testNbSubShapes(MultiTranslation_1, GeomAPI_Shape.VERTEX, [COPIES])
+model.testResultsVolumes(MultiTranslation_1, [0])
+refPoint = Vertex_1.defaultResult().shape().middlePoint()
+refPoint.setZ(refPoint.z() + DISTANCE / 2 * (COPIES - 1))
+midPoint = MultiTranslation_1.defaultResult().shape().middlePoint()
+assert(midPoint.distance(refPoint) < TOLERANCE)
+
+MultiTranslation_2 = model.addMultiTranslation(Part_1_doc, [model.selection("EDGE", "Edge_1_1")], model.selection("EDGE", "PartSet/OZ"), DISTANCE, COPIES, keepSubResults = True)
+model.testNbResults(MultiTranslation_2, 1)
+model.testNbSubResults(MultiTranslation_2, [COPIES])
+model.testNbSubShapes(MultiTranslation_2, GeomAPI_Shape.SOLID, [0])
+model.testNbSubShapes(MultiTranslation_2, GeomAPI_Shape.FACE, [0])
+model.testNbSubShapes(MultiTranslation_2, GeomAPI_Shape.EDGE, [COPIES])
+model.testNbSubShapes(MultiTranslation_2, GeomAPI_Shape.VERTEX, [2 * COPIES])
+model.testResultsVolumes(MultiTranslation_2, [0])
+comp = GeomAlgoAPI_CompoundBuilder.compound([Edge_1.defaultResult().shape()])
+refPoint = comp.middlePoint()
+refPoint.setZ(refPoint.z() + DISTANCE / 2 * (COPIES - 1))
+midPoint = MultiTranslation_2.defaultResult().shape().middlePoint()
+assert(midPoint.distance(refPoint) < TOLERANCE)
+
+MultiTranslation_3 = model.addMultiTranslation(Part_1_doc, [model.selection("WIRE", "Wire_1_1")], model.selection("EDGE", "PartSet/OZ"), DISTANCE, COPIES, keepSubResults = True)
+model.testNbResults(MultiTranslation_3, 1)
+model.testNbSubResults(MultiTranslation_3, [COPIES])
+model.testNbSubShapes(MultiTranslation_3, GeomAPI_Shape.SOLID, [0])
+model.testNbSubShapes(MultiTranslation_3, GeomAPI_Shape.FACE, [0])
+model.testNbSubShapes(MultiTranslation_3, GeomAPI_Shape.EDGE, [2 * COPIES])
+model.testNbSubShapes(MultiTranslation_3, GeomAPI_Shape.VERTEX, [4 * COPIES])
+model.testResultsVolumes(MultiTranslation_3, [0])
+comp = GeomAlgoAPI_CompoundBuilder.compound([Wire_1.defaultResult().shape()])
+refPoint = comp.middlePoint()
+refPoint.setZ(refPoint.z() + DISTANCE / 2 * (COPIES - 1))
+midPoint = MultiTranslation_3.defaultResult().shape().middlePoint()
+assert(midPoint.distance(refPoint) < TOLERANCE)
+
+MultiTranslation_4 = model.addMultiTranslation(Part_1_doc, [model.selection("FACE", "Face_1_1")], model.selection("EDGE", "PartSet/OZ"), DISTANCE, COPIES, keepSubResults = True)
+model.testNbResults(MultiTranslation_4, 1)
+model.testNbSubResults(MultiTranslation_4, [COPIES])
+model.testNbSubShapes(MultiTranslation_4, GeomAPI_Shape.SOLID, [0])
+model.testNbSubShapes(MultiTranslation_4, GeomAPI_Shape.FACE, [COPIES])
+model.testNbSubShapes(MultiTranslation_4, GeomAPI_Shape.EDGE, [4 * COPIES])
+model.testNbSubShapes(MultiTranslation_4, GeomAPI_Shape.VERTEX, [8 * COPIES])
+model.testResultsVolumes(MultiTranslation_4, [109.154152964914914 * COPIES])
+refPoint = Face_1.defaultResult().shape().middlePoint()
+refPoint.setZ(refPoint.z() + DISTANCE / 2 * (COPIES - 1))
+midPoint = MultiTranslation_4.defaultResult().shape().middlePoint()
+assert(midPoint.distance(refPoint) < TOLERANCE)
+
+MultiTranslation_5 = model.addMultiTranslation(Part_1_doc, [model.selection("SHELL", "Shell_1_1")], model.selection("EDGE", "PartSet/OZ"), DISTANCE, COPIES, keepSubResults = True)
+model.testNbResults(MultiTranslation_5, 1)
+model.testNbSubResults(MultiTranslation_5, [COPIES])
+model.testNbSubShapes(MultiTranslation_5, GeomAPI_Shape.SOLID, [0])
+model.testNbSubShapes(MultiTranslation_5, GeomAPI_Shape.FACE, [2 * COPIES])
+model.testNbSubShapes(MultiTranslation_5, GeomAPI_Shape.EDGE, [8 * COPIES])
+model.testNbSubShapes(MultiTranslation_5, GeomAPI_Shape.VERTEX, [16 * COPIES])
+model.testResultsVolumes(MultiTranslation_5, [182.822012116 * COPIES])
+refPoint = Shell_1.defaultResult().shape().middlePoint()
+refPoint.setZ(refPoint.z() + DISTANCE / 2 * (COPIES - 1))
+midPoint = MultiTranslation_5.defaultResult().shape().middlePoint()
+assert(midPoint.distance(refPoint) < TOLERANCE)
+
+MultiTranslation_6 = model.addMultiTranslation(Part_1_doc, [model.selection("SOLID", "Translation_1_1")], model.selection("EDGE", "PartSet/OZ"), DISTANCE, COPIES, keepSubResults = True)
+model.testNbResults(MultiTranslation_6, 1)
+model.testNbSubResults(MultiTranslation_6, [COPIES])
+model.testNbSubShapes(MultiTranslation_6, GeomAPI_Shape.SOLID, [COPIES])
+model.testNbSubShapes(MultiTranslation_6, GeomAPI_Shape.FACE, [6 * COPIES])
+model.testNbSubShapes(MultiTranslation_6, GeomAPI_Shape.EDGE, [24 * COPIES])
+model.testNbSubShapes(MultiTranslation_6, GeomAPI_Shape.VERTEX, [48 * COPIES])
+model.testResultsVolumes(MultiTranslation_6, [1000 * COPIES])
+refPoint = Translation_1.defaultResult().shape().middlePoint()
+refPoint.setZ(refPoint.z() + DISTANCE / 2 * (COPIES - 1))
+midPoint = MultiTranslation_6.defaultResult().shape().middlePoint()
+assert(midPoint.distance(refPoint) < TOLERANCE)
+
+MultiTranslation_7 = model.addMultiTranslation(Part_1_doc, [model.selection("COMPSOLID", "Partition_1_1")], model.selection("EDGE", "PartSet/OZ"), DISTANCE, COPIES, keepSubResults = True)
+model.testNbResults(MultiTranslation_7, 1)
+model.testNbSubResults(MultiTranslation_7, [COPIES])
+model.testNbSubShapes(MultiTranslation_7, GeomAPI_Shape.SOLID, [3 * COPIES])
+model.testNbSubShapes(MultiTranslation_7, GeomAPI_Shape.FACE, [17 * COPIES])
+model.testNbSubShapes(MultiTranslation_7, GeomAPI_Shape.EDGE, [66 * COPIES])
+model.testNbSubShapes(MultiTranslation_7, GeomAPI_Shape.VERTEX, [132 * COPIES])
+model.testResultsVolumes(MultiTranslation_7, [1589.0486226 * COPIES])
+refPoint = Partition_1.defaultResult().shape().middlePoint()
+refPoint.setZ(refPoint.z() + DISTANCE / 2 * (COPIES - 1))
+midPoint = MultiTranslation_7.defaultResult().shape().middlePoint()
+assert(midPoint.distance(refPoint) < TOLERANCE)
+
+MultiTranslation_8 = model.addMultiTranslation(Part_1_doc, [model.selection("COMPOUND", "AngularCopy_1_1")], model.selection("EDGE", "PartSet/OZ"), DISTANCE, COPIES, keepSubResults = True)
+model.testNbResults(MultiTranslation_8, 1)
+model.testNbSubResults(MultiTranslation_8, [COPIES])
+model.testNbSubShapes(MultiTranslation_8, GeomAPI_Shape.SOLID, [3 * COPIES])
+model.testNbSubShapes(MultiTranslation_8, GeomAPI_Shape.FACE, [18 * COPIES])
+model.testNbSubShapes(MultiTranslation_8, GeomAPI_Shape.EDGE, [72 * COPIES])
+model.testNbSubShapes(MultiTranslation_8, GeomAPI_Shape.VERTEX, [144 * COPIES])
+model.testResultsVolumes(MultiTranslation_8, [3000 * COPIES])
+refPoint = AngularCopy_1.defaultResult().shape().middlePoint()
+refPoint.setZ(refPoint.z() + DISTANCE / 2 * (COPIES - 1))
+midPoint = MultiTranslation_8.defaultResult().shape().middlePoint()
+assert(midPoint.distance(refPoint) < TOLERANCE)
+
+model.end()
+
+assert(model.checkPythonDump())
diff --git a/src/FeaturesPlugin/Test/TestMultiTranslation_MultiLevelCompound_v95_4.py b/src/FeaturesPlugin/Test/TestMultiTranslation_MultiLevelCompound_v95_4.py
new file mode 100644 (file)
index 0000000..4c87612
--- /dev/null
@@ -0,0 +1,169 @@
+# Copyright (C) 2020  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 salome.shaper import model
+from GeomAPI import *
+
+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"))
+SketchPoint_1 = Sketch_1.addPoint(44.29784155360136, 17.09942588468031)
+SketchArc_1 = Sketch_1.addArc(44.29784155360136, 17.09942588468031, 47.1668727423061, 12.27945348765633, 45.38299232715926, 22.60269052200972, False)
+SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchPoint_1.coordinates(), SketchArc_1.center())
+SketchLine_1 = Sketch_1.addLine(42.5764228403785, 22.14892077680068, 39.70739165167375, 16.41085839939117)
+SketchLine_2 = Sketch_1.addLine(39.70739165167375, 16.41085839939117, 43.03546783057126, 12.04993099255995)
+SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_2.startPoint())
+SketchLine_3 = Sketch_1.addLine(28.57555063949931, 12.96802097294547, 15.72229091410204, 12.96802097294547)
+SketchLine_4 = Sketch_1.addLine(15.72229091410204, 12.96802097294547, 15.72229091410204, 21.46035329151154)
+SketchLine_5 = Sketch_1.addLine(15.72229091410204, 21.46035329151154, 28.57555063949931, 21.46035329151154)
+SketchLine_6 = Sketch_1.addLine(28.57555063949931, 21.46035329151154, 28.57555063949931, 12.96802097294547)
+SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchLine_6.endPoint(), SketchLine_3.startPoint())
+SketchConstraintCoincidence_4 = Sketch_1.setCoincident(SketchLine_3.endPoint(), SketchLine_4.startPoint())
+SketchConstraintCoincidence_5 = Sketch_1.setCoincident(SketchLine_4.endPoint(), SketchLine_5.startPoint())
+SketchConstraintCoincidence_6 = Sketch_1.setCoincident(SketchLine_5.endPoint(), SketchLine_6.startPoint())
+SketchConstraintHorizontal_1 = Sketch_1.setHorizontal(SketchLine_3.result())
+SketchConstraintVertical_1 = Sketch_1.setVertical(SketchLine_4.result())
+SketchConstraintHorizontal_2 = Sketch_1.setHorizontal(SketchLine_5.result())
+SketchConstraintVertical_2 = Sketch_1.setVertical(SketchLine_6.result())
+SketchLine_7 = Sketch_1.addLine(-10.67279602198167, 14.78814178154371, -28.34602814440294, 14.78814178154371)
+SketchLine_8 = Sketch_1.addLine(-28.34602814440294, 14.78814178154371, -28.34602814440294, 25.13271321305362)
+SketchLine_9 = Sketch_1.addLine(-28.34602814440294, 25.13271321305362, -10.67279602198167, 25.13271321305362)
+SketchLine_10 = Sketch_1.addLine(-10.67279602198167, 25.13271321305362, -10.67279602198167, 14.78814178154371)
+SketchConstraintCoincidence_7 = Sketch_1.setCoincident(SketchLine_10.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())
+SketchConstraintCoincidence_10 = Sketch_1.setCoincident(SketchLine_9.endPoint(), SketchLine_10.startPoint())
+SketchConstraintHorizontal_3 = Sketch_1.setHorizontal(SketchLine_7.result())
+SketchConstraintVertical_3 = Sketch_1.setVertical(SketchLine_8.result())
+SketchConstraintHorizontal_4 = Sketch_1.setHorizontal(SketchLine_9.result())
+SketchConstraintVertical_4 = Sketch_1.setVertical(SketchLine_10.result())
+SketchLine_11 = Sketch_1.addLine(-17.67323212242127, 25.13271321305362, -21.80463703415611, 14.78814178154371)
+SketchConstraintCoincidence_11 = Sketch_1.setCoincident(SketchLine_11.startPoint(), SketchLine_9.result())
+SketchConstraintCoincidence_12 = Sketch_1.setCoincident(SketchLine_11.endPoint(), SketchLine_7.result())
+model.do()
+Vertex_1 = model.addVertex(Part_1_doc, [model.selection("VERTEX", "Sketch_1/SketchArc_1")], False)
+Edge_1 = model.addEdge(Part_1_doc, [model.selection("EDGE", "Sketch_1/SketchArc_1_2")], False)
+Wire_1 = model.addWire(Part_1_doc, [model.selection("EDGE", "Sketch_1/SketchLine_1"), model.selection("EDGE", "Sketch_1/SketchLine_2")], False)
+Face_1 = model.addFace(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_6r-SketchLine_5r-SketchLine_4r-SketchLine_3r")])
+Shell_1 = model.addShell(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_10r-SketchLine_9r-SketchLine_11f-SketchLine_7r"), model.selection("FACE", "Sketch_1/Face-SketchLine_11r-SketchLine_9r-SketchLine_8r-SketchLine_7r")])
+Box_1 = model.addBox(Part_1_doc, 10, 10, 10)
+Translation_1 = model.addTranslation(Part_1_doc, [model.selection("SOLID", "Box_1_1")], model.selection("EDGE", "PartSet/OX"), 50)
+Box_2 = model.addBox(Part_1_doc, 10, 10, 10)
+Cylinder_1 = model.addCylinder(Part_1_doc, model.selection("VERTEX", "PartSet/Origin"), model.selection("EDGE", "PartSet/OZ"), 5, 10)
+Partition_1 = model.addPartition(Part_1_doc, [model.selection("SOLID", "Box_2_1"), model.selection("SOLID", "Cylinder_1_1")], keepSubResults = True)
+Box_3 = model.addBox(Part_1_doc, 10, 10, 10)
+Translation_2 = model.addTranslation(Part_1_doc, [model.selection("SOLID", "Box_3_1")], model.selection("EDGE", "PartSet/OY"), 50)
+AngularCopy_1 = model.addMultiRotation(Part_1_doc, [model.selection("SOLID", "Translation_2_1")], model.selection("EDGE", "PartSet/OZ"), 30, 3)
+Compound_1_objects = [model.selection("VERTEX", "Vertex_1_1"), model.selection("EDGE", "Edge_1_1"), model.selection("WIRE", "Wire_1_1"), model.selection("FACE", "Face_1_1"), model.selection("SHELL", "Shell_1_1"), model.selection("SOLID", "Translation_1_1"), model.selection("COMPSOLID", "Partition_1_1"), model.selection("COMPOUND", "AngularCopy_1_1")]
+Compound_1 = model.addCompound(Part_1_doc, Compound_1_objects)
+model.end()
+
+TOLERANCE = 1.e-7
+DISTANCE = 20
+COPIES = 2
+
+NB_SOLIDS = 7
+NB_FACES = 44
+NB_EDGES = 177
+NB_VERTICES = 355
+VOLUME = 5589.0486226
+
+# collect reference data
+REFERENCE = []
+for ind in range(0, Compound_1.result().numberOfSubs()):
+    p = Compound_1.result().subResult(ind).resultSubShapePair()[1].middlePoint()
+    REFERENCE.append(p)
+
+def assertResult(theFeature, theNbMoved):
+    model.testNbResults(theFeature, 1)
+    model.testNbSubResults(theFeature, [8])
+    model.testNbSubShapes(theFeature, GeomAPI_Shape.SOLID, [NB_SOLIDS])
+    model.testNbSubShapes(theFeature, GeomAPI_Shape.FACE, [NB_FACES])
+    model.testNbSubShapes(theFeature, GeomAPI_Shape.EDGE, [NB_EDGES])
+    model.testNbSubShapes(theFeature, GeomAPI_Shape.VERTEX, [NB_VERTICES])
+    model.testResultsVolumes(theFeature, [VOLUME])
+
+    for ind in range(0, theFeature.result().numberOfSubs()):
+        ref = GeomAPI_Pnt(REFERENCE[ind].x(), REFERENCE[ind].y(), REFERENCE[ind].z())
+        if ind < theNbMoved:
+            ref.setZ(ref.z() + DISTANCE / 2 * (COPIES - 1))
+        midPoint = theFeature.result().subResult(ind).resultSubShapePair()[0].shape().middlePoint()
+        assert(midPoint.distance(ref) < TOLERANCE), "Sub-result {}; actual ({}, {}, {}) != expected ({}, {}, {})".format(ind, midPoint.x(), midPoint.y(), midPoint.z(), ref.x(), ref.y(), ref.z())
+
+
+model.begin()
+MultiTranslation_1 = model.addMultiTranslation(Part_1_doc, [model.selection("VERTEX", "Compound_1_1_1")], model.selection("EDGE", "PartSet/OZ"), DISTANCE, COPIES, keepSubResults = True)
+NB_VERTICES += COPIES - 1
+assertResult(MultiTranslation_1, 1)
+
+MultiTranslation_2 = model.addMultiTranslation(Part_1_doc, [model.selection("EDGE", "LinearCopy_1_1_2")], model.selection("EDGE", "PartSet/OZ"), DISTANCE, COPIES, keepSubResults = True)
+c = GeomAlgoAPI_CompoundBuilder.compound([Edge_1.defaultResult().shape()])
+REFERENCE[1] = c.middlePoint()
+NB_EDGES += COPIES - 1
+NB_VERTICES += 2 * (COPIES - 1)
+assertResult(MultiTranslation_2, 2)
+
+MultiTranslation_3 = model.addMultiTranslation(Part_1_doc, [model.selection("WIRE", "LinearCopy_2_1_3")], model.selection("EDGE", "PartSet/OZ"), DISTANCE, COPIES, keepSubResults = True)
+c = GeomAlgoAPI_CompoundBuilder.compound([Wire_1.defaultResult().shape()])
+REFERENCE[2] = c.middlePoint()
+NB_EDGES += 2 * (COPIES - 1)
+NB_VERTICES += 4 * (COPIES - 1)
+assertResult(MultiTranslation_3, 3)
+
+MultiTranslation_4 = model.addMultiTranslation(Part_1_doc, [model.selection("FACE", "LinearCopy_3_1_4")], model.selection("EDGE", "PartSet/OZ"), DISTANCE, COPIES, keepSubResults = True)
+NB_FACES += COPIES - 1
+NB_EDGES += 4 * (COPIES - 1)
+NB_VERTICES += 8 * (COPIES - 1)
+assertResult(MultiTranslation_4, 4)
+
+MultiTranslation_5 = model.addMultiTranslation(Part_1_doc, [model.selection("SHELL", "LinearCopy_4_1_5")], model.selection("EDGE", "PartSet/OZ"), DISTANCE, COPIES, keepSubResults = True)
+NB_FACES += 2 * (COPIES - 1)
+NB_EDGES += 8 * (COPIES - 1)
+NB_VERTICES += 16 * (COPIES - 1)
+assertResult(MultiTranslation_5, 5)
+
+MultiTranslation_6 = model.addMultiTranslation(Part_1_doc, [model.selection("SOLID", "LinearCopy_5_1_6")], model.selection("EDGE", "PartSet/OZ"), DISTANCE, COPIES, keepSubResults = True)
+NB_SOLIDS += COPIES - 1
+NB_FACES += 6 * (COPIES - 1)
+NB_EDGES += 24 * (COPIES - 1)
+NB_VERTICES += 48 * (COPIES - 1)
+VOLUME += 1000 * (COPIES - 1)
+assertResult(MultiTranslation_6, 6)
+
+MultiTranslation_7 = model.addMultiTranslation(Part_1_doc, [model.selection("COMPSOLID", "LinearCopy_6_1_7")], model.selection("EDGE", "PartSet/OZ"), DISTANCE, COPIES, keepSubResults = True)
+NB_SOLIDS += 3 * (COPIES - 1)
+NB_FACES += 17 * (COPIES - 1)
+NB_EDGES += 66 * (COPIES - 1)
+NB_VERTICES += 132 * (COPIES - 1)
+VOLUME += 1589.0486226 * (COPIES - 1)
+assertResult(MultiTranslation_7, 7)
+
+MultiTranslation_8 = model.addMultiTranslation(Part_1_doc, [model.selection("COMPOUND", "LinearCopy_7_1_8")], model.selection("EDGE", "PartSet/OZ"), DISTANCE, COPIES, keepSubResults = True)
+NB_SOLIDS += 3 * (COPIES - 1)
+NB_FACES += 18 * (COPIES - 1)
+NB_EDGES += 72 * (COPIES - 1)
+NB_VERTICES += 144 * (COPIES - 1)
+VOLUME += 3000 * (COPIES - 1)
+assertResult(MultiTranslation_8, 8)
+
+model.end()
+
+assert(model.checkPythonDump())
index ce706bb9a4faa70c840801486b2b0fc1d013025d..7594a8e8af6995487d5bb9918a20b58ab9a42bf0 100644 (file)
@@ -131,15 +131,18 @@ namespace ModelGeomAlgo_Shape
     aSR.mySubshape = theSubshape;
     aSR.myCenterType = theCenterType;
     // compound subshapes from other compounds should be processed as whole results
-    if (aSR.mySubshape && aSR.mySubshape->shapeType() == GeomAPI_Shape::COMPOUND &&
-        !theResult->shape()->isEqual(theSubshape)) {
-      ResultBodyPtr aResult = std::dynamic_pointer_cast<ModelAPI_ResultBody>(theResult);
-      for (int i = 0; aResult && i < aResult->numberOfSubs(); ++i) {
-        ResultBodyPtr aSub = aResult->subResult(i);
-        if (aSub->shape()->isEqual(theSubshape)) {
-          aSR.myResult = aSub;
-          aSR.mySubshape = GeomShapePtr();
-          break;
+    if (aSR.mySubshape && aSR.mySubshape->shapeType() <= GeomAPI_Shape::COMPSOLID) {
+      if (theResult->shape()->isEqual(theSubshape))
+        aSR.mySubshape = GeomShapePtr();
+      else {
+        ResultBodyPtr aResult = std::dynamic_pointer_cast<ModelAPI_ResultBody>(theResult);
+        for (int i = 0; aResult && i < aResult->numberOfSubs(); ++i) {
+          ResultBodyPtr aSub = aResult->subResult(i);
+          if (aSub->shape()->isEqual(theSubshape)) {
+            aSR.myResult = aSub;
+            aSR.mySubshape = GeomShapePtr();
+            break;
+          }
         }
       }
     }
index 33c52647d98ef1009250ab14075a844c7f387869..0f0078a3a550c49afc978457bce7eb911ff14f35 100644 (file)
@@ -21,6 +21,8 @@
 
 #include <ModelAPI_AttributeDouble.h>
 #include <GeomDataAPI_Point.h>
+
+#include <sstream>
 //--------------------------------------------------------------------------------------
 
 //--------------------------------------------------------------------------------------
@@ -52,6 +54,16 @@ double ModelHighAPI_Double::value() const
   return myDouble;
 }
 
+std::string ModelHighAPI_Double::string() const
+{
+  if (myVariantType == VT_STRING)
+    return myString;
+
+  std::ostringstream anOut;
+  anOut << myDouble;
+  return anOut.str();
+}
+
 //--------------------------------------------------------------------------------------
 void ModelHighAPI_Double::fillAttribute(
     const std::shared_ptr<ModelAPI_AttributeDouble> & theAttribute) const
index 9fe5df5369c272b49df1379bd0ba261fd5739f10..7aef756b9d7cdb5baed8effcc25ffc8c9eded51e 100644 (file)
@@ -63,6 +63,9 @@ public:
   /// Value of the attribute
   MODELHIGHAPI_EXPORT double value() const;
 
+  /// Returns a string representation of the value
+  MODELHIGHAPI_EXPORT virtual std::string string() const;
+
 private:
   enum VariantType { VT_DOUBLE, VT_STRING } myVariantType;
   double myDouble;
index 8691146f9a63d6f119048661d37b7389e8930bda..c76a3a963f59c4503957bdf0441374581ebb7d7f 100644 (file)
@@ -20,6 +20,8 @@
 #include "ModelHighAPI_Integer.h"
 
 #include <ModelAPI_AttributeInteger.h>
+
+#include <sstream>
 //--------------------------------------------------------------------------------------
 
 //--------------------------------------------------------------------------------------
@@ -60,3 +62,13 @@ int ModelHighAPI_Integer::intValue() const
   // needed for array of integer, which supports no text
   return myInt;
 }
+
+std::string ModelHighAPI_Integer::string() const
+{
+  if (myVariantType == VT_STRING)
+    return myString;
+
+  std::ostringstream anOut;
+  anOut << myInt;
+  return anOut.str();
+}
index 8fadf90105bfed900557f6558a349df3fe52e27f..d45c63b761473100a19566cc57ee14441e42a322 100644 (file)
@@ -55,6 +55,9 @@ public:
   /// Returns a value (must be used only for attributes which support no text)
   MODELHIGHAPI_EXPORT virtual int intValue() const;
 
+  /// Returns a string representation of the value
+  MODELHIGHAPI_EXPORT virtual std::string string() const;
+
 private:
   enum VariantType { VT_INT, VT_STRING } myVariantType;
   int myInt;