]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
High level objects history implementation for LinearCopy and AngularCopy features.
authorazv <azv@opencascade.com>
Fri, 25 Jan 2019 09:47:06 +0000 (12:47 +0300)
committerazv <azv@opencascade.com>
Fri, 25 Jan 2019 09:47:06 +0000 (12:47 +0300)
src/CollectionPlugin/Test/TestGroupMove5.py
src/FeaturesPlugin/FeaturesPlugin_MultiRotation.cpp
src/FeaturesPlugin/FeaturesPlugin_MultiTranslation.cpp
src/FeaturesPlugin/FeaturesPlugin_MultiTranslation.h
src/FeaturesPlugin/FeaturesPlugin_Tools.cpp
src/FeaturesPlugin/FeaturesPlugin_Tools.h

index 0acdd4a8e90c14f225990042b9da94ea401d5463..400fdaba65562b98d08d69717424855df9bdf36d 100644 (file)
@@ -34,8 +34,7 @@ Group_2_objects = [model.selection("FACE", "Box_1_1/Back"), model.selection("FAC
 Group_2 = model.addGroup(Part_1_doc, Group_2_objects)
 Group_3_objects = [model.selection("EDGE", "[Box_1_1/Back][Box_1_1/Bottom]"), model.selection("EDGE", "[Box_1_1/Back][Box_1_1/Right]"), model.selection("EDGE", "[Box_1_1/Back][Box_1_1/Left]"), model.selection("EDGE", "[Box_1_1/Back][Box_1_1/Top]"), model.selection("EDGE", "[Box_1_1/Right][Box_1_1/Bottom]"), model.selection("EDGE", "[Box_1_1/Left][Box_1_1/Top]"), model.selection("EDGE", "[Box_1_1/Left][Box_1_1/Bottom]"), model.selection("EDGE", "[Box_1_1/Right][Box_1_1/Top]"), model.selection("EDGE", "[Box_1_1/Front][Box_1_1/Bottom]"), model.selection("EDGE", "[Box_1_1/Front][Box_1_1/Left]"), model.selection("EDGE", "[Box_1_1/Front][Box_1_1/Right]"), model.selection("EDGE", "[Box_1_1/Front][Box_1_1/Top]")]
 Group_3 = model.addGroup(Part_1_doc, Group_3_objects)
-Axis_4 = model.addAxis(Part_1_doc, model.selection("VERTEX", "[Box_1_1/Back][Box_1_1/Left][Box_1_1/Bottom]"), model.selection("VERTEX", "[Box_1_1/Front][Box_1_1/Right][Box_1_1/Top]"))
-LinearCopy_1 = model.addMultiTranslation(Part_1_doc, [model.selection("SOLID", "Box_1_1")], model.selection("EDGE", "Axis_1"), 10, 2)
+LinearCopy_1 = model.addMultiTranslation(Part_1_doc, [model.selection("SOLID", "Box_1_1")], model.selection("EDGE", "PartSet/OX"), 15, 2)
 model.do()
 # move groups to the end
 Part_1_doc.moveFeature(Group_1.feature(), LinearCopy_1.feature())
@@ -46,9 +45,9 @@ model.end()
 from ModelAPI import *
 
 aFactory = ModelAPI_Session.get().validators()
-# check group 1: full compound should be selected
+# check group 1: all solids in compound should be selected
 selectionList = Group_1.feature().selectionList("group_list")
-assert(selectionList.size() == 1)
+assert(selectionList.size() == 2)
 assert(aFactory.validate(Group_1.feature()))
 # check group 2: number of faces is multiplied twice than original
 selectionList = Group_2.feature().selectionList("group_list")
@@ -59,4 +58,46 @@ selectionList = Group_3.feature().selectionList("group_list")
 assert(selectionList.size() == 24)
 assert(aFactory.validate(Group_3.feature()))
 
+model.begin()
+LinearCopy_2 = model.addMultiTranslation(Part_1_doc, [model.selection("COMPOUND", "LinearCopy_1_1")], model.selection("EDGE", "PartSet/OY"), 15, 2, model.selection("EDGE", "PartSet/OZ"), 15, 2)
+# move groups to the end
+Part_1_doc.moveFeature(Group_1.feature(), LinearCopy_2.feature())
+Part_1_doc.moveFeature(Group_2.feature(), Group_1.feature())
+Part_1_doc.moveFeature(Group_3.feature(), Group_2.feature())
+model.end()
+
+# check group 1: all solids in compound should be selected
+selectionList = Group_1.feature().selectionList("group_list")
+assert(selectionList.size() == 8)
+assert(aFactory.validate(Group_1.feature()))
+# check group 2: number of faces is multiplied twice than original
+selectionList = Group_2.feature().selectionList("group_list")
+assert(selectionList.size() == 48)
+assert(aFactory.validate(Group_2.feature()))
+# check group 3: number of edges is multiplied twice than original
+selectionList = Group_3.feature().selectionList("group_list")
+assert(selectionList.size() == 96)
+assert(aFactory.validate(Group_3.feature()))
+
+model.begin()
+AngularCopy_1 = model.addMultiRotation(Part_1_doc, [model.selection("SOLID", "LinearCopy_2_1_1_1"), model.selection("SOLID", "LinearCopy_2_1_1_2")], model.selection("EDGE", "PartSet/OZ"), 2)
+# move groups to the end
+Part_1_doc.moveFeature(Group_1.feature(), AngularCopy_1.feature())
+Part_1_doc.moveFeature(Group_2.feature(), Group_1.feature())
+Part_1_doc.moveFeature(Group_3.feature(), Group_2.feature())
+model.end()
+
+# check group 1: all solids in compound should be selected
+selectionList = Group_1.feature().selectionList("group_list")
+assert(selectionList.size() == 4)
+assert(aFactory.validate(Group_1.feature()))
+# check group 2: number of faces is multiplied twice than original
+selectionList = Group_2.feature().selectionList("group_list")
+assert(selectionList.size() == 24)
+assert(aFactory.validate(Group_2.feature()))
+# check group 3: number of edges is multiplied twice than original
+selectionList = Group_3.feature().selectionList("group_list")
+assert(selectionList.size() == 48)
+assert(aFactory.validate(Group_3.feature()))
+
 assert(model.checkPythonDump())
index 4206e904ff8c8e3927f82c3457d95fe55cc52fbb..dba9dedf2107ef6ca87a947bf1e132b5b5cf3cad 100644 (file)
@@ -5,8 +5,10 @@
 // Author:      Clarisse Genrault (CEA)
 
 #include <FeaturesPlugin_MultiRotation.h>
+#include <FeaturesPlugin_Tools.h>
 
 #include <GeomAlgoAPI_CompoundBuilder.h>
+#include <GeomAlgoAPI_MakeShapeList.h>
 #include <GeomAlgoAPI_ShapeTools.h>
 #include <GeomAlgoAPI_Tools.h>
 #include <GeomAlgoAPI_Translation.h>
@@ -176,7 +178,8 @@ void FeaturesPlugin_MultiRotation::performRotation1D()
     } else {
       std::string anError;
       ListOfShape aListOfShape;
-      std::list<std::shared_ptr<GeomAlgoAPI_Rotation> > aListOfRotationAlgo;
+      std::shared_ptr<GeomAlgoAPI_MakeShapeList>
+          aListOfRotationAlgo(new GeomAlgoAPI_MakeShapeList);
 
       for (int i=0; i<nbCopies; i++) {
         std::shared_ptr<GeomAlgoAPI_Rotation> aRotationnAlgo(
@@ -195,13 +198,16 @@ void FeaturesPlugin_MultiRotation::performRotation1D()
           break;
         }
         aListOfShape.push_back(aRotationnAlgo->shape());
-        aListOfRotationAlgo.push_back(aRotationnAlgo);
+        aListOfRotationAlgo->appendAlgo(aRotationnAlgo);
       }
       std::shared_ptr<GeomAPI_Shape> aCompound =
         GeomAlgoAPI_CompoundBuilder::compound(aListOfShape);
       ResultBodyPtr aResultBody = document()->createBody(data(), aResultIndex);
-      aResultBody->storeModified(aBaseShape, aCompound);
-      loadNamingDS(aListOfRotationAlgo, aResultBody, aBaseShape);
+
+      ListOfShape aBaseShapes;
+      aBaseShapes.push_back(aBaseShape);
+      FeaturesPlugin_Tools::loadModifiedShapes(aResultBody, aBaseShapes, ListOfShape(),
+                                               aListOfRotationAlgo, aCompound, "Rotated");
 
       setResult(aResultBody, aResultIndex);
     }
index ba1c1e8dfef99da42399c8960a6a2f15449ea977..ed3665792c5d26d4b91c89821494e6971a37f66f 100644 (file)
 //
 
 #include <FeaturesPlugin_MultiTranslation.h>
+#include <FeaturesPlugin_Tools.h>
 
 #include <GeomAlgoAPI_CompoundBuilder.h>
+#include <GeomAlgoAPI_MakeShapeList.h>
 #include <GeomAlgoAPI_Tools.h>
 
 #include <GeomAPI_Ax1.h>
@@ -172,7 +174,8 @@ void FeaturesPlugin_MultiTranslation::performOneDirection()
     } else {
       std::string anError;
       ListOfShape aListOfShape;
-      std::list<std::shared_ptr<GeomAlgoAPI_Translation> > aListOfTranslationAlgo;
+      std::shared_ptr<GeomAlgoAPI_MakeShapeList>
+          aListOfTranslationAlgo(new GeomAlgoAPI_MakeShapeList);
 
       for (int i=0; i<nbCopies; i++) {
         std::shared_ptr<GeomAlgoAPI_Translation> aTranslationAlgo(
@@ -192,13 +195,16 @@ void FeaturesPlugin_MultiTranslation::performOneDirection()
           break;
         }
         aListOfShape.push_back(aTranslationAlgo->shape());
-        aListOfTranslationAlgo.push_back(aTranslationAlgo);
+        aListOfTranslationAlgo->appendAlgo(aTranslationAlgo);
       }
       std::shared_ptr<GeomAPI_Shape> aCompound =
         GeomAlgoAPI_CompoundBuilder::compound(aListOfShape);
       ResultBodyPtr aResultBody = document()->createBody(data(), aResultIndex);
-      aResultBody->storeModified(aBaseShape, aCompound);
-      loadNamingDS(aListOfTranslationAlgo, aResultBody, aBaseShape);
+
+      ListOfShape aBaseShapes;
+      aBaseShapes.push_back(aBaseShape);
+      FeaturesPlugin_Tools::loadModifiedShapes(aResultBody, aBaseShapes, ListOfShape(),
+                                               aListOfTranslationAlgo, aCompound, "Translated");
 
       setResult(aResultBody, aResultIndex);
     }
