]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Task 3.2. To keep compounds’ sub-shapes for all operations (issue #3139)
authorazv <azv@opencascade.com>
Tue, 18 Feb 2020 11:10:27 +0000 (14:10 +0300)
committerazv <azv@opencascade.com>
Tue, 18 Feb 2020 11:28:10 +0000 (14:28 +0300)
Refactor the Rotation feature.

18 files changed:
src/FeaturesAPI/FeaturesAPI.i
src/FeaturesAPI/FeaturesAPI_Rotation.cpp
src/FeaturesAPI/FeaturesAPI_Rotation.h
src/FeaturesPlugin/CMakeLists.txt
src/FeaturesPlugin/FeaturesPlugin_Rotation.cpp
src/FeaturesPlugin/FeaturesPlugin_Rotation.h
src/FeaturesPlugin/FeaturesPlugin_Translation.cpp
src/FeaturesPlugin/Test/TestRotation_MultiLevelCompound_v0_1.py [new file with mode: 0644]
src/FeaturesPlugin/Test/TestRotation_MultiLevelCompound_v0_2.py [new file with mode: 0644]
src/FeaturesPlugin/Test/TestRotation_MultiLevelCompound_v0_3.py [new file with mode: 0644]
src/FeaturesPlugin/Test/TestRotation_MultiLevelCompound_v0_4.py [new file with mode: 0644]
src/FeaturesPlugin/Test/TestRotation_MultiLevelCompound_v95_1.py [new file with mode: 0644]
src/FeaturesPlugin/Test/TestRotation_MultiLevelCompound_v95_2.py [new file with mode: 0644]
src/FeaturesPlugin/Test/TestRotation_MultiLevelCompound_v95_3.py [new file with mode: 0644]
src/FeaturesPlugin/Test/TestRotation_MultiLevelCompound_v95_4.py [new file with mode: 0644]
src/GeomAPI/GeomAPI_Pnt.cpp
src/GeomAPI/GeomAPI_Pnt.h
src/ModelGeomAlgo/ModelGeomAlgo_Shape.cpp

index 1d3b9358b713af4ab8ced251adae391497afabf9..c2fc5179589d2cc28f7f645f9ad0b9769c54019b 100644 (file)
@@ -43,6 +43,7 @@
 %feature("kwargs") addFuse;
 %feature("kwargs") addPartition;
 %feature("kwargs") addPlacement;
+%feature("kwargs") addRotation;
 %feature("kwargs") addSplit;
 %feature("kwargs") addSmash;
 %feature("kwargs") addTranslation;
index 01c9caebac9fbe3f6d35900de119600b36f39608..1f8f965a0ddca4f1fd47ccd68b77a61ddf825ac3 100644 (file)
@@ -119,7 +119,7 @@ void FeaturesAPI_Rotation::dump(ModelHighAPI_Dumper& theDumper) const
   if (aCreationMethod == FeaturesPlugin_Rotation::CREATION_METHOD_BY_ANGLE()) {
     AttributeSelectionPtr anAttrAxis = aBase->selection(FeaturesPlugin_Rotation::AXIS_OBJECT_ID());
     AttributeDoublePtr anAttrAngle = aBase->real(FeaturesPlugin_Rotation::ANGLE_ID());
-    theDumper << ", " << anAttrAxis << ", " << anAttrAngle;
+    theDumper << ", axis = " << anAttrAxis << ", angle = " << anAttrAngle;
   } else if (aCreationMethod == FeaturesPlugin_Rotation::CREATION_METHOD_BY_THREE_POINTS()) {
     AttributeSelectionPtr anAttrCenterPoint =
       aBase->selection(FeaturesPlugin_Rotation::CENTER_POINT_ID());
@@ -127,30 +127,58 @@ void FeaturesAPI_Rotation::dump(ModelHighAPI_Dumper& theDumper) const
       aBase->selection(FeaturesPlugin_Rotation::START_POINT_ID());
     AttributeSelectionPtr anAttrEndPoint =
       aBase->selection(FeaturesPlugin_Rotation::END_POINT_ID());
-    theDumper << ", " << anAttrCenterPoint << ", " << anAttrStartPoint << ", " << anAttrEndPoint;
+    theDumper << ", center = " << anAttrCenterPoint
+              << ", start = " << anAttrStartPoint
+              << ", end = " << anAttrEndPoint;
   }
 
+  if (!aBase->data()->version().empty())
+    theDumper << ", keepSubResults = True";
+
   theDumper << ")" << std::endl;
 }
 
 //==================================================================================================
-RotationPtr addRotation(const std::shared_ptr<ModelAPI_Document>& thePart,
-                        const std::list<ModelHighAPI_Selection>& theMainObjects,
-                        const ModelHighAPI_Selection& theAxisObject,
-                        const ModelHighAPI_Double& theAngle)
+RotationPtr addRotation(const std::shared_ptr<ModelAPI_Document>& part,
+                        const std::list<ModelHighAPI_Selection>& objects,
+                        const ModelHighAPI_Selection& axis,
+                        const std::pair<ModelHighAPI_Selection, ModelHighAPI_Double>& angle,
+                        const ModelHighAPI_Selection& center,
+                        const ModelHighAPI_Selection& start,
+                        const ModelHighAPI_Selection& end,
+                        const bool keepSubResults)
 {
-  std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(FeaturesAPI_Rotation::ID());
-  return RotationPtr(new FeaturesAPI_Rotation(aFeature, theMainObjects, theAxisObject, theAngle));
-}
+  std::shared_ptr<ModelAPI_Feature> aFeature = part->addFeature(FeaturesAPI_Rotation::ID());
+  if (!keepSubResults)
+    aFeature->data()->setVersion("");
+
+  bool byAxis = false;
+  bool byPoints = false;
+  ModelHighAPI_Selection aPoints[3];
+  if (angle.first.variantType() == ModelHighAPI_Selection::VT_Empty) {
+    if (axis.variantType() == ModelHighAPI_Selection::VT_Empty) {
+      byPoints = true;
+      aPoints[0] = center;
+      aPoints[1] = start;
+      aPoints[2] = end;
+    }
+    else
+      byAxis = true;
+  }
+  else {
+    byPoints = true;
+    aPoints[0] = axis;
+    aPoints[1] = angle.first;
+    aPoints[2] = center;
+  }
 
-//==================================================================================================
-RotationPtr addRotation(const std::shared_ptr<ModelAPI_Document>& thePart,
-                        const std::list<ModelHighAPI_Selection>& theMainObjects,
-                        const ModelHighAPI_Selection& theCenterPoint,
-                        const ModelHighAPI_Selection& theStartPoint,
-                        const ModelHighAPI_Selection& theEndPoint)
-{
-  std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(FeaturesAPI_Rotation::ID());
-  return RotationPtr(new FeaturesAPI_Rotation(aFeature, theMainObjects, theCenterPoint,
-                                              theStartPoint, theEndPoint));
+
+  RotationPtr aRotation;
+  if (byAxis)
+    aRotation.reset(new FeaturesAPI_Rotation(aFeature, objects, axis, angle.second));
+  else if (byPoints) {
+    aRotation.reset(new FeaturesAPI_Rotation(aFeature, objects,
+                                             aPoints[0], aPoints[1], aPoints[2]));
+  }
+  return aRotation;
 }
index f11c8e35faca727885e1820edbb7abd19b5231ce..3139fc3495bdcf06256c34782979b893616c8647 100644 (file)
 
 #include <FeaturesPlugin_Rotation.h>
 
+#include <ModelHighAPI_Double.h>
 #include <ModelHighAPI_Interface.h>
 #include <ModelHighAPI_Macro.h>
+#include <ModelHighAPI_Selection.h>
 
-class ModelHighAPI_Double;
 class ModelHighAPI_Dumper;
-class ModelHighAPI_Selection;
 
 /// \class FeaturesAPI_Rotation
 /// \ingroup CPPHighAPI
@@ -103,21 +103,19 @@ public:
 /// Pointer on Rotation object.
 typedef std::shared_ptr<FeaturesAPI_Rotation> RotationPtr;
 
-/// \ingroup CPPHighAPI
-/// \brief Create Rotation feature.
-FEATURESAPI_EXPORT
-RotationPtr addRotation(const std::shared_ptr<ModelAPI_Document>& thePart,
-                        const std::list<ModelHighAPI_Selection>& theMainObjects,
-                        const ModelHighAPI_Selection& theAxisObject,
-                        const ModelHighAPI_Double& theAngle);
+
+#define DUMMY std::pair<ModelHighAPI_Selection, ModelHighAPI_Double>()
 
 /// \ingroup CPPHighAPI
 /// \brief Create Rotation feature.
-FEATURESAPI_EXPORT
-RotationPtr addRotation(const std::shared_ptr<ModelAPI_Document>& thePart,
-                        const std::list<ModelHighAPI_Selection>& theMainObjects,
-                        const ModelHighAPI_Selection& theCenterPoint,
-                        const ModelHighAPI_Selection& theStartPoint,
-                        const ModelHighAPI_Selection& theEndPoint);
+FEATURESAPI_EXPORT RotationPtr addRotation(
+    const std::shared_ptr<ModelAPI_Document>& part,
+    const std::list<ModelHighAPI_Selection>& objects,
+    const ModelHighAPI_Selection& axis = ModelHighAPI_Selection(),
+    const std::pair<ModelHighAPI_Selection, ModelHighAPI_Double>& angle = DUMMY,
+    const ModelHighAPI_Selection& center = ModelHighAPI_Selection(),
+    const ModelHighAPI_Selection& start = ModelHighAPI_Selection(),
+    const ModelHighAPI_Selection& end = ModelHighAPI_Selection(),
+    const bool keepSubResults = false);
 
 #endif // FeaturesAPI_Rotation_H_
