From: azv Date: Fri, 25 Jan 2019 09:47:06 +0000 (+0300) Subject: High level objects history implementation for LinearCopy and AngularCopy features. X-Git-Tag: HighLevelObjectsHierarchy~13^2~26 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=c5f8e9b29a4ec001befdc58ad894ad9938c840a0;p=modules%2Fshaper.git High level objects history implementation for LinearCopy and AngularCopy features. --- diff --git a/src/CollectionPlugin/Test/TestGroupMove5.py b/src/CollectionPlugin/Test/TestGroupMove5.py index 0acdd4a8e..400fdaba6 100644 --- a/src/CollectionPlugin/Test/TestGroupMove5.py +++ b/src/CollectionPlugin/Test/TestGroupMove5.py @@ -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()) diff --git a/src/FeaturesPlugin/FeaturesPlugin_MultiRotation.cpp b/src/FeaturesPlugin/FeaturesPlugin_MultiRotation.cpp index 4206e904f..dba9dedf2 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_MultiRotation.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_MultiRotation.cpp @@ -5,8 +5,10 @@ // Author: Clarisse Genrault (CEA) #include +#include #include +#include #include #include #include @@ -176,7 +178,8 @@ void FeaturesPlugin_MultiRotation::performRotation1D() } else { std::string anError; ListOfShape aListOfShape; - std::list > aListOfRotationAlgo; + std::shared_ptr + aListOfRotationAlgo(new GeomAlgoAPI_MakeShapeList); for (int i=0; i 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 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); } diff --git a/src/FeaturesPlugin/FeaturesPlugin_MultiTranslation.cpp b/src/FeaturesPlugin/FeaturesPlugin_MultiTranslation.cpp index ba1c1e8df..ed3665792 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_MultiTranslation.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_MultiTranslation.cpp @@ -19,8 +19,10 @@ // #include +#include #include +#include #include #include @@ -172,7 +174,8 @@ void FeaturesPlugin_MultiTranslation::performOneDirection() } else { std::string anError; ListOfShape aListOfShape; - std::list > aListOfTranslationAlgo; + std::shared_ptr + aListOfTranslationAlgo(new GeomAlgoAPI_MakeShapeList); for (int i=0; i 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 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 > aListOfTranslationAlgo; + std::shared_ptr + aListOfTranslationAlgo(new GeomAlgoAPI_MakeShapeList); for (int j=0; jshape()); - aListOfTranslationAlgo.push_back(aTranslationAlgo); + aListOfTranslationAlgo->appendAlgo(aTranslationAlgo); } } std::shared_ptr 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 > theListOfTranslationAlgo, - std::shared_ptr theResultBody, - std::shared_ptr theBaseShape) -{ - for (std::list >::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"); - } -} diff --git a/src/FeaturesPlugin/FeaturesPlugin_MultiTranslation.h b/src/FeaturesPlugin/FeaturesPlugin_MultiTranslation.h index 4edeb695f..bb28d98e7 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_MultiTranslation.h +++ b/src/FeaturesPlugin/FeaturesPlugin_MultiTranslation.h @@ -120,10 +120,6 @@ private: /// Perform the multi translation in two directions. void performTwoDirection(); - - void loadNamingDS(std::list > theListOfTranslationAlgo, - std::shared_ptr theResultBody, - std::shared_ptr theBaseShape); }; #endif // FEATURESPLUGIN_MULTITRANSLATION_H_ \ No newline at end of file diff --git a/src/FeaturesPlugin/FeaturesPlugin_Tools.cpp b/src/FeaturesPlugin/FeaturesPlugin_Tools.cpp index c2444556d..2106d4596 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_Tools.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_Tools.cpp @@ -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); } } diff --git a/src/FeaturesPlugin/FeaturesPlugin_Tools.h b/src/FeaturesPlugin/FeaturesPlugin_Tools.h index bda339111..815cfade0 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_Tools.h +++ b/src/FeaturesPlugin/FeaturesPlugin_Tools.h @@ -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,