From: mpv Date: Mon, 31 Jul 2017 15:28:18 +0000 (+0300) Subject: Fix for #2241 : correction of history of shapes during movement. X-Git-Tag: V_2.7.2~5 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=2ca2f176d8ee99adf29d119e7ca6fe658fa63e8b;p=modules%2Fshaper.git Fix for #2241 : correction of history of shapes during movement. --- diff --git a/src/FeaturesPlugin/FeaturesPlugin_RemoveSubShapes.cpp b/src/FeaturesPlugin/FeaturesPlugin_RemoveSubShapes.cpp index dbf4fc1ed..53d02ab83 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_RemoveSubShapes.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_RemoveSubShapes.cpp @@ -135,6 +135,8 @@ void FeaturesPlugin_RemoveSubShapes::execute() // find all removed shapes GeomAlgoAPI_MakeShapeCustom aDeletedSubs; + std::set aTypes; // types that where removed + aTypes.insert(GeomAPI_Shape::FACE); for(GeomAPI_ShapeIterator anIt(aBaseShape); anIt.more(); anIt.next()) { if (!anIt.current().get() || anIt.current()->isNull()) continue; @@ -147,9 +149,13 @@ void FeaturesPlugin_RemoveSubShapes::execute() } } if (anIndex == aSubsNb) { // not found in left - GeomAPI_ShapeExplorer aFaces(anIt.current(), GeomAPI_Shape::FACE); - for(; aFaces.more(); aFaces.next()) - aDeletedSubs.addDeleted(aFaces.current()); + aDeletedSubs.addDeleted(anIt.current()); + aTypes.insert(anIt.current()->shapeType()); + if (anIt.current()->shapeType() != GeomAPI_Shape::FACE) { + GeomAPI_ShapeExplorer aFaces(anIt.current(), GeomAPI_Shape::FACE); + for(; aFaces.more(); aFaces.next()) + aDeletedSubs.addDeleted(aFaces.current()); + } } } @@ -160,13 +166,15 @@ void FeaturesPlugin_RemoveSubShapes::execute() // Store result. ResultBodyPtr aResultBody = document()->createBody(data()); aResultBody->storeModified(aBaseShape, aResultShape, 1); - aResultBody->loadDeletedShapes(&aDeletedSubs, aBaseShape, GeomAPI_Shape::FACE, 1); + std::set::iterator aTypeIter = aTypes.begin(); + for(; aTypeIter != aTypes.end(); aTypeIter++) + aResultBody->loadDeletedShapes(&aDeletedSubs, aBaseShape, *aTypeIter, 1); aResultBody->loadAndOrientModifiedShapes(&aCopy, aBaseShape, GeomAPI_Shape::FACE, 2, "Modified_Face", *aCopy.mapOfSubShapes().get(), - true); + true, false, true); setResult(aResultBody); } diff --git a/src/Model/Model_AttributeSelection.cpp b/src/Model/Model_AttributeSelection.cpp index 315e60a88..53fbdccb8 100644 --- a/src/Model/Model_AttributeSelection.cpp +++ b/src/Model/Model_AttributeSelection.cpp @@ -779,16 +779,18 @@ void Model_AttributeSelection::computeValues( ResultPtr theOldContext, ResultPtr theNewContext, TopoDS_Shape theValShape, TopTools_ListOfShape& theShapes) { - TopoDS_Shape anOldContShape = theOldContext->shape()->impl(); - TopoDS_Shape aNewContShape = theNewContext->shape()->impl(); - if (anOldContShape.IsSame(theValShape)) { // full context shape substituted by new full context - theShapes.Append(aNewContShape); - return; - } - if (theValShape.IsNull()) { - theShapes.Append(theValShape); - return; + bool aWasWholeContext = theValShape.IsNull(); + if (aWasWholeContext) { + //theShapes.Append(theValShape); + //return; + theValShape = theOldContext->shape()->impl(); } + //TopoDS_Shape anOldContShape = theOldContext->shape()->impl(); + TopoDS_Shape aNewContShape = theNewContext->shape()->impl(); + //if (anOldContShape.IsSame(theValShape)) { // full context shape substituted by new full context + //theShapes.Append(aNewContShape); + //return; + //} // if a new value is unchanged in the new context, do nothing: value is correct TopExp_Explorer aSubExp(aNewContShape, theValShape.ShapeType()); for(; aSubExp.More(); aSubExp.Next()) { @@ -872,8 +874,9 @@ void Model_AttributeSelection::computeValues( } } } - if (theShapes.IsEmpty()) // nothing was changed - theShapes.Append(theValShape); + if (theShapes.IsEmpty()) { // nothing was changed + theShapes.Append(aWasWholeContext ? TopoDS_Shape() : theValShape); + } } bool Model_AttributeSelection::searchNewContext(std::shared_ptr theDoc, @@ -881,17 +884,24 @@ bool Model_AttributeSelection::searchNewContext(std::shared_ptr TDF_Label theAccessLabel, std::list& theResults, TopTools_ListOfShape& theValShapes) { - std::set aResults; // to avoid duplicates + std::set aResults; // to avoid duplicates, new context, null if deleted TopTools_ListOfShape aResContShapes; TNaming_SameShapeIterator aModifIter(theContShape, theAccessLabel); for(; aModifIter.More(); aModifIter.Next()) { + TDF_Label anObjLab = aModifIter.Label().Father(); ResultPtr aModifierObj = std::dynamic_pointer_cast - (theDoc->objects()->object(aModifIter.Label().Father())); - if (!aModifierObj.get()) - break; + (theDoc->objects()->object(anObjLab)); + if (!aModifierObj.get()) { + // #2241: shape may be sub-element of new object, not main (shell created from faces) + if (!anObjLab.IsRoot()) + aModifierObj = std::dynamic_pointer_cast + (theDoc->objects()->object(anObjLab.Father())); + if (!aModifierObj.get()) + continue; + } FeaturePtr aModifierFeat = theDoc->feature(aModifierObj); if (!aModifierFeat.get()) - break; + continue; FeaturePtr aThisFeature = std::dynamic_pointer_cast(owner()); if (aModifierFeat == aThisFeature || theDoc->objects()->isLater(aModifierFeat, aThisFeature)) continue; // the modifier feature is later than this, so, should not be used @@ -903,11 +913,11 @@ bool Model_AttributeSelection::searchNewContext(std::shared_ptr aModifIter.Label().FindAttribute(TNaming_NamedShape::GetID(), aNewNS); if (aNewNS->Evolution() == TNaming_MODIFY || aNewNS->Evolution() == TNaming_GENERATED) { aResults.insert(aModifierObj); - TNaming_Iterator aPairIter(aNewNS); - aResContShapes.Append(aPairIter.NewShape()); + //TNaming_Iterator aPairIter(aNewNS); + //aResContShapes.Append(aPairIter.NewShape()); + aResContShapes.Append(aModifierObj->shape()->impl()); } else if (aNewNS->Evolution() == TNaming_DELETE) { // a shape was deleted => result is empty aResults.insert(ResultPtr()); - aResContShapes.Append(TopoDS_Shape()); } else { // not-precessed modification => don't support it continue; } @@ -916,8 +926,7 @@ bool Model_AttributeSelection::searchNewContext(std::shared_ptr return false; // no modifications found, must stay the same // iterate all results to find futher modifications std::set::iterator aResIter = aResults.begin(); - TopTools_ListOfShape::Iterator aResShapes(aResContShapes); - for(; aResIter != aResults.end(); aResIter++, aResShapes.Next()) { + for(; aResIter != aResults.end(); aResIter++) { if (aResIter->get() != NULL) { // compute new values by two contextes: the old and the new TopTools_ListOfShape aValShapes; @@ -927,7 +936,11 @@ bool Model_AttributeSelection::searchNewContext(std::shared_ptr for(; aNewVal.More(); aNewVal.Next()) { std::list aNewRes; TopTools_ListOfShape aNewUpdatedVal; - if (searchNewContext(theDoc, aResShapes.Value(), *aResIter, aNewVal.Value(), + TopoDS_Shape aNewValSh = aNewVal.Value(); + TopoDS_Shape aNewContShape = (*aResIter)->shape()->impl(); + if (theValShape.IsNull() && aNewContShape.IsSame(aNewValSh)) + aNewValSh.Nullify(); + if (searchNewContext(theDoc, aNewContShape, *aResIter, aNewValSh, theAccessLabel, aNewRes, aNewUpdatedVal)) { // appeand new results instead of the current ones @@ -939,7 +952,7 @@ bool Model_AttributeSelection::searchNewContext(std::shared_ptr } } else { // the current result is good theResults.push_back(*aResIter); - theValShapes.Append(aNewVal.Value()); + theValShapes.Append(aNewValSh); } } } diff --git a/src/Model/Model_BodyBuilder.cpp b/src/Model/Model_BodyBuilder.cpp index c9384e4e0..ad63bee3e 100755 --- a/src/Model/Model_BodyBuilder.cpp +++ b/src/Model/Model_BodyBuilder.cpp @@ -31,6 +31,7 @@ #include #include #include +#include #include #include #include @@ -251,9 +252,16 @@ void Model_BodyBuilder::storeWithoutNaming(const std::shared_ptr void Model_BodyBuilder::clean() { + TDF_Label aLab = std::dynamic_pointer_cast(data())->shapeLab(); std::map::iterator aBuilder = myBuilders.begin(); - for(; aBuilder != myBuilders.end(); aBuilder++) + for(; aBuilder != myBuilders.end(); aBuilder++) { delete aBuilder->second; + // clear also shapes on cleaned sub-labels (#2241) + Handle(TNaming_NamedShape) aNS; + if (aLab.FindChild(aBuilder->first).FindAttribute(TNaming_NamedShape::GetID(), aNS)) { + aNS->Clear(); + } + } myBuilders.clear(); } diff --git a/src/ModelAPI/CMakeLists.txt b/src/ModelAPI/CMakeLists.txt index 8d574b697..0abe0893a 100644 --- a/src/ModelAPI/CMakeLists.txt +++ b/src/ModelAPI/CMakeLists.txt @@ -168,4 +168,5 @@ ADD_UNIT_TESTS(TestConstants.py Test2170.py TestExternalConstruction.py Test2228.py + Test2241.py ) diff --git a/src/ModelAPI/Test/Test2241.py b/src/ModelAPI/Test/Test2241.py new file mode 100644 index 000000000..5b5684d5b --- /dev/null +++ b/src/ModelAPI/Test/Test2241.py @@ -0,0 +1,171 @@ +## 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 +## + +from salome.shaper import model + +model.begin() +partSet = model.moduleDocument() +Part_1 = model.addPart(partSet) +Part_1_doc = Part_1.document() +model.addParameter(Part_1_doc, "l", "10") +Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY")) +SketchLine_1 = Sketch_1.addLine(0, 60, 10, 60) +SketchLine_2 = Sketch_1.addLine(model.selection("EDGE", "PartSet/OY")) +SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchLine_1.startPoint(), SketchLine_2.result()) +SketchLine_3 = Sketch_1.addLine(10, 60, 10, 40) +SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_3.startPoint()) +SketchLine_4 = Sketch_1.addLine(10, 40, 20, 40) +SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchLine_3.endPoint(), SketchLine_4.startPoint()) +SketchLine_5 = Sketch_1.addLine(20, 40, 20, 20) +SketchConstraintCoincidence_4 = Sketch_1.setCoincident(SketchLine_4.endPoint(), SketchLine_5.startPoint()) +SketchLine_6 = Sketch_1.addLine(20, 20, 30, 20) +SketchConstraintCoincidence_5 = Sketch_1.setCoincident(SketchLine_5.endPoint(), SketchLine_6.startPoint()) +SketchLine_7 = Sketch_1.addLine(30, 20, 30, 0) +SketchConstraintCoincidence_6 = Sketch_1.setCoincident(SketchLine_6.endPoint(), SketchLine_7.startPoint()) +SketchLine_8 = Sketch_1.addLine(model.selection("EDGE", "PartSet/OX")) +SketchConstraintCoincidence_7 = Sketch_1.setCoincident(SketchLine_7.endPoint(), SketchLine_8.result()) +SketchLine_9 = Sketch_1.addLine(30, 0, 81.26217508737108, 0) +SketchConstraintCoincidence_8 = Sketch_1.setCoincident(SketchLine_7.endPoint(), SketchLine_9.startPoint()) +SketchConstraintCoincidence_9 = Sketch_1.setCoincident(SketchLine_9.endPoint(), SketchLine_8.result()) +SketchLine_10 = Sketch_1.addLine(0, 60, 0, 81.26217508737108) +SketchConstraintCoincidence_10 = Sketch_1.setCoincident(SketchLine_1.startPoint(), SketchLine_10.startPoint()) +SketchConstraintCoincidence_11 = Sketch_1.setCoincident(SketchLine_10.endPoint(), SketchLine_2.result()) +SketchConstraintHorizontal_1 = Sketch_1.setHorizontal(SketchLine_1.result()) +SketchConstraintHorizontal_2 = Sketch_1.setHorizontal(SketchLine_4.result()) +SketchConstraintHorizontal_3 = Sketch_1.setHorizontal(SketchLine_6.result()) +SketchConstraintVertical_1 = Sketch_1.setVertical(SketchLine_3.result()) +SketchConstraintVertical_2 = Sketch_1.setVertical(SketchLine_5.result()) +SketchArc_1 = Sketch_1.addArc(4.151438510550382e-034, -3.089278765476956e-034, 81.26217508737108, 0, 0, 81.26217508737108, False) +SketchConstraintCoincidence_12 = Sketch_1.setCoincident(SketchLine_2.startPoint(), SketchArc_1.center()) +SketchConstraintCoincidence_13 = Sketch_1.setCoincident(SketchLine_9.endPoint(), SketchArc_1.startPoint()) +SketchConstraintCoincidence_14 = Sketch_1.setCoincident(SketchLine_2.result(), SketchArc_1.endPoint()) +SketchConstraintCoincidence_15 = Sketch_1.setCoincident(SketchLine_10.endPoint(), SketchArc_1.endPoint()) +SketchConstraintVertical_3 = Sketch_1.setVertical(SketchLine_7.result()) +SketchArc_2 = Sketch_1.addArc(4.151438510550382e-034, -3.089278765476956e-034, 76.26217508737108, 0, 0, 76.26217508737108, False) +SketchConstraintCoincidence_16 = Sketch_1.setCoincident(SketchLine_2.startPoint(), SketchArc_2.center()) +SketchConstraintCoincidence_16.setName("SketchConstraintCoincidence_23") +SketchConstraintCoincidence_17 = Sketch_1.setCoincident(SketchLine_9.result(), SketchArc_2.startPoint()) +SketchConstraintCoincidence_17.setName("SketchConstraintCoincidence_24") +SketchConstraintCoincidence_18 = Sketch_1.setCoincident(SketchLine_10.result(), SketchArc_2.endPoint()) +SketchConstraintCoincidence_18.setName("SketchConstraintCoincidence_25") +SketchConstraintDistance_1 = Sketch_1.setDistance(SketchArc_1.endPoint(), SketchArc_2.endPoint(), 5) +SketchConstraintLength_1 = Sketch_1.setLength(SketchLine_7.result(), "2*l") +SketchConstraintLength_1.setName("SketchConstraintLength_2") +SketchConstraintLength_2 = Sketch_1.setLength(SketchLine_6.result(), "l") +SketchConstraintLength_2.setName("SketchConstraintLength_3") +SketchConstraintEqual_1 = Sketch_1.setEqual(SketchLine_5.result(), SketchLine_7.result()) +SketchConstraintEqual_1.setName("SketchConstraintEqual_2") +SketchConstraintEqual_2 = Sketch_1.setEqual(SketchLine_6.result(), SketchLine_4.result()) +SketchConstraintEqual_2.setName("SketchConstraintEqual_3") +SketchConstraintEqual_3 = Sketch_1.setEqual(SketchLine_5.result(), SketchLine_3.result()) +SketchConstraintEqual_3.setName("SketchConstraintEqual_4") +SketchConstraintEqual_4 = Sketch_1.setEqual(SketchLine_4.result(), SketchLine_1.result()) +SketchConstraintEqual_4.setName("SketchConstraintEqual_5") +model.do() +Sketch_2 = model.addSketch(Part_1_doc, model.defaultPlane("XOY")) +SketchCircle_1 = Sketch_2.addCircle(9.082839147404137, 71.32948234489588, 2.005056553640547) +SketchCircle_2 = Sketch_2.addCircle(20.11065019242717, 63.7102674410618, 2.268462537186828) +SketchCircle_3 = Sketch_2.addCircle(26.52683116407693, 51.67992811921848, 2.727171758268866) +SketchCircle_4 = Sketch_2.addCircle(38.35666483055617, 58.29661474623231, 3.007584830460834) +SketchCircle_5 = Sketch_2.addCircle(33.94554041254697, 44.0607132153844, 3.054011155390377) +SketchCircle_6 = Sketch_2.addCircle(48.58245325412298, 42.45666797247195, 2.346858526438435) +SketchCircle_7 = Sketch_2.addCircle(38.95818179664835, 31.42885692744893, 3.547307159201095) +SketchCircle_8 = Sketch_2.addCircle(63.82088306179116, 27.41874382016783, 4.536925074373651) +SketchCircle_9 = Sketch_2.addCircle(50.18649849703544, 28.4212720969881, 4.820482891521984) +SketchCircle_10 = Sketch_2.addCircle(49.58498153094326, 15.18789884296047, 2.552020354335177) +SketchCircle_11 = Sketch_2.addCircle(66.22695092615982, 10.77677442495125, 4.536925074373645) +SketchCircle_12 = Sketch_2.addCircle(50.98852111849166, 6.165144351577979, 3.547307159201085) +model.do() +Face_1 = model.addFace(Part_1_doc, [model.selection("WIRE", "Sketch_1/Wire-SketchLine_1f-SketchLine_3f-SketchLine_4f-SketchLine_5f-SketchLine_6f-SketchLine_7f-SketchLine_9f-SketchLine_10r-SketchArc_2_2f")]) +Face_2 = model.addFace(Part_1_doc, [model.selection("WIRE", "Sketch_1/Wire-SketchLine_9f-SketchLine_10r-SketchArc_1_2f-SketchArc_2_2r")]) +Face_3 = model.addFace(Part_1_doc, [model.selection("EDGE", "Sketch_2/Edge-SketchCircle_1_2"), model.selection("EDGE", "Sketch_2/Edge-SketchCircle_2_2"), model.selection("EDGE", "Sketch_2/Edge-SketchCircle_3_2"), model.selection("EDGE", "Sketch_2/Edge-SketchCircle_4_2"), model.selection("EDGE", "Sketch_2/Edge-SketchCircle_5_2"), model.selection("EDGE", "Sketch_2/Edge-SketchCircle_6_2"), model.selection("EDGE", "Sketch_2/Edge-SketchCircle_7_2"), model.selection("EDGE", "Sketch_2/Edge-SketchCircle_9_2"), model.selection("EDGE", "Sketch_2/Edge-SketchCircle_8_2"), model.selection("EDGE", "Sketch_2/Edge-SketchCircle_10_2"), model.selection("EDGE", "Sketch_2/Edge-SketchCircle_12_2"), model.selection("EDGE", "Sketch_2/Edge-SketchCircle_11_2")]) +Face_4 = model.addFace(Part_1_doc, [model.selection("EDGE", "Sketch_2/Edge-SketchCircle_1_2"), model.selection("EDGE", "Sketch_2/Edge-SketchCircle_2_2"), model.selection("EDGE", "Sketch_2/Edge-SketchCircle_3_2"), model.selection("EDGE", "Sketch_2/Edge-SketchCircle_4_2"), model.selection("EDGE", "Sketch_2/Edge-SketchCircle_5_2"), model.selection("EDGE", "Sketch_2/Edge-SketchCircle_7_2"), model.selection("EDGE", "Sketch_2/Edge-SketchCircle_6_2"), model.selection("EDGE", "Sketch_2/Edge-SketchCircle_9_2"), model.selection("EDGE", "Sketch_2/Edge-SketchCircle_8_2"), model.selection("EDGE", "Sketch_2/Edge-SketchCircle_10_2"), model.selection("EDGE", "Sketch_2/Edge-SketchCircle_12_2"), model.selection("EDGE", "Sketch_2/Edge-SketchCircle_11_2"), model.selection("WIRE", "Sketch_1/Wire-SketchLine_1f-SketchLine_3f-SketchLine_4f-SketchLine_5f-SketchLine_6f-SketchLine_7f-SketchLine_9f-SketchLine_10r-SketchArc_2_2f")]) +Sketch_3 = model.addSketch(Part_1_doc, model.selection("FACE", "PartSet/XOY")) +SketchLine_11 = Sketch_3.addLine(40, 0, 30, 0) +SketchPoint_1 = Sketch_3.addPoint(model.selection("VERTEX", "Face_1_1/Edge_4&Face_1_1/Edge_5")) +SketchConstraintCoincidence_19 = Sketch_3.setCoincident(SketchLine_11.endPoint(), SketchPoint_1.result()) +SketchLine_12 = Sketch_3.addLine(30, 0, 30, 10) +SketchLine_13 = Sketch_3.addLine(30, 10, 40, 10) +SketchLine_14 = Sketch_3.addLine(40, 10, 40, 0) +SketchConstraintCoincidence_20 = Sketch_3.setCoincident(SketchLine_14.endPoint(), SketchLine_11.startPoint()) +SketchConstraintCoincidence_21 = Sketch_3.setCoincident(SketchLine_11.endPoint(), SketchLine_12.startPoint()) +SketchConstraintCoincidence_22 = Sketch_3.setCoincident(SketchLine_12.endPoint(), SketchLine_13.startPoint()) +SketchConstraintCoincidence_23 = Sketch_3.setCoincident(SketchLine_13.endPoint(), SketchLine_14.startPoint()) +SketchConstraintCoincidence_23.setName("SketchConstraintCoincidence_26") +SketchConstraintHorizontal_4 = Sketch_3.setHorizontal(SketchLine_11.result()) +SketchConstraintVertical_4 = Sketch_3.setVertical(SketchLine_12.result()) +SketchConstraintHorizontal_5 = Sketch_3.setHorizontal(SketchLine_13.result()) +SketchConstraintVertical_5 = Sketch_3.setVertical(SketchLine_14.result()) +SketchConstraintEqual_5 = Sketch_3.setEqual(SketchLine_14.result(), SketchLine_13.result()) +SketchConstraintEqual_5.setName("SketchConstraintEqual_6") +SketchConstraintLength_3 = Sketch_3.setLength(SketchLine_13.result(), "l") +SketchConstraintLength_3.setName("SketchConstraintLength_4") +model.do() +Face_5 = model.addFace(Part_1_doc, [model.selection("WIRE", "Sketch_3/Wire-SketchLine_11r-SketchLine_12r-SketchLine_13r-SketchLine_14r")]) +MultiTranslation_1 = model.addMultiTranslation(Part_1_doc, [model.selection("FACE", "Face_5_1")], model.selection("EDGE", "PartSet/OX"), "l", 4, model.selection("EDGE", "PartSet/OY"), "l", 2) +Recover_1 = model.addRecover(Part_1_doc, MultiTranslation_1, [Face_5.result()]) +Translation_1 = model.addTranslation(Part_1_doc, [model.selection("FACE", "Recover_1_1")], model.selection("VERTEX", "Face_4_1/Edge_4&Face_4_1/Edge_5"), model.selection("VERTEX", "Face_4_1/Edge_6&Face_4_1/Edge_7")) +MultiTranslation_2 = model.addMultiTranslation(Part_1_doc, [model.selection("FACE", "Translation_1_1")], model.selection("EDGE", "PartSet/OX"), "l", 4, model.selection("EDGE", "PartSet/OY"), "l", 2) +Recover_2 = model.addRecover(Part_1_doc, MultiTranslation_1, [Face_5.result()]) +Translation_2 = model.addTranslation(Part_1_doc, [model.selection("FACE", "Recover_2_1")], model.selection("VERTEX", "Face_4_1/Edge_4&Face_4_1/Edge_5"), model.selection("VERTEX", "Face_4_1/Edge_8&Face_4_1/Edge_9")) +MultiTranslation_3 = model.addMultiTranslation(Part_1_doc, [model.selection("FACE", "Translation_2_1")], model.selection("EDGE", "PartSet/OX"), "l", 4) +Recover_3 = model.addRecover(Part_1_doc, MultiTranslation_1, [Face_5.result()]) +Translation_3 = model.addTranslation(Part_1_doc, [model.selection("FACE", "Recover_3_1")], model.selection("VERTEX", "Face_4_1/Edge_4&Face_4_1/Edge_5"), model.selection("VERTEX", "MultiTranslation_3_1/Translated_Edge_1_4&MultiTranslation_3_1/Translated_Edge_1_1")) +MultiTranslation_4 = model.addMultiTranslation(Part_1_doc, [model.selection("FACE", "Translation_3_1")], model.selection("EDGE", "PartSet/OX"), "l", 3) +Recover_4 = model.addRecover(Part_1_doc, MultiTranslation_1, [Face_5.result()]) +Translation_4 = model.addTranslation(Part_1_doc, [model.selection("FACE", "Recover_4_1")], model.selection("VERTEX", "Face_4_1/Edge_4&Face_4_1/Edge_5"), model.selection("VERTEX", "Face_4_1/Edge_1&Face_4_1/Edge_2")) +MultiTranslation_5 = model.addMultiTranslation(Part_1_doc, [model.selection("FACE", "Translation_4_1")], model.selection("EDGE", "PartSet/OX"), "l", 2) +Group_1 = model.addGroup(Part_1_doc, [model.selection("FACE", "MultiTranslation_4_1_2"), model.selection("FACE", "MultiTranslation_1_1_8"), model.selection("FACE", "MultiTranslation_1_1_4"), model.selection("FACE", "MultiTranslation_1_1_3"), model.selection("FACE", "MultiTranslation_1_1_6"), model.selection("FACE", "MultiTranslation_1_1_2"), model.selection("FACE", "MultiTranslation_1_1_7"), model.selection("FACE", "MultiTranslation_2_1_3"), model.selection("FACE", "MultiTranslation_3_1_4"), model.selection("FACE", "MultiTranslation_2_1_8"), model.selection("FACE", "MultiTranslation_2_1_4"), model.selection("FACE", "MultiTranslation_2_1_7"), model.selection("FACE", "MultiTranslation_4_1_3"), model.selection("FACE", "MultiTranslation_1_1_1"), model.selection("FACE", "MultiTranslation_5_1_2"), model.selection("FACE", "MultiTranslation_4_1_1"), model.selection("FACE", "MultiTranslation_5_1_1"), model.selection("FACE", "MultiTranslation_3_1_3"), model.selection("FACE", "MultiTranslation_3_1_2"), model.selection("FACE", "MultiTranslation_3_1_1"), model.selection("FACE", "MultiTranslation_2_1_6"), model.selection("FACE", "MultiTranslation_2_1_2"), model.selection("FACE", "MultiTranslation_2_1_5"), model.selection("FACE", "MultiTranslation_2_1_1"), model.selection("FACE", "MultiTranslation_1_1_5")]) +Group_1.setName("Group_3") +Group_1.result().setName("assemblages") +Group_2 = model.addGroup(Part_1_doc, [model.selection("FACE", "Face_2_1"), model.selection("FACE", "Face_3_7"), model.selection("FACE", "Face_3_5"), model.selection("FACE", "Face_3_3"), model.selection("FACE", "Face_3_4"), model.selection("FACE", "Face_3_1"), model.selection("FACE", "Face_3_2"), model.selection("FACE", "Face_3_6"), model.selection("FACE", "Face_3_11"), model.selection("FACE", "Face_3_10"), model.selection("FACE", "Face_3_8"), model.selection("FACE", "Face_3_9"), model.selection("FACE", "Face_3_12")]) +Group_2.setName("Group_1") +Group_2.result().setName("eau") +Group_2.result().setColor(0, 170, 255) +Group_3 = model.addGroup(Part_1_doc, [model.selection("FACE", "Face_4_1")]) +Group_3.setName("Group_2") +Group_3.result().setName("acier") +Group_3.result().setColor(170, 85, 0) +Shell_1 = model.addShell(Part_1_doc, [model.selection("FACE", "MultiTranslation_1_1_1"), model.selection("FACE", "MultiTranslation_1_1_2"), model.selection("FACE", "MultiTranslation_1_1_3"), model.selection("FACE", "MultiTranslation_1_1_4"), model.selection("FACE", "MultiTranslation_1_1_5"), model.selection("FACE", "MultiTranslation_1_1_6"), model.selection("FACE", "MultiTranslation_1_1_7"), model.selection("FACE", "MultiTranslation_2_1_4"), model.selection("FACE", "MultiTranslation_2_1_5"), model.selection("FACE", "MultiTranslation_2_1_6"), model.selection("FACE", "MultiTranslation_2_1_7"), model.selection("FACE", "MultiTranslation_2_1_8"), model.selection("FACE", "MultiTranslation_2_1_1"), model.selection("FACE", "MultiTranslation_2_1_2"), model.selection("FACE", "MultiTranslation_2_1_3"), model.selection("FACE", "MultiTranslation_3_1_4"), model.selection("FACE", "MultiTranslation_3_1_3"), model.selection("FACE", "MultiTranslation_3_1_2"), model.selection("FACE", "MultiTranslation_3_1_1"), model.selection("FACE", "MultiTranslation_4_1_1"), model.selection("FACE", "MultiTranslation_4_1_2"), model.selection("FACE", "MultiTranslation_4_1_3"), model.selection("FACE", "MultiTranslation_5_1_1"), model.selection("FACE", "MultiTranslation_5_1_2"), model.selection("FACE", "MultiTranslation_1_1_8")]) +Partition_1 = model.addPartition(Part_1_doc, [model.selection("FACE", "Face_3_1"), model.selection("FACE", "Face_3_2"), model.selection("FACE", "Face_4_1"), model.selection("FACE", "Face_2_1"), model.selection("FACE", "Face_1_1"), model.selection("FACE", "Face_3_5"), model.selection("FACE", "Face_3_3"), model.selection("FACE", "Face_3_4"), model.selection("FACE", "Face_3_7"), model.selection("FACE", "Face_3_6"), model.selection("FACE", "Face_3_8"), model.selection("FACE", "Face_3_9"), model.selection("FACE", "Face_3_10"), model.selection("FACE", "Face_3_11"), model.selection("FACE", "Face_3_12"), model.selection("SHELL", "Shell_1_1")]) +Remove_SubShapes_1 = model.addRemoveSubShapes(Part_1_doc, model.selection("COMPOUND", "Partition_1_1")) +Remove_SubShapes_1.setSubShapesToKeep([model.selection("FACE", "Partition_1_1_2"), model.selection("FACE", "Partition_1_1_3"), model.selection("FACE", "Partition_1_1_4"), model.selection("FACE", "Partition_1_1_5"), model.selection("FACE", "Partition_1_1_6"), model.selection("FACE", "Partition_1_1_7"), model.selection("FACE", "Partition_1_1_8"), model.selection("FACE", "Partition_1_1_9"), model.selection("FACE", "Partition_1_1_10"), model.selection("FACE", "Partition_1_1_11"), model.selection("FACE", "Partition_1_1_12"), model.selection("FACE", "Partition_1_1_13"), model.selection("FACE", "Partition_1_1_14"), model.selection("FACE", "Partition_1_1_15"), model.selection("FACE", "Partition_1_1_16"), model.selection("FACE", "Partition_1_1_17"), model.selection("FACE", "Partition_1_1_18"), model.selection("FACE", "Partition_1_1_19"), model.selection("FACE", "Partition_1_1_20"), model.selection("FACE", "Partition_1_1_21"), model.selection("FACE", "Partition_1_1_22"), model.selection("FACE", "Partition_1_1_23"), model.selection("FACE", "Partition_1_1_24"), model.selection("FACE", "Partition_1_1_25"), model.selection("FACE", "Partition_1_1_26"), model.selection("FACE", "Partition_1_1_27"), model.selection("FACE", "Partition_1_1_28"), model.selection("FACE", "Partition_1_1_29"), model.selection("FACE", "Partition_1_1_30"), model.selection("FACE", "Partition_1_1_31"), model.selection("FACE", "Partition_1_1_32"), model.selection("FACE", "Partition_1_1_33"), model.selection("FACE", "Partition_1_1_34"), model.selection("FACE", "Partition_1_1_35"), model.selection("FACE", "Partition_1_1_36"), model.selection("FACE", "Partition_1_1_37"), model.selection("FACE", "Partition_1_1_38"), model.selection("FACE", "Partition_1_1_39"), model.selection("FACE", "Partition_1_1_40"), model.selection("FACE", "Partition_1_1_41"), model.selection("FACE", "Partition_1_1_42"), model.selection("FACE", "Partition_1_1_43"), model.selection("FACE", "Partition_1_1_44"), model.selection("FACE", "Partition_1_1_45"), model.selection("FACE", "Partition_1_1_46"), model.selection("FACE", "Partition_1_1_47"), model.selection("FACE", "Partition_1_1_48"), model.selection("FACE", "Partition_1_1_49"), model.selection("FACE", "Partition_1_1_50"), model.selection("FACE", "Partition_1_1_51"), model.selection("FACE", "Partition_1_1_52"), model.selection("FACE", "Partition_1_1_53"), model.selection("FACE", "Partition_1_1_54"), model.selection("FACE", "Partition_1_1_55"), model.selection("FACE", "Partition_1_1_56"), model.selection("FACE", "Partition_1_1_57")]) +model.end() + +# move groups +model.begin() +Part_1_doc.moveFeature(Group_1.feature(), Remove_SubShapes_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 that groups 2 and 3 are correct, but Group_1 elements are removed (because shell is removed) +from ModelAPI import * +aFactory = ModelAPI_Session.get().validators() +for Group in [Group_1, Group_2, Group_3]: + if Group != Group_1: + assert(aFactory.validate(Group.feature())) + assert(Group.groupList().size() != 0) + for a in range(Group.groupList().size()): + if Group == Group_1: + assert(len(Group.groupList().value(a).namingName()) == 0) + else: + assert(Group.groupList().value(a).value().shapeTypeStr() == "FACE") + assert(len(Group.groupList().value(a).namingName()) > 0)