]> SALOME platform Git repositories - modules/shaper.git/blobdiff - src/Model/Model_AttributeSelection.cpp
Salome HOME
Issue #2622: Weak naming
[modules/shaper.git] / src / Model / Model_AttributeSelection.cpp
index 7a06523911063668e287262f956f9f49f1791dd1..af1020ab5a9463bf89f95b52b181196c57fe907b 100644 (file)
@@ -42,6 +42,7 @@
 #include <GeomAPI_Pnt.h>
 #include <GeomAPI_Vertex.h>
 #include <GeomAlgoAPI_CompoundBuilder.h>
+#include <GeomAlgoAPI_NExplode.h>
 
 #include <TNaming_Selector.hxx>
 #include <TNaming_NamedShape.hxx>
@@ -1154,6 +1155,32 @@ void Model_AttributeSelection::selectSubShape(const std::string& theType,
   reset();
 }
 
+void Model_AttributeSelection::selectSubShape(const std::string& theType,
+  const std::string& theContextName, const int theIndex)
+{
+  // selection of context by name
+  //std::string aNamingContextName = theContextName + "/";
+  //selectSubShape(theType, aNamingContextName);
+  std::shared_ptr<Model_Document> aDoc =
+    std::dynamic_pointer_cast<Model_Document>(owner()->document());
+  if (aDoc.get()) {
+    bool aUnique = true;
+    std::string aContextName = theContextName;
+    std::string anEmptySub = "";
+    ResultPtr aContext = aDoc->findByName(aContextName, anEmptySub, aUnique);
+    //ResultPtr aContext = context();
+    if (aContext.get()) {
+      GeomShapePtr aContShape = aContext->shape();
+      if (aContShape.get()) {
+        GeomAlgoAPI_NExplode aNExp(aContShape, GeomAPI_Shape::shapeTypeByStr(theType));
+        GeomShapePtr aValue = aNExp.shape(theIndex);
+        if (aValue.get())
+          setValue(aContext, aValue);
+      }
+    }
+  }
+}
+
 int Model_AttributeSelection::Id()
 {
   int anID = 0;