@@ -361,7 +367,8 @@ void FeaturesPlugin_MultiTranslation::performTwoDirection()
     } else {
       std::string anError;
       ListOfShape aListOfShape;
-      std::list<std::shared_ptr<GeomAlgoAPI_Translation> > aListOfTranslationAlgo;
+      std::shared_ptr<GeomAlgoAPI_MakeShapeList>
+          aListOfTranslationAlgo(new GeomAlgoAPI_MakeShapeList);
 
       for (int j=0; j<aSecondNbCopies; j++) {
         for (int i=0; i<aFirstNbCopies; i++) {
@@ -385,14 +392,18 @@ void FeaturesPlugin_MultiTranslation::performTwoDirection()
             break;
           }
           aListOfShape.push_back(aTranslationAlgo->shape());
-          aListOfTranslationAlgo.push_back(aTranslationAlgo);
+          aListOfTranslationAlgo->appendAlgo(aTranslationAlgo);
         }
       }
       std::shared_ptr<GeomAPI_Shape> aCompound =
         GeomAlgoAPI_CompoundBuilder::compound(aListOfShape);
       ResultBodyPtr aResultBody = document()->createBody(data(), aResultIndex);
-      aResultBody->storeModified(aBaseShape, aCompound);
-      loadNamingDS(aListOfTranslationAlgo, aResultBody, aBaseShape);
+
+      ListOfShape aBaseShapes;
+      aBaseShapes.push_back(aBaseShape);
+      FeaturesPlugin_Tools::loadModifiedShapes(aResultBody, aBaseShapes, ListOfShape(),
+                                               aListOfTranslationAlgo, aCompound, "Translated");
+
       setResult(aResultBody, aResultIndex);
     }
     aResultIndex++;