index 2ccf72390520dd48377bcad6fdd3775571537aa9..50f6c7b016253ec6819906b52cfb2d4714f8b196 100644 (file)
@@ -591,4 +591,12 @@ ADD_UNIT_TESTS(TestExtrusion.py
                TestTranslation_MultiLevelCompound_v95_3.py
                TestTranslation_MultiLevelCompound_v95_4.py
                TestTranslation_MultiLevelCompound_v95_5.py
+               TestRotation_MultiLevelCompound_v0_1.py
+               TestRotation_MultiLevelCompound_v0_2.py
+               TestRotation_MultiLevelCompound_v0_3.py
+               TestRotation_MultiLevelCompound_v0_4.py
+               TestRotation_MultiLevelCompound_v95_1.py
+               TestRotation_MultiLevelCompound_v95_2.py
+               TestRotation_MultiLevelCompound_v95_3.py
+               TestRotation_MultiLevelCompound_v95_4.py
 )
index eee97cad3282e1064139ba09324f28babdba8012..1fe1e6a2ea2d1e92916acb1e91865dc19405db89 100644 (file)
 #include <ModelAPI_ResultBody.h>
 #include <ModelAPI_ResultPart.h>
 
+#include <GeomAlgoAPI_MakeShapeList.h>
 #include <GeomAlgoAPI_PointBuilder.h>
+#include <GeomAlgoAPI_Rotation.h>
 #include <GeomAlgoAPI_Tools.h>
 
 #include <GeomAPI_Ax1.h>
 #include <GeomAPI_Edge.h>
 #include <GeomAPI_Lin.h>
 #include <GeomAPI_ShapeIterator.h>
+#include <GeomAPI_ShapeHierarchy.h>
 #include <GeomAPI_Trsf.h>
 
 #include <FeaturesPlugin_Tools.h>
 
+static const std::string ROTATION_VERSION_1("v9.5");
+
 //=================================================================================================
 FeaturesPlugin_Rotation::FeaturesPlugin_Rotation()
 {
@@ -61,6 +66,11 @@ void FeaturesPlugin_Rotation::initAttributes()
                        ModelAPI_AttributeSelection::typeId());
   data()->addAttribute(FeaturesPlugin_Rotation::END_POINT_ID(),
                        ModelAPI_AttributeSelection::typeId());
+
+  if (!aSelection->isInitialized()) {
+    // new feature, not read from file
+    data()->setVersion(ROTATION_VERSION_1);
+  }
 }
 
 //=================================================================================================
@@ -69,37 +79,18 @@ void FeaturesPlugin_Rotation::execute()
   AttributeStringPtr aMethodTypeAttr = string(FeaturesPlugin_Rotation::CREATION_METHOD());
   std::string aMethodType = aMethodTypeAttr->value();
 
-  if (aMethodType == CREATION_METHOD_BY_ANGLE()) {
-    performTranslationByAxisAndAngle();
-  }
+  GeomTrsfPtr aTrsf;
+  if (aMethodType == CREATION_METHOD_BY_ANGLE())
+    aTrsf = rotationByAxisAndAngle();
+  else if (aMethodType == CREATION_METHOD_BY_THREE_POINTS())
+    aTrsf = rotationByThreePoints();
 
-  if (aMethodType == CREATION_METHOD_BY_THREE_POINTS()) {
-    performTranslationByThreePoints();
-  }
+  performRotation(aTrsf);
 }
 
 //=================================================================================================
-void FeaturesPlugin_Rotation::performTranslationByAxisAndAngle()
+GeomTrsfPtr FeaturesPlugin_Rotation::rotationByAxisAndAngle()
 {
-  // Getting objects.
-  ListOfShape anObjects;
-  std::list<ResultPtr> aContextes;
-  AttributeSelectionListPtr anObjectsSelList =
-    selectionList(FeaturesPlugin_Rotation::OBJECTS_LIST_ID());
-  if (anObjectsSelList->size() == 0) {
-    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()) {
-      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_OBJECT_ID());
@@ -111,7 +102,7 @@ void FeaturesPlugin_Rotation::performTranslationByAxisAndAngle()
   }
   if (!aShape.get()) {
     setError(aSelectionError);
-    return;
+    return GeomTrsfPtr();
   }
 
   GeomEdgePtr anEdge;
@@ -128,83 +119,21 @@ void FeaturesPlugin_Rotation::performTranslationByAxisAndAngle()
   if (!anEdge.get())
   {
     setError(aSelectionError);
-    return;
+    return GeomTrsfPtr();
   }
 
   std::shared_ptr<GeomAPI_Ax1> anAxis (new GeomAPI_Ax1(anEdge->line()->location(),
                                                        anEdge->line()->direction()));
-
-  // Getting angle.
   double anAngle = real(FeaturesPlugin_Rotation::ANGLE_ID())->value();
 
-  // Rotating 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();
-
-    // Setting result.
-    if (isPart) {
-      std::shared_ptr<GeomAPI_Trsf> aTrsf(new GeomAPI_Trsf());
-      aTrsf->setRotation(anAxis, anAngle);
-      ResultPartPtr anOrigin = std::dynamic_pointer_cast<ModelAPI_ResultPart>(*aContext);
-      ResultPartPtr aResultPart = document()->copyPart(anOrigin, data(), aResultIndex);
-      aResultPart->setTrsf(*aContext, aTrsf);
-      setResult(aResultPart, aResultIndex);
-    } else {
-      std::shared_ptr<GeomAlgoAPI_Rotation> aRotationAlgo(new GeomAlgoAPI_Rotation(aBaseShape,
-                                                                                   anAxis,
-                                                                                   anAngle));
-      // Checking that the algorithm worked properly.
-      if (GeomAlgoAPI_Tools::AlgoError::isAlgorithmFailed(aRotationAlgo, getKind(), anError)) {
-        setError(anError);
-        break;
-      }
-
-      ResultBodyPtr aResultBody = document()->createBody(data(), aResultIndex);
-
-      ListOfShape aShapes;
-      aShapes.push_back(aBaseShape);
-      FeaturesPlugin_Tools::loadModifiedShapes(aResultBody,
-                                               aShapes,
-                                               ListOfShape(),
-                                               aRotationAlgo,
-                                               aRotationAlgo->shape(),
-                                               "Rotated");
-      setResult(aResultBody, aResultIndex);
-    }
-    aResultIndex++;
-  }
-
-  // Remove the rest results if there were produced in the previous pass.
-  removeResults(aResultIndex);
+  GeomTrsfPtr aTrsf(new GeomAPI_Trsf());
+  aTrsf->setRotation(anAxis, anAngle);
+  return aTrsf;
 }
 
 //=================================================================================================
-void FeaturesPlugin_Rotation::performTranslationByThreePoints()
+GeomTrsfPtr FeaturesPlugin_Rotation::rotationByThreePoints()
 {
-  // Getting objects.
-  ListOfShape anObjects;
-  std::list<ResultPtr> aContextes;
-  AttributeSelectionListPtr anObjectsSelList =
-    selectionList(FeaturesPlugin_Rotation::OBJECTS_LIST_ID());
-  if (anObjectsSelList->size() == 0) {
-    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()) {
-      return;
-    }
-    anObjects.push_back(anObject);
-    aContextes.push_back(anObjectAttr->context());
-  }
-
   // Getting the center point and two points (start and end)
   std::shared_ptr<GeomAPI_Pnt> aCenterPoint;
   std::shared_ptr<GeomAPI_Pnt> aStartPoint;
@@ -232,48 +161,73 @@ void FeaturesPlugin_Rotation::performTranslationByThreePoints()
       aStartPoint = GeomAlgoAPI_PointBuilder::point(aStartShape);
       anEndPoint = GeomAlgoAPI_PointBuilder::point(anEndShape);
     }
