]> SALOME platform Git repositories - modules/shaper.git/blobdiff - src/Model/Model_AttributeSelection.cpp
Salome HOME
Merge branch 'Dev_0.7.1' of newgeom:newgeom into Dev_0.7.1
[modules/shaper.git] / src / Model / Model_AttributeSelection.cpp
index 7d2c9fa1b4b9a9a4d06794a53b78569c5459611c..33d1b25f5302f26d72bf60d2da27c8e19fbb2710 100644 (file)
@@ -1033,3 +1033,20 @@ void Model_AttributeSelection::selectSubShape(const std::string& theType, const
   }
 
 }
+
+int Model_AttributeSelection::Id()
+{
+  std::shared_ptr<GeomAPI_Shape> aSelection = value();
+  std::shared_ptr<GeomAPI_Shape> aContext = context()->shape();
+  const TopoDS_Shape& aMainShape = aContext->impl<TopoDS_Shape>();
+  const TopoDS_Shape& aSubShape = aSelection->impl<TopoDS_Shape>();
+  int anID = 0;
+  if (aSelection && !aSelection->isNull() &&
+      aContext   && !aContext->isNull())
+  {
+    TopTools_IndexedMapOfShape aSubShapesMap;
+    TopExp::MapShapes(aMainShape, aSubShapesMap);
+    anID = aSubShapesMap.FindIndex(aSubShape);
+  }
+  return anID;
+}