From: mpv Date: Fri, 4 Apr 2014 07:31:43 +0000 (+0400) Subject: Access to feature by index in group X-Git-Tag: V_0.1~39^2~1 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=e9ee9a2bdb4fe45183e82cc71763a33341840aaa;p=modules%2Fshaper.git Access to feature by index in group --- diff --git a/src/Model/Model_Document.cxx b/src/Model/Model_Document.cxx index 8a3f0bf45..3aea0ff6e 100644 --- a/src/Model/Model_Document.cxx +++ b/src/Model/Model_Document.cxx @@ -191,6 +191,14 @@ shared_ptr Model_Document::featuresIterator(const string theG return shared_ptr(new Model_Iterator(aThis, groupLabel(theGroup))); } +shared_ptr Model_Document::feature(const string& theGroupID, const int theIndex) +{ + // TODO: optimize this method + shared_ptr anIter = featuresIterator(theGroupID); + for(int a = 0; a != theIndex; anIter->next()) a++; + return anIter->current(); +} + Model_Document::Model_Document(const std::string theID) : myID(theID), myDoc(new TDocStd_Document("BinOcaf")) // binary OCAF format { diff --git a/src/Model/Model_Document.h b/src/Model/Model_Document.h index bc7d6db74..d96aa15dd 100644 --- a/src/Model/Model_Document.h +++ b/src/Model/Model_Document.h @@ -78,6 +78,10 @@ public: MODEL_EXPORT virtual const std::string& id() const {return myID;} + //! Returns the feature in the group by the index (started from zero) + MODEL_EXPORT virtual std::shared_ptr + feature(const std::string& theGroupID, const int theIndex); + protected: //! Returns (creates if needed) the group label diff --git a/src/ModelAPI/ModelAPI_Document.h b/src/ModelAPI/ModelAPI_Document.h index 90a6a9184..e40e9f5b5 100644 --- a/src/ModelAPI/ModelAPI_Document.h +++ b/src/ModelAPI/ModelAPI_Document.h @@ -78,8 +78,13 @@ public: MODELAPI_EXPORT virtual std::shared_ptr featuresIterator( const std::string theGroup) = 0; + ///! Returns the id of hte document MODELAPI_EXPORT virtual const std::string& id() const = 0; + //! Returns the feature in the group by the index (started from zero) + MODELAPI_EXPORT virtual std::shared_ptr + feature(const std::string& theGroupID, const int theIndex) = 0; + protected: /// Only for SWIG wrapping it is here MODELAPI_EXPORT ModelAPI_Document()