+
+    if (!aCenterPoint || !aStartPoint || !anEndPoint)
+      return GeomTrsfPtr();
+  }
+
+  GeomTrsfPtr aTrsf(new GeomAPI_Trsf());
+  aTrsf->setRotation(aCenterPoint, aStartPoint, anEndPoint);
+  return aTrsf;
+}
+
+//=================================================================================================
+void FeaturesPlugin_Rotation::performRotation(const GeomTrsfPtr& theTrsf)
+{
+  if (!theTrsf) {
+    setError("Invalid transformation.");
+    return;
   }
 
-  // Rotating each object.
+  bool isKeepSubShapes = data()->version() == ROTATION_VERSION_1;
+
+  // Getting objects.
+  GeomAPI_ShapeHierarchy anObjects;
+  std::list<ResultPtr> aParts;
+  AttributeSelectionListPtr anObjSelList = selectionList(OBJECTS_LIST_ID());
+  if (!FeaturesPlugin_Tools::shapesFromSelectionList(
+       anObjSelList, isKeepSubShapes, anObjects, aParts))
+    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++) {
+  // Rotating each part.
+  for (std::list<ResultPtr>::iterator aPRes = aParts.begin(); aPRes != aParts.end(); ++aPRes) {
+    ResultPartPtr anOriginal = std::dynamic_pointer_cast<ModelAPI_ResultPart>(*aPRes);
+    ResultPartPtr aResultPart = document()->copyPart(anOriginal, data(), aResultIndex);
+    aResultPart->setTrsf(anOriginal, theTrsf);
+    setResult(aResultPart, aResultIndex++);
+  }
+
+  // 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;
-    bool isPart = (*aContext)->groupName() == ModelAPI_ResultPart::group();
-
-    // Setting result.
-    if (isPart) {
-       std::shared_ptr<GeomAPI_Trsf> aTrsf(new GeomAPI_Trsf());
-       aTrsf->setRotation(aCenterPoint, aStartPoint, anEndPoint);
-       ResultPartPtr anOrigin = std::dynamic_pointer_cast<ModelAPI_ResultPart>(*aContext);
-       ResultPartPtr aResultPart = document()->copyPart(anOrigin, data(), aResultIndex);
-       aResultPart->setTrsf(*aContext, aTrsf);
-       setResult(aResultPart, aResultIndex);
-    } else {
-      std::shared_ptr<GeomAlgoAPI_Rotation> aRotationAlgo(new GeomAlgoAPI_Rotation(aBaseShape,
-                                                                                   aCenterPoint,
-                                                                                   aStartPoint,
-                                                                                   anEndPoint));
-      // Checking that the algorithm worked properly.
-      if (GeomAlgoAPI_Tools::AlgoError::isAlgorithmFailed(aRotationAlgo, getKind(), anError)) {
-        setError(anError);
-        break;
-      }
-
-      ResultBodyPtr aResultBody = document()->createBody(data(), aResultIndex);
-
-      ListOfShape aShapes;
-      aShapes.push_back(aBaseShape);
-      FeaturesPlugin_Tools::loadModifiedShapes(aResultBody,
-                                               aShapes,
-                                               ListOfShape(),
-                                               aRotationAlgo,
-                                               aRotationAlgo->shape(),
-                                               "Rotated");
-      setResult(aResultBody, aResultIndex);
+    std::shared_ptr<GeomAlgoAPI_Transform> aRotationAlgo(
+        new GeomAlgoAPI_Transform(aBaseShape, theTrsf));
+
+    // Checking that the algorithm worked properly.
+    if (GeomAlgoAPI_Tools::AlgoError::isAlgorithmFailed(aRotationAlgo, getKind(), anError)) {
+      setError(anError);
+      break;
     }
-    aResultIndex++;
+
+    anObjects.markModified(aBaseShape, aRotationAlgo->shape());
+    aMakeShapeList->appendAlgo(aRotationAlgo);
+  }
+
+  // Build results of the rotation.
+  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.
+  removeResults(aResultIndex);
 }
index e16601271c7ab00f7d2f0b298d00093e0f65b25f..96b865a0d923fbcec237880b7ad2c52d12aa0da7 100644 (file)
@@ -24,7 +24,7 @@
 
 #include <ModelAPI_Feature.h>
 
-#include <GeomAlgoAPI_Rotation.h>
+class GeomAPI_Trsf;
 
 /// \class FeaturesPlugin_Rotation
 /// \ingroup Plugins
@@ -119,11 +119,14 @@ class FeaturesPlugin_Rotation : public ModelAPI_Feature
   FeaturesPlugin_Rotation();
 
 private:
-  ///Perform the rotation using an axis and an angle.
-  void performTranslationByAxisAndAngle();
+  /// Calculate the rotation using an axis and an angle.
+  std::shared_ptr<GeomAPI_Trsf> rotationByAxisAndAngle();
 
-  ///Perform the rotation using a center and two points.
-  void performTranslationByThreePoints();
+  /// Calculate the rotation using a center and two points.
+  std::shared_ptr<GeomAPI_Trsf> rotationByThreePoints();
+
+  /// Perform the transformation
+  void performRotation(const std::shared_ptr<GeomAPI_Trsf>& theTrsf);
 };
 
 #endif
