]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Fix for the #1757 with full split of the selected sketch-face.
authormpv <mpv@opencascade.com>
Wed, 21 Nov 2018 07:26:12 +0000 (10:26 +0300)
committermpv <mpv@opencascade.com>
Wed, 21 Nov 2018 07:26:12 +0000 (10:26 +0300)
src/ModelAPI/Test/Test1757.py
src/Selector/Selector_Algo.cpp
src/Selector/Selector_AlgoWithSubs.cpp
src/Selector/Selector_AlgoWithSubs.h
src/Selector/Selector_FilterByNeighbors.cpp
src/SketchPlugin/Test/Test2119.py

index 4881b65eab985f545f8473d76dcfd452dad22533..6f725da2c00215d5f264119e5ee9680ab986e399 100644 (file)
@@ -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())
index ca141637f7866829d2a0cffacf7e64cc0ba395f5..9a387d1f0cd4533b63e6fbae4c3eb515912695df 100644 (file)
@@ -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);
index 32229e516e66e0564d283f8505349b17cfdd820f..c25014b5cf449a09c7fc7611ced7724872532635 100644 (file)
@@ -53,7 +53,7 @@ bool Selector_AlgoWithSubs::append(Selector_Algo* theAlgo, const bool theEraseIf
   return false;
 }
 
-const std::list<Selector_Algo*>& Selector_AlgoWithSubs::list() const
+std::list<Selector_Algo*>& Selector_AlgoWithSubs::list()
 {
   return mySubSelList;
 }
index 58734a31f7bae1394a84926c1b5c7f0a15bbdfaf..994953caffa774bca52d97ac7f81ed4788d47dc3 100644 (file)
@@ -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<Selector_Algo*>& list() const;
+  std::list<Selector_Algo*>& list();
 };
 
 #endif
index 06ae4785f03dafcb113b3c3452f2f1daee9f661a..2d5488e159d392b6c77b9d617b777eee7a46119a 100644 (file)
@@ -230,7 +230,7 @@ void Selector_FilterByNeighbors::store()
     TDataStd_IntegerArray::Set(label(), kLEVELS_ARRAY, 0, int(myNBLevel.size()) - 1);
   std::list<int>::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<Selector_Algo*>::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<int>::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<int>::iterator aLevel = myNBLevel.begin();
   std::list<Selector_Algo*>::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<TopoDS_Shape, int>((*aSubSel)->value(), *aLevel));
     }
-    aNBs.push_back(std::pair<TopoDS_Shape, int>((*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<int>::iterator aLevel = myNBLevel.begin();
   std::list<Selector_Algo*>::const_iterator aSubSel = list().cbegin();
   for(; aSubSel != list().cend(); aSubSel++, aLevel++) {
+    if (!*aSubSel)
+      continue;
     aResult += "(" + (*aSubSel)->name(theNameGenerator) + ")";
     if (*aLevel > 1) {
       std::ostringstream aLevelStr;
index 9cedb16118c6f3fb7cb7ec4cbcaededa94cc93eb..e9f70c2c6a9c834836af55e7c0ac6a38a36e67b1 100644 (file)
@@ -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)