@@ -401,31 +412,3 @@ void FeaturesPlugin_MultiTranslation::performTwoDirection()
   // Remove the rest results if there were produced in the previous pass.
   removeResults(aResultIndex);
 }
-
-//=================================================================================================
-void FeaturesPlugin_MultiTranslation::loadNamingDS(
-    std::list<std::shared_ptr<GeomAlgoAPI_Translation> > theListOfTranslationAlgo,
-    std::shared_ptr<ModelAPI_ResultBody> theResultBody,
-    std::shared_ptr<GeomAPI_Shape> theBaseShape)
-{
-  for (std::list<std::shared_ptr<GeomAlgoAPI_Translation> >::const_iterator anIt =
-    theListOfTranslationAlgo.begin(); anIt != theListOfTranslationAlgo.cend(); ++anIt) {
-    // naming of faces
-    theResultBody->loadModifiedShapes(*anIt,
-                                      theBaseShape,
-                                      GeomAPI_Shape::FACE,
-                                      "Translated_Face");
-
-    // naming of edges
-    theResultBody->loadModifiedShapes(*anIt,
-                                      theBaseShape,
-                                      GeomAPI_Shape::EDGE,
-                                      "Translated_Edge");
-
-    // naming of vertex
-    theResultBody->loadModifiedShapes(*anIt,
-                                      theBaseShape,
-                                      GeomAPI_Shape::VERTEX,
-                                      "Translated_Vertex");
-  }
-}
index 4edeb695f7432a0703e4e84d78c4432ebaae7ec3..bb28d98e739994bc74bccb2e380e666ea090643d 100644 (file)
@@ -120,10 +120,6 @@ private:
 
   /// Perform the multi translation in two directions.
   void performTwoDirection();
