]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Added findByName method for naming issue
authormpv <mpv@opencascade.com>
Tue, 30 Dec 2014 08:18:07 +0000 (11:18 +0300)
committermpv <mpv@opencascade.com>
Tue, 30 Dec 2014 08:18:07 +0000 (11:18 +0300)
src/Model/Model_Document.cpp
src/Model/Model_Document.h

index 1f5eedfe9a7a11639486087bc77cb32616532026..7b1b6db85abeb5aa0264f346a08b01d52d282bd1 100644 (file)
@@ -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<TDF_Label, FeaturePtr>::Iterator anObjIter(myObjs);
+  for(; anObjIter.More(); anObjIter.Next()) {
+    FeaturePtr& aFeature = anObjIter.ChangeValue();
+    if (!aFeature) // may be on close
+      continue;
+    const std::list<std::shared_ptr<ModelAPI_Result> >& aResults = aFeature->results();
+    std::list<std::shared_ptr<ModelAPI_Result> >::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();
+}
index 6aa9ef4e83578e0e0793e58107c887da9086960e..ad309ce94ff6a117f647ae7a88d9bbc91ea625b7 100644 (file)
@@ -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: