]> SALOME platform Git repositories - modules/shaper.git/blobdiff - src/ModelAPI/ModelAPI_Tools.cpp
Salome HOME
Speed-up of the access from OB to complicated compsolids in the frames of issue ...
[modules/shaper.git] / src / ModelAPI / ModelAPI_Tools.cpp
index 9dd0d9d6c7eee1985ad332b2c8a2614e4ca7c4d5..3be42d1f47248161f147105f5eecac93fa1d1534 100755 (executable)
@@ -268,6 +268,7 @@ CompositeFeaturePtr compositeOwner(const FeaturePtr& theFeature)
 
 ResultCompSolidPtr compSolidOwner(const ResultPtr& theSub)
 {
+  int anIndex;
   ResultBodyPtr aBody = std::dynamic_pointer_cast<ModelAPI_ResultBody>(theSub);
   if (aBody.get()) {
     FeaturePtr aFeatureOwner = aBody->document()->feature(aBody);
@@ -276,7 +277,7 @@ ResultCompSolidPtr compSolidOwner(const ResultPtr& theSub)
         aFeatureOwner->results().cbegin();
       for(; aResIter != aFeatureOwner->results().cend(); aResIter++) {
         ResultCompSolidPtr aComp = std::dynamic_pointer_cast<ModelAPI_ResultCompSolid>(*aResIter);
-        if (aComp && aComp->isSub(aBody))
+        if (aComp && aComp->isSub(aBody, anIndex))
           return aComp;
       }
     }
@@ -284,6 +285,25 @@ ResultCompSolidPtr compSolidOwner(const ResultPtr& theSub)
   return ResultCompSolidPtr(); // not found
 }
 
+int compSolidIndex(const ResultPtr& theSub)
+{
+  int anIndex = -1;
+  ResultBodyPtr aBody = std::dynamic_pointer_cast<ModelAPI_ResultBody>(theSub);
+  if (aBody.get()) {
+    FeaturePtr aFeatureOwner = aBody->document()->feature(aBody);
+    if (aFeatureOwner.get()) {
+      std::list<std::shared_ptr<ModelAPI_Result> >::const_iterator aResIter =
+        aFeatureOwner->results().cbegin();
+      for(; aResIter != aFeatureOwner->results().cend(); aResIter++) {
+        ResultCompSolidPtr aComp = std::dynamic_pointer_cast<ModelAPI_ResultCompSolid>(*aResIter);
+        if (aComp && aComp->isSub(aBody, anIndex))
+          return anIndex;
+      }
+    }
+  }
+  return anIndex; // not found
+}
+
 bool hasSubResults(const ResultPtr& theResult)
 {
   ResultCompSolidPtr aCompSolid = std::dynamic_pointer_cast<ModelAPI_ResultCompSolid>(theResult);