]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Fixes for the updated naming rules for generation of lower-level topology
authormpv <mpv@opencascade.com>
Thu, 14 Dec 2017 13:50:20 +0000 (16:50 +0300)
committermpv <mpv@opencascade.com>
Thu, 14 Dec 2017 13:50:34 +0000 (16:50 +0300)
src/Model/Model_AttributeSelection.cpp
src/ModelAPI/Test/Test1757.py

index c29cca22998cc6c335de633a089f0a77f9eb0baa..5c35d4b9cefc669cf681b6bc783d97cfc296a152 100644 (file)
@@ -35,6 +35,7 @@
 #include <ModelAPI_CompositeFeature.h>
 #include <ModelAPI_Tools.h>
 #include <ModelAPI_Session.h>
+#include <ModelAPI_Validator.h>
 #include <Events_InfoMessage.h>
 #include <GeomAPI_Edge.h>
 #include <GeomAPI_Vertex.h>
@@ -658,7 +659,7 @@ void Model_AttributeSelection::selectBody(
     bool isFound = false;
     TopExp_Explorer anExp(aNewContext, aNewSub.ShapeType());
     for(; anExp.More(); anExp.Next()) {
-      if (anExp.Current().IsEqual(aNewSub)) {
+      if (anExp.Current().IsSame(aNewSub)) {
         isFound = true;
         break;
       }
@@ -863,7 +864,41 @@ void Model_AttributeSelection::selectSubShape(
             }
           }
         }
+        // try to find the latest active result that must be used instead of the selected
+        // to set the active context (like in GUI selection), not concealed one
+        bool aFindNewContext = true;
+        while(aFindNewContext && aCont.get() && aShapeToBeSelected.get()) {
+          aFindNewContext = false;
+          const std::set<AttributePtr>& aRefs = aCont->data()->refsToMe();
+          std::set<AttributePtr>::const_iterator aRef = aRefs.begin();
+          for(; !aFindNewContext && aRef != aRefs.end(); aRef++) {
+            if (!aRef->get() || !(*aRef)->owner().get())
+              continue;
+            // concealed attribute only
+            FeaturePtr aRefFeat = std::dynamic_pointer_cast<ModelAPI_Feature>((*aRef)->owner());
+            if (!ModelAPI_Session::get()->validators()->isConcealed(
+                    aRefFeat->getKind(), (*aRef)->id()))
+              continue;
+            // search the feature result that contains sub-shape selected
+            std::list<std::shared_ptr<ModelAPI_Result> > aResults;
+            ModelAPI_Tools::allResults(aRefFeat, aResults);
+            std::list<std::shared_ptr<ModelAPI_Result> >::iterator aResIter = aResults.begin();
+            for(; aResIter != aResults.end(); aResIter++) {
+              if (!aResIter->get() || !(*aResIter)->data()->isValid() || (*aResIter)->isDisabled())
+                continue;
+              GeomShapePtr aShape = (*aResIter)->shape();
+              if (aShape.get() && aShape->isSubShape(aShapeToBeSelected, false)) {
+                aCont = *aResIter; // found new context (produced from this) with same subshape
+                //if (!aShape->isSubShape(aShapeToBeSelected, true)) // take context orientation
+                //  aShapeToBeSelected->setOrientation();
+                aFindNewContext = true; // continue searching futher
+                break;
+              }
+            }
+          }
+        }
       }
+
       if (aCenterType != NOT_CENTER) {
         if (!aShapeToBeSelected->isEdge())
           continue;
index 52f4dcb21046358ff506852a103c0ed52817e9e5..8418bdc89bf762d073b2768ab3ce4e1982cfb223 100644 (file)
@@ -80,7 +80,7 @@ model.do()
 # Make a cylindrical hole using one of the produced faces
 #=========================================================================
 ExtrusionCut_2 = model.addExtrusionCut(Part_1_doc, [], model.selection(), model.selection(), 0, model.selection("FACE", "Extrusion_1_1/Generated_Face_2"), 0, [model.selection("SOLID", "ExtrusionCut_1_1")])
-Sketch_3 = model.addSketch(Part_1_doc, model.selection("FACE", "ExtrusionCut_1_1/Modfied_4"))
+Sketch_3 = model.addSketch(Part_1_doc, model.selection("FACE", "ExtrusionCut_1_1/Modfied_3"))
 SketchCircle_1 = Sketch_3.addCircle(143.412751420315, -228.52745656314, 32.158435160764)
 ExtrusionCut_2.setNestedSketch(Sketch_3)
 
@@ -92,8 +92,8 @@ 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_3"), -50, [model.selection("SOLID", "ExtrusionCut_1_1")])
-Sketch_4 = model.addSketch(Part_1_doc, model.selection("FACE", "Extrusion_1_1/Generated_Face_1"))
+ExtrusionCut_3 = model.addExtrusionCut(Part_1_doc, [], model.selection(), model.selection(), 0, model.selection("FACE", "Extrusion_1_1/Generated_Face_1"), -50, [model.selection("SOLID", "ExtrusionCut_1_1")])
+Sketch_4 = model.addSketch(Part_1_doc, model.selection("FACE", "Extrusion_1_1/Generated_Face_3"))
 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)
 SketchLine_11 = Sketch_4.addLine(-91.83965287802501, -84.473709256573, -176.701443076057, -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/Modfied_4")
+assert(Sketch_3.feature().selection("External").namingName() == "ExtrusionCut_3_1/Modfied_5")
 
 assert(model.checkPythonDump())