return ObjectPtr();
}
+std::shared_ptr<ModelAPI_Object> Model_Document::objectByName(
+ const std::string& theGroupID, const std::string& theName)
+{
+ if (theGroupID == ModelAPI_Feature::group()) {
+ int anIndex = 0;
+ TDF_ChildIDIterator aLabIter(featuresLabel(), TDataStd_Comment::GetID());
+ for (; aLabIter.More(); aLabIter.Next()) {
+ TDF_Label aFLabel = aLabIter.Value()->Label();
+ FeaturePtr aFeature = feature(aFLabel);
+ if (aFeature && aFeature->name() == theName)
+ return aFeature;
+ }
+ } else {
+ // comment must be in any feature: it is kind
+ int anIndex = 0;
+ TDF_ChildIDIterator aLabIter(featuresLabel(), TDataStd_Comment::GetID());
+ for (; aLabIter.More(); aLabIter.Next()) {
+ TDF_Label aFLabel = aLabIter.Value()->Label();
+ FeaturePtr aFeature = feature(aFLabel);
+ 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)->groupName() == theGroupID && (*aRIter)->data()->name() == theName)
+ return *aRIter;
+ }
+ }
+ }
+ // not found
+ return ObjectPtr();
+}
+
int Model_Document::size(const std::string& theGroupID, const bool theHidden)
{
int aResult = 0;
//! \param theLabel base label of the object
MODEL_EXPORT virtual ObjectPtr object(TDF_Label theLabel);
+ //! Returns the first found object in the group by the object name
+ //! \param theGroupID group that contains an object
+ //! \param theName name of the object to search
+ //! \returns null if such object is not found
+ MODEL_EXPORT virtual std::shared_ptr<ModelAPI_Object> objectByName(
+ const std::string& theGroupID, const std::string& theName);
+
+
//! Adds a new sub-document by the identifier, or returns existing one if it is already exist
MODEL_EXPORT virtual std::shared_ptr<ModelAPI_Document> subDocument(std::string theDocID);
const int theIndex,
const bool theHidden = false) = 0;
+ //! Returns the first found object in the group by the object name
+ //! \param theGroupID group that contains an object
+ //! \param theName name of the object to search
+ //! \returns null if such object is not found
+ virtual std::shared_ptr<ModelAPI_Object> objectByName(const std::string& theGroupID,
+ const std::string& theName) = 0;
+
//! Returns the number of objects in the group of objects
//! If theHidden is true, it counts also the features that are not in tree
virtual int size(const std::string& theGroupID, const bool theHidden = false) = 0;