From: azv Date: Wed, 30 Jan 2019 13:14:43 +0000 (+0300) Subject: High level objects history implementation for Fillet feature. X-Git-Tag: HighLevelObjectsHierarchy~13^2~20 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=ae8dbf817ae24d214f25fd55333fffc827e6c15d;p=modules%2Fshaper.git High level objects history implementation for Fillet feature. --- diff --git a/src/CollectionPlugin/CMakeLists.txt b/src/CollectionPlugin/CMakeLists.txt index 489360376..390923332 100644 --- a/src/CollectionPlugin/CMakeLists.txt +++ b/src/CollectionPlugin/CMakeLists.txt @@ -35,7 +35,7 @@ SET(PROJECT_HEADERS CollectionPlugin_Field.h CollectionPlugin_WidgetCreator.h CollectionPlugin_WidgetField.h - CollectionPlugin_Validators.h + CollectionPlugin_Validators.h ) SET(PROJECT_MOC_HEADERS @@ -48,7 +48,7 @@ SET(PROJECT_SOURCES CollectionPlugin_Field.cpp CollectionPlugin_WidgetCreator.cpp CollectionPlugin_WidgetField.cpp - CollectionPlugin_Validators.cpp + CollectionPlugin_Validators.cpp ) SET(XML_RESOURCES @@ -115,5 +115,6 @@ ADD_UNIT_TESTS( TestGroupMove5.py TestGroupMove6.py TestGroupMove7.py + TestGroupMove8.py TestGroupShareTopology.py ) diff --git a/src/CollectionPlugin/Test/TestGroupMove8.py b/src/CollectionPlugin/Test/TestGroupMove8.py new file mode 100644 index 000000000..7c0451e57 --- /dev/null +++ b/src/CollectionPlugin/Test/TestGroupMove8.py @@ -0,0 +1,128 @@ +## Copyright (C) 2014-2017 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 +## + +# Test of deep nested results history. Fillet operation. +# Check the groups of initial solids moved to the end contain the corresponding +# results, but divided. + +from salome.shaper import model + +model.begin() +partSet = model.moduleDocument() +Part_1 = model.addPart(partSet) +Part_1_doc = Part_1.document() +Box_1 = model.addBox(Part_1_doc, 10, 10, 10) +Group_1 = model.addGroup(Part_1_doc, [model.selection("SOLID", "Box_1_1")]) +Group_2_objects = [model.selection("FACE", "Box_1_1/Back"), model.selection("FACE", "Box_1_1/Top"), model.selection("FACE", "Box_1_1/Right"), model.selection("FACE", "Box_1_1/Left"), model.selection("FACE", "Box_1_1/Bottom"), model.selection("FACE", "Box_1_1/Front")] +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/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/Right][Box_1_1/Bottom]"), model.selection("EDGE", "[Box_1_1/Front][Box_1_1/Bottom]"), model.selection("EDGE", "[Box_1_1/Front][Box_1_1/Right]"), model.selection("EDGE", "[Box_1_1/Front][Box_1_1/Left]"), model.selection("EDGE", "[Box_1_1/Front][Box_1_1/Top]")] +Group_3 = model.addGroup(Part_1_doc, Group_3_objects) +Cylinder_1 = model.addCylinder(Part_1_doc, model.selection("VERTEX", "[Box_1_1/Back][Box_1_1/Left][Box_1_1/Top]"), model.selection("EDGE", "PartSet/OZ"), 5, 10) +Group_4 = model.addGroup(Part_1_doc, [model.selection("SOLID", "Cylinder_1_1")]) +Group_5_objects = [model.selection("FACE", "Cylinder_1_1/Face_1"), model.selection("FACE", "Cylinder_1_1/Face_2"), model.selection("FACE", "Cylinder_1_1/Face_3")] +Group_5 = model.addGroup(Part_1_doc, Group_5_objects) +Group_6_objects = [model.selection("EDGE", "[Cylinder_1_1/Face_1][Cylinder_1_1/Face_2]"), model.selection("EDGE", "[Cylinder_1_1/Face_1][Cylinder_1_1/Face_3]"), model.selection("EDGE", "([Cylinder_1_1/Face_1][Cylinder_1_1/Face_2])([Cylinder_1_1/Face_1][Cylinder_1_1/Face_3])")] +Group_6 = model.addGroup(Part_1_doc, Group_6_objects) +Fillet_1 = model.addFillet(Part_1_doc, [model.selection("EDGE", "[Box_1_1/Front][Box_1_1/Top]")], 2) +model.do() +# move groups to the end +Part_1_doc.moveFeature(Group_1.feature(), Fillet_1.feature()) +Part_1_doc.moveFeature(Group_2.feature(), Group_1.feature()) +Part_1_doc.moveFeature(Group_3.feature(), Group_2.feature()) +model.end() + +from ModelAPI import * + +aFactory = ModelAPI_Session.get().validators() + +# groups related to original box should be split +selectionList = Group_1.feature().selectionList("group_list") +assert(selectionList.size() == 1) +assert(aFactory.validate(Group_1.feature())) + +selectionList = Group_2.feature().selectionList("group_list") +assert(selectionList.size() == 6) +assert(aFactory.validate(Group_2.feature())) + +selectionList = Group_3.feature().selectionList("group_list") +assert(selectionList.size() == 11) +assert(aFactory.validate(Group_3.feature())) + +model.begin() +Fillet_2 = model.addFillet(Part_1_doc, [model.selection("FACE", "Cylinder_1_1/Face_2")], 2) +model.do() +# move groups to the end +Part_1_doc.moveFeature(Group_4.feature(), Fillet_2.feature()) +Part_1_doc.moveFeature(Group_5.feature(), Group_4.feature()) +Part_1_doc.moveFeature(Group_6.feature(), Group_5.feature()) +model.end() + +# groups related to original cylinder should be split +selectionList = Group_4.feature().selectionList("group_list") +assert(selectionList.size() == 1) +assert(aFactory.validate(Group_4.feature())) + +selectionList = Group_5.feature().selectionList("group_list") +assert(selectionList.size() == 3) +assert(aFactory.validate(Group_5.feature())) + +selectionList = Group_6.feature().selectionList("group_list") +assert(selectionList.size() == 3) +assert(aFactory.validate(Group_6.feature())) + +model.begin() +Fillet_3 = model.addFillet(Part_1_doc, [model.selection("EDGE", "[Fillet_1_1/MF:Fillet_Face&Box_1_1/Front][Fillet_1_1/MF:Fillet_Face&Box_1_1/Left]")], 1, 2) +model.do() +# move groups to the end +Part_1_doc.moveFeature(Group_1.feature(), Fillet_3.feature()) +Part_1_doc.moveFeature(Group_2.feature(), Group_1.feature()) +Part_1_doc.moveFeature(Group_3.feature(), Group_2.feature()) +Part_1_doc.moveFeature(Group_4.feature(), Group_3.feature()) +Part_1_doc.moveFeature(Group_5.feature(), Group_4.feature()) +Part_1_doc.moveFeature(Group_6.feature(), Group_5.feature()) +model.end() + +# groups related to original box should be split +selectionList = Group_1.feature().selectionList("group_list") +assert(selectionList.size() == 1) +assert(aFactory.validate(Group_1.feature())) + +selectionList = Group_2.feature().selectionList("group_list") +assert(selectionList.size() == 6) +assert(aFactory.validate(Group_2.feature())) + +selectionList = Group_3.feature().selectionList("group_list") +assert(selectionList.size() == 9) +assert(aFactory.validate(Group_3.feature())) + +# groups related to original cylinder should stay untouched +selectionList = Group_4.feature().selectionList("group_list") +assert(selectionList.size() == 1) +assert(aFactory.validate(Group_4.feature())) + +selectionList = Group_5.feature().selectionList("group_list") +assert(selectionList.size() == 3) +assert(aFactory.validate(Group_5.feature())) + +selectionList = Group_6.feature().selectionList("group_list") +assert(selectionList.size() == 2) +assert(aFactory.validate(Group_6.feature())) + +assert(model.checkPythonDump()) diff --git a/src/FeaturesPlugin/FeaturesPlugin_Fillet.cpp b/src/FeaturesPlugin/FeaturesPlugin_Fillet.cpp index cf1dda3d2..6419dfe57 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_Fillet.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_Fillet.cpp @@ -19,6 +19,7 @@ // #include "FeaturesPlugin_Fillet.h" +#include "FeaturesPlugin_Tools.h" #include #include @@ -29,6 +30,7 @@ #include #include +#include #include #include #include @@ -62,7 +64,7 @@ static ListOfShape selectEdges(const ListOfShape& theShapes) return anEdges; } -// If theShape is a compound of single shape, return it +// If theShape is a compound of a single sub-shape, return this sub-shape static GeomShapePtr unwrapCompound(const GeomShapePtr& theShape) { GeomShapePtr aShape = theShape; @@ -150,6 +152,9 @@ void FeaturesPlugin_Fillet::execute() int aResultIndex = 0; std::string anError; + std::vector aResultBaseAlgoList; + ListOfShape anOriginalShapesList, aResultShapesList; + GeomAPI_DataMapOfShapeMapOfShapes::iterator anIt = aSolidsAndSubs.begin(); for (; anIt != aSolidsAndSubs.end(); ++anIt) { GeomShapePtr aSolid = anIt.first(); @@ -170,10 +175,29 @@ void FeaturesPlugin_Fillet::execute() std::shared_ptr aResultBody = document()->createBody(data(), aResultIndex); - loadNamingDS(aResultBody, aSolid, aResult, aFilletBuilder); + ListOfShape aBaseShapes; + aBaseShapes.push_back(aSolid); + FeaturesPlugin_Tools::loadModifiedShapes(aResultBody, aBaseShapes, ListOfShape(), + aFilletBuilder, aResult, "Fillet"); + setResult(aResultBody, aResultIndex); aResultIndex++; + + FeaturesPlugin_Tools::ResultBaseAlgo aRBA; + aRBA.resultBody = aResultBody; + aRBA.baseShape = aSolid; + aRBA.makeShape = aFilletBuilder; + aResultBaseAlgoList.push_back(aRBA); + aResultShapesList.push_back(aResult); + anOriginalShapesList.push_back(aSolid); } + + // Store deleted shapes after all results has been proceeded. This is to avoid issue when in one + // result shape has been deleted, but in another it was modified or stayed. + GeomShapePtr aResultShapesCompound = GeomAlgoAPI_CompoundBuilder::compound(aResultShapesList); + FeaturesPlugin_Tools::loadDeletedShapes(aResultBaseAlgoList, + anOriginalShapesList, aResultShapesCompound); + removeResults(aResultIndex); }