]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Case FeaturesPlugin_TestPartitionBox4Planes when shape type of the sub-component...
authormpv <mpv@opencascade.com>
Fri, 26 Oct 2018 16:36:53 +0000 (19:36 +0300)
committermpv <mpv@opencascade.com>
Mon, 19 Nov 2018 08:45:52 +0000 (11:45 +0300)
src/FeaturesPlugin/Test/Test2233.py
src/FeaturesPlugin/Test/Test2246.py
src/Selector/Selector_Selector.cpp

index 088e7da8d74b14c6829fcb84ab1fe63995c96d64..1b67c69875dab1b05d0f4e9031bd7e5b47ea8156 100644 (file)
@@ -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()
 
index 5a0cad94d9ede7486c6a3dde3b296e5557878dfb..ad02faa1e5576ac0e0d00a140429500f1a9a8d64 100644 (file)
@@ -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()
 
index d6c3a61f6139875eb06545330c218d7dd48936e1..2b651c030e8ed949f6738a8c8a2ca6ce529344b5 100644 (file)
@@ -26,6 +26,7 @@
 #include <TDF_ChildIDIterator.hxx>
 #include <TopoDS_Iterator.hxx>
 #include <TopoDS_Builder.hxx>
+#include <TopoDS.hxx>
 #include <TopExp_Explorer.hxx>
 #include <TNaming_Tool.hxx>
 #include <TNaming_NewShapeIterator.hxx>
@@ -34,6 +35,7 @@
 #include <TNaming_Iterator.hxx>
 #include <TNaming_Builder.hxx>
 #include <TopTools_MapOfShape.hxx>
+#include <BRep_Tool.hxx>
 
 #include <TDataStd_Integer.hxx>
 #include <TDataStd_ReferenceArray.hxx>
@@ -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)) {