Salome HOME
Merge branch 'Dev_2.8.0'
[modules/shaper.git] / src / Model / Model_AttributeSelection.cpp
index 344ee30ee36009e59b2dea139d2c2b92d3b907ac..6d97b417e48eda32395f55ed9b6d958507a52a59 100644 (file)
@@ -153,6 +153,12 @@ void Model_AttributeSelection::setValue(const ResultPtr& theContext,
     std::shared_ptr<GeomAPI_Shape> aSubShape;
     if (theSubShape.get() && !theContext->shape()->isEqual(theSubShape))
       aSubShape = theSubShape; // the whole context
+    if (aConstruction->isInfinite()) {
+      // For correct naming selection, put the shape into the naming structure.
+      // It seems sub-shapes are not needed: only this shape is (and can be ) selected.
+      TNaming_Builder aBuilder(aSelLab);
+      aBuilder.Generated(theContext->shape()->impl<TopoDS_Shape>());
+    }
     int anIndex = aConstruction->select(theSubShape, owner()->document());
     TDataStd_Integer::Set(aSelLab, anIndex);
   } else if (theContext->groupName() == ModelAPI_ResultPart::group()) {
@@ -298,21 +304,23 @@ std::shared_ptr<GeomAPI_Shape> Model_AttributeSelection::internalValue(CenterTyp
       }
     }
 
+    std::shared_ptr<Model_ResultConstruction> aConstr =
+      std::dynamic_pointer_cast<Model_ResultConstruction>(context());
+    if (aConstr) {
+      if (aConstr->isInfinite())
+        return aResult; // empty result
+    }
     Handle(TNaming_NamedShape) aSelection;
     if (aSelLab.FindAttribute(TNaming_NamedShape::GetID(), aSelection)) {
       TopoDS_Shape aSelShape = aSelection->Get();
       aResult = std::shared_ptr<GeomAPI_Shape>(new GeomAPI_Shape);
       aResult->setImpl(new TopoDS_Shape(aSelShape));
-    } else { // for simple construction element: just shape of this construction element
-      std::shared_ptr<Model_ResultConstruction> aConstr =
-        std::dynamic_pointer_cast<Model_ResultConstruction>(context());
-      if (aConstr) {
-        Handle(TDataStd_Integer) anIndex;
-        if (aSelLab.FindAttribute(TDataStd_Integer::GetID(), anIndex)) {
-          if (anIndex->Get() == 0) // it is just reference to construction, nothing is in value
-            return aResult;
-          return aConstr->shape(anIndex->Get(), owner()->document());
-        }
+    } else if (aConstr) { // simple construction element: just shape of this construction element
+      Handle(TDataStd_Integer) anIndex;
+      if (aSelLab.FindAttribute(TDataStd_Integer::GetID(), anIndex)) {
+        if (anIndex->Get() == 0) // it is just reference to construction, nothing is in value
+          return aResult;
+        return aConstr->shape(anIndex->Get(), owner()->document());
       }
     }
   }