From: mpv Date: Tue, 30 Dec 2014 08:18:07 +0000 (+0300) Subject: Added findByName method for naming issue X-Git-Tag: V_0.7.0_rc1^2~7 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=9b2d78cb08922282d21bc87f418d03824653ce3f;p=modules%2Fshaper.git Added findByName method for naming issue --- diff --git a/src/Model/Model_Document.cpp b/src/Model/Model_Document.cpp index 1f5eedfe9..7b1b6db85 100644 --- a/src/Model/Model_Document.cpp +++ b/src/Model/Model_Document.cpp @@ -1130,3 +1130,23 @@ TDF_Label Model_Document::findNamingName(std::string theName) return TDF_Label(); // not found return aFind->second; } + +ResultPtr Model_Document::findByName(const std::string theName) +{ + NCollection_DataMap::Iterator anObjIter(myObjs); + for(; anObjIter.More(); anObjIter.Next()) { + FeaturePtr& aFeature = anObjIter.ChangeValue(); + if (!aFeature) // may be on close + continue; + const std::list >& aResults = aFeature->results(); + std::list >::const_iterator aRIter = aResults.begin(); + for (; aRIter != aResults.cend(); aRIter++) { + if (aRIter->get() && (*aRIter)->data() && (*aRIter)->data()->isValid() && + (*aRIter)->data()->name() == theName) { + return *aRIter; + } + } + } + // not found + return ResultPtr(); +} diff --git a/src/Model/Model_Document.h b/src/Model/Model_Document.h index 6aa9ef4e8..ad309ce94 100644 --- a/src/Model/Model_Document.h +++ b/src/Model/Model_Document.h @@ -140,6 +140,9 @@ class Model_Document : public ModelAPI_Document void addNamingName(const TDF_Label theLabel, std::string theName); //! Returns the label, keeper of the name for the topological naming needs TDF_Label findNamingName(std::string theName); + //! Returns the result by name of the result (names of results must be unique, used for naming + //! selection by name. + ResultPtr findByName(const std::string theName); protected: