From: mpv Date: Wed, 21 Nov 2018 07:26:12 +0000 (+0300) Subject: Fix for the #1757 with full split of the selected sketch-face. X-Git-Tag: End2018~159 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=43bf7e7ab5fd11b71c8221f0929252de9bf6a7e0;p=modules%2Fshaper.git Fix for the #1757 with full split of the selected sketch-face. --- diff --git a/src/ModelAPI/Test/Test1757.py b/src/ModelAPI/Test/Test1757.py index 4881b65ea..6f725da2c 100644 --- a/src/ModelAPI/Test/Test1757.py +++ b/src/ModelAPI/Test/Test1757.py @@ -92,7 +92,7 @@ Part_1.document().setCurrentFeature(ExtrusionCut_1.feature(), True) #========================================================================= # Modify the cylindrical hole base face by another groove in the history before the hole is created #========================================================================= -ExtrusionCut_3 = model.addExtrusionCut(Part_1_doc, [], model.selection(), model.selection(), 0, model.selection("FACE", "Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_4"), -50, [model.selection("SOLID", "ExtrusionCut_1_1")]) +ExtrusionCut_3 = model.addExtrusionCut(Part_1_doc, [], model.selection(), model.selection(), 0, model.selection("FACE", "Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_4"), 0, [model.selection("SOLID", "ExtrusionCut_1_1")]) Sketch_4 = model.addSketch(Part_1_doc, model.selection("FACE", "Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_2")) SketchLine_9 = Sketch_4.addLine(-176.701443076057, -151.212050129331, -91.83965287802501, -151.212050129331) SketchLine_10 = Sketch_4.addLine(-91.83965287802501, -151.212050129331, -91.83965287802501, -84.473709256573) @@ -125,6 +125,6 @@ import ModelAPI assert(ModelAPI.ModelAPI_Session.get().validators().validate(Sketch_4.feature())) assert(ModelAPI.ModelAPI_Session.get().validators().validate(ExtrusionCut_2.feature())) -assert(Sketch_3.feature().selection("External").namingName() == "(ExtrusionCut_1_1/Modified_Face&Extrusion_1_1/From_Face)(ExtrusionCut_3_1/Modified_Face&Sketch_2/SketchLine_6)(ExtrusionCut_1_1/Modified_Face&Extrusion_1_1/To_Face)(Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_4)") +assert(Sketch_3.feature().selection("External").namingName() == "(ExtrusionCut_3_1/Modified_Face&Sketch_2/SketchLine_6)(ExtrusionCut_3_1/Modified_Face&Sketch_1/SketchLine_4)(ExtrusionCut_1_1/Modified_Face&Extrusion_1_1/To_Face)") assert(model.checkPythonDump()) diff --git a/src/Selector/Selector_Algo.cpp b/src/Selector/Selector_Algo.cpp index ca141637f..9a387d1f0 100644 --- a/src/Selector/Selector_Algo.cpp +++ b/src/Selector/Selector_Algo.cpp @@ -417,6 +417,7 @@ Selector_Algo* Selector_Algo::restoreByName(TDF_Label theLab, TDF_Label theBaseD void Selector_Algo::storeType(const Selector_Type theType) { + myLab.ForgetAllAttributes(true); TDataStd_Integer::Set(myLab, kSEL_TYPE, (int)(theType)); if (myGeometricalNaming) TDataStd_UAttribute::Set(myLab, kGEOMETRICAL_NAMING); diff --git a/src/Selector/Selector_AlgoWithSubs.cpp b/src/Selector/Selector_AlgoWithSubs.cpp index 32229e516..c25014b5c 100644 --- a/src/Selector/Selector_AlgoWithSubs.cpp +++ b/src/Selector/Selector_AlgoWithSubs.cpp @@ -53,7 +53,7 @@ bool Selector_AlgoWithSubs::append(Selector_Algo* theAlgo, const bool theEraseIf return false; } -const std::list& Selector_AlgoWithSubs::list() const +std::list& Selector_AlgoWithSubs::list() { return mySubSelList; } diff --git a/src/Selector/Selector_AlgoWithSubs.h b/src/Selector/Selector_AlgoWithSubs.h index 58734a31f..994953caf 100644 --- a/src/Selector/Selector_AlgoWithSubs.h +++ b/src/Selector/Selector_AlgoWithSubs.h @@ -45,7 +45,7 @@ public: /// Appends a new algorithm to the list, erases list if it is null (failed) bool append(Selector_Algo* theAlgo, const bool theEraseIfNull = true); /// Returns the stored list of sub-algorithms. - const std::list& list() const; + std::list& list(); }; #endif diff --git a/src/Selector/Selector_FilterByNeighbors.cpp b/src/Selector/Selector_FilterByNeighbors.cpp index 06ae4785f..2d5488e15 100644 --- a/src/Selector/Selector_FilterByNeighbors.cpp +++ b/src/Selector/Selector_FilterByNeighbors.cpp @@ -230,7 +230,7 @@ void Selector_FilterByNeighbors::store() TDataStd_IntegerArray::Set(label(), kLEVELS_ARRAY, 0, int(myNBLevel.size()) - 1); std::list::iterator aLevel = myNBLevel.begin(); for(int anIndex = 0; aLevel != myNBLevel.end(); aLevel++, anIndex++) { - anArray->SetValue(anIndex, *aLevel); + anArray->SetValue(anIndex, Abs(*aLevel)); } // store all sub-selectors std::list::const_iterator aSubSel = list().cbegin(); @@ -257,10 +257,19 @@ bool Selector_FilterByNeighbors::restore() for(TDF_ChildIterator aSub(label(), false); aSub.More(); aSub.Next()) { Selector_Algo* aSubSel = restoreByLab(aSub.Value(), baseDocument()); if (!append(aSubSel, false)) { - break; // some empty label left in the end + if (!aSub.Value().HasAttribute()) + break; // some empty label left in the end + // some selector fails, try to use rest selectors, myNBLevel becomes negative: unused + if (myNBLevel.size() > list().size()) { + std::list::iterator aListIter = myNBLevel.begin(); + for(int a = 0; a < list().size(); a++) + aListIter++; + *aListIter = -*aListIter; + list().push_back(NULL); + } } } - return myNBLevel.size() == list().size(); + return myNBLevel.size() == list().size() && !myNBLevel.empty(); } TDF_Label Selector_FilterByNeighbors::restoreByName(std::string theName, @@ -324,15 +333,18 @@ bool Selector_FilterByNeighbors::solve(const TopoDS_Shape& theContext) std::list::iterator aLevel = myNBLevel.begin(); std::list::const_iterator aSubSel = list().cbegin(); for(; aSubSel != list().cend(); aSubSel++, aLevel++) { - if (!(*aSubSel)->solve(theContext)) { - return false; + if (*aLevel < 0) + continue; // skip because sub-selector is not good + if ((*aSubSel)->solve(theContext)) { + aNBs.push_back(std::pair((*aSubSel)->value(), *aLevel)); } - aNBs.push_back(std::pair((*aSubSel)->value(), *aLevel)); } - aResult = findNeighbor(theContext, aNBs, geometricalNaming()); - if (!aResult.IsNull()) { - Selector_Algo::store(aResult); - return true; + if (!aNBs.empty()) { + aResult = findNeighbor(theContext, aNBs, geometricalNaming()); + if (!aResult.IsNull()) { + Selector_Algo::store(aResult); + return true; + } } return false; } @@ -344,6 +356,8 @@ std::string Selector_FilterByNeighbors::name(Selector_NameGenerator* theNameGene std::list::iterator aLevel = myNBLevel.begin(); std::list::const_iterator aSubSel = list().cbegin(); for(; aSubSel != list().cend(); aSubSel++, aLevel++) { + if (!*aSubSel) + continue; aResult += "(" + (*aSubSel)->name(theNameGenerator) + ")"; if (*aLevel > 1) { std::ostringstream aLevelStr; diff --git a/src/SketchPlugin/Test/Test2119.py b/src/SketchPlugin/Test/Test2119.py index 9cedb1611..e9f70c2c6 100644 --- a/src/SketchPlugin/Test/Test2119.py +++ b/src/SketchPlugin/Test/Test2119.py @@ -95,15 +95,15 @@ SketchConstraintCoincidence_15 = Sketch_2.setCoincident(SketchCircle_1.center(), SketchConstraintRadius_3 = Sketch_2.setRadius(SketchCircle_1.results()[1], "50/2") model.do() ExtrusionCut_1 = model.addExtrusionCut(Part_1_doc, [model.selection("WIRE", "Sketch_2/Face-SketchCircle_1_2f_wire")], model.selection(), 0, 13, [model.selection("SOLID", "Extrusion_1_1")]) -Sketch_3 = model.addSketch(Part_1_doc, model.selection("FACE", "_weak_name_6_ExtrusionCut_1_1")) -SketchProjection_2 = Sketch_3.addProjection(model.selection("VERTEX", "[ExtrusionCut_1_1/Modified_Face&Sketch_1/SketchArc_1_2][ExtrusionCut_1_1/Modified_Face&Sketch_1/SketchLine_9][_weak_name_6_ExtrusionCut_1_1]"), False) +Sketch_3 = model.addSketch(Part_1_doc, model.selection("FACE", "ExtrusionCut_1_1/Modified_Face&ExtrusionCut_1_1/From_Face")) +SketchProjection_2 = Sketch_3.addProjection(model.selection("VERTEX", "ExtrusionCut_1_1/Generated_Vertex&ExtrusionCut_1_1/From_Face"), False) SketchPoint_3 = SketchProjection_2.createdFeature() -SketchProjection_3 = Sketch_3.addProjection(model.selection("EDGE", "[ExtrusionCut_1_1/Modified_Face&Sketch_1/SketchLine_9][_weak_name_6_ExtrusionCut_1_1]"), False) +SketchProjection_3 = Sketch_3.addProjection(model.selection("EDGE", "ExtrusionCut_1_1/Generated_Edge&ExtrusionCut_1_1/From_Face&weak_name_2"), False) SketchLine_11 = SketchProjection_3.createdFeature() SketchArc_3 = Sketch_3.addArc(-15, 35, -15, 46.0103340429751, -17.02045759563166, 24.17663606626138, True) SketchConstraintCoincidence_16 = Sketch_3.setCoincident(SketchPoint_3.result(), SketchArc_3.center()) SketchConstraintCoincidence_17 = Sketch_3.setCoincident(SketchLine_11.result(), SketchArc_3.startPoint()) -SketchProjection_4 = Sketch_3.addProjection(model.selection("EDGE", "[ExtrusionCut_1_1/Modified_Face&Sketch_1/SketchArc_1_2][_weak_name_6_ExtrusionCut_1_1]"), False) +SketchProjection_4 = Sketch_3.addProjection(model.selection("EDGE", "ExtrusionCut_1_1/Generated_Edge&ExtrusionCut_1_1/From_Face&weak_name_1"), False) SketchArc_4 = SketchProjection_4.createdFeature() SketchConstraintCoincidence_18 = Sketch_3.setCoincident(SketchArc_3.endPoint(), SketchArc_4.results()[1]) SketchLine_12 = Sketch_3.addLine(-15, 46.0103340429751, -15, 35)