Salome HOME
Fix for the unit-test TestGroup1799.py
authormpv <mpv@opencascade.com>
Wed, 7 Nov 2018 11:37:48 +0000 (14:37 +0300)
committermpv <mpv@opencascade.com>
Mon, 19 Nov 2018 08:45:52 +0000 (11:45 +0300)
src/Model/Model_AttributeSelection.cpp

index 7bb436eeead70794300a36aa0ef3e848113eb885..7cb073f3b2f56cc06fdd0695342d95ee0e96770f 100644 (file)
@@ -1199,7 +1199,7 @@ void Model_AttributeSelection::computeValues(
         std::dynamic_pointer_cast<Model_Data>((*aNewContIter)->data());
       TDF_Label aNewLab = aNewData->shapeLab();
       // searching for produced sub-shape fully on some label
-      TDF_ChildIDIterator aNSIter(aNewLab, TNaming_NamedShape::GetID(), Standard_True);
+      TDF_ChildIDIterator aNSIter(aNewLab, TNaming_NamedShape::GetID());
       for(; aNSIter.More(); aNSIter.Next()) {
         Handle(TNaming_NamedShape) aNS = Handle(TNaming_NamedShape)::DownCast(aNSIter.Value());
         for(TNaming_Iterator aPairIter(aNS); aPairIter.More(); aPairIter.Next()) {
@@ -1420,51 +1420,44 @@ void Model_AttributeSelection::updateInHistory()
   TopTools_ListOfShape aValShapes;
   if (searchNewContext(aDoc, aNewCShape, aContext, aValShape, aContLab, aNewContexts, aValShapes))
   {
+    GeomAPI_Shape::ShapeType aListShapeType = GeomAPI_Shape::SHAPE;
+    if (myParent->selectionType() == "VERTEX") aListShapeType = GeomAPI_Shape::VERTEX;
+    else if (myParent->selectionType() == "EDGE") aListShapeType = GeomAPI_Shape::EDGE;
+    else if (myParent->selectionType() == "FACE") aListShapeType = GeomAPI_Shape::FACE;
+
     std::list<ResultPtr>::iterator aNewCont = aNewContexts.begin();
     TopTools_ListIteratorOfListOfShape aNewValues(aValShapes);
-    if (aNewCont == aNewContexts.end()) { // all results were deleted
+    bool aFirst = true; // first is set to this, next are appended to parent
+    for(; aNewCont != aNewContexts.end(); aNewCont++, aNewValues.Next()) {
+
+      GeomShapePtr aValueShape;
+      if (!aNewValues.Value().IsNull()) {
+        aValueShape = std::make_shared<GeomAPI_Shape>();
+        aValueShape->setImpl<TopoDS_Shape>(new TopoDS_Shape(aNewValues.Value()));
+      }
+      // Check that list has the same type of shape selection before adding.
+      GeomAPI_Shape::ShapeType aShapeShapeType = GeomAPI_Shape::SHAPE;
+      if (aValueShape.get()) {
+        aShapeShapeType = aValueShape->shapeType();
+      } else {
+        (*aNewCont)->shape()->shapeType();
+      }
+      if (aListShapeType != GeomAPI_Shape::SHAPE && aListShapeType != aShapeShapeType) {
+        continue;
+      }
+      if (aFirst) {
+        setValue(*aNewCont, aValueShape);
+        aFirst = false;
+      } else if (myParent) {
+        myParent->append(*aNewCont, aValueShape);
+      }
+    }
+    if (aFirst) { // nothing was added, all results were deleted
       ResultPtr anEmptyContext;
       std::shared_ptr<GeomAPI_Shape> anEmptyShape;
       setValue(anEmptyContext, anEmptyShape); // nullify the selection
       return;
     }
-
-    GeomShapePtr aValueShape;
-    if (!aNewValues.Value().IsNull()) {
-      aValueShape = std::make_shared<GeomAPI_Shape>();
-      aValueShape->setImpl<TopoDS_Shape>(new TopoDS_Shape(aNewValues.Value()));
-    }
-    setValue(*aNewCont, aValueShape);
-    // if there are more than one result, put them by "append" into "parent" list
-    if (myParent) {
-      for(aNewCont++, aNewValues.Next(); aNewCont != aNewContexts.end();
-          aNewCont++, aNewValues.Next()) {
-        GeomShapePtr aValueShape;
-        if (!aNewValues.Value().IsNull()) {
-          aValueShape = std::make_shared<GeomAPI_Shape>();
-          aValueShape->setImpl<TopoDS_Shape>(new TopoDS_Shape(aNewValues.Value()));
-        }
-
-        // Check that list has the same type of shape selection before adding.
-        GeomAPI_Shape::ShapeType aListShapeType = GeomAPI_Shape::SHAPE;
-        if (myParent->selectionType() == "VERTEX") aListShapeType = GeomAPI_Shape::VERTEX;
-        else if (myParent->selectionType() == "EDGE") aListShapeType = GeomAPI_Shape::EDGE;
-        else if (myParent->selectionType() == "FACE") aListShapeType = GeomAPI_Shape::FACE;
-
-        GeomAPI_Shape::ShapeType aShapeShapeType = GeomAPI_Shape::SHAPE;
-        if (aValueShape.get()) {
-          aShapeShapeType = aValueShape->shapeType();
-        } else {
-          (*aNewCont)->shape()->shapeType();
-        }
-
-        if (aListShapeType != GeomAPI_Shape::SHAPE && aListShapeType != aShapeShapeType) {
-          continue;
-        }
-
-        myParent->append(*aNewCont, aValueShape);
-      }
-    }
   }
 }