]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Object Browser tree needed method implementation
authormpv <mpv@opencascade.com>
Wed, 19 Aug 2015 12:05:38 +0000 (15:05 +0300)
committermpv <mpv@opencascade.com>
Wed, 19 Aug 2015 12:05:38 +0000 (15:05 +0300)
src/ModelAPI/ModelAPI_Tools.cpp
src/ModelAPI/ModelAPI_Tools.h

index a1e962da29b60ed26eede345e48143809dcc6dfa..31e2b031b866d2912ee96c6ec6b20f1992f2a6f6 100644 (file)
@@ -185,4 +185,23 @@ CompositeFeaturePtr compositeOwner(const FeaturePtr& theFeature)
   return CompositeFeaturePtr(); // not found
 }
 
+ResultCompSolidPtr compSolidOwner(const ResultPtr& theSub)
+{
+  ResultBodyPtr aBody = std::dynamic_pointer_cast<ModelAPI_ResultBody>(theSub);
+  if (theSub.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))
+          return aComp;
+      }
+    }
+  }
+  return ResultCompSolidPtr(); // not found
+}
+
 } // namespace ModelAPI_Tools
+
index 11e4b6ff0a29d42803b89b2b38d52915f48eb710..97b93c9d569c3bc479930c84d90125780f80b0d8 100644 (file)
@@ -14,6 +14,7 @@
 #include <ModelAPI_Feature.h>
 #include <ModelAPI_Result.h>
 #include <ModelAPI_ResultParameter.h>
+#include <ModelAPI_ResultCompSolid.h>
 
 #include <GeomAPI_Shape.h>
 
@@ -59,6 +60,13 @@ MODELAPI_EXPORT ResultPtr findPartResult(const DocumentPtr& theMain, const Docum
  */
 MODELAPI_EXPORT CompositeFeaturePtr compositeOwner(const FeaturePtr& theFeature);
 
+/*!
+ * Returns the compsolid result - parent of this result.
+ * \param theSub the sub-element of comp-solid
+ * \returns null if it is not sub-element of composite
+ */
+MODELAPI_EXPORT ResultCompSolidPtr compSolidOwner(const ResultPtr& theSub);
+
 }
 
 #endif