From: mpv Date: Wed, 19 Aug 2015 12:05:38 +0000 (+0300) Subject: Object Browser tree needed method implementation X-Git-Tag: V_1.4.0_beta4~344 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=8ebc9a7d5f87057b61b174e7568e01e44571549d;p=modules%2Fshaper.git Object Browser tree needed method implementation --- diff --git a/src/ModelAPI/ModelAPI_Tools.cpp b/src/ModelAPI/ModelAPI_Tools.cpp index a1e962da2..31e2b031b 100644 --- a/src/ModelAPI/ModelAPI_Tools.cpp +++ b/src/ModelAPI/ModelAPI_Tools.cpp @@ -185,4 +185,23 @@ CompositeFeaturePtr compositeOwner(const FeaturePtr& theFeature) return CompositeFeaturePtr(); // not found } +ResultCompSolidPtr compSolidOwner(const ResultPtr& theSub) +{ + ResultBodyPtr aBody = std::dynamic_pointer_cast(theSub); + if (theSub.get()) { + FeaturePtr aFeatureOwner = aBody->document()->feature(aBody); + if (aFeatureOwner.get()) { + std::list >::const_iterator aResIter = + aFeatureOwner->results().cbegin(); + for(; aResIter != aFeatureOwner->results().cend(); aResIter++) { + ResultCompSolidPtr aComp = std::dynamic_pointer_cast(*aResIter); + if (aComp && aComp->isSub(aBody)) + return aComp; + } + } + } + return ResultCompSolidPtr(); // not found +} + } // namespace ModelAPI_Tools + diff --git a/src/ModelAPI/ModelAPI_Tools.h b/src/ModelAPI/ModelAPI_Tools.h index 11e4b6ff0..97b93c9d5 100644 --- a/src/ModelAPI/ModelAPI_Tools.h +++ b/src/ModelAPI/ModelAPI_Tools.h @@ -14,6 +14,7 @@ #include #include #include +#include #include @@ -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