-
-  void loadNamingDS(std::list<std::shared_ptr<GeomAlgoAPI_Translation> > theListOfTranslationAlgo,
-                    std::shared_ptr<ModelAPI_ResultBody> theResultBody,
-                    std::shared_ptr<GeomAPI_Shape> theBaseShape);
 };
 
 #endif // FEATURESPLUGIN_MULTITRANSLATION_H_
\ No newline at end of file
index c2444556d0c40416c6acab27c0703eed5b626368..2106d4596aba66894eb6d0b99c2496610a7dc1c1 100644 (file)
@@ -29,7 +29,8 @@ void FeaturesPlugin_Tools::loadModifiedShapes(ResultBodyPtr theResultBody,
                                               const ListOfShape& theBaseShapes,
                                               const ListOfShape& theTools,
                                               const GeomMakeShapePtr& theMakeShape,
-                                              const GeomShapePtr theResultShape)
+                                              const GeomShapePtr theResultShape,
+                                              const std::string& theNamePrefix)
 {
   theResultBody->storeModified(theBaseShapes, theResultShape, theMakeShape);
 
@@ -38,11 +39,18 @@ void FeaturesPlugin_Tools::loadModifiedShapes(ResultBodyPtr theResultBody,
   for(; aToolIter != theTools.cend(); aToolIter++)
     aShapes.push_back(*aToolIter);
 
+  std::string aVertexName, anEdgeName, aFaceName;
+  if (!theNamePrefix.empty()) {
+    aVertexName = theNamePrefix + "_Vertex";
+    anEdgeName = theNamePrefix + "_Edge";
+    aFaceName = theNamePrefix + "_Face";
+  }
+
   for (ListOfShape::const_iterator anIter = aShapes.begin(); anIter != aShapes.end(); ++anIter)
   {
-    theResultBody->loadModifiedShapes(theMakeShape, *anIter, GeomAPI_Shape::VERTEX);
-    theResultBody->loadModifiedShapes(theMakeShape, *anIter, GeomAPI_Shape::EDGE);
-    theResultBody->loadModifiedShapes(theMakeShape, *anIter, GeomAPI_Shape::FACE);
+    theResultBody->loadModifiedShapes(theMakeShape, *anIter, GeomAPI_Shape::VERTEX, aVertexName);
+    theResultBody->loadModifiedShapes(theMakeShape, *anIter, GeomAPI_Shape::EDGE, anEdgeName);
+    theResultBody->loadModifiedShapes(theMakeShape, *anIter, GeomAPI_Shape::FACE, aFaceName);
   }
 }
 
index bda339111c61b0def7d5f310eb4d96c4b0d0cea9..815cfade0e622edb4fc17320cc3771c0ff6eebff 100644 (file)
@@ -39,7 +39,8 @@ public:
                                  const ListOfShape& theBaseShapes,
                                  const ListOfShape& theTools,
                                  const GeomMakeShapePtr& theMakeShape,
-                                 const GeomShapePtr theResultShape);
+                                 const GeomShapePtr theResultShape,
+                                 const std::string& theNamePrefix = "");
 
   static void loadModifiedShapes(ResultBodyPtr theResultBody,
                                  const GeomShapePtr& theBaseShape,