From b1831ed726cb11165fce344cc3f815daaa4769c4 Mon Sep 17 00:00:00 2001 From: mpv Date: Fri, 26 Oct 2018 19:36:53 +0300 Subject: [PATCH] Case FeaturesPlugin_TestPartitionBox4Planes when shape type of the sub-component of intersection or container is needed (like weak name). --- src/FeaturesPlugin/Test/Test2233.py | 2 +- src/FeaturesPlugin/Test/Test2246.py | 2 +- src/Selector/Selector_Selector.cpp | 36 ++++++++++++++++++++++++++++- 3 files changed, 37 insertions(+), 3 deletions(-) diff --git a/src/FeaturesPlugin/Test/Test2233.py b/src/FeaturesPlugin/Test/Test2233.py index 088e7da8d..1b67c6987 100644 --- a/src/FeaturesPlugin/Test/Test2233.py +++ b/src/FeaturesPlugin/Test/Test2233.py @@ -38,7 +38,7 @@ SketchConstraintCoincidence_4 = Sketch_1.setCoincident(SketchArc_1.startPoint(), SketchConstraintCoincidence_5 = Sketch_1.setCoincident(SketchLine_2.endPoint(), SketchArc_1.endPoint()) model.do() Revolution_1 = model.addRevolution(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchArc_1_2f-SketchLine_2f")], model.selection("EDGE", "Sketch_1/SketchLine_2"), 360, 0) -Group_1 = model.addGroup(Part_1_doc, [model.selection("VERTEX", "[[Revolution_1_1/Generated_Face&Sketch_1/SketchArc_1_2][weak_name_1]][[Revolution_1_1/Generated_Face&Sketch_1/SketchArc_1_2][weak_name_3]]"), model.selection("VERTEX", "[[Revolution_1_1/Generated_Face&Sketch_1/SketchArc_1_2][weak_name_2]][[Revolution_1_1/Generated_Face&Sketch_1/SketchArc_1_2][weak_name_3]]")]) +Group_1 = model.addGroup(Part_1_doc, [model.selection("VERTEX", "[Revolution_1_1/Generated_Face&Sketch_1/SketchArc_1_2][weak_name_1]"), model.selection("VERTEX", "[Revolution_1_1/Generated_Face&Sketch_1/SketchArc_1_2][weak_name_2]")]) model.do() model.end() diff --git a/src/FeaturesPlugin/Test/Test2246.py b/src/FeaturesPlugin/Test/Test2246.py index 5a0cad94d..ad02faa1e 100644 --- a/src/FeaturesPlugin/Test/Test2246.py +++ b/src/FeaturesPlugin/Test/Test2246.py @@ -39,7 +39,7 @@ SketchConstraintCoincidence_5 = Sketch_1.setCoincident(SketchArc_1.startPoint(), model.do() Revolution_1 = model.addRevolution(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchArc_1_2f-SketchLine_2f")], model.selection("EDGE", "Sketch_1/SketchLine_2"), 360, 0) Translation_1 = model.addTranslation(Part_1_doc, [model.selection("SOLID", "Revolution_1_1")], model.selection("EDGE", "PartSet/OY"), 150) -Group_1 = model.addGroup(Part_1_doc, [model.selection("VERTEX", "[[Translation_1_1/MF:Translated&Sketch_1/SketchArc_1_2][weak_name_2]][[Translation_1_1/MF:Translated&Sketch_1/SketchArc_1_2][weak_name_1]]"), model.selection("VERTEX", "[[Translation_1_1/MF:Translated&Sketch_1/SketchArc_1_2][weak_name_3]][[Translation_1_1/MF:Translated&Sketch_1/SketchArc_1_2][weak_name_1]]")]) +Group_1 = model.addGroup(Part_1_doc, [model.selection("VERTEX", "[Translation_1_1/MF:Translated&Sketch_1/SketchArc_1_2][weak_name_1]"), model.selection("VERTEX", "[Translation_1_1/MF:Translated&Sketch_1/SketchArc_1_2][weak_name_2]")]) model.do() model.end() diff --git a/src/Selector/Selector_Selector.cpp b/src/Selector/Selector_Selector.cpp index d6c3a61f6..2b651c030 100644 --- a/src/Selector/Selector_Selector.cpp +++ b/src/Selector/Selector_Selector.cpp @@ -26,6 +26,7 @@ #include #include #include +#include #include #include #include @@ -34,6 +35,7 @@ #include #include #include +#include #include #include @@ -296,6 +298,8 @@ bool Selector_Selector::select(const TopoDS_Shape theContext, const TopoDS_Shape TopTools_MapOfShape anIntersectors; // shapes of aSelectionType that contain theValue TopoDS_ListOfShape anIntList; // same as anIntersectors for(TopExp_Explorer aSelExp(theContext, aSelectionType); aSelExp.More(); aSelExp.Next()) { + if (aSelectionType == TopAbs_EDGE && BRep_Tool::Degenerated(TopoDS::Edge(aSelExp.Current()))) + continue; TopExp_Explorer aSubExp(aSelExp.Current(), theValue.ShapeType()); for(; aSubExp.More(); aSubExp.Next()) { if (aSubExp.Current().IsSame(theValue)) { @@ -905,6 +909,20 @@ std::string Selector_Selector::name(Selector_NameGenerator* theNameGenerator) { aResult += '['; aResult += aSubSel->name(theNameGenerator); aResult += ']'; + TopAbs_ShapeEnum aSubType = aSubSel->value().ShapeType(); + if (aSubType != TopAbs_FACE) { // in case the sub shape type must be stored + switch(aSubType) { + case TopAbs_COMPOUND: aResult += "c"; break; + case TopAbs_COMPSOLID: aResult += "o"; break; + case TopAbs_SOLID: aResult += "s"; break; + case TopAbs_SHELL: aResult += "h"; break; + case TopAbs_WIRE: aResult += "w"; break; + case TopAbs_EDGE: aResult += "e"; break; + case TopAbs_VERTEX: aResult += "v"; break; + default: + ; + } + } } if (myWeakIndex != -1) { std::ostringstream aWeakStr; @@ -1004,9 +1022,25 @@ TDF_Label Selector_Selector::restoreByName( myWeakIndex = atoi(aWeakIndex.c_str()); continue; } + TopAbs_ShapeEnum aSubShapeType = TopAbs_FACE; + if (anEndPos != std::string::npos && anEndPos + 1 > theName.size()) { + char aShapeChar = theName[anEndPos + 1]; + if (theName[anEndPos + 1] != '[') { + switch(aShapeChar) { + case 'c': aSubShapeType = TopAbs_COMPOUND; break; + case 'o': aSubShapeType = TopAbs_COMPSOLID; break; + case 's': aSubShapeType = TopAbs_SOLID; break; + case 'h': aSubShapeType = TopAbs_SHELL; break; + case 'w': aSubShapeType = TopAbs_WIRE; break; + case 'e': aSubShapeType = TopAbs_EDGE; break; + case 'v': aSubShapeType = TopAbs_VERTEX; break; + default:; + } + } + } mySubSelList.push_back(Selector_Selector(myLab.FindChild(int(mySubSelList.size()) + 1))); TDF_Label aSubContext = - mySubSelList.back().restoreByName(aSubStr, theShapeType, theNameGenerator); + mySubSelList.back().restoreByName(aSubStr, aSubShapeType, theNameGenerator); if (aSubContext.IsNull()) return aSubContext; // invalid sub-selection parsing if (!aContext.IsNull() && !aContext.IsEqual(aSubContext)) { -- 2.39.2