index 3eeaac0fa512846cca9b25338e2359b6dd59c8d4..c2adb34a5157f11c844a373c87d9f081d0ad147e 100644 (file)
@@ -185,8 +185,10 @@ GeomTrsfPtr FeaturesPlugin_Translation::translationByTwoPoints()
 //=================================================================================================
 void FeaturesPlugin_Translation::performTranslation(const GeomTrsfPtr& theTrsf)
 {
-  if (!theTrsf)
+  if (!theTrsf) {
+    setError("Invalid transformation.");
     return;
+  }
 
   bool isKeepSubShapes = data()->version() == TRANSLATION_VERSION_1;
 
diff --git a/src/FeaturesPlugin/Test/TestRotation_MultiLevelCompound_v0_1.py b/src/FeaturesPlugin/Test/TestRotation_MultiLevelCompound_v0_1.py
new file mode 100644 (file)
index 0000000..e576dc2
--- /dev/null
@@ -0,0 +1,141 @@
+# 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 = 45
+TOLERANCE = 1.e-7
+
+ORIGIN = GeomAPI_Pnt(0, 0, 0)
+OX = GeomAPI_Ax1(ORIGIN, GeomAPI_Dir(1, 0, 0))
+OY = GeomAPI_Ax1(ORIGIN, GeomAPI_Dir(0, 1, 0))
+OZ = GeomAPI_Ax1(ORIGIN, GeomAPI_Dir(0, 0, 1))
+
+
+model.begin()
+Rotation_1 = model.addRotation(Part_1_doc, [model.selection("SOLID", "Compound_2_1_1_5")], model.selection("EDGE", "PartSet/OX"), ANGLE)
+model.testNbResults(Rotation_1, 1)
+model.testNbSubResults(Rotation_1, [0])
+model.testNbSubShapes(Rotation_1, GeomAPI_Shape.SOLID, [1])
+model.testNbSubShapes(Rotation_1, GeomAPI_Shape.FACE, [5])
+model.testNbSubShapes(Rotation_1, GeomAPI_Shape.EDGE, [18])
+model.testNbSubShapes(Rotation_1, GeomAPI_Shape.VERTEX, [36])
+model.testResultsVolumes(Rotation_1, [542.746463956])
+
+refPoint = Extrusion_1.results()[0].subResult(4).resultSubShapePair()[0].shape().middlePoint()
+refPoint.rotate(OX, ANGLE)
+midPoint = Rotation_1.defaultResult().shape().middlePoint()
+assert(midPoint.distance(refPoint) < TOLERANCE)
+
+
+Recover_1 = model.addRecover(Part_1_doc, Rotation_1, [Compound_2.result()], True)
+Rotation_2 = model.addRotation(Part_1_doc, [model.selection("SOLID", "Recover_1_1_2_1")], model.selection("EDGE", "PartSet/OY"), ANGLE)
+model.testNbResults(Rotation_2, 1)
+model.testNbSubResults(Rotation_2, [0])
+model.testNbSubShapes(Rotation_2, GeomAPI_Shape.SOLID, [1])
+model.testNbSubShapes(Rotation_2, GeomAPI_Shape.FACE, [3])
+model.testNbSubShapes(Rotation_2, GeomAPI_Shape.EDGE, [6])
+model.testNbSubShapes(Rotation_2, GeomAPI_Shape.VERTEX, [12])
+model.testResultsVolumes(Rotation_2, [785.39816339745])
+
+refPoint = Recover_1.result().subResult(1).subResult(0).resultSubShapePair()[0].shape().middlePoint()
+refPoint.rotate(OY, ANGLE)
+midPoint = Rotation_2.defaultResult().shape().middlePoint()
+assert(midPoint.distance(refPoint) < TOLERANCE)
+
+
+Recover_2 = model.addRecover(Part_1_doc, Rotation_2, [Recover_1.result()], True)
+Rotation_3 = model.addRotation(Part_1_doc, [model.selection("SOLID", "Recover_2_1_3")], model.selection("EDGE", "PartSet/OZ"), ANGLE)
+model.testNbResults(Rotation_3, 1)
+model.testNbSubResults(Rotation_3, [0])
+model.testNbSubShapes(Rotation_3, GeomAPI_Shape.SOLID, [1])
+model.testNbSubShapes(Rotation_3, GeomAPI_Shape.FACE, [3])
+model.testNbSubShapes(Rotation_3, GeomAPI_Shape.EDGE, [6])
+model.testNbSubShapes(Rotation_3, GeomAPI_Shape.VERTEX, [12])
+model.testResultsVolumes(Rotation_3, [785.39816339745])
+
+refPoint = Recover_2.result().subResult(2).resultSubShapePair()[0].shape().middlePoint()
+refPoint.rotate(OZ, ANGLE)
+midPoint = Rotation_3.defaultResult().shape().middlePoint()
+assert(midPoint.distance(refPoint) < TOLERANCE)
+
+
+Recover_3 = model.addRecover(Part_1_doc, Rotation_3, [Recover_2.result()], True)
+Rotation_4 = model.addRotation(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)
+model.testNbResults(Rotation_4, 3)
+model.testNbSubResults(Rotation_4, [0, 0, 0])
+model.testNbSubShapes(Rotation_4, GeomAPI_Shape.SOLID, [1, 1, 1])
+model.testNbSubShapes(Rotation_4, GeomAPI_Shape.FACE, [6, 3, 3])
+model.testNbSubShapes(Rotation_4, GeomAPI_Shape.EDGE, [24, 6, 6])
+model.testNbSubShapes(Rotation_4, GeomAPI_Shape.VERTEX, [48, 12, 12])
+model.testResultsVolumes(Rotation_4, [3444.394198615, 785.39816339745, 785.39816339745])
+
+REFERENCE = [Recover_3.result().subResult(0).subResult(0).resultSubShapePair()[0].shape().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(Rotation_4.results(), REFERENCE):
+    ref.rotate(OZ, -ANGLE)
+    midPoint = res.resultSubShapePair()[0].shape().middlePoint()
+    assert(midPoint.distance(ref) < TOLERANCE)
+
+model.end()
+
+assert(model.checkPythonDump())
diff --git a/src/FeaturesPlugin/Test/TestRotation_MultiLevelCompound_v0_2.py b/src/FeaturesPlugin/Test/TestRotation_MultiLevelCompound_v0_2.py
new file mode 100644 (file)
index 0000000..64ef8cd
--- /dev/null
@@ -0,0 +1,138 @@
+# 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
+CENTER = SketchEllipse_1.secondFocus().pnt()
+ANGLE = GeomAPI_Angle2d(CENTER, GeomAPI_Pnt2d(0, 0), SketchCircle_1.center().pnt()).angleDegree()
+AXIS = GeomAPI_Ax1(GeomAPI_Pnt(CENTER.x(), CENTER.y(), 0), GeomAPI_Dir(0, 0, 1))
+
+
+model.begin()
+Rotation_1 = model.addRotation(Part_1_doc, [model.selection("SOLID", "Compound_2_1_1_5")], model.selection("VERTEX", "Sketch_1/SketchEllipse_1_ellipse_second_focus"), model.selection("VERTEX", "PartSet/Origin"), model.selection("VERTEX", "Sketch_1/SketchCircle_1"))
+model.testNbResults(Rotation_1, 1)
+model.testNbSubResults(Rotation_1, [0])
+model.testNbSubShapes(Rotation_1, GeomAPI_Shape.SOLID, [1])
+model.testNbSubShapes(Rotation_1, GeomAPI_Shape.FACE, [5])
+model.testNbSubShapes(Rotation_1, GeomAPI_Shape.EDGE, [18])
+model.testNbSubShapes(Rotation_1, GeomAPI_Shape.VERTEX, [36])
+model.testResultsVolumes(Rotation_1, [542.746463956])
+
+refPoint = Extrusion_1.results()[0].subResult(4).resultSubShapePair()[0].shape().middlePoint()
+refPoint.rotate(AXIS, ANGLE)
+midPoint = Rotation_1.defaultResult().shape().middlePoint()
+assert(midPoint.distance(refPoint) < TOLERANCE)
+
+
+Recover_1 = model.addRecover(Part_1_doc, Rotation_1, [Compound_2.result()], True)
+Rotation_2 = model.addRotation(Part_1_doc, [model.selection("SOLID", "Recover_1_1_2_1")], model.selection("VERTEX", "Sketch_1/SketchEllipse_1_ellipse_second_focus"), model.selection("VERTEX", "PartSet/Origin"), model.selection("VERTEX", "Sketch_1/SketchCircle_1"))
+model.testNbResults(Rotation_2, 1)
+model.testNbSubResults(Rotation_2, [0])
+model.testNbSubShapes(Rotation_2, GeomAPI_Shape.SOLID, [1])
+model.testNbSubShapes(Rotation_2, GeomAPI_Shape.FACE, [3])
+model.testNbSubShapes(Rotation_2, GeomAPI_Shape.EDGE, [6])
+model.testNbSubShapes(Rotation_2, GeomAPI_Shape.VERTEX, [12])
+model.testResultsVolumes(Rotation_2, [785.39816339745])
+
+refPoint = Recover_1.result().subResult(1).subResult(0).resultSubShapePair()[0].shape().middlePoint()
+refPoint.rotate(AXIS, ANGLE)
+midPoint = Rotation_2.defaultResult().shape().middlePoint()
+assert(midPoint.distance(refPoint) < TOLERANCE)
+
+
+Recover_2 = model.addRecover(Part_1_doc, Rotation_2, [Recover_1.result()], True)
+Rotation_3 = model.addRotation(Part_1_doc, [model.selection("SOLID", "Recover_2_1_3")], model.selection("VERTEX", "Sketch_1/SketchEllipse_1_ellipse_second_focus"), model.selection("VERTEX", "PartSet/Origin"), model.selection("VERTEX", "Sketch_1/SketchCircle_1"))
+model.testNbResults(Rotation_3, 1)
+model.testNbSubResults(Rotation_3, [0])
+model.testNbSubShapes(Rotation_3, GeomAPI_Shape.SOLID, [1])
+model.testNbSubShapes(Rotation_3, GeomAPI_Shape.FACE, [3])
+model.testNbSubShapes(Rotation_3, GeomAPI_Shape.EDGE, [6])
+model.testNbSubShapes(Rotation_3, GeomAPI_Shape.VERTEX, [12])
+model.testResultsVolumes(Rotation_3, [785.39816339745])
+
+refPoint = Recover_2.result().subResult(2).resultSubShapePair()[0].shape().middlePoint()
+refPoint.rotate(AXIS, ANGLE)
+midPoint = Rotation_3.defaultResult().shape().middlePoint()
+assert(midPoint.distance(refPoint) < TOLERANCE)
+
+
+Recover_3 = model.addRecover(Part_1_doc, Rotation_3, [Recover_2.result()], True)
+Rotation_4 = model.addRotation(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("VERTEX", "Sketch_1/SketchEllipse_1_ellipse_second_focus"), model.selection("VERTEX", "Sketch_1/SketchCircle_1"), model.selection("VERTEX", "PartSet/Origin"))
+model.testNbResults(Rotation_4, 3)
+model.testNbSubResults(Rotation_4, [0, 0, 0])
+model.testNbSubShapes(Rotation_4, GeomAPI_Shape.SOLID, [1, 1, 1])
+model.testNbSubShapes(Rotation_4, GeomAPI_Shape.FACE, [6, 3, 3])
+model.testNbSubShapes(Rotation_4, GeomAPI_Shape.EDGE, [24, 6, 6])
+model.testNbSubShapes(Rotation_4, GeomAPI_Shape.VERTEX, [48, 12, 12])
+model.testResultsVolumes(Rotation_4, [3444.394198615, 785.39816339745, 785.39816339745])
+
+REFERENCE = [Recover_3.result().subResult(0).subResult(0).resultSubShapePair()[0].shape().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(Rotation_4.results(), REFERENCE):
+    ref.rotate(AXIS, -ANGLE)
+    midPoint = res.resultSubShapePair()[0].shape().middlePoint()
+    assert(midPoint.distance(ref) < TOLERANCE)
+
+model.end()
+
+assert(model.checkPythonDump())
diff --git a/src/FeaturesPlugin/Test/TestRotation_MultiLevelCompound_v0_3.py b/src/FeaturesPlugin/Test/TestRotation_MultiLevelCompound_v0_3.py
new file mode 100644 (file)
index 0000000..663d605
--- /dev/null
@@ -0,0 +1,187 @@
+# 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")])
+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
+ANGLE = 30
+AXIS = GeomAPI_Ax1(GeomAPI_Pnt(0, 0, 0), GeomAPI_Dir(0, 0, 1))
+
+
+model.begin()
+Rotation_1 = model.addRotation(Part_1_doc, [model.selection("VERTEX", "Vertex_1_1")], model.selection("EDGE", "PartSet/OZ"), ANGLE)
+model.testNbResults(Rotation_1, 1)
+model.testNbSubResults(Rotation_1, [0])
+model.testNbSubShapes(Rotation_1, GeomAPI_Shape.SOLID, [0])
+model.testNbSubShapes(Rotation_1, GeomAPI_Shape.FACE, [0])
+model.testNbSubShapes(Rotation_1, GeomAPI_Shape.EDGE, [0])
+model.testNbSubShapes(Rotation_1, GeomAPI_Shape.VERTEX, [1])
+model.testResultsVolumes(Rotation_1, [0])
+refPoint = Vertex_1.defaultResult().shape().middlePoint()
+refPoint.rotate(AXIS, ANGLE)
+midPoint = Rotation_1.defaultResult().shape().middlePoint()
+assert(midPoint.distance(refPoint) < TOLERANCE)
+
+Rotation_2 = model.addRotation(Part_1_doc, [model.selection("EDGE", "Edge_1_1")], model.selection("EDGE", "PartSet/OZ"), ANGLE)
+model.testNbResults(Rotation_2, 1)
+model.testNbSubResults(Rotation_2, [0])
+model.testNbSubShapes(Rotation_2, GeomAPI_Shape.SOLID, [0])
+model.testNbSubShapes(Rotation_2, GeomAPI_Shape.FACE, [0])
+model.testNbSubShapes(Rotation_2, GeomAPI_Shape.EDGE, [1])
+model.testNbSubShapes(Rotation_2, GeomAPI_Shape.VERTEX, [2])
+model.testResultsVolumes(Rotation_2, [0])
+refPoint = Edge_1.defaultResult().shape().middlePoint()
+refPoint.rotate(AXIS, ANGLE)
+midPoint = Rotation_2.defaultResult().shape().middlePoint()
+assert(midPoint.distance(refPoint) < TOLERANCE)
+
+Rotation_3 = model.addRotation(Part_1_doc, [model.selection("WIRE", "Wire_1_1")], model.selection("EDGE", "PartSet/OZ"), ANGLE)
+model.testNbResults(Rotation_3, 1)
+model.testNbSubResults(Rotation_3, [0])
+model.testNbSubShapes(Rotation_3, GeomAPI_Shape.SOLID, [0])
+model.testNbSubShapes(Rotation_3, GeomAPI_Shape.FACE, [0])
+model.testNbSubShapes(Rotation_3, GeomAPI_Shape.EDGE, [2])
+model.testNbSubShapes(Rotation_3, GeomAPI_Shape.VERTEX, [4])
+model.testResultsVolumes(Rotation_3, [0])
+refPoint = Wire_1.defaultResult().shape().middlePoint()
+refPoint.rotate(AXIS, ANGLE)
+midPoint = Rotation_3.defaultResult().shape().middlePoint()
+assert(midPoint.distance(refPoint) < TOLERANCE)
+
+Rotation_4 = model.addRotation(Part_1_doc, [model.selection("FACE", "Face_1_1")], model.selection("EDGE", "PartSet/OZ"), ANGLE)
+model.testNbResults(Rotation_4, 1)
+model.testNbSubResults(Rotation_4, [0])
+model.testNbSubShapes(Rotation_4, GeomAPI_Shape.SOLID, [0])
+model.testNbSubShapes(Rotation_4, GeomAPI_Shape.FACE, [1])
+model.testNbSubShapes(Rotation_4, GeomAPI_Shape.EDGE, [4])
+model.testNbSubShapes(Rotation_4, GeomAPI_Shape.VERTEX, [8])
+model.testResultsVolumes(Rotation_4, [109.154152964914914])
+refPoint = Face_1.defaultResult().shape().middlePoint()
+refPoint.rotate(AXIS, ANGLE)
+midPoint = Rotation_4.defaultResult().shape().middlePoint()
+assert(midPoint.distance(refPoint) < TOLERANCE)
+
+Rotation_5 = model.addRotation(Part_1_doc, [model.selection("SHELL", "Shell_1_1")], model.selection("EDGE", "PartSet/OZ"), ANGLE)
+model.testNbResults(Rotation_5, 1)
+model.testNbSubResults(Rotation_5, [0])
+model.testNbSubShapes(Rotation_5, GeomAPI_Shape.SOLID, [0])
+model.testNbSubShapes(Rotation_5, GeomAPI_Shape.FACE, [2])
+model.testNbSubShapes(Rotation_5, GeomAPI_Shape.EDGE, [8])
+model.testNbSubShapes(Rotation_5, GeomAPI_Shape.VERTEX, [16])
+model.testResultsVolumes(Rotation_5, [182.822012116])
+refPoint = Shell_1.defaultResult().shape().middlePoint()
+refPoint.rotate(AXIS, ANGLE)
+midPoint = Rotation_5.defaultResult().shape().middlePoint()
+assert(midPoint.distance(refPoint) < TOLERANCE)
+
+Rotation_6 = model.addRotation(Part_1_doc, [model.selection("SOLID", "Translation_1_1")], model.selection("EDGE", "PartSet/OZ"), ANGLE)
+model.testNbResults(Rotation_6, 1)
+model.testNbSubResults(Rotation_6, [0])
+model.testNbSubShapes(Rotation_6, GeomAPI_Shape.SOLID, [1])
+model.testNbSubShapes(Rotation_6, GeomAPI_Shape.FACE, [6])
+model.testNbSubShapes(Rotation_6, GeomAPI_Shape.EDGE, [24])
+model.testNbSubShapes(Rotation_6, GeomAPI_Shape.VERTEX, [48])
+model.testResultsVolumes(Rotation_6, [1000])
+refPoint = Translation_1.defaultResult().shape().middlePoint()
+refPoint.rotate(AXIS, ANGLE)
+midPoint = Rotation_6.defaultResult().shape().middlePoint()
+assert(midPoint.distance(refPoint) < TOLERANCE)
+
+Rotation_7 = model.addRotation(Part_1_doc, [model.selection("COMPSOLID", "Partition_1_1")], model.selection("EDGE", "PartSet/OZ"), ANGLE)
+model.testNbResults(Rotation_7, 1)
+model.testNbSubResults(Rotation_7, [3])
+model.testNbSubShapes(Rotation_7, GeomAPI_Shape.SOLID, [3])
+model.testNbSubShapes(Rotation_7, GeomAPI_Shape.FACE, [17])
+model.testNbSubShapes(Rotation_7, GeomAPI_Shape.EDGE, [66])
+model.testNbSubShapes(Rotation_7, GeomAPI_Shape.VERTEX, [132])
+model.testResultsVolumes(Rotation_7, [1589.0486226])
+refPoint = GeomAPI_Pnt(1.830127, 4.330127, 5.0)
+midPoint = Rotation_7.defaultResult().shape().middlePoint()
+assert(midPoint.distance(refPoint) < TOLERANCE)
+
+Rotation_8 = model.addRotation(Part_1_doc, [model.selection("COMPOUND", "AngularCopy_1_1")], model.selection("EDGE", "PartSet/OZ"), ANGLE)
+model.testNbResults(Rotation_8, 1)
+model.testNbSubResults(Rotation_8, [3])
+model.testNbSubShapes(Rotation_8, GeomAPI_Shape.SOLID, [3])
+model.testNbSubShapes(Rotation_8, GeomAPI_Shape.FACE, [18])
+model.testNbSubShapes(Rotation_8, GeomAPI_Shape.EDGE, [72])
+model.testNbSubShapes(Rotation_8, GeomAPI_Shape.VERTEX, [144])
+model.testResultsVolumes(Rotation_8, [3000])
+refPoint = GeomAPI_Pnt(-38.169872981, 28.4807621, 5.0)
+midPoint = Rotation_8.defaultResult().shape().middlePoint()
+assert(midPoint.distance(refPoint) < TOLERANCE)
+
+model.end()
+
+assert(model.checkPythonDump())
diff --git a/src/FeaturesPlugin/Test/TestRotation_MultiLevelCompound_v0_4.py b/src/FeaturesPlugin/Test/TestRotation_MultiLevelCompound_v0_4.py
new file mode 100644 (file)
index 0000000..b092bf0
--- /dev/null
@@ -0,0 +1,196 @@
+# 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")])
+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
+ANGLE = 30
+AXIS = GeomAPI_Ax1(GeomAPI_Pnt(0, 0, 0), GeomAPI_Dir(0, 0, 1))
+
+
+model.begin()
+Rotation_1 = model.addRotation(Part_1_doc, [model.selection("VERTEX", "Compound_1_1_1")], model.selection("EDGE", "PartSet/OZ"), ANGLE)
+model.testNbResults(Rotation_1, 1)
+model.testNbSubResults(Rotation_1, [0])
+model.testNbSubShapes(Rotation_1, GeomAPI_Shape.SOLID, [0])
+model.testNbSubShapes(Rotation_1, GeomAPI_Shape.FACE, [0])
+model.testNbSubShapes(Rotation_1, GeomAPI_Shape.EDGE, [0])
+model.testNbSubShapes(Rotation_1, GeomAPI_Shape.VERTEX, [1])
+model.testResultsVolumes(Rotation_1, [0])
+refPoint = Compound_1.result().subResult(0).resultSubShapePair()[0].shape().middlePoint()
+refPoint.rotate(AXIS, ANGLE)
+midPoint = Rotation_1.defaultResult().shape().middlePoint()
+assert(midPoint.distance(refPoint) < TOLERANCE)
+
+Recover_1 = model.addRecover(Part_1_doc, Rotation_1, [Compound_1.result()], True)
+Rotation_2 = model.addRotation(Part_1_doc, [model.selection("EDGE", "Recover_1_1_2")], model.selection("EDGE", "PartSet/OZ"), ANGLE)
+model.testNbResults(Rotation_2, 1)
+model.testNbSubResults(Rotation_2, [0])
+model.testNbSubShapes(Rotation_2, GeomAPI_Shape.SOLID, [0])
+model.testNbSubShapes(Rotation_2, GeomAPI_Shape.FACE, [0])
+model.testNbSubShapes(Rotation_2, GeomAPI_Shape.EDGE, [1])
+model.testNbSubShapes(Rotation_2, GeomAPI_Shape.VERTEX, [2])
+model.testResultsVolumes(Rotation_2, [0])
+refPoint = Compound_1.result().subResult(1).resultSubShapePair()[0].shape().middlePoint()
+refPoint.rotate(AXIS, ANGLE)
+midPoint = Rotation_2.defaultResult().shape().middlePoint()
+assert(midPoint.distance(refPoint) < TOLERANCE)
+
+Recover_2 = model.addRecover(Part_1_doc, Rotation_2, [Recover_1.result()])
+Rotation_3 = model.addRotation(Part_1_doc, [model.selection("WIRE", "Recover_2_1_3")], model.selection("EDGE", "PartSet/OZ"), ANGLE)
+model.testNbResults(Rotation_3, 1)
+model.testNbSubResults(Rotation_3, [0])
+model.testNbSubShapes(Rotation_3, GeomAPI_Shape.SOLID, [0])
+model.testNbSubShapes(Rotation_3, GeomAPI_Shape.FACE, [0])
+model.testNbSubShapes(Rotation_3, GeomAPI_Shape.EDGE, [2])
+model.testNbSubShapes(Rotation_3, GeomAPI_Shape.VERTEX, [4])
+model.testResultsVolumes(Rotation_3, [0])
+refPoint = Compound_1.result().subResult(2).resultSubShapePair()[0].shape().middlePoint()
+refPoint.rotate(AXIS, ANGLE)
+midPoint = Rotation_3.defaultResult().shape().middlePoint()
+assert(midPoint.distance(refPoint) < TOLERANCE)
+
+Recover_3 = model.addRecover(Part_1_doc, Rotation_3, [Recover_2.result()])
+Rotation_4 = model.addRotation(Part_1_doc, [model.selection("FACE", "Recover_3_1_4")], model.selection("EDGE", "PartSet/OZ"), ANGLE)
+model.testNbResults(Rotation_4, 1)
+model.testNbSubResults(Rotation_4, [0])
+model.testNbSubShapes(Rotation_4, GeomAPI_Shape.SOLID, [0])
+model.testNbSubShapes(Rotation_4, GeomAPI_Shape.FACE, [1])
+model.testNbSubShapes(Rotation_4, GeomAPI_Shape.EDGE, [4])
+model.testNbSubShapes(Rotation_4, GeomAPI_Shape.VERTEX, [8])
+model.testResultsVolumes(Rotation_4, [109.154152964914914])
+refPoint = Compound_1.result().subResult(3).resultSubShapePair()[0].shape().middlePoint()
+refPoint.rotate(AXIS, ANGLE)
+midPoint = Rotation_4.defaultResult().shape().middlePoint()
+assert(midPoint.distance(refPoint) < TOLERANCE)
+
+Recover_4 = model.addRecover(Part_1_doc, Rotation_4, [Recover_3.result()])
+Rotation_5 = model.addRotation(Part_1_doc, [model.selection("SHELL", "Recover_4_1_5")], model.selection("EDGE", "PartSet/OZ"), ANGLE)
+model.testNbResults(Rotation_5, 1)
+model.testNbSubResults(Rotation_5, [0])
+model.testNbSubShapes(Rotation_5, GeomAPI_Shape.SOLID, [0])
+model.testNbSubShapes(Rotation_5, GeomAPI_Shape.FACE, [2])
+model.testNbSubShapes(Rotation_5, GeomAPI_Shape.EDGE, [8])
+model.testNbSubShapes(Rotation_5, GeomAPI_Shape.VERTEX, [16])
+model.testResultsVolumes(Rotation_5, [182.822012116])
+refPoint = Compound_1.result().subResult(4).resultSubShapePair()[0].shape().middlePoint()
+refPoint.rotate(AXIS, ANGLE)
+midPoint = Rotation_5.defaultResult().shape().middlePoint()
+assert(midPoint.distance(refPoint) < TOLERANCE)
+
+Recover_5 = model.addRecover(Part_1_doc, Rotation_5, [Recover_4.result()])
+Rotation_6 = model.addRotation(Part_1_doc, [model.selection("SOLID", "Recover_5_1_6")], model.selection("EDGE", "PartSet/OZ"), ANGLE)
+model.testNbResults(Rotation_6, 1)
+model.testNbSubResults(Rotation_6, [0])
+model.testNbSubShapes(Rotation_6, GeomAPI_Shape.SOLID, [1])
+model.testNbSubShapes(Rotation_6, GeomAPI_Shape.FACE, [6])
+model.testNbSubShapes(Rotation_6, GeomAPI_Shape.EDGE, [24])
+model.testNbSubShapes(Rotation_6, GeomAPI_Shape.VERTEX, [48])
+model.testResultsVolumes(Rotation_6, [1000])
+refPoint = Compound_1.result().subResult(5).resultSubShapePair()[0].shape().middlePoint()
+refPoint.rotate(AXIS, ANGLE)
+midPoint = Rotation_6.defaultResult().shape().middlePoint()
+assert(midPoint.distance(refPoint) < TOLERANCE)
+
+Recover_6 = model.addRecover(Part_1_doc, Rotation_6, [Recover_5.result()])
+Rotation_7 = model.addRotation(Part_1_doc, [model.selection("COMPSOLID", "Recover_6_1_7")], model.selection("EDGE", "PartSet/OZ"), ANGLE)
+model.testNbResults(Rotation_7, 1)
+model.testNbSubResults(Rotation_7, [3])
+model.testNbSubShapes(Rotation_7, GeomAPI_Shape.SOLID, [3])
+model.testNbSubShapes(Rotation_7, GeomAPI_Shape.FACE, [17])
+model.testNbSubShapes(Rotation_7, GeomAPI_Shape.EDGE, [66])
+model.testNbSubShapes(Rotation_7, GeomAPI_Shape.VERTEX, [132])
+model.testResultsVolumes(Rotation_7, [1589.0486226])
+refPoint = GeomAPI_Pnt(1.830127, 4.330127, 5.0)
+midPoint = Rotation_7.defaultResult().shape().middlePoint()
+assert(midPoint.distance(refPoint) < TOLERANCE)
+
+Recover_7 = model.addRecover(Part_1_doc, Rotation_7, [Recover_6.result()])
+Rotation_8 = model.addRotation(Part_1_doc, [model.selection("COMPOUND", "Recover_7_1_8")], model.selection("EDGE", "PartSet/OZ"), ANGLE)
+model.testNbResults(Rotation_8, 1)
+model.testNbSubResults(Rotation_8, [3])
+model.testNbSubShapes(Rotation_8, GeomAPI_Shape.SOLID, [3])
+model.testNbSubShapes(Rotation_8, GeomAPI_Shape.FACE, [18])
+model.testNbSubShapes(Rotation_8, GeomAPI_Shape.EDGE, [72])
+model.testNbSubShapes(Rotation_8, GeomAPI_Shape.VERTEX, [144])
+model.testResultsVolumes(Rotation_8, [3000])
+refPoint = GeomAPI_Pnt(-38.169872981, 28.4807621, 5.0)
+midPoint = Rotation_8.defaultResult().shape().middlePoint()
+assert(midPoint.distance(refPoint) < TOLERANCE)
+
+model.end()
+
+assert(model.checkPythonDump())
diff --git a/src/FeaturesPlugin/Test/TestRotation_MultiLevelCompound_v95_1.py b/src/FeaturesPlugin/Test/TestRotation_MultiLevelCompound_v95_1.py
new file mode 100644 (file)
index 0000000..bcd0cb9
--- /dev/null
@@ -0,0 +1,125 @@
+# 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 = 45
+TOLERANCE = 1.e-7
+
+ORIGIN = GeomAPI_Pnt(0, 0, 0)
+OX = GeomAPI_Ax1(ORIGIN, GeomAPI_Dir(1, 0, 0))
+OY = GeomAPI_Ax1(ORIGIN, GeomAPI_Dir(0, 1, 0))
+OZ = GeomAPI_Ax1(ORIGIN, GeomAPI_Dir(0, 0, 1))
+
+REFERENCE = []
+for ind in range(0, Compound_2.result().numberOfSubs()):
+    p = Compound_2.result().subResult(ind).resultSubShapePair()[0].shape().middlePoint()
+    REFERENCE.append(p)
+
+def assertResult(theFeature):
+    model.testNbResults(theFeature, 1)
+    model.testNbSubResults(theFeature, [3])
+    model.testNbSubShapes(theFeature, GeomAPI_Shape.SOLID, [10])
+    model.testNbSubShapes(theFeature, GeomAPI_Shape.FACE, [47])
+    model.testNbSubShapes(theFeature, GeomAPI_Shape.EDGE, [162])
+    model.testNbSubShapes(theFeature, GeomAPI_Shape.VERTEX, [324])
+    model.testResultsVolumes(theFeature, [14319.99602674256])
+
+    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()
+Rotation_1 = model.addRotation(Part_1_doc, [model.selection("SOLID", "Compound_2_1_1_5")], axis = model.selection("EDGE", "PartSet/OX"), angle = ANGLE, keepSubResults = True)
+model.end()
+# selection of a compsolid part is prohibited
+assert(Rotation_1.feature().error() != "")
+
+model.begin()
+Rotation_1.setMainObjects([model.selection("COMPSOLID", "Compound_2_1_1")])
+REFERENCE[0].rotate(OX, ANGLE)
+assertResult(Rotation_1)
+
+Rotation_2 = model.addRotation(Part_1_doc, [model.selection("SOLID", "Rotation_1_1_2_1")], axis = model.selection("EDGE", "PartSet/OY"), angle = ANGLE, keepSubResults = True)
+REFERENCE[1] = GeomAPI_Pnt(7.06766468, -32.16838976, -11.327215745975)
+assertResult(Rotation_2)
+
+Rotation_3 = model.addRotation(Part_1_doc, [model.selection("SOLID", "Rotation_2_1_3")], axis = model.selection("EDGE", "PartSet/OZ"), angle = ANGLE, keepSubResults = True)
+REFERENCE[2].rotate(OZ, ANGLE)
+assertResult(Rotation_3)
+
+Rotation_4 = model.addRotation(Part_1_doc, [model.selection("SOLID", "Rotation_3_1_1_1"), model.selection("SOLID", "Rotation_3_1_2_2"), model.selection("SOLID", "Rotation_3_1_3")], axis = model.selection("EDGE", "PartSet/OZ"), angle = -ANGLE, keepSubResults = True)
+model.end()
+# selection of a compsolid part is prohibited
+assert(Rotation_4.feature().error() != "")
+
+model.begin()
+Rotation_4.setMainObjects([model.selection("COMPSOLID", "Rotation_3_1_1"), model.selection("SOLID", "Rotation_3_1_2_2"), model.selection("SOLID", "Rotation_3_1_3")])
+REFERENCE[0] = GeomAPI_Pnt(-28.2523903833, -26.7476096167, -31.819805153)
+REFERENCE[1] = GeomAPI_Pnt(5.0142082456, -22.789092613, -11.327215746)
+REFERENCE[2].rotate(OZ, -ANGLE)
+assertResult(Rotation_4)
+
+model.end()
+
+assert(model.checkPythonDump())
diff --git a/src/FeaturesPlugin/Test/TestRotation_MultiLevelCompound_v95_2.py b/src/FeaturesPlugin/Test/TestRotation_MultiLevelCompound_v95_2.py
new file mode 100644 (file)
index 0000000..3a511e0
--- /dev/null
@@ -0,0 +1,126 @@
+# 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
+CENTER = SketchEllipse_1.secondFocus().pnt()
+ANGLE = GeomAPI_Angle2d(CENTER, GeomAPI_Pnt2d(0, 0), SketchCircle_1.center().pnt()).angleDegree()
+AXIS = GeomAPI_Ax1(GeomAPI_Pnt(CENTER.x(), CENTER.y(), 0), GeomAPI_Dir(0, 0, 1))
+
+REFERENCE = []
+for ind in range(0, Compound_2.result().numberOfSubs()):
+    p = Compound_2.result().subResult(ind).resultSubShapePair()[0].shape().middlePoint()
+    REFERENCE.append(p)
+
+def assertResult(theFeature):
+    model.testNbResults(theFeature, 1)
+    model.testNbSubResults(theFeature, [3])
+    model.testNbSubShapes(theFeature, GeomAPI_Shape.SOLID, [10])
+    model.testNbSubShapes(theFeature, GeomAPI_Shape.FACE, [47])
+    model.testNbSubShapes(theFeature, GeomAPI_Shape.EDGE, [162])
+    model.testNbSubShapes(theFeature, GeomAPI_Shape.VERTEX, [324])
+    model.testResultsVolumes(theFeature, [14319.99602674256])
+
+    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()
+Rotation_1 = model.addRotation(Part_1_doc, [model.selection("SOLID", "Compound_2_1_1_5")], center = model.selection("VERTEX", "Sketch_1/SketchEllipse_1_ellipse_second_focus"), start = model.selection("VERTEX", "PartSet/Origin"), end = model.selection("VERTEX", "Sketch_1/SketchCircle_1"), keepSubResults = True)
+model.end()
+# selection of a compsolid part is prohibited
+assert(Rotation_1.feature().error() != "")
+
+model.begin()
+Rotation_1.setMainObjects([model.selection("COMPSOLID", "Compound_2_1_1")])
+REFERENCE[0].rotate(AXIS, ANGLE)
+assertResult(Rotation_1)
+
+Rotation_2 = model.addRotation(Part_1_doc, [model.selection("SOLID", "Rotation_1_1_2_1")], center = model.selection("VERTEX", "Sketch_1/SketchEllipse_1_ellipse_second_focus"), start = model.selection("VERTEX", "PartSet/Origin"), end = model.selection("VERTEX", "Sketch_1/SketchCircle_1"), keepSubResults = True)
+mp0 = Compound_2.result().subResult(1).subResult(0).resultSubShapePair()[0].shape().middlePoint()
+mp1 = Compound_2.result().subResult(1).subResult(1).resultSubShapePair()[0].shape().middlePoint()
+mp0.rotate(AXIS, ANGLE)
+REFERENCE[1] = GeomAPI_Pnt((mp0.x() + mp1.x()) / 2, (mp0.y() + mp1.y()) / 2, (mp0.z() + mp1.z()) / 2)
+assertResult(Rotation_2)
+
+Rotation_3 = model.addRotation(Part_1_doc, [model.selection("SOLID", "Rotation_2_1_3")], center = model.selection("VERTEX", "Sketch_1/SketchEllipse_1_ellipse_second_focus"), start = model.selection("VERTEX", "PartSet/Origin"), end = model.selection("VERTEX", "Sketch_1/SketchCircle_1"), keepSubResults = True)
+REFERENCE[2].rotate(AXIS, ANGLE)
+assertResult(Rotation_3)
+
+Rotation_4 = model.addRotation(Part_1_doc, [model.selection("SOLID", "Rotation_3_1_1_1"), model.selection("SOLID", "Rotation_3_1_2_2"), model.selection("SOLID", "Rotation_3_1_3")], center = model.selection("VERTEX", "Sketch_1/SketchEllipse_1_ellipse_second_focus"), end = model.selection("VERTEX", "PartSet/Origin"), start = model.selection("VERTEX", "Sketch_1/SketchCircle_1"), keepSubResults = True)
+model.end()
+# selection of a compsolid part is prohibited
+assert(Rotation_4.feature().error() != "")
+
+model.begin()
+Rotation_4.setMainObjects([model.selection("COMPSOLID", "Rotation_3_1_1"), model.selection("SOLID", "Rotation_3_1_2_2"), model.selection("SOLID", "Rotation_3_1_3")])
+REFERENCE[0].rotate(AXIS, -ANGLE)
+mp1.rotate(AXIS, -ANGLE)
+REFERENCE[1] = GeomAPI_Pnt((mp0.x() + mp1.x()) / 2, (mp0.y() + mp1.y()) / 2, (mp0.z() + mp1.z()) / 2)
+REFERENCE[2].rotate(AXIS, -ANGLE)
+assertResult(Rotation_4)
+
+model.end()
+
+assert(model.checkPythonDump())
diff --git a/src/FeaturesPlugin/Test/TestRotation_MultiLevelCompound_v95_3.py b/src/FeaturesPlugin/Test/TestRotation_MultiLevelCompound_v95_3.py
new file mode 100644 (file)
index 0000000..45750ed
--- /dev/null
@@ -0,0 +1,187 @@
+# 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)
+model.end()
+
+TOLERANCE = 1.e-7
+ANGLE = 30
+AXIS = GeomAPI_Ax1(GeomAPI_Pnt(0, 0, 0), GeomAPI_Dir(0, 0, 1))
+
+
+model.begin()
+Rotation_1 = model.addRotation(Part_1_doc, [model.selection("VERTEX", "Vertex_1_1")], axis = model.selection("EDGE", "PartSet/OZ"), angle = ANGLE, keepSubResults = True)
+model.testNbResults(Rotation_1, 1)
+model.testNbSubResults(Rotation_1, [0])
+model.testNbSubShapes(Rotation_1, GeomAPI_Shape.SOLID, [0])
+model.testNbSubShapes(Rotation_1, GeomAPI_Shape.FACE, [0])
+model.testNbSubShapes(Rotation_1, GeomAPI_Shape.EDGE, [0])
+model.testNbSubShapes(Rotation_1, GeomAPI_Shape.VERTEX, [1])
+model.testResultsVolumes(Rotation_1, [0])
+refPoint = Vertex_1.defaultResult().shape().middlePoint()
+refPoint.rotate(AXIS, ANGLE)
+midPoint = Rotation_1.defaultResult().shape().middlePoint()
+assert(midPoint.distance(refPoint) < TOLERANCE)
+
+Rotation_2 = model.addRotation(Part_1_doc, [model.selection("EDGE", "Edge_1_1")], axis = model.selection("EDGE", "PartSet/OZ"), angle = ANGLE, keepSubResults = True)
+model.testNbResults(Rotation_2, 1)
+model.testNbSubResults(Rotation_2, [0])
+model.testNbSubShapes(Rotation_2, GeomAPI_Shape.SOLID, [0])
+model.testNbSubShapes(Rotation_2, GeomAPI_Shape.FACE, [0])
+model.testNbSubShapes(Rotation_2, GeomAPI_Shape.EDGE, [1])
+model.testNbSubShapes(Rotation_2, GeomAPI_Shape.VERTEX, [2])
+model.testResultsVolumes(Rotation_2, [0])
+refPoint = Edge_1.defaultResult().shape().middlePoint()
+refPoint.rotate(AXIS, ANGLE)
+midPoint = Rotation_2.defaultResult().shape().middlePoint()
+assert(midPoint.distance(refPoint) < TOLERANCE)
+
+Rotation_3 = model.addRotation(Part_1_doc, [model.selection("WIRE", "Wire_1_1")], axis = model.selection("EDGE", "PartSet/OZ"), angle = ANGLE, keepSubResults = True)
+model.testNbResults(Rotation_3, 1)
+model.testNbSubResults(Rotation_3, [0])
+model.testNbSubShapes(Rotation_3, GeomAPI_Shape.SOLID, [0])
+model.testNbSubShapes(Rotation_3, GeomAPI_Shape.FACE, [0])
+model.testNbSubShapes(Rotation_3, GeomAPI_Shape.EDGE, [2])
+model.testNbSubShapes(Rotation_3, GeomAPI_Shape.VERTEX, [4])
+model.testResultsVolumes(Rotation_3, [0])
+refPoint = Wire_1.defaultResult().shape().middlePoint()
+refPoint.rotate(AXIS, ANGLE)
+midPoint = Rotation_3.defaultResult().shape().middlePoint()
+assert(midPoint.distance(refPoint) < TOLERANCE)
+
+Rotation_4 = model.addRotation(Part_1_doc, [model.selection("FACE", "Face_1_1")], axis = model.selection("EDGE", "PartSet/OZ"), angle = ANGLE, keepSubResults = True)
+model.testNbResults(Rotation_4, 1)
+model.testNbSubResults(Rotation_4, [0])
+model.testNbSubShapes(Rotation_4, GeomAPI_Shape.SOLID, [0])
+model.testNbSubShapes(Rotation_4, GeomAPI_Shape.FACE, [1])
+model.testNbSubShapes(Rotation_4, GeomAPI_Shape.EDGE, [4])
+model.testNbSubShapes(Rotation_4, GeomAPI_Shape.VERTEX, [8])
+model.testResultsVolumes(Rotation_4, [109.154152964914914])
+refPoint = Face_1.defaultResult().shape().middlePoint()
+refPoint.rotate(AXIS, ANGLE)
+midPoint = Rotation_4.defaultResult().shape().middlePoint()
+assert(midPoint.distance(refPoint) < TOLERANCE)
+
+Rotation_5 = model.addRotation(Part_1_doc, [model.selection("SHELL", "Shell_1_1")], axis = model.selection("EDGE", "PartSet/OZ"), angle = ANGLE, keepSubResults = True)
+model.testNbResults(Rotation_5, 1)
+model.testNbSubResults(Rotation_5, [0])
+model.testNbSubShapes(Rotation_5, GeomAPI_Shape.SOLID, [0])
+model.testNbSubShapes(Rotation_5, GeomAPI_Shape.FACE, [2])
+model.testNbSubShapes(Rotation_5, GeomAPI_Shape.EDGE, [8])
+model.testNbSubShapes(Rotation_5, GeomAPI_Shape.VERTEX, [16])
+model.testResultsVolumes(Rotation_5, [182.822012116])
+refPoint = Shell_1.defaultResult().shape().middlePoint()
+refPoint.rotate(AXIS, ANGLE)
+midPoint = Rotation_5.defaultResult().shape().middlePoint()
+assert(midPoint.distance(refPoint) < TOLERANCE)
+
+Rotation_6 = model.addRotation(Part_1_doc, [model.selection("SOLID", "Translation_1_1")], axis = model.selection("EDGE", "PartSet/OZ"), angle = ANGLE, keepSubResults = True)
+model.testNbResults(Rotation_6, 1)
+model.testNbSubResults(Rotation_6, [0])
+model.testNbSubShapes(Rotation_6, GeomAPI_Shape.SOLID, [1])
+model.testNbSubShapes(Rotation_6, GeomAPI_Shape.FACE, [6])
+model.testNbSubShapes(Rotation_6, GeomAPI_Shape.EDGE, [24])
+model.testNbSubShapes(Rotation_6, GeomAPI_Shape.VERTEX, [48])
+model.testResultsVolumes(Rotation_6, [1000])
+refPoint = Translation_1.defaultResult().shape().middlePoint()
+refPoint.rotate(AXIS, ANGLE)
+midPoint = Rotation_6.defaultResult().shape().middlePoint()
+assert(midPoint.distance(refPoint) < TOLERANCE)
+
+Rotation_7 = model.addRotation(Part_1_doc, [model.selection("COMPSOLID", "Partition_1_1")], axis = model.selection("EDGE", "PartSet/OZ"), angle = ANGLE, keepSubResults = True)
+model.testNbResults(Rotation_7, 1)
+model.testNbSubResults(Rotation_7, [3])
+model.testNbSubShapes(Rotation_7, GeomAPI_Shape.SOLID, [3])
+model.testNbSubShapes(Rotation_7, GeomAPI_Shape.FACE, [17])
+model.testNbSubShapes(Rotation_7, GeomAPI_Shape.EDGE, [66])
+model.testNbSubShapes(Rotation_7, GeomAPI_Shape.VERTEX, [132])
+model.testResultsVolumes(Rotation_7, [1589.0486226])
+refPoint = GeomAPI_Pnt(1.830127, 4.330127, 5.0)
+midPoint = Rotation_7.defaultResult().shape().middlePoint()
+assert(midPoint.distance(refPoint) < TOLERANCE)
+
+Rotation_8 = model.addRotation(Part_1_doc, [model.selection("COMPOUND", "AngularCopy_1_1")], axis = model.selection("EDGE", "PartSet/OZ"), angle = ANGLE, keepSubResults = True)
+model.testNbResults(Rotation_8, 1)
+model.testNbSubResults(Rotation_8, [3])
+model.testNbSubShapes(Rotation_8, GeomAPI_Shape.SOLID, [3])
+model.testNbSubShapes(Rotation_8, GeomAPI_Shape.FACE, [18])
+model.testNbSubShapes(Rotation_8, GeomAPI_Shape.EDGE, [72])
+model.testNbSubShapes(Rotation_8, GeomAPI_Shape.VERTEX, [144])
+model.testResultsVolumes(Rotation_8, [3000])
+refPoint = GeomAPI_Pnt(-38.169872981, 28.4807621, 5.0)
+midPoint = Rotation_8.defaultResult().shape().middlePoint()
+assert(midPoint.distance(refPoint) < TOLERANCE)
+
+model.end()
+
+assert(model.checkPythonDump())
diff --git a/src/FeaturesPlugin/Test/TestRotation_MultiLevelCompound_v95_4.py b/src/FeaturesPlugin/Test/TestRotation_MultiLevelCompound_v95_4.py
new file mode 100644 (file)
index 0000000..6ce8a8a
--- /dev/null
@@ -0,0 +1,135 @@
+# 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()
+
+ANGLE = 30
+AXIS = GeomAPI_Ax1(GeomAPI_Pnt(0, 0, 0), GeomAPI_Dir(0, 0, 1))
+TOLERANCE = 1.e-7
+
+# 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, [7])
+    model.testNbSubShapes(theFeature, GeomAPI_Shape.FACE, [44])
+    model.testNbSubShapes(theFeature, GeomAPI_Shape.EDGE, [177])
+    model.testNbSubShapes(theFeature, GeomAPI_Shape.VERTEX, [355])
+    model.testResultsVolumes(theFeature, [5589.0486226])
+
+    for ind in range(0, theFeature.result().numberOfSubs()):
+        ref = GeomAPI_Pnt(REFERENCE[ind].x(), REFERENCE[ind].y(), REFERENCE[ind].z())
+        if ind < theNbMoved:
+            ref.rotate(AXIS, ANGLE)
+        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()
+Rotation_1 = model.addRotation(Part_1_doc, [model.selection("VERTEX", "Compound_1_1_1")], axis = model.selection("EDGE", "PartSet/OZ"), angle = ANGLE, keepSubResults = True)
+assertResult(Rotation_1, 1)
+
+Rotation_2 = model.addRotation(Part_1_doc, [model.selection("EDGE", "Rotation_1_1_2")], axis = model.selection("EDGE", "PartSet/OZ"), angle = ANGLE, keepSubResults = True)
+assertResult(Rotation_2, 2)
+
+Rotation_3 = model.addRotation(Part_1_doc, [model.selection("WIRE", "Rotation_2_1_3")], axis = model.selection("EDGE", "PartSet/OZ"), angle = ANGLE, keepSubResults = True)
+assertResult(Rotation_3, 3)
+
+Rotation_4 = model.addRotation(Part_1_doc, [model.selection("FACE", "Rotation_3_1_4")], axis = model.selection("EDGE", "PartSet/OZ"), angle = ANGLE, keepSubResults = True)
+assertResult(Rotation_4, 4)
+
+Rotation_5 = model.addRotation(Part_1_doc, [model.selection("SHELL", "Rotation_4_1_5")], axis = model.selection("EDGE", "PartSet/OZ"), angle = ANGLE, keepSubResults = True)
+assertResult(Rotation_5, 5)
+
+Rotation_6 = model.addRotation(Part_1_doc, [model.selection("SOLID", "Rotation_5_1_6")], axis = model.selection("EDGE", "PartSet/OZ"), angle = ANGLE, keepSubResults = True)
+assertResult(Rotation_6, 6)
+
+Rotation_7 = model.addRotation(Part_1_doc, [model.selection("COMPSOLID", "Rotation_6_1_7")], axis = model.selection("EDGE", "PartSet/OZ"), angle = ANGLE, keepSubResults = True)
+REFERENCE[6] = GeomAPI_Pnt(1.83012701892, 4.33012701892, 5.0)
+assertResult(Rotation_7, 6)
+
+Rotation_8 = model.addRotation(Part_1_doc, [model.selection("COMPOUND", "Rotation_7_1_8")], axis = model.selection("EDGE", "PartSet/OZ"), angle = ANGLE, keepSubResults = True)
+REFERENCE[7] = GeomAPI_Pnt(-38.169872981, 28.48076211, 5.0)
+assertResult(Rotation_8, 6)
+
+model.end()
+
+assert(model.checkPythonDump())
index 4f7607c8fe5d7524df48e78b4abee954912eae09..2dec8f3bb4e712b66186dca3cc81462c23553a8e 100644 (file)
@@ -18,6 +18,7 @@
 //
 
 #include<GeomAPI_Pnt.h>
+#include <GeomAPI_Ax1.h>
 #include<GeomAPI_XYZ.h>
 #include<GeomAPI_Pnt2d.h>
 #include<GeomAPI_Dir.h>
@@ -127,3 +128,8 @@ std::shared_ptr<GeomAPI_Pnt2d> GeomAPI_Pnt::to2D(const std::shared_ptr<GeomAPI_P
   gp_Pnt2d aRes = ProjLib::Project(aPln, *MY_PNT);
   return std::shared_ptr<GeomAPI_Pnt2d>(new GeomAPI_Pnt2d(aRes.X(), aRes.Y()));
 }
+
+void GeomAPI_Pnt::rotate(const std::shared_ptr<GeomAPI_Ax1>& theAxis, const double theAngle)
+{
+  MY_PNT->Rotate(theAxis->impl<gp_Ax1>(), theAngle / 180.0 * M_PI);
+}
index 693934412b107193e6af3a992d85bc8d7f291f23..4fd518d9deb5208524a98af5a993ec314ba739ae 100644 (file)
@@ -23,6 +23,7 @@
 #include <GeomAPI_Interface.h>
 #include <memory>
 
+class GeomAPI_Ax1;
 class GeomAPI_XYZ;
 class GeomAPI_Pnt2d;
 class GeomAPI_Dir;
@@ -95,6 +96,9 @@ class GeomAPI_Pnt : public GeomAPI_Interface
   /// Translates the point along direction theDir on distance theDist
   GEOMAPI_EXPORT
   void translate(const std::shared_ptr<GeomAPI_Dir>& theDir, double theDist);
+
+  /// Rotates the point along axis for the given angle (in degrees)
+  GEOMAPI_EXPORT void rotate(const std::shared_ptr<GeomAPI_Ax1>& theAxis, double theAngle);
 };
 
 //! Pointer on the object
index 2f81c1f3891aae552165d7a04672495d5f0ba7d4..ce706bb9a4faa70c840801486b2b0fc1d013025d 100644 (file)
@@ -271,10 +271,12 @@ namespace ModelGeomAlgo_Shape
       }
     }
 
+    bool processSketch = theSelected.empty() || (theSelected.size() == 1 &&
+        theSelected.front().myCenterType != (int)ModelAPI_AttributeSelection::NOT_CENTER);
     // one more special case: the selected entity is a separated sketch point
     // or an auxiliary sketch edge; they are not included into the sketch result;
     // thus, it is necessary to pass through the sketch sub-features and find selected.
-    if (theSelected.empty() && !aResults.empty() &&
+    if (processSketch && !aResults.empty() &&
        (theShapeType == GeomAPI_Shape::VERTEX || theShapeType == GeomAPI_Shape::EDGE)) {
       CompositeFeaturePtr aCF = std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(theFeature);
       std::shared_ptr<GeomAPI_PlanarEdges> aSketchEdges =